documentation.d.ts 3.3 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335
  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. private _hookArray;
  20301. /**
  20302. * Define if particles should be rendered in your texture.
  20303. */
  20304. renderParticles: boolean;
  20305. /**
  20306. * Define if sprites should be rendered in your texture.
  20307. */
  20308. renderSprites: boolean;
  20309. /**
  20310. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20311. */
  20312. coordinatesMode: number;
  20313. /**
  20314. * Define the camera used to render the texture.
  20315. */
  20316. activeCamera: Nullable<Camera>;
  20317. /**
  20318. * Override the render function of the texture with your own one.
  20319. */
  20320. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20321. /**
  20322. * Define if camera post processes should be use while rendering the texture.
  20323. */
  20324. useCameraPostProcesses: boolean;
  20325. /**
  20326. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20327. */
  20328. ignoreCameraViewport: boolean;
  20329. private _postProcessManager;
  20330. private _postProcesses;
  20331. private _resizeObserver;
  20332. /**
  20333. * An event triggered when the texture is unbind.
  20334. */
  20335. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20336. /**
  20337. * An event triggered when the texture is unbind.
  20338. */
  20339. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20340. private _onAfterUnbindObserver;
  20341. /**
  20342. * Set a after unbind callback in the texture.
  20343. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20344. */
  20345. set onAfterUnbind(callback: () => void);
  20346. /**
  20347. * An event triggered before rendering the texture
  20348. */
  20349. onBeforeRenderObservable: Observable<number>;
  20350. private _onBeforeRenderObserver;
  20351. /**
  20352. * Set a before render callback in the texture.
  20353. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20354. */
  20355. set onBeforeRender(callback: (faceIndex: number) => void);
  20356. /**
  20357. * An event triggered after rendering the texture
  20358. */
  20359. onAfterRenderObservable: Observable<number>;
  20360. private _onAfterRenderObserver;
  20361. /**
  20362. * Set a after render callback in the texture.
  20363. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20364. */
  20365. set onAfterRender(callback: (faceIndex: number) => void);
  20366. /**
  20367. * An event triggered after the texture clear
  20368. */
  20369. onClearObservable: Observable<Engine>;
  20370. private _onClearObserver;
  20371. /**
  20372. * Set a clear callback in the texture.
  20373. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20374. */
  20375. set onClear(callback: (Engine: Engine) => void);
  20376. /**
  20377. * An event triggered when the texture is resized.
  20378. */
  20379. onResizeObservable: Observable<RenderTargetTexture>;
  20380. /**
  20381. * Define the clear color of the Render Target if it should be different from the scene.
  20382. */
  20383. clearColor: Color4;
  20384. protected _size: number | {
  20385. width: number;
  20386. height: number;
  20387. layers?: number;
  20388. };
  20389. protected _initialSizeParameter: number | {
  20390. width: number;
  20391. height: number;
  20392. } | {
  20393. ratio: number;
  20394. };
  20395. protected _sizeRatio: Nullable<number>;
  20396. /** @hidden */
  20397. _generateMipMaps: boolean;
  20398. protected _renderingManager: RenderingManager;
  20399. /** @hidden */
  20400. _waitingRenderList: string[];
  20401. protected _doNotChangeAspectRatio: boolean;
  20402. protected _currentRefreshId: number;
  20403. protected _refreshRate: number;
  20404. protected _textureMatrix: Matrix;
  20405. protected _samples: number;
  20406. protected _renderTargetOptions: RenderTargetCreationOptions;
  20407. /**
  20408. * Gets render target creation options that were used.
  20409. */
  20410. get renderTargetOptions(): RenderTargetCreationOptions;
  20411. protected _engine: Engine;
  20412. protected _onRatioRescale(): void;
  20413. /**
  20414. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20415. * It must define where the camera used to render the texture is set
  20416. */
  20417. boundingBoxPosition: Vector3;
  20418. private _boundingBoxSize;
  20419. /**
  20420. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20421. * When defined, the cubemap will switch to local mode
  20422. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20423. * @example https://www.babylonjs-playground.com/#RNASML
  20424. */
  20425. set boundingBoxSize(value: Vector3);
  20426. get boundingBoxSize(): Vector3;
  20427. /**
  20428. * In case the RTT has been created with a depth texture, get the associated
  20429. * depth texture.
  20430. * Otherwise, return null.
  20431. */
  20432. get depthStencilTexture(): Nullable<InternalTexture>;
  20433. /**
  20434. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20435. * or used a shadow, depth texture...
  20436. * @param name The friendly name of the texture
  20437. * @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)
  20438. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20439. * @param generateMipMaps True if mip maps need to be generated after render.
  20440. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20441. * @param type The type of the buffer in the RTT (int, half float, float...)
  20442. * @param isCube True if a cube texture needs to be created
  20443. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20444. * @param generateDepthBuffer True to generate a depth buffer
  20445. * @param generateStencilBuffer True to generate a stencil buffer
  20446. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20447. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20448. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20449. */
  20450. constructor(name: string, size: number | {
  20451. width: number;
  20452. height: number;
  20453. layers?: number;
  20454. } | {
  20455. ratio: number;
  20456. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20457. /**
  20458. * Creates a depth stencil texture.
  20459. * This is only available in WebGL 2 or with the depth texture extension available.
  20460. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20461. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20462. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20463. */
  20464. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20465. private _processSizeParameter;
  20466. /**
  20467. * Define the number of samples to use in case of MSAA.
  20468. * It defaults to one meaning no MSAA has been enabled.
  20469. */
  20470. get samples(): number;
  20471. set samples(value: number);
  20472. /**
  20473. * Resets the refresh counter of the texture and start bak from scratch.
  20474. * Could be useful to regenerate the texture if it is setup to render only once.
  20475. */
  20476. resetRefreshCounter(): void;
  20477. /**
  20478. * Define the refresh rate of the texture or the rendering frequency.
  20479. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20480. */
  20481. get refreshRate(): number;
  20482. set refreshRate(value: number);
  20483. /**
  20484. * Adds a post process to the render target rendering passes.
  20485. * @param postProcess define the post process to add
  20486. */
  20487. addPostProcess(postProcess: PostProcess): void;
  20488. /**
  20489. * Clear all the post processes attached to the render target
  20490. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20491. */
  20492. clearPostProcesses(dispose?: boolean): void;
  20493. /**
  20494. * Remove one of the post process from the list of attached post processes to the texture
  20495. * @param postProcess define the post process to remove from the list
  20496. */
  20497. removePostProcess(postProcess: PostProcess): void;
  20498. /** @hidden */
  20499. _shouldRender(): boolean;
  20500. /**
  20501. * Gets the actual render size of the texture.
  20502. * @returns the width of the render size
  20503. */
  20504. getRenderSize(): number;
  20505. /**
  20506. * Gets the actual render width of the texture.
  20507. * @returns the width of the render size
  20508. */
  20509. getRenderWidth(): number;
  20510. /**
  20511. * Gets the actual render height of the texture.
  20512. * @returns the height of the render size
  20513. */
  20514. getRenderHeight(): number;
  20515. /**
  20516. * Gets the actual number of layers of the texture.
  20517. * @returns the number of layers
  20518. */
  20519. getRenderLayers(): number;
  20520. /**
  20521. * Get if the texture can be rescaled or not.
  20522. */
  20523. get canRescale(): boolean;
  20524. /**
  20525. * Resize the texture using a ratio.
  20526. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20527. */
  20528. scale(ratio: number): void;
  20529. /**
  20530. * Get the texture reflection matrix used to rotate/transform the reflection.
  20531. * @returns the reflection matrix
  20532. */
  20533. getReflectionTextureMatrix(): Matrix;
  20534. /**
  20535. * Resize the texture to a new desired size.
  20536. * Be carrefull as it will recreate all the data in the new texture.
  20537. * @param size Define the new size. It can be:
  20538. * - a number for squared texture,
  20539. * - an object containing { width: number, height: number }
  20540. * - or an object containing a ratio { ratio: number }
  20541. */
  20542. resize(size: number | {
  20543. width: number;
  20544. height: number;
  20545. } | {
  20546. ratio: number;
  20547. }): void;
  20548. /**
  20549. * Renders all the objects from the render list into the texture.
  20550. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20551. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20552. */
  20553. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20554. private _bestReflectionRenderTargetDimension;
  20555. /**
  20556. * @hidden
  20557. * @param faceIndex face index to bind to if this is a cubetexture
  20558. * @param layer defines the index of the texture to bind in the array
  20559. */
  20560. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  20561. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20562. private renderToTarget;
  20563. /**
  20564. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20565. * This allowed control for front to back rendering or reversly depending of the special needs.
  20566. *
  20567. * @param renderingGroupId The rendering group id corresponding to its index
  20568. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20569. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20570. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20571. */
  20572. 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;
  20573. /**
  20574. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20575. *
  20576. * @param renderingGroupId The rendering group id corresponding to its index
  20577. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20578. */
  20579. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20580. /**
  20581. * Clones the texture.
  20582. * @returns the cloned texture
  20583. */
  20584. clone(): RenderTargetTexture;
  20585. /**
  20586. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20587. * @returns The JSON representation of the texture
  20588. */
  20589. serialize(): any;
  20590. /**
  20591. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20592. */
  20593. disposeFramebufferObjects(): void;
  20594. /**
  20595. * Dispose the texture and release its associated resources.
  20596. */
  20597. dispose(): void;
  20598. /** @hidden */
  20599. _rebuild(): void;
  20600. /**
  20601. * Clear the info related to rendering groups preventing retention point in material dispose.
  20602. */
  20603. freeRenderingGroups(): void;
  20604. /**
  20605. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20606. * @returns the view count
  20607. */
  20608. getViewCount(): number;
  20609. }
  20610. }
  20611. declare module BABYLON {
  20612. /**
  20613. * Options for compiling materials.
  20614. */
  20615. export interface IMaterialCompilationOptions {
  20616. /**
  20617. * Defines whether clip planes are enabled.
  20618. */
  20619. clipPlane: boolean;
  20620. /**
  20621. * Defines whether instances are enabled.
  20622. */
  20623. useInstances: boolean;
  20624. }
  20625. /**
  20626. * Base class for the main features of a material in Babylon.js
  20627. */
  20628. export class Material implements IAnimatable {
  20629. /**
  20630. * Returns the triangle fill mode
  20631. */
  20632. static readonly TriangleFillMode: number;
  20633. /**
  20634. * Returns the wireframe mode
  20635. */
  20636. static readonly WireFrameFillMode: number;
  20637. /**
  20638. * Returns the point fill mode
  20639. */
  20640. static readonly PointFillMode: number;
  20641. /**
  20642. * Returns the point list draw mode
  20643. */
  20644. static readonly PointListDrawMode: number;
  20645. /**
  20646. * Returns the line list draw mode
  20647. */
  20648. static readonly LineListDrawMode: number;
  20649. /**
  20650. * Returns the line loop draw mode
  20651. */
  20652. static readonly LineLoopDrawMode: number;
  20653. /**
  20654. * Returns the line strip draw mode
  20655. */
  20656. static readonly LineStripDrawMode: number;
  20657. /**
  20658. * Returns the triangle strip draw mode
  20659. */
  20660. static readonly TriangleStripDrawMode: number;
  20661. /**
  20662. * Returns the triangle fan draw mode
  20663. */
  20664. static readonly TriangleFanDrawMode: number;
  20665. /**
  20666. * Stores the clock-wise side orientation
  20667. */
  20668. static readonly ClockWiseSideOrientation: number;
  20669. /**
  20670. * Stores the counter clock-wise side orientation
  20671. */
  20672. static readonly CounterClockWiseSideOrientation: number;
  20673. /**
  20674. * The dirty texture flag value
  20675. */
  20676. static readonly TextureDirtyFlag: number;
  20677. /**
  20678. * The dirty light flag value
  20679. */
  20680. static readonly LightDirtyFlag: number;
  20681. /**
  20682. * The dirty fresnel flag value
  20683. */
  20684. static readonly FresnelDirtyFlag: number;
  20685. /**
  20686. * The dirty attribute flag value
  20687. */
  20688. static readonly AttributesDirtyFlag: number;
  20689. /**
  20690. * The dirty misc flag value
  20691. */
  20692. static readonly MiscDirtyFlag: number;
  20693. /**
  20694. * The all dirty flag value
  20695. */
  20696. static readonly AllDirtyFlag: number;
  20697. /**
  20698. * The ID of the material
  20699. */
  20700. id: string;
  20701. /**
  20702. * Gets or sets the unique id of the material
  20703. */
  20704. uniqueId: number;
  20705. /**
  20706. * The name of the material
  20707. */
  20708. name: string;
  20709. /**
  20710. * Gets or sets user defined metadata
  20711. */
  20712. metadata: any;
  20713. /**
  20714. * For internal use only. Please do not use.
  20715. */
  20716. reservedDataStore: any;
  20717. /**
  20718. * Specifies if the ready state should be checked on each call
  20719. */
  20720. checkReadyOnEveryCall: boolean;
  20721. /**
  20722. * Specifies if the ready state should be checked once
  20723. */
  20724. checkReadyOnlyOnce: boolean;
  20725. /**
  20726. * The state of the material
  20727. */
  20728. state: string;
  20729. /**
  20730. * The alpha value of the material
  20731. */
  20732. protected _alpha: number;
  20733. /**
  20734. * List of inspectable custom properties (used by the Inspector)
  20735. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20736. */
  20737. inspectableCustomProperties: IInspectable[];
  20738. /**
  20739. * Sets the alpha value of the material
  20740. */
  20741. set alpha(value: number);
  20742. /**
  20743. * Gets the alpha value of the material
  20744. */
  20745. get alpha(): number;
  20746. /**
  20747. * Specifies if back face culling is enabled
  20748. */
  20749. protected _backFaceCulling: boolean;
  20750. /**
  20751. * Sets the back-face culling state
  20752. */
  20753. set backFaceCulling(value: boolean);
  20754. /**
  20755. * Gets the back-face culling state
  20756. */
  20757. get backFaceCulling(): boolean;
  20758. /**
  20759. * Stores the value for side orientation
  20760. */
  20761. sideOrientation: number;
  20762. /**
  20763. * Callback triggered when the material is compiled
  20764. */
  20765. onCompiled: Nullable<(effect: Effect) => void>;
  20766. /**
  20767. * Callback triggered when an error occurs
  20768. */
  20769. onError: Nullable<(effect: Effect, errors: string) => void>;
  20770. /**
  20771. * Callback triggered to get the render target textures
  20772. */
  20773. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20774. /**
  20775. * Gets a boolean indicating that current material needs to register RTT
  20776. */
  20777. get hasRenderTargetTextures(): boolean;
  20778. /**
  20779. * Specifies if the material should be serialized
  20780. */
  20781. doNotSerialize: boolean;
  20782. /**
  20783. * @hidden
  20784. */
  20785. _storeEffectOnSubMeshes: boolean;
  20786. /**
  20787. * Stores the animations for the material
  20788. */
  20789. animations: Nullable<Array<Animation>>;
  20790. /**
  20791. * An event triggered when the material is disposed
  20792. */
  20793. onDisposeObservable: Observable<Material>;
  20794. /**
  20795. * An observer which watches for dispose events
  20796. */
  20797. private _onDisposeObserver;
  20798. private _onUnBindObservable;
  20799. /**
  20800. * Called during a dispose event
  20801. */
  20802. set onDispose(callback: () => void);
  20803. private _onBindObservable;
  20804. /**
  20805. * An event triggered when the material is bound
  20806. */
  20807. get onBindObservable(): Observable<AbstractMesh>;
  20808. /**
  20809. * An observer which watches for bind events
  20810. */
  20811. private _onBindObserver;
  20812. /**
  20813. * Called during a bind event
  20814. */
  20815. set onBind(callback: (Mesh: AbstractMesh) => void);
  20816. /**
  20817. * An event triggered when the material is unbound
  20818. */
  20819. get onUnBindObservable(): Observable<Material>;
  20820. /**
  20821. * Stores the value of the alpha mode
  20822. */
  20823. private _alphaMode;
  20824. /**
  20825. * Sets the value of the alpha mode.
  20826. *
  20827. * | Value | Type | Description |
  20828. * | --- | --- | --- |
  20829. * | 0 | ALPHA_DISABLE | |
  20830. * | 1 | ALPHA_ADD | |
  20831. * | 2 | ALPHA_COMBINE | |
  20832. * | 3 | ALPHA_SUBTRACT | |
  20833. * | 4 | ALPHA_MULTIPLY | |
  20834. * | 5 | ALPHA_MAXIMIZED | |
  20835. * | 6 | ALPHA_ONEONE | |
  20836. * | 7 | ALPHA_PREMULTIPLIED | |
  20837. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20838. * | 9 | ALPHA_INTERPOLATE | |
  20839. * | 10 | ALPHA_SCREENMODE | |
  20840. *
  20841. */
  20842. set alphaMode(value: number);
  20843. /**
  20844. * Gets the value of the alpha mode
  20845. */
  20846. get alphaMode(): number;
  20847. /**
  20848. * Stores the state of the need depth pre-pass value
  20849. */
  20850. private _needDepthPrePass;
  20851. /**
  20852. * Sets the need depth pre-pass value
  20853. */
  20854. set needDepthPrePass(value: boolean);
  20855. /**
  20856. * Gets the depth pre-pass value
  20857. */
  20858. get needDepthPrePass(): boolean;
  20859. /**
  20860. * Specifies if depth writing should be disabled
  20861. */
  20862. disableDepthWrite: boolean;
  20863. /**
  20864. * Specifies if depth writing should be forced
  20865. */
  20866. forceDepthWrite: boolean;
  20867. /**
  20868. * Specifies the depth function that should be used. 0 means the default engine function
  20869. */
  20870. depthFunction: number;
  20871. /**
  20872. * Specifies if there should be a separate pass for culling
  20873. */
  20874. separateCullingPass: boolean;
  20875. /**
  20876. * Stores the state specifing if fog should be enabled
  20877. */
  20878. private _fogEnabled;
  20879. /**
  20880. * Sets the state for enabling fog
  20881. */
  20882. set fogEnabled(value: boolean);
  20883. /**
  20884. * Gets the value of the fog enabled state
  20885. */
  20886. get fogEnabled(): boolean;
  20887. /**
  20888. * Stores the size of points
  20889. */
  20890. pointSize: number;
  20891. /**
  20892. * Stores the z offset value
  20893. */
  20894. zOffset: number;
  20895. /**
  20896. * Gets a value specifying if wireframe mode is enabled
  20897. */
  20898. get wireframe(): boolean;
  20899. /**
  20900. * Sets the state of wireframe mode
  20901. */
  20902. set wireframe(value: boolean);
  20903. /**
  20904. * Gets the value specifying if point clouds are enabled
  20905. */
  20906. get pointsCloud(): boolean;
  20907. /**
  20908. * Sets the state of point cloud mode
  20909. */
  20910. set pointsCloud(value: boolean);
  20911. /**
  20912. * Gets the material fill mode
  20913. */
  20914. get fillMode(): number;
  20915. /**
  20916. * Sets the material fill mode
  20917. */
  20918. set fillMode(value: number);
  20919. /**
  20920. * @hidden
  20921. * Stores the effects for the material
  20922. */
  20923. _effect: Nullable<Effect>;
  20924. /**
  20925. * Specifies if uniform buffers should be used
  20926. */
  20927. private _useUBO;
  20928. /**
  20929. * Stores a reference to the scene
  20930. */
  20931. private _scene;
  20932. /**
  20933. * Stores the fill mode state
  20934. */
  20935. private _fillMode;
  20936. /**
  20937. * Specifies if the depth write state should be cached
  20938. */
  20939. private _cachedDepthWriteState;
  20940. /**
  20941. * Specifies if the depth function state should be cached
  20942. */
  20943. private _cachedDepthFunctionState;
  20944. /**
  20945. * Stores the uniform buffer
  20946. */
  20947. protected _uniformBuffer: UniformBuffer;
  20948. /** @hidden */
  20949. _indexInSceneMaterialArray: number;
  20950. /** @hidden */
  20951. meshMap: Nullable<{
  20952. [id: string]: AbstractMesh | undefined;
  20953. }>;
  20954. /**
  20955. * Creates a material instance
  20956. * @param name defines the name of the material
  20957. * @param scene defines the scene to reference
  20958. * @param doNotAdd specifies if the material should be added to the scene
  20959. */
  20960. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  20961. /**
  20962. * Returns a string representation of the current material
  20963. * @param fullDetails defines a boolean indicating which levels of logging is desired
  20964. * @returns a string with material information
  20965. */
  20966. toString(fullDetails?: boolean): string;
  20967. /**
  20968. * Gets the class name of the material
  20969. * @returns a string with the class name of the material
  20970. */
  20971. getClassName(): string;
  20972. /**
  20973. * Specifies if updates for the material been locked
  20974. */
  20975. get isFrozen(): boolean;
  20976. /**
  20977. * Locks updates for the material
  20978. */
  20979. freeze(): void;
  20980. /**
  20981. * Unlocks updates for the material
  20982. */
  20983. unfreeze(): void;
  20984. /**
  20985. * Specifies if the material is ready to be used
  20986. * @param mesh defines the mesh to check
  20987. * @param useInstances specifies if instances should be used
  20988. * @returns a boolean indicating if the material is ready to be used
  20989. */
  20990. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  20991. /**
  20992. * Specifies that the submesh is ready to be used
  20993. * @param mesh defines the mesh to check
  20994. * @param subMesh defines which submesh to check
  20995. * @param useInstances specifies that instances should be used
  20996. * @returns a boolean indicating that the submesh is ready or not
  20997. */
  20998. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20999. /**
  21000. * Returns the material effect
  21001. * @returns the effect associated with the material
  21002. */
  21003. getEffect(): Nullable<Effect>;
  21004. /**
  21005. * Returns the current scene
  21006. * @returns a Scene
  21007. */
  21008. getScene(): Scene;
  21009. /**
  21010. * Specifies if the material will require alpha blending
  21011. * @returns a boolean specifying if alpha blending is needed
  21012. */
  21013. needAlphaBlending(): boolean;
  21014. /**
  21015. * Specifies if the mesh will require alpha blending
  21016. * @param mesh defines the mesh to check
  21017. * @returns a boolean specifying if alpha blending is needed for the mesh
  21018. */
  21019. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21020. /**
  21021. * Specifies if this material should be rendered in alpha test mode
  21022. * @returns a boolean specifying if an alpha test is needed.
  21023. */
  21024. needAlphaTesting(): boolean;
  21025. /**
  21026. * Gets the texture used for the alpha test
  21027. * @returns the texture to use for alpha testing
  21028. */
  21029. getAlphaTestTexture(): Nullable<BaseTexture>;
  21030. /**
  21031. * Marks the material to indicate that it needs to be re-calculated
  21032. */
  21033. markDirty(): void;
  21034. /** @hidden */
  21035. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21036. /**
  21037. * Binds the material to the mesh
  21038. * @param world defines the world transformation matrix
  21039. * @param mesh defines the mesh to bind the material to
  21040. */
  21041. bind(world: Matrix, mesh?: Mesh): void;
  21042. /**
  21043. * Binds the submesh to the material
  21044. * @param world defines the world transformation matrix
  21045. * @param mesh defines the mesh containing the submesh
  21046. * @param subMesh defines the submesh to bind the material to
  21047. */
  21048. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21049. /**
  21050. * Binds the world matrix to the material
  21051. * @param world defines the world transformation matrix
  21052. */
  21053. bindOnlyWorldMatrix(world: Matrix): void;
  21054. /**
  21055. * Binds the scene's uniform buffer to the effect.
  21056. * @param effect defines the effect to bind to the scene uniform buffer
  21057. * @param sceneUbo defines the uniform buffer storing scene data
  21058. */
  21059. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21060. /**
  21061. * Binds the view matrix to the effect
  21062. * @param effect defines the effect to bind the view matrix to
  21063. */
  21064. bindView(effect: Effect): void;
  21065. /**
  21066. * Binds the view projection matrix to the effect
  21067. * @param effect defines the effect to bind the view projection matrix to
  21068. */
  21069. bindViewProjection(effect: Effect): void;
  21070. /**
  21071. * Specifies if material alpha testing should be turned on for the mesh
  21072. * @param mesh defines the mesh to check
  21073. */
  21074. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21075. /**
  21076. * Processes to execute after binding the material to a mesh
  21077. * @param mesh defines the rendered mesh
  21078. */
  21079. protected _afterBind(mesh?: Mesh): void;
  21080. /**
  21081. * Unbinds the material from the mesh
  21082. */
  21083. unbind(): void;
  21084. /**
  21085. * Gets the active textures from the material
  21086. * @returns an array of textures
  21087. */
  21088. getActiveTextures(): BaseTexture[];
  21089. /**
  21090. * Specifies if the material uses a texture
  21091. * @param texture defines the texture to check against the material
  21092. * @returns a boolean specifying if the material uses the texture
  21093. */
  21094. hasTexture(texture: BaseTexture): boolean;
  21095. /**
  21096. * Makes a duplicate of the material, and gives it a new name
  21097. * @param name defines the new name for the duplicated material
  21098. * @returns the cloned material
  21099. */
  21100. clone(name: string): Nullable<Material>;
  21101. /**
  21102. * Gets the meshes bound to the material
  21103. * @returns an array of meshes bound to the material
  21104. */
  21105. getBindedMeshes(): AbstractMesh[];
  21106. /**
  21107. * Force shader compilation
  21108. * @param mesh defines the mesh associated with this material
  21109. * @param onCompiled defines a function to execute once the material is compiled
  21110. * @param options defines the options to configure the compilation
  21111. * @param onError defines a function to execute if the material fails compiling
  21112. */
  21113. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21114. /**
  21115. * Force shader compilation
  21116. * @param mesh defines the mesh that will use this material
  21117. * @param options defines additional options for compiling the shaders
  21118. * @returns a promise that resolves when the compilation completes
  21119. */
  21120. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21121. private static readonly _AllDirtyCallBack;
  21122. private static readonly _ImageProcessingDirtyCallBack;
  21123. private static readonly _TextureDirtyCallBack;
  21124. private static readonly _FresnelDirtyCallBack;
  21125. private static readonly _MiscDirtyCallBack;
  21126. private static readonly _LightsDirtyCallBack;
  21127. private static readonly _AttributeDirtyCallBack;
  21128. private static _FresnelAndMiscDirtyCallBack;
  21129. private static _TextureAndMiscDirtyCallBack;
  21130. private static readonly _DirtyCallbackArray;
  21131. private static readonly _RunDirtyCallBacks;
  21132. /**
  21133. * Marks a define in the material to indicate that it needs to be re-computed
  21134. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21135. */
  21136. markAsDirty(flag: number): void;
  21137. /**
  21138. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21139. * @param func defines a function which checks material defines against the submeshes
  21140. */
  21141. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21142. /**
  21143. * Indicates that we need to re-calculated for all submeshes
  21144. */
  21145. protected _markAllSubMeshesAsAllDirty(): void;
  21146. /**
  21147. * Indicates that image processing needs to be re-calculated for all submeshes
  21148. */
  21149. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21150. /**
  21151. * Indicates that textures need to be re-calculated for all submeshes
  21152. */
  21153. protected _markAllSubMeshesAsTexturesDirty(): void;
  21154. /**
  21155. * Indicates that fresnel needs to be re-calculated for all submeshes
  21156. */
  21157. protected _markAllSubMeshesAsFresnelDirty(): void;
  21158. /**
  21159. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21160. */
  21161. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21162. /**
  21163. * Indicates that lights need to be re-calculated for all submeshes
  21164. */
  21165. protected _markAllSubMeshesAsLightsDirty(): void;
  21166. /**
  21167. * Indicates that attributes need to be re-calculated for all submeshes
  21168. */
  21169. protected _markAllSubMeshesAsAttributesDirty(): void;
  21170. /**
  21171. * Indicates that misc needs to be re-calculated for all submeshes
  21172. */
  21173. protected _markAllSubMeshesAsMiscDirty(): void;
  21174. /**
  21175. * Indicates that textures and misc need to be re-calculated for all submeshes
  21176. */
  21177. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21178. /**
  21179. * Disposes the material
  21180. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21181. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21182. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21183. */
  21184. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21185. /** @hidden */
  21186. private releaseVertexArrayObject;
  21187. /**
  21188. * Serializes this material
  21189. * @returns the serialized material object
  21190. */
  21191. serialize(): any;
  21192. /**
  21193. * Creates a material from parsed material data
  21194. * @param parsedMaterial defines parsed material data
  21195. * @param scene defines the hosting scene
  21196. * @param rootUrl defines the root URL to use to load textures
  21197. * @returns a new material
  21198. */
  21199. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21200. }
  21201. }
  21202. declare module BABYLON {
  21203. /**
  21204. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21205. * separate meshes. This can be use to improve performances.
  21206. * @see http://doc.babylonjs.com/how_to/multi_materials
  21207. */
  21208. export class MultiMaterial extends Material {
  21209. private _subMaterials;
  21210. /**
  21211. * Gets or Sets the list of Materials used within the multi material.
  21212. * They need to be ordered according to the submeshes order in the associated mesh
  21213. */
  21214. get subMaterials(): Nullable<Material>[];
  21215. set subMaterials(value: Nullable<Material>[]);
  21216. /**
  21217. * Function used to align with Node.getChildren()
  21218. * @returns the list of Materials used within the multi material
  21219. */
  21220. getChildren(): Nullable<Material>[];
  21221. /**
  21222. * Instantiates a new Multi Material
  21223. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21224. * separate meshes. This can be use to improve performances.
  21225. * @see http://doc.babylonjs.com/how_to/multi_materials
  21226. * @param name Define the name in the scene
  21227. * @param scene Define the scene the material belongs to
  21228. */
  21229. constructor(name: string, scene: Scene);
  21230. private _hookArray;
  21231. /**
  21232. * Get one of the submaterial by its index in the submaterials array
  21233. * @param index The index to look the sub material at
  21234. * @returns The Material if the index has been defined
  21235. */
  21236. getSubMaterial(index: number): Nullable<Material>;
  21237. /**
  21238. * Get the list of active textures for the whole sub materials list.
  21239. * @returns All the textures that will be used during the rendering
  21240. */
  21241. getActiveTextures(): BaseTexture[];
  21242. /**
  21243. * Gets the current class name of the material e.g. "MultiMaterial"
  21244. * Mainly use in serialization.
  21245. * @returns the class name
  21246. */
  21247. getClassName(): string;
  21248. /**
  21249. * Checks if the material is ready to render the requested sub mesh
  21250. * @param mesh Define the mesh the submesh belongs to
  21251. * @param subMesh Define the sub mesh to look readyness for
  21252. * @param useInstances Define whether or not the material is used with instances
  21253. * @returns true if ready, otherwise false
  21254. */
  21255. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21256. /**
  21257. * Clones the current material and its related sub materials
  21258. * @param name Define the name of the newly cloned material
  21259. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21260. * @returns the cloned material
  21261. */
  21262. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21263. /**
  21264. * Serializes the materials into a JSON representation.
  21265. * @returns the JSON representation
  21266. */
  21267. serialize(): any;
  21268. /**
  21269. * Dispose the material and release its associated resources
  21270. * @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)
  21271. * @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)
  21272. * @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)
  21273. */
  21274. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21275. /**
  21276. * Creates a MultiMaterial from parsed MultiMaterial data.
  21277. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21278. * @param scene defines the hosting scene
  21279. * @returns a new MultiMaterial
  21280. */
  21281. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21282. }
  21283. }
  21284. declare module BABYLON {
  21285. /**
  21286. * Base class for submeshes
  21287. */
  21288. export class BaseSubMesh {
  21289. /** @hidden */
  21290. _materialDefines: Nullable<MaterialDefines>;
  21291. /** @hidden */
  21292. _materialEffect: Nullable<Effect>;
  21293. /**
  21294. * Gets material defines used by the effect associated to the sub mesh
  21295. */
  21296. get materialDefines(): Nullable<MaterialDefines>;
  21297. /**
  21298. * Sets material defines used by the effect associated to the sub mesh
  21299. */
  21300. set materialDefines(defines: Nullable<MaterialDefines>);
  21301. /**
  21302. * Gets associated effect
  21303. */
  21304. get effect(): Nullable<Effect>;
  21305. /**
  21306. * Sets associated effect (effect used to render this submesh)
  21307. * @param effect defines the effect to associate with
  21308. * @param defines defines the set of defines used to compile this effect
  21309. */
  21310. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21311. }
  21312. /**
  21313. * Defines a subdivision inside a mesh
  21314. */
  21315. export class SubMesh extends BaseSubMesh implements ICullable {
  21316. /** the material index to use */
  21317. materialIndex: number;
  21318. /** vertex index start */
  21319. verticesStart: number;
  21320. /** vertices count */
  21321. verticesCount: number;
  21322. /** index start */
  21323. indexStart: number;
  21324. /** indices count */
  21325. indexCount: number;
  21326. /** @hidden */
  21327. _linesIndexCount: number;
  21328. private _mesh;
  21329. private _renderingMesh;
  21330. private _boundingInfo;
  21331. private _linesIndexBuffer;
  21332. /** @hidden */
  21333. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21334. /** @hidden */
  21335. _trianglePlanes: Plane[];
  21336. /** @hidden */
  21337. _lastColliderTransformMatrix: Nullable<Matrix>;
  21338. /** @hidden */
  21339. _renderId: number;
  21340. /** @hidden */
  21341. _alphaIndex: number;
  21342. /** @hidden */
  21343. _distanceToCamera: number;
  21344. /** @hidden */
  21345. _id: number;
  21346. private _currentMaterial;
  21347. /**
  21348. * Add a new submesh to a mesh
  21349. * @param materialIndex defines the material index to use
  21350. * @param verticesStart defines vertex index start
  21351. * @param verticesCount defines vertices count
  21352. * @param indexStart defines index start
  21353. * @param indexCount defines indices count
  21354. * @param mesh defines the parent mesh
  21355. * @param renderingMesh defines an optional rendering mesh
  21356. * @param createBoundingBox defines if bounding box should be created for this submesh
  21357. * @returns the new submesh
  21358. */
  21359. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21360. /**
  21361. * Creates a new submesh
  21362. * @param materialIndex defines the material index to use
  21363. * @param verticesStart defines vertex index start
  21364. * @param verticesCount defines vertices count
  21365. * @param indexStart defines index start
  21366. * @param indexCount defines indices count
  21367. * @param mesh defines the parent mesh
  21368. * @param renderingMesh defines an optional rendering mesh
  21369. * @param createBoundingBox defines if bounding box should be created for this submesh
  21370. */
  21371. constructor(
  21372. /** the material index to use */
  21373. materialIndex: number,
  21374. /** vertex index start */
  21375. verticesStart: number,
  21376. /** vertices count */
  21377. verticesCount: number,
  21378. /** index start */
  21379. indexStart: number,
  21380. /** indices count */
  21381. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21382. /**
  21383. * Returns true if this submesh covers the entire parent mesh
  21384. * @ignorenaming
  21385. */
  21386. get IsGlobal(): boolean;
  21387. /**
  21388. * Returns the submesh BoudingInfo object
  21389. * @returns current bounding info (or mesh's one if the submesh is global)
  21390. */
  21391. getBoundingInfo(): BoundingInfo;
  21392. /**
  21393. * Sets the submesh BoundingInfo
  21394. * @param boundingInfo defines the new bounding info to use
  21395. * @returns the SubMesh
  21396. */
  21397. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21398. /**
  21399. * Returns the mesh of the current submesh
  21400. * @return the parent mesh
  21401. */
  21402. getMesh(): AbstractMesh;
  21403. /**
  21404. * Returns the rendering mesh of the submesh
  21405. * @returns the rendering mesh (could be different from parent mesh)
  21406. */
  21407. getRenderingMesh(): Mesh;
  21408. /**
  21409. * Returns the submesh material
  21410. * @returns null or the current material
  21411. */
  21412. getMaterial(): Nullable<Material>;
  21413. /**
  21414. * Sets a new updated BoundingInfo object to the submesh
  21415. * @param data defines an optional position array to use to determine the bounding info
  21416. * @returns the SubMesh
  21417. */
  21418. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21419. /** @hidden */
  21420. _checkCollision(collider: Collider): boolean;
  21421. /**
  21422. * Updates the submesh BoundingInfo
  21423. * @param world defines the world matrix to use to update the bounding info
  21424. * @returns the submesh
  21425. */
  21426. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21427. /**
  21428. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21429. * @param frustumPlanes defines the frustum planes
  21430. * @returns true if the submesh is intersecting with the frustum
  21431. */
  21432. isInFrustum(frustumPlanes: Plane[]): boolean;
  21433. /**
  21434. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21435. * @param frustumPlanes defines the frustum planes
  21436. * @returns true if the submesh is inside the frustum
  21437. */
  21438. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21439. /**
  21440. * Renders the submesh
  21441. * @param enableAlphaMode defines if alpha needs to be used
  21442. * @returns the submesh
  21443. */
  21444. render(enableAlphaMode: boolean): SubMesh;
  21445. /**
  21446. * @hidden
  21447. */
  21448. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21449. /**
  21450. * Checks if the submesh intersects with a ray
  21451. * @param ray defines the ray to test
  21452. * @returns true is the passed ray intersects the submesh bounding box
  21453. */
  21454. canIntersects(ray: Ray): boolean;
  21455. /**
  21456. * Intersects current submesh with a ray
  21457. * @param ray defines the ray to test
  21458. * @param positions defines mesh's positions array
  21459. * @param indices defines mesh's indices array
  21460. * @param fastCheck defines if only bounding info should be used
  21461. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21462. * @returns intersection info or null if no intersection
  21463. */
  21464. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21465. /** @hidden */
  21466. private _intersectLines;
  21467. /** @hidden */
  21468. private _intersectUnIndexedLines;
  21469. /** @hidden */
  21470. private _intersectTriangles;
  21471. /** @hidden */
  21472. private _intersectUnIndexedTriangles;
  21473. /** @hidden */
  21474. _rebuild(): void;
  21475. /**
  21476. * Creates a new submesh from the passed mesh
  21477. * @param newMesh defines the new hosting mesh
  21478. * @param newRenderingMesh defines an optional rendering mesh
  21479. * @returns the new submesh
  21480. */
  21481. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21482. /**
  21483. * Release associated resources
  21484. */
  21485. dispose(): void;
  21486. /**
  21487. * Gets the class name
  21488. * @returns the string "SubMesh".
  21489. */
  21490. getClassName(): string;
  21491. /**
  21492. * Creates a new submesh from indices data
  21493. * @param materialIndex the index of the main mesh material
  21494. * @param startIndex the index where to start the copy in the mesh indices array
  21495. * @param indexCount the number of indices to copy then from the startIndex
  21496. * @param mesh the main mesh to create the submesh from
  21497. * @param renderingMesh the optional rendering mesh
  21498. * @returns a new submesh
  21499. */
  21500. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21501. }
  21502. }
  21503. declare module BABYLON {
  21504. /**
  21505. * Class used to represent data loading progression
  21506. */
  21507. export class SceneLoaderFlags {
  21508. private static _ForceFullSceneLoadingForIncremental;
  21509. private static _ShowLoadingScreen;
  21510. private static _CleanBoneMatrixWeights;
  21511. private static _loggingLevel;
  21512. /**
  21513. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21514. */
  21515. static get ForceFullSceneLoadingForIncremental(): boolean;
  21516. static set ForceFullSceneLoadingForIncremental(value: boolean);
  21517. /**
  21518. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21519. */
  21520. static get ShowLoadingScreen(): boolean;
  21521. static set ShowLoadingScreen(value: boolean);
  21522. /**
  21523. * Defines the current logging level (while loading the scene)
  21524. * @ignorenaming
  21525. */
  21526. static get loggingLevel(): number;
  21527. static set loggingLevel(value: number);
  21528. /**
  21529. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21530. */
  21531. static get CleanBoneMatrixWeights(): boolean;
  21532. static set CleanBoneMatrixWeights(value: boolean);
  21533. }
  21534. }
  21535. declare module BABYLON {
  21536. /**
  21537. * Class used to store geometry data (vertex buffers + index buffer)
  21538. */
  21539. export class Geometry implements IGetSetVerticesData {
  21540. /**
  21541. * Gets or sets the ID of the geometry
  21542. */
  21543. id: string;
  21544. /**
  21545. * Gets or sets the unique ID of the geometry
  21546. */
  21547. uniqueId: number;
  21548. /**
  21549. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21550. */
  21551. delayLoadState: number;
  21552. /**
  21553. * Gets the file containing the data to load when running in delay load state
  21554. */
  21555. delayLoadingFile: Nullable<string>;
  21556. /**
  21557. * Callback called when the geometry is updated
  21558. */
  21559. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21560. private _scene;
  21561. private _engine;
  21562. private _meshes;
  21563. private _totalVertices;
  21564. /** @hidden */
  21565. _indices: IndicesArray;
  21566. /** @hidden */
  21567. _vertexBuffers: {
  21568. [key: string]: VertexBuffer;
  21569. };
  21570. private _isDisposed;
  21571. private _extend;
  21572. private _boundingBias;
  21573. /** @hidden */
  21574. _delayInfo: Array<string>;
  21575. private _indexBuffer;
  21576. private _indexBufferIsUpdatable;
  21577. /** @hidden */
  21578. _boundingInfo: Nullable<BoundingInfo>;
  21579. /** @hidden */
  21580. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21581. /** @hidden */
  21582. _softwareSkinningFrameId: number;
  21583. private _vertexArrayObjects;
  21584. private _updatable;
  21585. /** @hidden */
  21586. _positions: Nullable<Vector3[]>;
  21587. /**
  21588. * 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
  21589. */
  21590. get boundingBias(): Vector2;
  21591. /**
  21592. * 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
  21593. */
  21594. set boundingBias(value: Vector2);
  21595. /**
  21596. * Static function used to attach a new empty geometry to a mesh
  21597. * @param mesh defines the mesh to attach the geometry to
  21598. * @returns the new Geometry
  21599. */
  21600. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21601. /**
  21602. * Creates a new geometry
  21603. * @param id defines the unique ID
  21604. * @param scene defines the hosting scene
  21605. * @param vertexData defines the VertexData used to get geometry data
  21606. * @param updatable defines if geometry must be updatable (false by default)
  21607. * @param mesh defines the mesh that will be associated with the geometry
  21608. */
  21609. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21610. /**
  21611. * Gets the current extend of the geometry
  21612. */
  21613. get extend(): {
  21614. minimum: Vector3;
  21615. maximum: Vector3;
  21616. };
  21617. /**
  21618. * Gets the hosting scene
  21619. * @returns the hosting Scene
  21620. */
  21621. getScene(): Scene;
  21622. /**
  21623. * Gets the hosting engine
  21624. * @returns the hosting Engine
  21625. */
  21626. getEngine(): Engine;
  21627. /**
  21628. * Defines if the geometry is ready to use
  21629. * @returns true if the geometry is ready to be used
  21630. */
  21631. isReady(): boolean;
  21632. /**
  21633. * Gets a value indicating that the geometry should not be serialized
  21634. */
  21635. get doNotSerialize(): boolean;
  21636. /** @hidden */
  21637. _rebuild(): void;
  21638. /**
  21639. * Affects all geometry data in one call
  21640. * @param vertexData defines the geometry data
  21641. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21642. */
  21643. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21644. /**
  21645. * Set specific vertex data
  21646. * @param kind defines the data kind (Position, normal, etc...)
  21647. * @param data defines the vertex data to use
  21648. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21649. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21650. */
  21651. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21652. /**
  21653. * Removes a specific vertex data
  21654. * @param kind defines the data kind (Position, normal, etc...)
  21655. */
  21656. removeVerticesData(kind: string): void;
  21657. /**
  21658. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21659. * @param buffer defines the vertex buffer to use
  21660. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21661. */
  21662. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21663. /**
  21664. * Update a specific vertex buffer
  21665. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21666. * It will do nothing if the buffer is not updatable
  21667. * @param kind defines the data kind (Position, normal, etc...)
  21668. * @param data defines the data to use
  21669. * @param offset defines the offset in the target buffer where to store the data
  21670. * @param useBytes set to true if the offset is in bytes
  21671. */
  21672. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21673. /**
  21674. * Update a specific vertex buffer
  21675. * This function will create a new buffer if the current one is not updatable
  21676. * @param kind defines the data kind (Position, normal, etc...)
  21677. * @param data defines the data to use
  21678. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21679. */
  21680. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21681. private _updateBoundingInfo;
  21682. /** @hidden */
  21683. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21684. /**
  21685. * Gets total number of vertices
  21686. * @returns the total number of vertices
  21687. */
  21688. getTotalVertices(): number;
  21689. /**
  21690. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21691. * @param kind defines the data kind (Position, normal, etc...)
  21692. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21693. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21694. * @returns a float array containing vertex data
  21695. */
  21696. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21697. /**
  21698. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21699. * @param kind defines the data kind (Position, normal, etc...)
  21700. * @returns true if the vertex buffer with the specified kind is updatable
  21701. */
  21702. isVertexBufferUpdatable(kind: string): boolean;
  21703. /**
  21704. * Gets a specific vertex buffer
  21705. * @param kind defines the data kind (Position, normal, etc...)
  21706. * @returns a VertexBuffer
  21707. */
  21708. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21709. /**
  21710. * Returns all vertex buffers
  21711. * @return an object holding all vertex buffers indexed by kind
  21712. */
  21713. getVertexBuffers(): Nullable<{
  21714. [key: string]: VertexBuffer;
  21715. }>;
  21716. /**
  21717. * Gets a boolean indicating if specific vertex buffer is present
  21718. * @param kind defines the data kind (Position, normal, etc...)
  21719. * @returns true if data is present
  21720. */
  21721. isVerticesDataPresent(kind: string): boolean;
  21722. /**
  21723. * Gets a list of all attached data kinds (Position, normal, etc...)
  21724. * @returns a list of string containing all kinds
  21725. */
  21726. getVerticesDataKinds(): string[];
  21727. /**
  21728. * Update index buffer
  21729. * @param indices defines the indices to store in the index buffer
  21730. * @param offset defines the offset in the target buffer where to store the data
  21731. * @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)
  21732. */
  21733. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21734. /**
  21735. * Creates a new index buffer
  21736. * @param indices defines the indices to store in the index buffer
  21737. * @param totalVertices defines the total number of vertices (could be null)
  21738. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21739. */
  21740. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21741. /**
  21742. * Return the total number of indices
  21743. * @returns the total number of indices
  21744. */
  21745. getTotalIndices(): number;
  21746. /**
  21747. * Gets the index buffer array
  21748. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21749. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21750. * @returns the index buffer array
  21751. */
  21752. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21753. /**
  21754. * Gets the index buffer
  21755. * @return the index buffer
  21756. */
  21757. getIndexBuffer(): Nullable<DataBuffer>;
  21758. /** @hidden */
  21759. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21760. /**
  21761. * Release the associated resources for a specific mesh
  21762. * @param mesh defines the source mesh
  21763. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21764. */
  21765. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21766. /**
  21767. * Apply current geometry to a given mesh
  21768. * @param mesh defines the mesh to apply geometry to
  21769. */
  21770. applyToMesh(mesh: Mesh): void;
  21771. private _updateExtend;
  21772. private _applyToMesh;
  21773. private notifyUpdate;
  21774. /**
  21775. * Load the geometry if it was flagged as delay loaded
  21776. * @param scene defines the hosting scene
  21777. * @param onLoaded defines a callback called when the geometry is loaded
  21778. */
  21779. load(scene: Scene, onLoaded?: () => void): void;
  21780. private _queueLoad;
  21781. /**
  21782. * Invert the geometry to move from a right handed system to a left handed one.
  21783. */
  21784. toLeftHanded(): void;
  21785. /** @hidden */
  21786. _resetPointsArrayCache(): void;
  21787. /** @hidden */
  21788. _generatePointsArray(): boolean;
  21789. /**
  21790. * Gets a value indicating if the geometry is disposed
  21791. * @returns true if the geometry was disposed
  21792. */
  21793. isDisposed(): boolean;
  21794. private _disposeVertexArrayObjects;
  21795. /**
  21796. * Free all associated resources
  21797. */
  21798. dispose(): void;
  21799. /**
  21800. * Clone the current geometry into a new geometry
  21801. * @param id defines the unique ID of the new geometry
  21802. * @returns a new geometry object
  21803. */
  21804. copy(id: string): Geometry;
  21805. /**
  21806. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21807. * @return a JSON representation of the current geometry data (without the vertices data)
  21808. */
  21809. serialize(): any;
  21810. private toNumberArray;
  21811. /**
  21812. * Serialize all vertices data into a JSON oject
  21813. * @returns a JSON representation of the current geometry data
  21814. */
  21815. serializeVerticeData(): any;
  21816. /**
  21817. * Extracts a clone of a mesh geometry
  21818. * @param mesh defines the source mesh
  21819. * @param id defines the unique ID of the new geometry object
  21820. * @returns the new geometry object
  21821. */
  21822. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21823. /**
  21824. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21825. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21826. * Be aware Math.random() could cause collisions, but:
  21827. * "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"
  21828. * @returns a string containing a new GUID
  21829. */
  21830. static RandomId(): string;
  21831. /** @hidden */
  21832. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21833. private static _CleanMatricesWeights;
  21834. /**
  21835. * Create a new geometry from persisted data (Using .babylon file format)
  21836. * @param parsedVertexData defines the persisted data
  21837. * @param scene defines the hosting scene
  21838. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21839. * @returns the new geometry object
  21840. */
  21841. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21842. }
  21843. }
  21844. declare module BABYLON {
  21845. /**
  21846. * Define an interface for all classes that will get and set the data on vertices
  21847. */
  21848. export interface IGetSetVerticesData {
  21849. /**
  21850. * Gets a boolean indicating if specific vertex data is present
  21851. * @param kind defines the vertex data kind to use
  21852. * @returns true is data kind is present
  21853. */
  21854. isVerticesDataPresent(kind: string): boolean;
  21855. /**
  21856. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21857. * @param kind defines the data kind (Position, normal, etc...)
  21858. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21859. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21860. * @returns a float array containing vertex data
  21861. */
  21862. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21863. /**
  21864. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21865. * @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.
  21866. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21867. * @returns the indices array or an empty array if the mesh has no geometry
  21868. */
  21869. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21870. /**
  21871. * Set specific vertex data
  21872. * @param kind defines the data kind (Position, normal, etc...)
  21873. * @param data defines the vertex data to use
  21874. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21875. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21876. */
  21877. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21878. /**
  21879. * Update a specific associated vertex buffer
  21880. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21881. * - VertexBuffer.PositionKind
  21882. * - VertexBuffer.UVKind
  21883. * - VertexBuffer.UV2Kind
  21884. * - VertexBuffer.UV3Kind
  21885. * - VertexBuffer.UV4Kind
  21886. * - VertexBuffer.UV5Kind
  21887. * - VertexBuffer.UV6Kind
  21888. * - VertexBuffer.ColorKind
  21889. * - VertexBuffer.MatricesIndicesKind
  21890. * - VertexBuffer.MatricesIndicesExtraKind
  21891. * - VertexBuffer.MatricesWeightsKind
  21892. * - VertexBuffer.MatricesWeightsExtraKind
  21893. * @param data defines the data source
  21894. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21895. * @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)
  21896. */
  21897. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21898. /**
  21899. * Creates a new index buffer
  21900. * @param indices defines the indices to store in the index buffer
  21901. * @param totalVertices defines the total number of vertices (could be null)
  21902. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21903. */
  21904. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21905. }
  21906. /**
  21907. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21908. */
  21909. export class VertexData {
  21910. /**
  21911. * Mesh side orientation : usually the external or front surface
  21912. */
  21913. static readonly FRONTSIDE: number;
  21914. /**
  21915. * Mesh side orientation : usually the internal or back surface
  21916. */
  21917. static readonly BACKSIDE: number;
  21918. /**
  21919. * Mesh side orientation : both internal and external or front and back surfaces
  21920. */
  21921. static readonly DOUBLESIDE: number;
  21922. /**
  21923. * Mesh side orientation : by default, `FRONTSIDE`
  21924. */
  21925. static readonly DEFAULTSIDE: number;
  21926. /**
  21927. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21928. */
  21929. positions: Nullable<FloatArray>;
  21930. /**
  21931. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  21932. */
  21933. normals: Nullable<FloatArray>;
  21934. /**
  21935. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  21936. */
  21937. tangents: Nullable<FloatArray>;
  21938. /**
  21939. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21940. */
  21941. uvs: Nullable<FloatArray>;
  21942. /**
  21943. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21944. */
  21945. uvs2: Nullable<FloatArray>;
  21946. /**
  21947. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21948. */
  21949. uvs3: Nullable<FloatArray>;
  21950. /**
  21951. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21952. */
  21953. uvs4: Nullable<FloatArray>;
  21954. /**
  21955. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21956. */
  21957. uvs5: Nullable<FloatArray>;
  21958. /**
  21959. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  21960. */
  21961. uvs6: Nullable<FloatArray>;
  21962. /**
  21963. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  21964. */
  21965. colors: Nullable<FloatArray>;
  21966. /**
  21967. * 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).
  21968. */
  21969. matricesIndices: Nullable<FloatArray>;
  21970. /**
  21971. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  21972. */
  21973. matricesWeights: Nullable<FloatArray>;
  21974. /**
  21975. * An array extending the number of possible indices
  21976. */
  21977. matricesIndicesExtra: Nullable<FloatArray>;
  21978. /**
  21979. * An array extending the number of possible weights when the number of indices is extended
  21980. */
  21981. matricesWeightsExtra: Nullable<FloatArray>;
  21982. /**
  21983. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  21984. */
  21985. indices: Nullable<IndicesArray>;
  21986. /**
  21987. * Uses the passed data array to set the set the values for the specified kind of data
  21988. * @param data a linear array of floating numbers
  21989. * @param kind the type of data that is being set, eg positions, colors etc
  21990. */
  21991. set(data: FloatArray, kind: string): void;
  21992. /**
  21993. * Associates the vertexData to the passed Mesh.
  21994. * Sets it as updatable or not (default `false`)
  21995. * @param mesh the mesh the vertexData is applied to
  21996. * @param updatable when used and having the value true allows new data to update the vertexData
  21997. * @returns the VertexData
  21998. */
  21999. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22000. /**
  22001. * Associates the vertexData to the passed Geometry.
  22002. * Sets it as updatable or not (default `false`)
  22003. * @param geometry the geometry the vertexData is applied to
  22004. * @param updatable when used and having the value true allows new data to update the vertexData
  22005. * @returns VertexData
  22006. */
  22007. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22008. /**
  22009. * Updates the associated mesh
  22010. * @param mesh the mesh to be updated
  22011. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22012. * @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
  22013. * @returns VertexData
  22014. */
  22015. updateMesh(mesh: Mesh): VertexData;
  22016. /**
  22017. * Updates the associated geometry
  22018. * @param geometry the geometry to be updated
  22019. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22020. * @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
  22021. * @returns VertexData.
  22022. */
  22023. updateGeometry(geometry: Geometry): VertexData;
  22024. private _applyTo;
  22025. private _update;
  22026. /**
  22027. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22028. * @param matrix the transforming matrix
  22029. * @returns the VertexData
  22030. */
  22031. transform(matrix: Matrix): VertexData;
  22032. /**
  22033. * Merges the passed VertexData into the current one
  22034. * @param other the VertexData to be merged into the current one
  22035. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22036. * @returns the modified VertexData
  22037. */
  22038. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22039. private _mergeElement;
  22040. private _validate;
  22041. /**
  22042. * Serializes the VertexData
  22043. * @returns a serialized object
  22044. */
  22045. serialize(): any;
  22046. /**
  22047. * Extracts the vertexData from a mesh
  22048. * @param mesh the mesh from which to extract the VertexData
  22049. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22050. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22051. * @returns the object VertexData associated to the passed mesh
  22052. */
  22053. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22054. /**
  22055. * Extracts the vertexData from the geometry
  22056. * @param geometry the geometry from which to extract the VertexData
  22057. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22058. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22059. * @returns the object VertexData associated to the passed mesh
  22060. */
  22061. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22062. private static _ExtractFrom;
  22063. /**
  22064. * Creates the VertexData for a Ribbon
  22065. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22066. * * pathArray array of paths, each of which an array of successive Vector3
  22067. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22068. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22069. * * 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
  22070. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22071. * * 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)
  22072. * * 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)
  22073. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22074. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22075. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22076. * @returns the VertexData of the ribbon
  22077. */
  22078. static CreateRibbon(options: {
  22079. pathArray: Vector3[][];
  22080. closeArray?: boolean;
  22081. closePath?: boolean;
  22082. offset?: number;
  22083. sideOrientation?: number;
  22084. frontUVs?: Vector4;
  22085. backUVs?: Vector4;
  22086. invertUV?: boolean;
  22087. uvs?: Vector2[];
  22088. colors?: Color4[];
  22089. }): VertexData;
  22090. /**
  22091. * Creates the VertexData for a box
  22092. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22093. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22094. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22095. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22096. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22097. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22098. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22099. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22100. * * 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)
  22101. * * 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)
  22102. * @returns the VertexData of the box
  22103. */
  22104. static CreateBox(options: {
  22105. size?: number;
  22106. width?: number;
  22107. height?: number;
  22108. depth?: number;
  22109. faceUV?: Vector4[];
  22110. faceColors?: Color4[];
  22111. sideOrientation?: number;
  22112. frontUVs?: Vector4;
  22113. backUVs?: Vector4;
  22114. }): VertexData;
  22115. /**
  22116. * Creates the VertexData for a tiled box
  22117. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22118. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22119. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22120. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22121. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22122. * @returns the VertexData of the box
  22123. */
  22124. static CreateTiledBox(options: {
  22125. pattern?: number;
  22126. width?: number;
  22127. height?: number;
  22128. depth?: number;
  22129. tileSize?: number;
  22130. tileWidth?: number;
  22131. tileHeight?: number;
  22132. alignHorizontal?: number;
  22133. alignVertical?: number;
  22134. faceUV?: Vector4[];
  22135. faceColors?: Color4[];
  22136. sideOrientation?: number;
  22137. }): VertexData;
  22138. /**
  22139. * Creates the VertexData for a tiled plane
  22140. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22141. * * pattern a limited pattern arrangement depending on the number
  22142. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22143. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22144. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22145. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22146. * * 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)
  22147. * * 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)
  22148. * @returns the VertexData of the tiled plane
  22149. */
  22150. static CreateTiledPlane(options: {
  22151. pattern?: number;
  22152. tileSize?: number;
  22153. tileWidth?: number;
  22154. tileHeight?: number;
  22155. size?: number;
  22156. width?: number;
  22157. height?: number;
  22158. alignHorizontal?: number;
  22159. alignVertical?: number;
  22160. sideOrientation?: number;
  22161. frontUVs?: Vector4;
  22162. backUVs?: Vector4;
  22163. }): VertexData;
  22164. /**
  22165. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22166. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22167. * * segments sets the number of horizontal strips optional, default 32
  22168. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22169. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22170. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22171. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22172. * * 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
  22173. * * 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
  22174. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22175. * * 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)
  22176. * * 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)
  22177. * @returns the VertexData of the ellipsoid
  22178. */
  22179. static CreateSphere(options: {
  22180. segments?: number;
  22181. diameter?: number;
  22182. diameterX?: number;
  22183. diameterY?: number;
  22184. diameterZ?: number;
  22185. arc?: number;
  22186. slice?: number;
  22187. sideOrientation?: number;
  22188. frontUVs?: Vector4;
  22189. backUVs?: Vector4;
  22190. }): VertexData;
  22191. /**
  22192. * Creates the VertexData for a cylinder, cone or prism
  22193. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22194. * * height sets the height (y direction) of the cylinder, optional, default 2
  22195. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22196. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22197. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22198. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22199. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22200. * * 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
  22201. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22202. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22203. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22204. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22205. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22206. * * 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)
  22207. * * 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)
  22208. * @returns the VertexData of the cylinder, cone or prism
  22209. */
  22210. static CreateCylinder(options: {
  22211. height?: number;
  22212. diameterTop?: number;
  22213. diameterBottom?: number;
  22214. diameter?: number;
  22215. tessellation?: number;
  22216. subdivisions?: number;
  22217. arc?: number;
  22218. faceColors?: Color4[];
  22219. faceUV?: Vector4[];
  22220. hasRings?: boolean;
  22221. enclose?: boolean;
  22222. sideOrientation?: number;
  22223. frontUVs?: Vector4;
  22224. backUVs?: Vector4;
  22225. }): VertexData;
  22226. /**
  22227. * Creates the VertexData for a torus
  22228. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22229. * * diameter the diameter of the torus, optional default 1
  22230. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22231. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22232. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22233. * * 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)
  22234. * * 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)
  22235. * @returns the VertexData of the torus
  22236. */
  22237. static CreateTorus(options: {
  22238. diameter?: number;
  22239. thickness?: number;
  22240. tessellation?: number;
  22241. sideOrientation?: number;
  22242. frontUVs?: Vector4;
  22243. backUVs?: Vector4;
  22244. }): VertexData;
  22245. /**
  22246. * Creates the VertexData of the LineSystem
  22247. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22248. * - lines an array of lines, each line being an array of successive Vector3
  22249. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22250. * @returns the VertexData of the LineSystem
  22251. */
  22252. static CreateLineSystem(options: {
  22253. lines: Vector3[][];
  22254. colors?: Nullable<Color4[][]>;
  22255. }): VertexData;
  22256. /**
  22257. * Create the VertexData for a DashedLines
  22258. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22259. * - points an array successive Vector3
  22260. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22261. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22262. * - dashNb the intended total number of dashes, optional, default 200
  22263. * @returns the VertexData for the DashedLines
  22264. */
  22265. static CreateDashedLines(options: {
  22266. points: Vector3[];
  22267. dashSize?: number;
  22268. gapSize?: number;
  22269. dashNb?: number;
  22270. }): VertexData;
  22271. /**
  22272. * Creates the VertexData for a Ground
  22273. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22274. * - width the width (x direction) of the ground, optional, default 1
  22275. * - height the height (z direction) of the ground, optional, default 1
  22276. * - subdivisions the number of subdivisions per side, optional, default 1
  22277. * @returns the VertexData of the Ground
  22278. */
  22279. static CreateGround(options: {
  22280. width?: number;
  22281. height?: number;
  22282. subdivisions?: number;
  22283. subdivisionsX?: number;
  22284. subdivisionsY?: number;
  22285. }): VertexData;
  22286. /**
  22287. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22288. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22289. * * xmin the ground minimum X coordinate, optional, default -1
  22290. * * zmin the ground minimum Z coordinate, optional, default -1
  22291. * * xmax the ground maximum X coordinate, optional, default 1
  22292. * * zmax the ground maximum Z coordinate, optional, default 1
  22293. * * 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}
  22294. * * 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}
  22295. * @returns the VertexData of the TiledGround
  22296. */
  22297. static CreateTiledGround(options: {
  22298. xmin: number;
  22299. zmin: number;
  22300. xmax: number;
  22301. zmax: number;
  22302. subdivisions?: {
  22303. w: number;
  22304. h: number;
  22305. };
  22306. precision?: {
  22307. w: number;
  22308. h: number;
  22309. };
  22310. }): VertexData;
  22311. /**
  22312. * Creates the VertexData of the Ground designed from a heightmap
  22313. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22314. * * width the width (x direction) of the ground
  22315. * * height the height (z direction) of the ground
  22316. * * subdivisions the number of subdivisions per side
  22317. * * minHeight the minimum altitude on the ground, optional, default 0
  22318. * * maxHeight the maximum altitude on the ground, optional default 1
  22319. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22320. * * buffer the array holding the image color data
  22321. * * bufferWidth the width of image
  22322. * * bufferHeight the height of image
  22323. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22324. * @returns the VertexData of the Ground designed from a heightmap
  22325. */
  22326. static CreateGroundFromHeightMap(options: {
  22327. width: number;
  22328. height: number;
  22329. subdivisions: number;
  22330. minHeight: number;
  22331. maxHeight: number;
  22332. colorFilter: Color3;
  22333. buffer: Uint8Array;
  22334. bufferWidth: number;
  22335. bufferHeight: number;
  22336. alphaFilter: number;
  22337. }): VertexData;
  22338. /**
  22339. * Creates the VertexData for a Plane
  22340. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22341. * * size sets the width and height of the plane to the value of size, optional default 1
  22342. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22343. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22344. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22345. * * 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)
  22346. * * 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)
  22347. * @returns the VertexData of the box
  22348. */
  22349. static CreatePlane(options: {
  22350. size?: number;
  22351. width?: number;
  22352. height?: number;
  22353. sideOrientation?: number;
  22354. frontUVs?: Vector4;
  22355. backUVs?: Vector4;
  22356. }): VertexData;
  22357. /**
  22358. * Creates the VertexData of the Disc or regular Polygon
  22359. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22360. * * radius the radius of the disc, optional default 0.5
  22361. * * tessellation the number of polygon sides, optional, default 64
  22362. * * 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
  22363. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22364. * * 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)
  22365. * * 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)
  22366. * @returns the VertexData of the box
  22367. */
  22368. static CreateDisc(options: {
  22369. radius?: number;
  22370. tessellation?: number;
  22371. arc?: number;
  22372. sideOrientation?: number;
  22373. frontUVs?: Vector4;
  22374. backUVs?: Vector4;
  22375. }): VertexData;
  22376. /**
  22377. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22378. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22379. * @param polygon a mesh built from polygonTriangulation.build()
  22380. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22381. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22382. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22383. * @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)
  22384. * @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)
  22385. * @returns the VertexData of the Polygon
  22386. */
  22387. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22388. /**
  22389. * Creates the VertexData of the IcoSphere
  22390. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22391. * * radius the radius of the IcoSphere, optional default 1
  22392. * * radiusX allows stretching in the x direction, optional, default radius
  22393. * * radiusY allows stretching in the y direction, optional, default radius
  22394. * * radiusZ allows stretching in the z direction, optional, default radius
  22395. * * flat when true creates a flat shaded mesh, optional, default true
  22396. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22397. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22398. * * 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)
  22399. * * 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)
  22400. * @returns the VertexData of the IcoSphere
  22401. */
  22402. static CreateIcoSphere(options: {
  22403. radius?: number;
  22404. radiusX?: number;
  22405. radiusY?: number;
  22406. radiusZ?: number;
  22407. flat?: boolean;
  22408. subdivisions?: number;
  22409. sideOrientation?: number;
  22410. frontUVs?: Vector4;
  22411. backUVs?: Vector4;
  22412. }): VertexData;
  22413. /**
  22414. * Creates the VertexData for a Polyhedron
  22415. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22416. * * type provided types are:
  22417. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22418. * * 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)
  22419. * * size the size of the IcoSphere, optional default 1
  22420. * * sizeX allows stretching in the x direction, optional, default size
  22421. * * sizeY allows stretching in the y direction, optional, default size
  22422. * * sizeZ allows stretching in the z direction, optional, default size
  22423. * * 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
  22424. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22425. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22426. * * flat when true creates a flat shaded mesh, optional, default true
  22427. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22428. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22429. * * 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)
  22430. * * 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)
  22431. * @returns the VertexData of the Polyhedron
  22432. */
  22433. static CreatePolyhedron(options: {
  22434. type?: number;
  22435. size?: number;
  22436. sizeX?: number;
  22437. sizeY?: number;
  22438. sizeZ?: number;
  22439. custom?: any;
  22440. faceUV?: Vector4[];
  22441. faceColors?: Color4[];
  22442. flat?: boolean;
  22443. sideOrientation?: number;
  22444. frontUVs?: Vector4;
  22445. backUVs?: Vector4;
  22446. }): VertexData;
  22447. /**
  22448. * Creates the VertexData for a TorusKnot
  22449. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22450. * * radius the radius of the torus knot, optional, default 2
  22451. * * tube the thickness of the tube, optional, default 0.5
  22452. * * radialSegments the number of sides on each tube segments, optional, default 32
  22453. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22454. * * p the number of windings around the z axis, optional, default 2
  22455. * * q the number of windings around the x axis, optional, default 3
  22456. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22457. * * 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)
  22458. * * 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)
  22459. * @returns the VertexData of the Torus Knot
  22460. */
  22461. static CreateTorusKnot(options: {
  22462. radius?: number;
  22463. tube?: number;
  22464. radialSegments?: number;
  22465. tubularSegments?: number;
  22466. p?: number;
  22467. q?: number;
  22468. sideOrientation?: number;
  22469. frontUVs?: Vector4;
  22470. backUVs?: Vector4;
  22471. }): VertexData;
  22472. /**
  22473. * Compute normals for given positions and indices
  22474. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22475. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22476. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22477. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22478. * * facetNormals : optional array of facet normals (vector3)
  22479. * * facetPositions : optional array of facet positions (vector3)
  22480. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22481. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22482. * * bInfo : optional bounding info, required for facetPartitioning computation
  22483. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22484. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22485. * * useRightHandedSystem: optional boolean to for right handed system computation
  22486. * * depthSort : optional boolean to enable the facet depth sort computation
  22487. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22488. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22489. */
  22490. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22491. facetNormals?: any;
  22492. facetPositions?: any;
  22493. facetPartitioning?: any;
  22494. ratio?: number;
  22495. bInfo?: any;
  22496. bbSize?: Vector3;
  22497. subDiv?: any;
  22498. useRightHandedSystem?: boolean;
  22499. depthSort?: boolean;
  22500. distanceTo?: Vector3;
  22501. depthSortedFacets?: any;
  22502. }): void;
  22503. /** @hidden */
  22504. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22505. /**
  22506. * Applies VertexData created from the imported parameters to the geometry
  22507. * @param parsedVertexData the parsed data from an imported file
  22508. * @param geometry the geometry to apply the VertexData to
  22509. */
  22510. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22511. }
  22512. }
  22513. declare module BABYLON {
  22514. /**
  22515. * Defines a target to use with MorphTargetManager
  22516. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22517. */
  22518. export class MorphTarget implements IAnimatable {
  22519. /** defines the name of the target */
  22520. name: string;
  22521. /**
  22522. * Gets or sets the list of animations
  22523. */
  22524. animations: Animation[];
  22525. private _scene;
  22526. private _positions;
  22527. private _normals;
  22528. private _tangents;
  22529. private _uvs;
  22530. private _influence;
  22531. private _uniqueId;
  22532. /**
  22533. * Observable raised when the influence changes
  22534. */
  22535. onInfluenceChanged: Observable<boolean>;
  22536. /** @hidden */
  22537. _onDataLayoutChanged: Observable<void>;
  22538. /**
  22539. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22540. */
  22541. get influence(): number;
  22542. set influence(influence: number);
  22543. /**
  22544. * Gets or sets the id of the morph Target
  22545. */
  22546. id: string;
  22547. private _animationPropertiesOverride;
  22548. /**
  22549. * Gets or sets the animation properties override
  22550. */
  22551. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  22552. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  22553. /**
  22554. * Creates a new MorphTarget
  22555. * @param name defines the name of the target
  22556. * @param influence defines the influence to use
  22557. * @param scene defines the scene the morphtarget belongs to
  22558. */
  22559. constructor(
  22560. /** defines the name of the target */
  22561. name: string, influence?: number, scene?: Nullable<Scene>);
  22562. /**
  22563. * Gets the unique ID of this manager
  22564. */
  22565. get uniqueId(): number;
  22566. /**
  22567. * Gets a boolean defining if the target contains position data
  22568. */
  22569. get hasPositions(): boolean;
  22570. /**
  22571. * Gets a boolean defining if the target contains normal data
  22572. */
  22573. get hasNormals(): boolean;
  22574. /**
  22575. * Gets a boolean defining if the target contains tangent data
  22576. */
  22577. get hasTangents(): boolean;
  22578. /**
  22579. * Gets a boolean defining if the target contains texture coordinates data
  22580. */
  22581. get hasUVs(): boolean;
  22582. /**
  22583. * Affects position data to this target
  22584. * @param data defines the position data to use
  22585. */
  22586. setPositions(data: Nullable<FloatArray>): void;
  22587. /**
  22588. * Gets the position data stored in this target
  22589. * @returns a FloatArray containing the position data (or null if not present)
  22590. */
  22591. getPositions(): Nullable<FloatArray>;
  22592. /**
  22593. * Affects normal data to this target
  22594. * @param data defines the normal data to use
  22595. */
  22596. setNormals(data: Nullable<FloatArray>): void;
  22597. /**
  22598. * Gets the normal data stored in this target
  22599. * @returns a FloatArray containing the normal data (or null if not present)
  22600. */
  22601. getNormals(): Nullable<FloatArray>;
  22602. /**
  22603. * Affects tangent data to this target
  22604. * @param data defines the tangent data to use
  22605. */
  22606. setTangents(data: Nullable<FloatArray>): void;
  22607. /**
  22608. * Gets the tangent data stored in this target
  22609. * @returns a FloatArray containing the tangent data (or null if not present)
  22610. */
  22611. getTangents(): Nullable<FloatArray>;
  22612. /**
  22613. * Affects texture coordinates data to this target
  22614. * @param data defines the texture coordinates data to use
  22615. */
  22616. setUVs(data: Nullable<FloatArray>): void;
  22617. /**
  22618. * Gets the texture coordinates data stored in this target
  22619. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22620. */
  22621. getUVs(): Nullable<FloatArray>;
  22622. /**
  22623. * Clone the current target
  22624. * @returns a new MorphTarget
  22625. */
  22626. clone(): MorphTarget;
  22627. /**
  22628. * Serializes the current target into a Serialization object
  22629. * @returns the serialized object
  22630. */
  22631. serialize(): any;
  22632. /**
  22633. * Returns the string "MorphTarget"
  22634. * @returns "MorphTarget"
  22635. */
  22636. getClassName(): string;
  22637. /**
  22638. * Creates a new target from serialized data
  22639. * @param serializationObject defines the serialized data to use
  22640. * @returns a new MorphTarget
  22641. */
  22642. static Parse(serializationObject: any): MorphTarget;
  22643. /**
  22644. * Creates a MorphTarget from mesh data
  22645. * @param mesh defines the source mesh
  22646. * @param name defines the name to use for the new target
  22647. * @param influence defines the influence to attach to the target
  22648. * @returns a new MorphTarget
  22649. */
  22650. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22651. }
  22652. }
  22653. declare module BABYLON {
  22654. /**
  22655. * This class is used to deform meshes using morphing between different targets
  22656. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22657. */
  22658. export class MorphTargetManager {
  22659. private _targets;
  22660. private _targetInfluenceChangedObservers;
  22661. private _targetDataLayoutChangedObservers;
  22662. private _activeTargets;
  22663. private _scene;
  22664. private _influences;
  22665. private _supportsNormals;
  22666. private _supportsTangents;
  22667. private _supportsUVs;
  22668. private _vertexCount;
  22669. private _uniqueId;
  22670. private _tempInfluences;
  22671. /**
  22672. * Gets or sets a boolean indicating if normals must be morphed
  22673. */
  22674. enableNormalMorphing: boolean;
  22675. /**
  22676. * Gets or sets a boolean indicating if tangents must be morphed
  22677. */
  22678. enableTangentMorphing: boolean;
  22679. /**
  22680. * Gets or sets a boolean indicating if UV must be morphed
  22681. */
  22682. enableUVMorphing: boolean;
  22683. /**
  22684. * Creates a new MorphTargetManager
  22685. * @param scene defines the current scene
  22686. */
  22687. constructor(scene?: Nullable<Scene>);
  22688. /**
  22689. * Gets the unique ID of this manager
  22690. */
  22691. get uniqueId(): number;
  22692. /**
  22693. * Gets the number of vertices handled by this manager
  22694. */
  22695. get vertexCount(): number;
  22696. /**
  22697. * Gets a boolean indicating if this manager supports morphing of normals
  22698. */
  22699. get supportsNormals(): boolean;
  22700. /**
  22701. * Gets a boolean indicating if this manager supports morphing of tangents
  22702. */
  22703. get supportsTangents(): boolean;
  22704. /**
  22705. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22706. */
  22707. get supportsUVs(): boolean;
  22708. /**
  22709. * Gets the number of targets stored in this manager
  22710. */
  22711. get numTargets(): number;
  22712. /**
  22713. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22714. */
  22715. get numInfluencers(): number;
  22716. /**
  22717. * Gets the list of influences (one per target)
  22718. */
  22719. get influences(): Float32Array;
  22720. /**
  22721. * Gets the active target at specified index. An active target is a target with an influence > 0
  22722. * @param index defines the index to check
  22723. * @returns the requested target
  22724. */
  22725. getActiveTarget(index: number): MorphTarget;
  22726. /**
  22727. * Gets the target at specified index
  22728. * @param index defines the index to check
  22729. * @returns the requested target
  22730. */
  22731. getTarget(index: number): MorphTarget;
  22732. /**
  22733. * Add a new target to this manager
  22734. * @param target defines the target to add
  22735. */
  22736. addTarget(target: MorphTarget): void;
  22737. /**
  22738. * Removes a target from the manager
  22739. * @param target defines the target to remove
  22740. */
  22741. removeTarget(target: MorphTarget): void;
  22742. /**
  22743. * Clone the current manager
  22744. * @returns a new MorphTargetManager
  22745. */
  22746. clone(): MorphTargetManager;
  22747. /**
  22748. * Serializes the current manager into a Serialization object
  22749. * @returns the serialized object
  22750. */
  22751. serialize(): any;
  22752. private _syncActiveTargets;
  22753. /**
  22754. * Syncrhonize the targets with all the meshes using this morph target manager
  22755. */
  22756. synchronize(): void;
  22757. /**
  22758. * Creates a new MorphTargetManager from serialized data
  22759. * @param serializationObject defines the serialized data
  22760. * @param scene defines the hosting scene
  22761. * @returns the new MorphTargetManager
  22762. */
  22763. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22764. }
  22765. }
  22766. declare module BABYLON {
  22767. /**
  22768. * Class used to represent a specific level of detail of a mesh
  22769. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22770. */
  22771. export class MeshLODLevel {
  22772. /** Defines the distance where this level should start being displayed */
  22773. distance: number;
  22774. /** Defines the mesh to use to render this level */
  22775. mesh: Nullable<Mesh>;
  22776. /**
  22777. * Creates a new LOD level
  22778. * @param distance defines the distance where this level should star being displayed
  22779. * @param mesh defines the mesh to use to render this level
  22780. */
  22781. constructor(
  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. }
  22788. declare module BABYLON {
  22789. /**
  22790. * Mesh representing the gorund
  22791. */
  22792. export class GroundMesh extends Mesh {
  22793. /** If octree should be generated */
  22794. generateOctree: boolean;
  22795. private _heightQuads;
  22796. /** @hidden */
  22797. _subdivisionsX: number;
  22798. /** @hidden */
  22799. _subdivisionsY: number;
  22800. /** @hidden */
  22801. _width: number;
  22802. /** @hidden */
  22803. _height: number;
  22804. /** @hidden */
  22805. _minX: number;
  22806. /** @hidden */
  22807. _maxX: number;
  22808. /** @hidden */
  22809. _minZ: number;
  22810. /** @hidden */
  22811. _maxZ: number;
  22812. constructor(name: string, scene: Scene);
  22813. /**
  22814. * "GroundMesh"
  22815. * @returns "GroundMesh"
  22816. */
  22817. getClassName(): string;
  22818. /**
  22819. * The minimum of x and y subdivisions
  22820. */
  22821. get subdivisions(): number;
  22822. /**
  22823. * X subdivisions
  22824. */
  22825. get subdivisionsX(): number;
  22826. /**
  22827. * Y subdivisions
  22828. */
  22829. get subdivisionsY(): number;
  22830. /**
  22831. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22832. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22833. * @param chunksCount the number of subdivisions for x and y
  22834. * @param octreeBlocksSize (Default: 32)
  22835. */
  22836. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22837. /**
  22838. * Returns a height (y) value in the Worl system :
  22839. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22840. * @param x x coordinate
  22841. * @param z z coordinate
  22842. * @returns the ground y position if (x, z) are outside the ground surface.
  22843. */
  22844. getHeightAtCoordinates(x: number, z: number): number;
  22845. /**
  22846. * Returns a normalized vector (Vector3) orthogonal to the ground
  22847. * at the ground coordinates (x, z) expressed in the World system.
  22848. * @param x x coordinate
  22849. * @param z z coordinate
  22850. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22851. */
  22852. getNormalAtCoordinates(x: number, z: number): Vector3;
  22853. /**
  22854. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22855. * at the ground coordinates (x, z) expressed in the World system.
  22856. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22857. * @param x x coordinate
  22858. * @param z z coordinate
  22859. * @param ref vector to store the result
  22860. * @returns the GroundMesh.
  22861. */
  22862. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22863. /**
  22864. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22865. * if the ground has been updated.
  22866. * This can be used in the render loop.
  22867. * @returns the GroundMesh.
  22868. */
  22869. updateCoordinateHeights(): GroundMesh;
  22870. private _getFacetAt;
  22871. private _initHeightQuads;
  22872. private _computeHeightQuads;
  22873. /**
  22874. * Serializes this ground mesh
  22875. * @param serializationObject object to write serialization to
  22876. */
  22877. serialize(serializationObject: any): void;
  22878. /**
  22879. * Parses a serialized ground mesh
  22880. * @param parsedMesh the serialized mesh
  22881. * @param scene the scene to create the ground mesh in
  22882. * @returns the created ground mesh
  22883. */
  22884. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22885. }
  22886. }
  22887. declare module BABYLON {
  22888. /**
  22889. * Interface for Physics-Joint data
  22890. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22891. */
  22892. export interface PhysicsJointData {
  22893. /**
  22894. * The main pivot of the joint
  22895. */
  22896. mainPivot?: Vector3;
  22897. /**
  22898. * The connected pivot of the joint
  22899. */
  22900. connectedPivot?: Vector3;
  22901. /**
  22902. * The main axis of the joint
  22903. */
  22904. mainAxis?: Vector3;
  22905. /**
  22906. * The connected axis of the joint
  22907. */
  22908. connectedAxis?: Vector3;
  22909. /**
  22910. * The collision of the joint
  22911. */
  22912. collision?: boolean;
  22913. /**
  22914. * Native Oimo/Cannon/Energy data
  22915. */
  22916. nativeParams?: any;
  22917. }
  22918. /**
  22919. * This is a holder class for the physics joint created by the physics plugin
  22920. * It holds a set of functions to control the underlying joint
  22921. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22922. */
  22923. export class PhysicsJoint {
  22924. /**
  22925. * The type of the physics joint
  22926. */
  22927. type: number;
  22928. /**
  22929. * The data for the physics joint
  22930. */
  22931. jointData: PhysicsJointData;
  22932. private _physicsJoint;
  22933. protected _physicsPlugin: IPhysicsEnginePlugin;
  22934. /**
  22935. * Initializes the physics joint
  22936. * @param type The type of the physics joint
  22937. * @param jointData The data for the physics joint
  22938. */
  22939. constructor(
  22940. /**
  22941. * The type of the physics joint
  22942. */
  22943. type: number,
  22944. /**
  22945. * The data for the physics joint
  22946. */
  22947. jointData: PhysicsJointData);
  22948. /**
  22949. * Gets the physics joint
  22950. */
  22951. get physicsJoint(): any;
  22952. /**
  22953. * Sets the physics joint
  22954. */
  22955. set physicsJoint(newJoint: any);
  22956. /**
  22957. * Sets the physics plugin
  22958. */
  22959. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  22960. /**
  22961. * Execute a function that is physics-plugin specific.
  22962. * @param {Function} func the function that will be executed.
  22963. * It accepts two parameters: the physics world and the physics joint
  22964. */
  22965. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  22966. /**
  22967. * Distance-Joint type
  22968. */
  22969. static DistanceJoint: number;
  22970. /**
  22971. * Hinge-Joint type
  22972. */
  22973. static HingeJoint: number;
  22974. /**
  22975. * Ball-and-Socket joint type
  22976. */
  22977. static BallAndSocketJoint: number;
  22978. /**
  22979. * Wheel-Joint type
  22980. */
  22981. static WheelJoint: number;
  22982. /**
  22983. * Slider-Joint type
  22984. */
  22985. static SliderJoint: number;
  22986. /**
  22987. * Prismatic-Joint type
  22988. */
  22989. static PrismaticJoint: number;
  22990. /**
  22991. * Universal-Joint type
  22992. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  22993. */
  22994. static UniversalJoint: number;
  22995. /**
  22996. * Hinge-Joint 2 type
  22997. */
  22998. static Hinge2Joint: number;
  22999. /**
  23000. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23001. */
  23002. static PointToPointJoint: number;
  23003. /**
  23004. * Spring-Joint type
  23005. */
  23006. static SpringJoint: number;
  23007. /**
  23008. * Lock-Joint type
  23009. */
  23010. static LockJoint: number;
  23011. }
  23012. /**
  23013. * A class representing a physics distance joint
  23014. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23015. */
  23016. export class DistanceJoint extends PhysicsJoint {
  23017. /**
  23018. *
  23019. * @param jointData The data for the Distance-Joint
  23020. */
  23021. constructor(jointData: DistanceJointData);
  23022. /**
  23023. * Update the predefined distance.
  23024. * @param maxDistance The maximum preferred distance
  23025. * @param minDistance The minimum preferred distance
  23026. */
  23027. updateDistance(maxDistance: number, minDistance?: number): void;
  23028. }
  23029. /**
  23030. * Represents a Motor-Enabled Joint
  23031. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23032. */
  23033. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23034. /**
  23035. * Initializes the Motor-Enabled Joint
  23036. * @param type The type of the joint
  23037. * @param jointData The physica joint data for the joint
  23038. */
  23039. constructor(type: number, jointData: PhysicsJointData);
  23040. /**
  23041. * Set the motor values.
  23042. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23043. * @param force the force to apply
  23044. * @param maxForce max force for this motor.
  23045. */
  23046. setMotor(force?: number, maxForce?: number): void;
  23047. /**
  23048. * Set the motor's limits.
  23049. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23050. * @param upperLimit The upper limit of the motor
  23051. * @param lowerLimit The lower limit of the motor
  23052. */
  23053. setLimit(upperLimit: number, lowerLimit?: number): void;
  23054. }
  23055. /**
  23056. * This class represents a single physics Hinge-Joint
  23057. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23058. */
  23059. export class HingeJoint extends MotorEnabledJoint {
  23060. /**
  23061. * Initializes the Hinge-Joint
  23062. * @param jointData The joint data for the Hinge-Joint
  23063. */
  23064. constructor(jointData: PhysicsJointData);
  23065. /**
  23066. * Set the motor values.
  23067. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23068. * @param {number} force the force to apply
  23069. * @param {number} maxForce max force for this motor.
  23070. */
  23071. setMotor(force?: number, maxForce?: number): void;
  23072. /**
  23073. * Set the motor's limits.
  23074. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23075. * @param upperLimit The upper limit of the motor
  23076. * @param lowerLimit The lower limit of the motor
  23077. */
  23078. setLimit(upperLimit: number, lowerLimit?: number): void;
  23079. }
  23080. /**
  23081. * This class represents a dual hinge physics joint (same as wheel joint)
  23082. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23083. */
  23084. export class Hinge2Joint extends MotorEnabledJoint {
  23085. /**
  23086. * Initializes the Hinge2-Joint
  23087. * @param jointData The joint data for the Hinge2-Joint
  23088. */
  23089. constructor(jointData: PhysicsJointData);
  23090. /**
  23091. * Set the motor values.
  23092. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23093. * @param {number} targetSpeed the speed the motor is to reach
  23094. * @param {number} maxForce max force for this motor.
  23095. * @param {motorIndex} the motor's index, 0 or 1.
  23096. */
  23097. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23098. /**
  23099. * Set the motor limits.
  23100. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23101. * @param {number} upperLimit the upper limit
  23102. * @param {number} lowerLimit lower limit
  23103. * @param {motorIndex} the motor's index, 0 or 1.
  23104. */
  23105. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23106. }
  23107. /**
  23108. * Interface for a motor enabled joint
  23109. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23110. */
  23111. export interface IMotorEnabledJoint {
  23112. /**
  23113. * Physics joint
  23114. */
  23115. physicsJoint: any;
  23116. /**
  23117. * Sets the motor of the motor-enabled joint
  23118. * @param force The force of the motor
  23119. * @param maxForce The maximum force of the motor
  23120. * @param motorIndex The index of the motor
  23121. */
  23122. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23123. /**
  23124. * Sets the limit of the motor
  23125. * @param upperLimit The upper limit of the motor
  23126. * @param lowerLimit The lower limit of the motor
  23127. * @param motorIndex The index of the motor
  23128. */
  23129. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23130. }
  23131. /**
  23132. * Joint data for a Distance-Joint
  23133. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23134. */
  23135. export interface DistanceJointData extends PhysicsJointData {
  23136. /**
  23137. * Max distance the 2 joint objects can be apart
  23138. */
  23139. maxDistance: number;
  23140. }
  23141. /**
  23142. * Joint data from a spring joint
  23143. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23144. */
  23145. export interface SpringJointData extends PhysicsJointData {
  23146. /**
  23147. * Length of the spring
  23148. */
  23149. length: number;
  23150. /**
  23151. * Stiffness of the spring
  23152. */
  23153. stiffness: number;
  23154. /**
  23155. * Damping of the spring
  23156. */
  23157. damping: number;
  23158. /** this callback will be called when applying the force to the impostors. */
  23159. forceApplicationCallback: () => void;
  23160. }
  23161. }
  23162. declare module BABYLON {
  23163. /**
  23164. * Holds the data for the raycast result
  23165. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23166. */
  23167. export class PhysicsRaycastResult {
  23168. private _hasHit;
  23169. private _hitDistance;
  23170. private _hitNormalWorld;
  23171. private _hitPointWorld;
  23172. private _rayFromWorld;
  23173. private _rayToWorld;
  23174. /**
  23175. * Gets if there was a hit
  23176. */
  23177. get hasHit(): boolean;
  23178. /**
  23179. * Gets the distance from the hit
  23180. */
  23181. get hitDistance(): number;
  23182. /**
  23183. * Gets the hit normal/direction in the world
  23184. */
  23185. get hitNormalWorld(): Vector3;
  23186. /**
  23187. * Gets the hit point in the world
  23188. */
  23189. get hitPointWorld(): Vector3;
  23190. /**
  23191. * Gets the ray "start point" of the ray in the world
  23192. */
  23193. get rayFromWorld(): Vector3;
  23194. /**
  23195. * Gets the ray "end point" of the ray in the world
  23196. */
  23197. get rayToWorld(): Vector3;
  23198. /**
  23199. * Sets the hit data (normal & point in world space)
  23200. * @param hitNormalWorld defines the normal in world space
  23201. * @param hitPointWorld defines the point in world space
  23202. */
  23203. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23204. /**
  23205. * Sets the distance from the start point to the hit point
  23206. * @param distance
  23207. */
  23208. setHitDistance(distance: number): void;
  23209. /**
  23210. * Calculates the distance manually
  23211. */
  23212. calculateHitDistance(): void;
  23213. /**
  23214. * Resets all the values to default
  23215. * @param from The from point on world space
  23216. * @param to The to point on world space
  23217. */
  23218. reset(from?: Vector3, to?: Vector3): void;
  23219. }
  23220. /**
  23221. * Interface for the size containing width and height
  23222. */
  23223. interface IXYZ {
  23224. /**
  23225. * X
  23226. */
  23227. x: number;
  23228. /**
  23229. * Y
  23230. */
  23231. y: number;
  23232. /**
  23233. * Z
  23234. */
  23235. z: number;
  23236. }
  23237. }
  23238. declare module BABYLON {
  23239. /**
  23240. * Interface used to describe a physics joint
  23241. */
  23242. export interface PhysicsImpostorJoint {
  23243. /** Defines the main impostor to which the joint is linked */
  23244. mainImpostor: PhysicsImpostor;
  23245. /** Defines the impostor that is connected to the main impostor using this joint */
  23246. connectedImpostor: PhysicsImpostor;
  23247. /** Defines the joint itself */
  23248. joint: PhysicsJoint;
  23249. }
  23250. /** @hidden */
  23251. export interface IPhysicsEnginePlugin {
  23252. world: any;
  23253. name: string;
  23254. setGravity(gravity: Vector3): void;
  23255. setTimeStep(timeStep: number): void;
  23256. getTimeStep(): number;
  23257. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23258. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23259. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23260. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23261. removePhysicsBody(impostor: PhysicsImpostor): void;
  23262. generateJoint(joint: PhysicsImpostorJoint): void;
  23263. removeJoint(joint: PhysicsImpostorJoint): void;
  23264. isSupported(): boolean;
  23265. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23266. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23267. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23268. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23269. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23270. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23271. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23272. getBodyMass(impostor: PhysicsImpostor): number;
  23273. getBodyFriction(impostor: PhysicsImpostor): number;
  23274. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23275. getBodyRestitution(impostor: PhysicsImpostor): number;
  23276. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23277. getBodyPressure?(impostor: PhysicsImpostor): number;
  23278. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23279. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23280. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23281. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23282. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23283. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23284. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23285. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23286. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23287. sleepBody(impostor: PhysicsImpostor): void;
  23288. wakeUpBody(impostor: PhysicsImpostor): void;
  23289. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23290. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23291. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23292. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23293. getRadius(impostor: PhysicsImpostor): number;
  23294. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23295. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23296. dispose(): void;
  23297. }
  23298. /**
  23299. * Interface used to define a physics engine
  23300. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23301. */
  23302. export interface IPhysicsEngine {
  23303. /**
  23304. * Gets the gravity vector used by the simulation
  23305. */
  23306. gravity: Vector3;
  23307. /**
  23308. * Sets the gravity vector used by the simulation
  23309. * @param gravity defines the gravity vector to use
  23310. */
  23311. setGravity(gravity: Vector3): void;
  23312. /**
  23313. * Set the time step of the physics engine.
  23314. * Default is 1/60.
  23315. * To slow it down, enter 1/600 for example.
  23316. * To speed it up, 1/30
  23317. * @param newTimeStep the new timestep to apply to this world.
  23318. */
  23319. setTimeStep(newTimeStep: number): void;
  23320. /**
  23321. * Get the time step of the physics engine.
  23322. * @returns the current time step
  23323. */
  23324. getTimeStep(): number;
  23325. /**
  23326. * Set the sub time step of the physics engine.
  23327. * Default is 0 meaning there is no sub steps
  23328. * To increase physics resolution precision, set a small value (like 1 ms)
  23329. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23330. */
  23331. setSubTimeStep(subTimeStep: number): void;
  23332. /**
  23333. * Get the sub time step of the physics engine.
  23334. * @returns the current sub time step
  23335. */
  23336. getSubTimeStep(): number;
  23337. /**
  23338. * Release all resources
  23339. */
  23340. dispose(): void;
  23341. /**
  23342. * Gets the name of the current physics plugin
  23343. * @returns the name of the plugin
  23344. */
  23345. getPhysicsPluginName(): string;
  23346. /**
  23347. * Adding a new impostor for the impostor tracking.
  23348. * This will be done by the impostor itself.
  23349. * @param impostor the impostor to add
  23350. */
  23351. addImpostor(impostor: PhysicsImpostor): void;
  23352. /**
  23353. * Remove an impostor from the engine.
  23354. * This impostor and its mesh will not longer be updated by the physics engine.
  23355. * @param impostor the impostor to remove
  23356. */
  23357. removeImpostor(impostor: PhysicsImpostor): void;
  23358. /**
  23359. * Add a joint to the physics engine
  23360. * @param mainImpostor defines the main impostor to which the joint is added.
  23361. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23362. * @param joint defines the joint that will connect both impostors.
  23363. */
  23364. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23365. /**
  23366. * Removes a joint from the simulation
  23367. * @param mainImpostor defines the impostor used with the joint
  23368. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23369. * @param joint defines the joint to remove
  23370. */
  23371. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23372. /**
  23373. * Gets the current plugin used to run the simulation
  23374. * @returns current plugin
  23375. */
  23376. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23377. /**
  23378. * Gets the list of physic impostors
  23379. * @returns an array of PhysicsImpostor
  23380. */
  23381. getImpostors(): Array<PhysicsImpostor>;
  23382. /**
  23383. * Gets the impostor for a physics enabled object
  23384. * @param object defines the object impersonated by the impostor
  23385. * @returns the PhysicsImpostor or null if not found
  23386. */
  23387. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23388. /**
  23389. * Gets the impostor for a physics body object
  23390. * @param body defines physics body used by the impostor
  23391. * @returns the PhysicsImpostor or null if not found
  23392. */
  23393. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23394. /**
  23395. * Does a raycast in the physics world
  23396. * @param from when should the ray start?
  23397. * @param to when should the ray end?
  23398. * @returns PhysicsRaycastResult
  23399. */
  23400. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23401. /**
  23402. * Called by the scene. No need to call it.
  23403. * @param delta defines the timespam between frames
  23404. */
  23405. _step(delta: number): void;
  23406. }
  23407. }
  23408. declare module BABYLON {
  23409. /**
  23410. * The interface for the physics imposter parameters
  23411. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23412. */
  23413. export interface PhysicsImpostorParameters {
  23414. /**
  23415. * The mass of the physics imposter
  23416. */
  23417. mass: number;
  23418. /**
  23419. * The friction of the physics imposter
  23420. */
  23421. friction?: number;
  23422. /**
  23423. * The coefficient of restitution of the physics imposter
  23424. */
  23425. restitution?: number;
  23426. /**
  23427. * The native options of the physics imposter
  23428. */
  23429. nativeOptions?: any;
  23430. /**
  23431. * Specifies if the parent should be ignored
  23432. */
  23433. ignoreParent?: boolean;
  23434. /**
  23435. * Specifies if bi-directional transformations should be disabled
  23436. */
  23437. disableBidirectionalTransformation?: boolean;
  23438. /**
  23439. * The pressure inside the physics imposter, soft object only
  23440. */
  23441. pressure?: number;
  23442. /**
  23443. * The stiffness the physics imposter, soft object only
  23444. */
  23445. stiffness?: number;
  23446. /**
  23447. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23448. */
  23449. velocityIterations?: number;
  23450. /**
  23451. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23452. */
  23453. positionIterations?: number;
  23454. /**
  23455. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23456. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23457. * Add to fix multiple points
  23458. */
  23459. fixedPoints?: number;
  23460. /**
  23461. * The collision margin around a soft object
  23462. */
  23463. margin?: number;
  23464. /**
  23465. * The collision margin around a soft object
  23466. */
  23467. damping?: number;
  23468. /**
  23469. * The path for a rope based on an extrusion
  23470. */
  23471. path?: any;
  23472. /**
  23473. * The shape of an extrusion used for a rope based on an extrusion
  23474. */
  23475. shape?: any;
  23476. }
  23477. /**
  23478. * Interface for a physics-enabled object
  23479. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23480. */
  23481. export interface IPhysicsEnabledObject {
  23482. /**
  23483. * The position of the physics-enabled object
  23484. */
  23485. position: Vector3;
  23486. /**
  23487. * The rotation of the physics-enabled object
  23488. */
  23489. rotationQuaternion: Nullable<Quaternion>;
  23490. /**
  23491. * The scale of the physics-enabled object
  23492. */
  23493. scaling: Vector3;
  23494. /**
  23495. * The rotation of the physics-enabled object
  23496. */
  23497. rotation?: Vector3;
  23498. /**
  23499. * The parent of the physics-enabled object
  23500. */
  23501. parent?: any;
  23502. /**
  23503. * The bounding info of the physics-enabled object
  23504. * @returns The bounding info of the physics-enabled object
  23505. */
  23506. getBoundingInfo(): BoundingInfo;
  23507. /**
  23508. * Computes the world matrix
  23509. * @param force Specifies if the world matrix should be computed by force
  23510. * @returns A world matrix
  23511. */
  23512. computeWorldMatrix(force: boolean): Matrix;
  23513. /**
  23514. * Gets the world matrix
  23515. * @returns A world matrix
  23516. */
  23517. getWorldMatrix?(): Matrix;
  23518. /**
  23519. * Gets the child meshes
  23520. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23521. * @returns An array of abstract meshes
  23522. */
  23523. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23524. /**
  23525. * Gets the vertex data
  23526. * @param kind The type of vertex data
  23527. * @returns A nullable array of numbers, or a float32 array
  23528. */
  23529. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23530. /**
  23531. * Gets the indices from the mesh
  23532. * @returns A nullable array of index arrays
  23533. */
  23534. getIndices?(): Nullable<IndicesArray>;
  23535. /**
  23536. * Gets the scene from the mesh
  23537. * @returns the indices array or null
  23538. */
  23539. getScene?(): Scene;
  23540. /**
  23541. * Gets the absolute position from the mesh
  23542. * @returns the absolute position
  23543. */
  23544. getAbsolutePosition(): Vector3;
  23545. /**
  23546. * Gets the absolute pivot point from the mesh
  23547. * @returns the absolute pivot point
  23548. */
  23549. getAbsolutePivotPoint(): Vector3;
  23550. /**
  23551. * Rotates the mesh
  23552. * @param axis The axis of rotation
  23553. * @param amount The amount of rotation
  23554. * @param space The space of the rotation
  23555. * @returns The rotation transform node
  23556. */
  23557. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23558. /**
  23559. * Translates the mesh
  23560. * @param axis The axis of translation
  23561. * @param distance The distance of translation
  23562. * @param space The space of the translation
  23563. * @returns The transform node
  23564. */
  23565. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23566. /**
  23567. * Sets the absolute position of the mesh
  23568. * @param absolutePosition The absolute position of the mesh
  23569. * @returns The transform node
  23570. */
  23571. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23572. /**
  23573. * Gets the class name of the mesh
  23574. * @returns The class name
  23575. */
  23576. getClassName(): string;
  23577. }
  23578. /**
  23579. * Represents a physics imposter
  23580. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23581. */
  23582. export class PhysicsImpostor {
  23583. /**
  23584. * The physics-enabled object used as the physics imposter
  23585. */
  23586. object: IPhysicsEnabledObject;
  23587. /**
  23588. * The type of the physics imposter
  23589. */
  23590. type: number;
  23591. private _options;
  23592. private _scene?;
  23593. /**
  23594. * The default object size of the imposter
  23595. */
  23596. static DEFAULT_OBJECT_SIZE: Vector3;
  23597. /**
  23598. * The identity quaternion of the imposter
  23599. */
  23600. static IDENTITY_QUATERNION: Quaternion;
  23601. /** @hidden */
  23602. _pluginData: any;
  23603. private _physicsEngine;
  23604. private _physicsBody;
  23605. private _bodyUpdateRequired;
  23606. private _onBeforePhysicsStepCallbacks;
  23607. private _onAfterPhysicsStepCallbacks;
  23608. /** @hidden */
  23609. _onPhysicsCollideCallbacks: Array<{
  23610. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23611. otherImpostors: Array<PhysicsImpostor>;
  23612. }>;
  23613. private _deltaPosition;
  23614. private _deltaRotation;
  23615. private _deltaRotationConjugated;
  23616. /** @hidden */
  23617. _isFromLine: boolean;
  23618. private _parent;
  23619. private _isDisposed;
  23620. private static _tmpVecs;
  23621. private static _tmpQuat;
  23622. /**
  23623. * Specifies if the physics imposter is disposed
  23624. */
  23625. get isDisposed(): boolean;
  23626. /**
  23627. * Gets the mass of the physics imposter
  23628. */
  23629. get mass(): number;
  23630. set mass(value: number);
  23631. /**
  23632. * Gets the coefficient of friction
  23633. */
  23634. get friction(): number;
  23635. /**
  23636. * Sets the coefficient of friction
  23637. */
  23638. set friction(value: number);
  23639. /**
  23640. * Gets the coefficient of restitution
  23641. */
  23642. get restitution(): number;
  23643. /**
  23644. * Sets the coefficient of restitution
  23645. */
  23646. set restitution(value: number);
  23647. /**
  23648. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23649. */
  23650. get pressure(): number;
  23651. /**
  23652. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23653. */
  23654. set pressure(value: number);
  23655. /**
  23656. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23657. */
  23658. get stiffness(): number;
  23659. /**
  23660. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23661. */
  23662. set stiffness(value: number);
  23663. /**
  23664. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23665. */
  23666. get velocityIterations(): number;
  23667. /**
  23668. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23669. */
  23670. set velocityIterations(value: number);
  23671. /**
  23672. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23673. */
  23674. get positionIterations(): number;
  23675. /**
  23676. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23677. */
  23678. set positionIterations(value: number);
  23679. /**
  23680. * The unique id of the physics imposter
  23681. * set by the physics engine when adding this impostor to the array
  23682. */
  23683. uniqueId: number;
  23684. /**
  23685. * @hidden
  23686. */
  23687. soft: boolean;
  23688. /**
  23689. * @hidden
  23690. */
  23691. segments: number;
  23692. private _joints;
  23693. /**
  23694. * Initializes the physics imposter
  23695. * @param object The physics-enabled object used as the physics imposter
  23696. * @param type The type of the physics imposter
  23697. * @param _options The options for the physics imposter
  23698. * @param _scene The Babylon scene
  23699. */
  23700. constructor(
  23701. /**
  23702. * The physics-enabled object used as the physics imposter
  23703. */
  23704. object: IPhysicsEnabledObject,
  23705. /**
  23706. * The type of the physics imposter
  23707. */
  23708. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23709. /**
  23710. * This function will completly initialize this impostor.
  23711. * It will create a new body - but only if this mesh has no parent.
  23712. * If it has, this impostor will not be used other than to define the impostor
  23713. * of the child mesh.
  23714. * @hidden
  23715. */
  23716. _init(): void;
  23717. private _getPhysicsParent;
  23718. /**
  23719. * Should a new body be generated.
  23720. * @returns boolean specifying if body initialization is required
  23721. */
  23722. isBodyInitRequired(): boolean;
  23723. /**
  23724. * Sets the updated scaling
  23725. * @param updated Specifies if the scaling is updated
  23726. */
  23727. setScalingUpdated(): void;
  23728. /**
  23729. * Force a regeneration of this or the parent's impostor's body.
  23730. * Use under cautious - This will remove all joints already implemented.
  23731. */
  23732. forceUpdate(): void;
  23733. /**
  23734. * Gets the body that holds this impostor. Either its own, or its parent.
  23735. */
  23736. get physicsBody(): any;
  23737. /**
  23738. * Get the parent of the physics imposter
  23739. * @returns Physics imposter or null
  23740. */
  23741. get parent(): Nullable<PhysicsImpostor>;
  23742. /**
  23743. * Sets the parent of the physics imposter
  23744. */
  23745. set parent(value: Nullable<PhysicsImpostor>);
  23746. /**
  23747. * Set the physics body. Used mainly by the physics engine/plugin
  23748. */
  23749. set physicsBody(physicsBody: any);
  23750. /**
  23751. * Resets the update flags
  23752. */
  23753. resetUpdateFlags(): void;
  23754. /**
  23755. * Gets the object extend size
  23756. * @returns the object extend size
  23757. */
  23758. getObjectExtendSize(): Vector3;
  23759. /**
  23760. * Gets the object center
  23761. * @returns The object center
  23762. */
  23763. getObjectCenter(): Vector3;
  23764. /**
  23765. * Get a specific parametes from the options parameter
  23766. * @param paramName The object parameter name
  23767. * @returns The object parameter
  23768. */
  23769. getParam(paramName: string): any;
  23770. /**
  23771. * Sets a specific parameter in the options given to the physics plugin
  23772. * @param paramName The parameter name
  23773. * @param value The value of the parameter
  23774. */
  23775. setParam(paramName: string, value: number): void;
  23776. /**
  23777. * Specifically change the body's mass option. Won't recreate the physics body object
  23778. * @param mass The mass of the physics imposter
  23779. */
  23780. setMass(mass: number): void;
  23781. /**
  23782. * Gets the linear velocity
  23783. * @returns linear velocity or null
  23784. */
  23785. getLinearVelocity(): Nullable<Vector3>;
  23786. /**
  23787. * Sets the linear velocity
  23788. * @param velocity linear velocity or null
  23789. */
  23790. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23791. /**
  23792. * Gets the angular velocity
  23793. * @returns angular velocity or null
  23794. */
  23795. getAngularVelocity(): Nullable<Vector3>;
  23796. /**
  23797. * Sets the angular velocity
  23798. * @param velocity The velocity or null
  23799. */
  23800. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23801. /**
  23802. * Execute a function with the physics plugin native code
  23803. * Provide a function the will have two variables - the world object and the physics body object
  23804. * @param func The function to execute with the physics plugin native code
  23805. */
  23806. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23807. /**
  23808. * Register a function that will be executed before the physics world is stepping forward
  23809. * @param func The function to execute before the physics world is stepped forward
  23810. */
  23811. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23812. /**
  23813. * Unregister a function that will be executed before the physics world is stepping forward
  23814. * @param func The function to execute before the physics world is stepped forward
  23815. */
  23816. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23817. /**
  23818. * Register a function that will be executed after the physics step
  23819. * @param func The function to execute after physics step
  23820. */
  23821. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23822. /**
  23823. * Unregisters a function that will be executed after the physics step
  23824. * @param func The function to execute after physics step
  23825. */
  23826. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23827. /**
  23828. * register a function that will be executed when this impostor collides against a different body
  23829. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23830. * @param func Callback that is executed on collision
  23831. */
  23832. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23833. /**
  23834. * Unregisters the physics imposter on contact
  23835. * @param collideAgainst The physics object to collide against
  23836. * @param func Callback to execute on collision
  23837. */
  23838. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23839. private _tmpQuat;
  23840. private _tmpQuat2;
  23841. /**
  23842. * Get the parent rotation
  23843. * @returns The parent rotation
  23844. */
  23845. getParentsRotation(): Quaternion;
  23846. /**
  23847. * this function is executed by the physics engine.
  23848. */
  23849. beforeStep: () => void;
  23850. /**
  23851. * this function is executed by the physics engine
  23852. */
  23853. afterStep: () => void;
  23854. /**
  23855. * Legacy collision detection event support
  23856. */
  23857. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23858. /**
  23859. * event and body object due to cannon's event-based architecture.
  23860. */
  23861. onCollide: (e: {
  23862. body: any;
  23863. }) => void;
  23864. /**
  23865. * Apply a force
  23866. * @param force The force to apply
  23867. * @param contactPoint The contact point for the force
  23868. * @returns The physics imposter
  23869. */
  23870. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23871. /**
  23872. * Apply an impulse
  23873. * @param force The impulse force
  23874. * @param contactPoint The contact point for the impulse force
  23875. * @returns The physics imposter
  23876. */
  23877. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23878. /**
  23879. * A help function to create a joint
  23880. * @param otherImpostor A physics imposter used to create a joint
  23881. * @param jointType The type of joint
  23882. * @param jointData The data for the joint
  23883. * @returns The physics imposter
  23884. */
  23885. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23886. /**
  23887. * Add a joint to this impostor with a different impostor
  23888. * @param otherImpostor A physics imposter used to add a joint
  23889. * @param joint The joint to add
  23890. * @returns The physics imposter
  23891. */
  23892. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23893. /**
  23894. * Add an anchor to a cloth impostor
  23895. * @param otherImpostor rigid impostor to anchor to
  23896. * @param width ratio across width from 0 to 1
  23897. * @param height ratio up height from 0 to 1
  23898. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23899. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23900. * @returns impostor the soft imposter
  23901. */
  23902. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23903. /**
  23904. * Add a hook to a rope impostor
  23905. * @param otherImpostor rigid impostor to anchor to
  23906. * @param length ratio across rope from 0 to 1
  23907. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23908. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23909. * @returns impostor the rope imposter
  23910. */
  23911. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23912. /**
  23913. * Will keep this body still, in a sleep mode.
  23914. * @returns the physics imposter
  23915. */
  23916. sleep(): PhysicsImpostor;
  23917. /**
  23918. * Wake the body up.
  23919. * @returns The physics imposter
  23920. */
  23921. wakeUp(): PhysicsImpostor;
  23922. /**
  23923. * Clones the physics imposter
  23924. * @param newObject The physics imposter clones to this physics-enabled object
  23925. * @returns A nullable physics imposter
  23926. */
  23927. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23928. /**
  23929. * Disposes the physics imposter
  23930. */
  23931. dispose(): void;
  23932. /**
  23933. * Sets the delta position
  23934. * @param position The delta position amount
  23935. */
  23936. setDeltaPosition(position: Vector3): void;
  23937. /**
  23938. * Sets the delta rotation
  23939. * @param rotation The delta rotation amount
  23940. */
  23941. setDeltaRotation(rotation: Quaternion): void;
  23942. /**
  23943. * Gets the box size of the physics imposter and stores the result in the input parameter
  23944. * @param result Stores the box size
  23945. * @returns The physics imposter
  23946. */
  23947. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  23948. /**
  23949. * Gets the radius of the physics imposter
  23950. * @returns Radius of the physics imposter
  23951. */
  23952. getRadius(): number;
  23953. /**
  23954. * Sync a bone with this impostor
  23955. * @param bone The bone to sync to the impostor.
  23956. * @param boneMesh The mesh that the bone is influencing.
  23957. * @param jointPivot The pivot of the joint / bone in local space.
  23958. * @param distToJoint Optional distance from the impostor to the joint.
  23959. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23960. */
  23961. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  23962. /**
  23963. * Sync impostor to a bone
  23964. * @param bone The bone that the impostor will be synced to.
  23965. * @param boneMesh The mesh that the bone is influencing.
  23966. * @param jointPivot The pivot of the joint / bone in local space.
  23967. * @param distToJoint Optional distance from the impostor to the joint.
  23968. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  23969. * @param boneAxis Optional vector3 axis the bone is aligned with
  23970. */
  23971. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  23972. /**
  23973. * No-Imposter type
  23974. */
  23975. static NoImpostor: number;
  23976. /**
  23977. * Sphere-Imposter type
  23978. */
  23979. static SphereImpostor: number;
  23980. /**
  23981. * Box-Imposter type
  23982. */
  23983. static BoxImpostor: number;
  23984. /**
  23985. * Plane-Imposter type
  23986. */
  23987. static PlaneImpostor: number;
  23988. /**
  23989. * Mesh-imposter type
  23990. */
  23991. static MeshImpostor: number;
  23992. /**
  23993. * Capsule-Impostor type (Ammo.js plugin only)
  23994. */
  23995. static CapsuleImpostor: number;
  23996. /**
  23997. * Cylinder-Imposter type
  23998. */
  23999. static CylinderImpostor: number;
  24000. /**
  24001. * Particle-Imposter type
  24002. */
  24003. static ParticleImpostor: number;
  24004. /**
  24005. * Heightmap-Imposter type
  24006. */
  24007. static HeightmapImpostor: number;
  24008. /**
  24009. * ConvexHull-Impostor type (Ammo.js plugin only)
  24010. */
  24011. static ConvexHullImpostor: number;
  24012. /**
  24013. * Custom-Imposter type (Ammo.js plugin only)
  24014. */
  24015. static CustomImpostor: number;
  24016. /**
  24017. * Rope-Imposter type
  24018. */
  24019. static RopeImpostor: number;
  24020. /**
  24021. * Cloth-Imposter type
  24022. */
  24023. static ClothImpostor: number;
  24024. /**
  24025. * Softbody-Imposter type
  24026. */
  24027. static SoftbodyImpostor: number;
  24028. }
  24029. }
  24030. declare module BABYLON {
  24031. /**
  24032. * @hidden
  24033. **/
  24034. export class _CreationDataStorage {
  24035. closePath?: boolean;
  24036. closeArray?: boolean;
  24037. idx: number[];
  24038. dashSize: number;
  24039. gapSize: number;
  24040. path3D: Path3D;
  24041. pathArray: Vector3[][];
  24042. arc: number;
  24043. radius: number;
  24044. cap: number;
  24045. tessellation: number;
  24046. }
  24047. /**
  24048. * @hidden
  24049. **/
  24050. class _InstanceDataStorage {
  24051. visibleInstances: any;
  24052. batchCache: _InstancesBatch;
  24053. instancesBufferSize: number;
  24054. instancesBuffer: Nullable<Buffer>;
  24055. instancesData: Float32Array;
  24056. overridenInstanceCount: number;
  24057. isFrozen: boolean;
  24058. previousBatch: Nullable<_InstancesBatch>;
  24059. hardwareInstancedRendering: boolean;
  24060. sideOrientation: number;
  24061. manualUpdate: boolean;
  24062. }
  24063. /**
  24064. * @hidden
  24065. **/
  24066. export class _InstancesBatch {
  24067. mustReturn: boolean;
  24068. visibleInstances: Nullable<InstancedMesh[]>[];
  24069. renderSelf: boolean[];
  24070. hardwareInstancedRendering: boolean[];
  24071. }
  24072. /**
  24073. * Class used to represent renderable models
  24074. */
  24075. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24076. /**
  24077. * Mesh side orientation : usually the external or front surface
  24078. */
  24079. static readonly FRONTSIDE: number;
  24080. /**
  24081. * Mesh side orientation : usually the internal or back surface
  24082. */
  24083. static readonly BACKSIDE: number;
  24084. /**
  24085. * Mesh side orientation : both internal and external or front and back surfaces
  24086. */
  24087. static readonly DOUBLESIDE: number;
  24088. /**
  24089. * Mesh side orientation : by default, `FRONTSIDE`
  24090. */
  24091. static readonly DEFAULTSIDE: number;
  24092. /**
  24093. * Mesh cap setting : no cap
  24094. */
  24095. static readonly NO_CAP: number;
  24096. /**
  24097. * Mesh cap setting : one cap at the beginning of the mesh
  24098. */
  24099. static readonly CAP_START: number;
  24100. /**
  24101. * Mesh cap setting : one cap at the end of the mesh
  24102. */
  24103. static readonly CAP_END: number;
  24104. /**
  24105. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24106. */
  24107. static readonly CAP_ALL: number;
  24108. /**
  24109. * Mesh pattern setting : no flip or rotate
  24110. */
  24111. static readonly NO_FLIP: number;
  24112. /**
  24113. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24114. */
  24115. static readonly FLIP_TILE: number;
  24116. /**
  24117. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24118. */
  24119. static readonly ROTATE_TILE: number;
  24120. /**
  24121. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24122. */
  24123. static readonly FLIP_ROW: number;
  24124. /**
  24125. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24126. */
  24127. static readonly ROTATE_ROW: number;
  24128. /**
  24129. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24130. */
  24131. static readonly FLIP_N_ROTATE_TILE: number;
  24132. /**
  24133. * Mesh pattern setting : rotate pattern and rotate
  24134. */
  24135. static readonly FLIP_N_ROTATE_ROW: number;
  24136. /**
  24137. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24138. */
  24139. static readonly CENTER: number;
  24140. /**
  24141. * Mesh tile positioning : part tiles on left
  24142. */
  24143. static readonly LEFT: number;
  24144. /**
  24145. * Mesh tile positioning : part tiles on right
  24146. */
  24147. static readonly RIGHT: number;
  24148. /**
  24149. * Mesh tile positioning : part tiles on top
  24150. */
  24151. static readonly TOP: number;
  24152. /**
  24153. * Mesh tile positioning : part tiles on bottom
  24154. */
  24155. static readonly BOTTOM: number;
  24156. /**
  24157. * Gets the default side orientation.
  24158. * @param orientation the orientation to value to attempt to get
  24159. * @returns the default orientation
  24160. * @hidden
  24161. */
  24162. static _GetDefaultSideOrientation(orientation?: number): number;
  24163. private _internalMeshDataInfo;
  24164. /**
  24165. * An event triggered before rendering the mesh
  24166. */
  24167. get onBeforeRenderObservable(): Observable<Mesh>;
  24168. /**
  24169. * An event triggered before binding the mesh
  24170. */
  24171. get onBeforeBindObservable(): Observable<Mesh>;
  24172. /**
  24173. * An event triggered after rendering the mesh
  24174. */
  24175. get onAfterRenderObservable(): Observable<Mesh>;
  24176. /**
  24177. * An event triggered before drawing the mesh
  24178. */
  24179. get onBeforeDrawObservable(): Observable<Mesh>;
  24180. private _onBeforeDrawObserver;
  24181. /**
  24182. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24183. */
  24184. set onBeforeDraw(callback: () => void);
  24185. get hasInstances(): boolean;
  24186. /**
  24187. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24188. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24189. */
  24190. delayLoadState: number;
  24191. /**
  24192. * Gets the list of instances created from this mesh
  24193. * it is not supposed to be modified manually.
  24194. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24195. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24196. */
  24197. instances: InstancedMesh[];
  24198. /**
  24199. * Gets the file containing delay loading data for this mesh
  24200. */
  24201. delayLoadingFile: string;
  24202. /** @hidden */
  24203. _binaryInfo: any;
  24204. /**
  24205. * User defined function used to change how LOD level selection is done
  24206. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24207. */
  24208. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24209. /**
  24210. * Gets or sets the morph target manager
  24211. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24212. */
  24213. get morphTargetManager(): Nullable<MorphTargetManager>;
  24214. set morphTargetManager(value: Nullable<MorphTargetManager>);
  24215. /** @hidden */
  24216. _creationDataStorage: Nullable<_CreationDataStorage>;
  24217. /** @hidden */
  24218. _geometry: Nullable<Geometry>;
  24219. /** @hidden */
  24220. _delayInfo: Array<string>;
  24221. /** @hidden */
  24222. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24223. /** @hidden */
  24224. _instanceDataStorage: _InstanceDataStorage;
  24225. private _effectiveMaterial;
  24226. /** @hidden */
  24227. _shouldGenerateFlatShading: boolean;
  24228. /** @hidden */
  24229. _originalBuilderSideOrientation: number;
  24230. /**
  24231. * Use this property to change the original side orientation defined at construction time
  24232. */
  24233. overrideMaterialSideOrientation: Nullable<number>;
  24234. /**
  24235. * Gets the source mesh (the one used to clone this one from)
  24236. */
  24237. get source(): Nullable<Mesh>;
  24238. /**
  24239. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24240. */
  24241. get isUnIndexed(): boolean;
  24242. set isUnIndexed(value: boolean);
  24243. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24244. get worldMatrixInstancedBuffer(): Float32Array;
  24245. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24246. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  24247. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  24248. /**
  24249. * @constructor
  24250. * @param name The value used by scene.getMeshByName() to do a lookup.
  24251. * @param scene The scene to add this mesh to.
  24252. * @param parent The parent of this mesh, if it has one
  24253. * @param source An optional Mesh from which geometry is shared, cloned.
  24254. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24255. * When false, achieved by calling a clone(), also passing False.
  24256. * This will make creation of children, recursive.
  24257. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24258. */
  24259. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24260. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24261. doNotInstantiate: boolean;
  24262. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24263. /**
  24264. * Gets the class name
  24265. * @returns the string "Mesh".
  24266. */
  24267. getClassName(): string;
  24268. /** @hidden */
  24269. get _isMesh(): boolean;
  24270. /**
  24271. * Returns a description of this mesh
  24272. * @param fullDetails define if full details about this mesh must be used
  24273. * @returns a descriptive string representing this mesh
  24274. */
  24275. toString(fullDetails?: boolean): string;
  24276. /** @hidden */
  24277. _unBindEffect(): void;
  24278. /**
  24279. * Gets a boolean indicating if this mesh has LOD
  24280. */
  24281. get hasLODLevels(): boolean;
  24282. /**
  24283. * Gets the list of MeshLODLevel associated with the current mesh
  24284. * @returns an array of MeshLODLevel
  24285. */
  24286. getLODLevels(): MeshLODLevel[];
  24287. private _sortLODLevels;
  24288. /**
  24289. * Add a mesh as LOD level triggered at the given distance.
  24290. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24291. * @param distance The distance from the center of the object to show this level
  24292. * @param mesh The mesh to be added as LOD level (can be null)
  24293. * @return This mesh (for chaining)
  24294. */
  24295. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24296. /**
  24297. * Returns the LOD level mesh at the passed distance or null if not found.
  24298. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24299. * @param distance The distance from the center of the object to show this level
  24300. * @returns a Mesh or `null`
  24301. */
  24302. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24303. /**
  24304. * Remove a mesh from the LOD array
  24305. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24306. * @param mesh defines the mesh to be removed
  24307. * @return This mesh (for chaining)
  24308. */
  24309. removeLODLevel(mesh: Mesh): Mesh;
  24310. /**
  24311. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24312. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24313. * @param camera defines the camera to use to compute distance
  24314. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24315. * @return This mesh (for chaining)
  24316. */
  24317. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24318. /**
  24319. * Gets the mesh internal Geometry object
  24320. */
  24321. get geometry(): Nullable<Geometry>;
  24322. /**
  24323. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24324. * @returns the total number of vertices
  24325. */
  24326. getTotalVertices(): number;
  24327. /**
  24328. * Returns the content of an associated vertex buffer
  24329. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24330. * - VertexBuffer.PositionKind
  24331. * - VertexBuffer.UVKind
  24332. * - VertexBuffer.UV2Kind
  24333. * - VertexBuffer.UV3Kind
  24334. * - VertexBuffer.UV4Kind
  24335. * - VertexBuffer.UV5Kind
  24336. * - VertexBuffer.UV6Kind
  24337. * - VertexBuffer.ColorKind
  24338. * - VertexBuffer.MatricesIndicesKind
  24339. * - VertexBuffer.MatricesIndicesExtraKind
  24340. * - VertexBuffer.MatricesWeightsKind
  24341. * - VertexBuffer.MatricesWeightsExtraKind
  24342. * @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
  24343. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24344. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24345. */
  24346. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24347. /**
  24348. * Returns the mesh VertexBuffer object from the requested `kind`
  24349. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24350. * - VertexBuffer.PositionKind
  24351. * - VertexBuffer.NormalKind
  24352. * - VertexBuffer.UVKind
  24353. * - VertexBuffer.UV2Kind
  24354. * - VertexBuffer.UV3Kind
  24355. * - VertexBuffer.UV4Kind
  24356. * - VertexBuffer.UV5Kind
  24357. * - VertexBuffer.UV6Kind
  24358. * - VertexBuffer.ColorKind
  24359. * - VertexBuffer.MatricesIndicesKind
  24360. * - VertexBuffer.MatricesIndicesExtraKind
  24361. * - VertexBuffer.MatricesWeightsKind
  24362. * - VertexBuffer.MatricesWeightsExtraKind
  24363. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24364. */
  24365. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24366. /**
  24367. * Tests if a specific vertex buffer is associated with this mesh
  24368. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24369. * - VertexBuffer.PositionKind
  24370. * - VertexBuffer.NormalKind
  24371. * - VertexBuffer.UVKind
  24372. * - VertexBuffer.UV2Kind
  24373. * - VertexBuffer.UV3Kind
  24374. * - VertexBuffer.UV4Kind
  24375. * - VertexBuffer.UV5Kind
  24376. * - VertexBuffer.UV6Kind
  24377. * - VertexBuffer.ColorKind
  24378. * - VertexBuffer.MatricesIndicesKind
  24379. * - VertexBuffer.MatricesIndicesExtraKind
  24380. * - VertexBuffer.MatricesWeightsKind
  24381. * - VertexBuffer.MatricesWeightsExtraKind
  24382. * @returns a boolean
  24383. */
  24384. isVerticesDataPresent(kind: string): boolean;
  24385. /**
  24386. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24387. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24388. * - VertexBuffer.PositionKind
  24389. * - VertexBuffer.UVKind
  24390. * - VertexBuffer.UV2Kind
  24391. * - VertexBuffer.UV3Kind
  24392. * - VertexBuffer.UV4Kind
  24393. * - VertexBuffer.UV5Kind
  24394. * - VertexBuffer.UV6Kind
  24395. * - VertexBuffer.ColorKind
  24396. * - VertexBuffer.MatricesIndicesKind
  24397. * - VertexBuffer.MatricesIndicesExtraKind
  24398. * - VertexBuffer.MatricesWeightsKind
  24399. * - VertexBuffer.MatricesWeightsExtraKind
  24400. * @returns a boolean
  24401. */
  24402. isVertexBufferUpdatable(kind: string): boolean;
  24403. /**
  24404. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24405. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24406. * - VertexBuffer.PositionKind
  24407. * - VertexBuffer.NormalKind
  24408. * - VertexBuffer.UVKind
  24409. * - VertexBuffer.UV2Kind
  24410. * - VertexBuffer.UV3Kind
  24411. * - VertexBuffer.UV4Kind
  24412. * - VertexBuffer.UV5Kind
  24413. * - VertexBuffer.UV6Kind
  24414. * - VertexBuffer.ColorKind
  24415. * - VertexBuffer.MatricesIndicesKind
  24416. * - VertexBuffer.MatricesIndicesExtraKind
  24417. * - VertexBuffer.MatricesWeightsKind
  24418. * - VertexBuffer.MatricesWeightsExtraKind
  24419. * @returns an array of strings
  24420. */
  24421. getVerticesDataKinds(): string[];
  24422. /**
  24423. * Returns a positive integer : the total number of indices in this mesh geometry.
  24424. * @returns the numner of indices or zero if the mesh has no geometry.
  24425. */
  24426. getTotalIndices(): number;
  24427. /**
  24428. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24429. * @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.
  24430. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24431. * @returns the indices array or an empty array if the mesh has no geometry
  24432. */
  24433. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24434. get isBlocked(): boolean;
  24435. /**
  24436. * Determine if the current mesh is ready to be rendered
  24437. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24438. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24439. * @returns true if all associated assets are ready (material, textures, shaders)
  24440. */
  24441. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24442. /**
  24443. * 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.
  24444. */
  24445. get areNormalsFrozen(): boolean;
  24446. /**
  24447. * 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.
  24448. * @returns the current mesh
  24449. */
  24450. freezeNormals(): Mesh;
  24451. /**
  24452. * 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
  24453. * @returns the current mesh
  24454. */
  24455. unfreezeNormals(): Mesh;
  24456. /**
  24457. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24458. */
  24459. set overridenInstanceCount(count: number);
  24460. /** @hidden */
  24461. _preActivate(): Mesh;
  24462. /** @hidden */
  24463. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24464. /** @hidden */
  24465. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24466. /**
  24467. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24468. * This means the mesh underlying bounding box and sphere are recomputed.
  24469. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24470. * @returns the current mesh
  24471. */
  24472. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24473. /** @hidden */
  24474. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24475. /**
  24476. * This function will subdivide the mesh into multiple submeshes
  24477. * @param count defines the expected number of submeshes
  24478. */
  24479. subdivide(count: number): void;
  24480. /**
  24481. * Copy a FloatArray into a specific associated vertex buffer
  24482. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24483. * - VertexBuffer.PositionKind
  24484. * - VertexBuffer.UVKind
  24485. * - VertexBuffer.UV2Kind
  24486. * - VertexBuffer.UV3Kind
  24487. * - VertexBuffer.UV4Kind
  24488. * - VertexBuffer.UV5Kind
  24489. * - VertexBuffer.UV6Kind
  24490. * - VertexBuffer.ColorKind
  24491. * - VertexBuffer.MatricesIndicesKind
  24492. * - VertexBuffer.MatricesIndicesExtraKind
  24493. * - VertexBuffer.MatricesWeightsKind
  24494. * - VertexBuffer.MatricesWeightsExtraKind
  24495. * @param data defines the data source
  24496. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24497. * @param stride defines the data stride size (can be null)
  24498. * @returns the current mesh
  24499. */
  24500. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24501. /**
  24502. * Delete a vertex buffer associated with this mesh
  24503. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24504. * - VertexBuffer.PositionKind
  24505. * - VertexBuffer.UVKind
  24506. * - VertexBuffer.UV2Kind
  24507. * - VertexBuffer.UV3Kind
  24508. * - VertexBuffer.UV4Kind
  24509. * - VertexBuffer.UV5Kind
  24510. * - VertexBuffer.UV6Kind
  24511. * - VertexBuffer.ColorKind
  24512. * - VertexBuffer.MatricesIndicesKind
  24513. * - VertexBuffer.MatricesIndicesExtraKind
  24514. * - VertexBuffer.MatricesWeightsKind
  24515. * - VertexBuffer.MatricesWeightsExtraKind
  24516. */
  24517. removeVerticesData(kind: string): void;
  24518. /**
  24519. * Flags an associated vertex buffer as updatable
  24520. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24521. * - VertexBuffer.PositionKind
  24522. * - VertexBuffer.UVKind
  24523. * - VertexBuffer.UV2Kind
  24524. * - VertexBuffer.UV3Kind
  24525. * - VertexBuffer.UV4Kind
  24526. * - VertexBuffer.UV5Kind
  24527. * - VertexBuffer.UV6Kind
  24528. * - VertexBuffer.ColorKind
  24529. * - VertexBuffer.MatricesIndicesKind
  24530. * - VertexBuffer.MatricesIndicesExtraKind
  24531. * - VertexBuffer.MatricesWeightsKind
  24532. * - VertexBuffer.MatricesWeightsExtraKind
  24533. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24534. */
  24535. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24536. /**
  24537. * Sets the mesh global Vertex Buffer
  24538. * @param buffer defines the buffer to use
  24539. * @returns the current mesh
  24540. */
  24541. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24542. /**
  24543. * Update a specific associated vertex buffer
  24544. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24545. * - VertexBuffer.PositionKind
  24546. * - VertexBuffer.UVKind
  24547. * - VertexBuffer.UV2Kind
  24548. * - VertexBuffer.UV3Kind
  24549. * - VertexBuffer.UV4Kind
  24550. * - VertexBuffer.UV5Kind
  24551. * - VertexBuffer.UV6Kind
  24552. * - VertexBuffer.ColorKind
  24553. * - VertexBuffer.MatricesIndicesKind
  24554. * - VertexBuffer.MatricesIndicesExtraKind
  24555. * - VertexBuffer.MatricesWeightsKind
  24556. * - VertexBuffer.MatricesWeightsExtraKind
  24557. * @param data defines the data source
  24558. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24559. * @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)
  24560. * @returns the current mesh
  24561. */
  24562. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24563. /**
  24564. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24565. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24566. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24567. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24568. * @returns the current mesh
  24569. */
  24570. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24571. /**
  24572. * Creates a un-shared specific occurence of the geometry for the mesh.
  24573. * @returns the current mesh
  24574. */
  24575. makeGeometryUnique(): Mesh;
  24576. /**
  24577. * Set the index buffer of this mesh
  24578. * @param indices defines the source data
  24579. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24580. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24581. * @returns the current mesh
  24582. */
  24583. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24584. /**
  24585. * Update the current index buffer
  24586. * @param indices defines the source data
  24587. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24588. * @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)
  24589. * @returns the current mesh
  24590. */
  24591. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24592. /**
  24593. * Invert the geometry to move from a right handed system to a left handed one.
  24594. * @returns the current mesh
  24595. */
  24596. toLeftHanded(): Mesh;
  24597. /** @hidden */
  24598. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24599. /** @hidden */
  24600. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24601. /**
  24602. * Registers for this mesh a javascript function called just before the rendering process
  24603. * @param func defines the function to call before rendering this mesh
  24604. * @returns the current mesh
  24605. */
  24606. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24607. /**
  24608. * Disposes a previously registered javascript function called before the rendering
  24609. * @param func defines the function to remove
  24610. * @returns the current mesh
  24611. */
  24612. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24613. /**
  24614. * Registers for this mesh a javascript function called just after the rendering is complete
  24615. * @param func defines the function to call after rendering this mesh
  24616. * @returns the current mesh
  24617. */
  24618. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24619. /**
  24620. * Disposes a previously registered javascript function called after the rendering.
  24621. * @param func defines the function to remove
  24622. * @returns the current mesh
  24623. */
  24624. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24625. /** @hidden */
  24626. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  24627. /** @hidden */
  24628. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24629. /** @hidden */
  24630. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  24631. /** @hidden */
  24632. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24633. /** @hidden */
  24634. _rebuild(): void;
  24635. /** @hidden */
  24636. _freeze(): void;
  24637. /** @hidden */
  24638. _unFreeze(): void;
  24639. /**
  24640. * 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
  24641. * @param subMesh defines the subMesh to render
  24642. * @param enableAlphaMode defines if alpha mode can be changed
  24643. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  24644. * @returns the current mesh
  24645. */
  24646. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  24647. private _onBeforeDraw;
  24648. /**
  24649. * Renormalize the mesh and patch it up if there are no weights
  24650. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24651. * However in the case of zero weights then we set just a single influence to 1.
  24652. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24653. */
  24654. cleanMatrixWeights(): void;
  24655. private normalizeSkinFourWeights;
  24656. private normalizeSkinWeightsAndExtra;
  24657. /**
  24658. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24659. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24660. * the user know there was an issue with importing the mesh
  24661. * @returns a validation object with skinned, valid and report string
  24662. */
  24663. validateSkinning(): {
  24664. skinned: boolean;
  24665. valid: boolean;
  24666. report: string;
  24667. };
  24668. /** @hidden */
  24669. _checkDelayState(): Mesh;
  24670. private _queueLoad;
  24671. /**
  24672. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24673. * A mesh is in the frustum if its bounding box intersects the frustum
  24674. * @param frustumPlanes defines the frustum to test
  24675. * @returns true if the mesh is in the frustum planes
  24676. */
  24677. isInFrustum(frustumPlanes: Plane[]): boolean;
  24678. /**
  24679. * Sets the mesh material by the material or multiMaterial `id` property
  24680. * @param id is a string identifying the material or the multiMaterial
  24681. * @returns the current mesh
  24682. */
  24683. setMaterialByID(id: string): Mesh;
  24684. /**
  24685. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24686. * @returns an array of IAnimatable
  24687. */
  24688. getAnimatables(): IAnimatable[];
  24689. /**
  24690. * Modifies the mesh geometry according to the passed transformation matrix.
  24691. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24692. * The mesh normals are modified using the same transformation.
  24693. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24694. * @param transform defines the transform matrix to use
  24695. * @see http://doc.babylonjs.com/resources/baking_transformations
  24696. * @returns the current mesh
  24697. */
  24698. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24699. /**
  24700. * Modifies the mesh geometry according to its own current World Matrix.
  24701. * The mesh World Matrix is then reset.
  24702. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24703. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24704. * @see http://doc.babylonjs.com/resources/baking_transformations
  24705. * @returns the current mesh
  24706. */
  24707. bakeCurrentTransformIntoVertices(): Mesh;
  24708. /** @hidden */
  24709. get _positions(): Nullable<Vector3[]>;
  24710. /** @hidden */
  24711. _resetPointsArrayCache(): Mesh;
  24712. /** @hidden */
  24713. _generatePointsArray(): boolean;
  24714. /**
  24715. * Returns a new Mesh object generated from the current mesh properties.
  24716. * This method must not get confused with createInstance()
  24717. * @param name is a string, the name given to the new mesh
  24718. * @param newParent can be any Node object (default `null`)
  24719. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24720. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24721. * @returns a new mesh
  24722. */
  24723. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  24724. /**
  24725. * Releases resources associated with this mesh.
  24726. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24727. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24728. */
  24729. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24730. /** @hidden */
  24731. _disposeInstanceSpecificData(): void;
  24732. /**
  24733. * Modifies the mesh geometry according to a displacement map.
  24734. * 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.
  24735. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24736. * @param url is a string, the URL from the image file is to be downloaded.
  24737. * @param minHeight is the lower limit of the displacement.
  24738. * @param maxHeight is the upper limit of the displacement.
  24739. * @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.
  24740. * @param uvOffset is an optional vector2 used to offset UV.
  24741. * @param uvScale is an optional vector2 used to scale UV.
  24742. * @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.
  24743. * @returns the Mesh.
  24744. */
  24745. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24746. /**
  24747. * Modifies the mesh geometry according to a displacementMap buffer.
  24748. * 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.
  24749. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24750. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24751. * @param heightMapWidth is the width of the buffer image.
  24752. * @param heightMapHeight is the height of the buffer image.
  24753. * @param minHeight is the lower limit of the displacement.
  24754. * @param maxHeight is the upper limit of the displacement.
  24755. * @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.
  24756. * @param uvOffset is an optional vector2 used to offset UV.
  24757. * @param uvScale is an optional vector2 used to scale UV.
  24758. * @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.
  24759. * @returns the Mesh.
  24760. */
  24761. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24762. /**
  24763. * Modify the mesh to get a flat shading rendering.
  24764. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24765. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24766. * @returns current mesh
  24767. */
  24768. convertToFlatShadedMesh(): Mesh;
  24769. /**
  24770. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24771. * In other words, more vertices, no more indices and a single bigger VBO.
  24772. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24773. * @returns current mesh
  24774. */
  24775. convertToUnIndexedMesh(): Mesh;
  24776. /**
  24777. * Inverses facet orientations.
  24778. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24779. * @param flipNormals will also inverts the normals
  24780. * @returns current mesh
  24781. */
  24782. flipFaces(flipNormals?: boolean): Mesh;
  24783. /**
  24784. * Increase the number of facets and hence vertices in a mesh
  24785. * Vertex normals are interpolated from existing vertex normals
  24786. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24787. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24788. */
  24789. increaseVertices(numberPerEdge: number): void;
  24790. /**
  24791. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24792. * This will undo any application of covertToFlatShadedMesh
  24793. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24794. */
  24795. forceSharedVertices(): void;
  24796. /** @hidden */
  24797. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24798. /** @hidden */
  24799. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24800. /**
  24801. * Creates a new InstancedMesh object from the mesh model.
  24802. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24803. * @param name defines the name of the new instance
  24804. * @returns a new InstancedMesh
  24805. */
  24806. createInstance(name: string): InstancedMesh;
  24807. /**
  24808. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24809. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24810. * @returns the current mesh
  24811. */
  24812. synchronizeInstances(): Mesh;
  24813. /**
  24814. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24815. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24816. * This should be used together with the simplification to avoid disappearing triangles.
  24817. * @param successCallback an optional success callback to be called after the optimization finished.
  24818. * @returns the current mesh
  24819. */
  24820. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24821. /**
  24822. * Serialize current mesh
  24823. * @param serializationObject defines the object which will receive the serialization data
  24824. */
  24825. serialize(serializationObject: any): void;
  24826. /** @hidden */
  24827. _syncGeometryWithMorphTargetManager(): void;
  24828. /** @hidden */
  24829. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24830. /**
  24831. * Returns a new Mesh object parsed from the source provided.
  24832. * @param parsedMesh is the source
  24833. * @param scene defines the hosting scene
  24834. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24835. * @returns a new Mesh
  24836. */
  24837. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24838. /**
  24839. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24840. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24841. * @param name defines the name of the mesh to create
  24842. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24843. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24844. * @param closePath creates a seam between the first and the last points of each path of the path array
  24845. * @param offset is taken in account only if the `pathArray` is containing a single path
  24846. * @param scene defines the hosting scene
  24847. * @param updatable defines if the mesh must be flagged as updatable
  24848. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24849. * @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)
  24850. * @returns a new Mesh
  24851. */
  24852. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24853. /**
  24854. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24855. * @param name defines the name of the mesh to create
  24856. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24857. * @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
  24858. * @param scene defines the hosting scene
  24859. * @param updatable defines if the mesh must be flagged as updatable
  24860. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24861. * @returns a new Mesh
  24862. */
  24863. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24864. /**
  24865. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24866. * @param name defines the name of the mesh to create
  24867. * @param size sets the size (float) of each box side (default 1)
  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 CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24874. /**
  24875. * Creates a sphere 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 segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24878. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24879. * @param scene defines the hosting scene
  24880. * @param updatable defines if the mesh must be flagged as updatable
  24881. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24882. * @returns a new Mesh
  24883. */
  24884. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24885. /**
  24886. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24887. * @param name defines the name of the mesh to create
  24888. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24889. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24890. * @param scene defines the hosting scene
  24891. * @returns a new Mesh
  24892. */
  24893. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24894. /**
  24895. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24896. * @param name defines the name of the mesh to create
  24897. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24898. * @param diameterTop set the top cap diameter (floats, default 1)
  24899. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24900. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24901. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24902. * @param scene defines the hosting scene
  24903. * @param updatable defines if the mesh must be flagged as updatable
  24904. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24905. * @returns a new Mesh
  24906. */
  24907. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24908. /**
  24909. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24910. * @param name defines the name of the mesh to create
  24911. * @param diameter sets the diameter size (float) of the torus (default 1)
  24912. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24913. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24914. * @param scene defines the hosting scene
  24915. * @param updatable defines if the mesh must be flagged as updatable
  24916. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24917. * @returns a new Mesh
  24918. */
  24919. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24920. /**
  24921. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24922. * @param name defines the name of the mesh to create
  24923. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24924. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24925. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24926. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24927. * @param p the number of windings on X axis (positive integers, default 2)
  24928. * @param q the number of windings on Y axis (positive integers, default 3)
  24929. * @param scene defines the hosting scene
  24930. * @param updatable defines if the mesh must be flagged as updatable
  24931. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24932. * @returns a new Mesh
  24933. */
  24934. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24935. /**
  24936. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24937. * @param name defines the name of the mesh to create
  24938. * @param points is an array successive Vector3
  24939. * @param scene defines the hosting scene
  24940. * @param updatable defines if the mesh must be flagged as updatable
  24941. * @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).
  24942. * @returns a new Mesh
  24943. */
  24944. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  24945. /**
  24946. * Creates a dashed 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 dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  24950. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  24951. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  24952. * @param scene defines the hosting scene
  24953. * @param updatable defines if the mesh must be flagged as updatable
  24954. * @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)
  24955. * @returns a new Mesh
  24956. */
  24957. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  24958. /**
  24959. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  24960. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  24961. * 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.
  24962. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24963. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  24964. * Remember you can only change the shape positions, not their number when updating a polygon.
  24965. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  24966. * @param name defines the name of the mesh to create
  24967. * @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
  24968. * @param scene defines the hosting scene
  24969. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24970. * @param updatable defines if the mesh must be flagged as updatable
  24971. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24972. * @param earcutInjection can be used to inject your own earcut reference
  24973. * @returns a new Mesh
  24974. */
  24975. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24976. /**
  24977. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  24978. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  24979. * @param name defines the name of the mesh to create
  24980. * @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
  24981. * @param depth defines the height of extrusion
  24982. * @param scene defines the hosting scene
  24983. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  24984. * @param updatable defines if the mesh must be flagged as updatable
  24985. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24986. * @param earcutInjection can be used to inject your own earcut reference
  24987. * @returns a new Mesh
  24988. */
  24989. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  24990. /**
  24991. * Creates an extruded shape mesh.
  24992. * 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
  24993. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24994. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  24995. * @param name defines the name of the mesh to create
  24996. * @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
  24997. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  24998. * @param scale is the value to scale the shape
  24999. * @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
  25000. * @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
  25001. * @param scene defines the hosting scene
  25002. * @param updatable defines if the mesh must be flagged as updatable
  25003. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25004. * @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)
  25005. * @returns a new Mesh
  25006. */
  25007. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25008. /**
  25009. * Creates an custom extruded shape mesh.
  25010. * The custom extrusion is a parametric shape.
  25011. * It has no predefined shape. Its final shape will depend on the input parameters.
  25012. * Please consider using the same method from the MeshBuilder class instead
  25013. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25014. * @param name defines the name of the mesh to create
  25015. * @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
  25016. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25017. * @param scaleFunction is a custom Javascript function called on each path point
  25018. * @param rotationFunction is a custom Javascript function called on each path point
  25019. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25020. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25021. * @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
  25022. * @param scene defines the hosting scene
  25023. * @param updatable defines if the mesh must be flagged as updatable
  25024. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25025. * @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)
  25026. * @returns a new Mesh
  25027. */
  25028. 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;
  25029. /**
  25030. * Creates lathe mesh.
  25031. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25032. * Please consider using the same method from the MeshBuilder class instead
  25033. * @param name defines the name of the mesh to create
  25034. * @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
  25035. * @param radius is the radius value of the lathe
  25036. * @param tessellation is the side number of the lathe.
  25037. * @param scene defines the hosting scene
  25038. * @param updatable defines if the mesh must be flagged as updatable
  25039. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25040. * @returns a new Mesh
  25041. */
  25042. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25043. /**
  25044. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25045. * @param name defines the name of the mesh to create
  25046. * @param size sets the size (float) of both sides of the plane at once (default 1)
  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 CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25053. /**
  25054. * Creates a ground mesh.
  25055. * Please consider using the same method from the MeshBuilder class instead
  25056. * @param name defines the name of the mesh to create
  25057. * @param width set the width of the ground
  25058. * @param height set the height of the ground
  25059. * @param subdivisions sets the number of subdivisions per side
  25060. * @param scene defines the hosting scene
  25061. * @param updatable defines if the mesh must be flagged as updatable
  25062. * @returns a new Mesh
  25063. */
  25064. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25065. /**
  25066. * Creates a tiled ground mesh.
  25067. * Please consider using the same method from the MeshBuilder class instead
  25068. * @param name defines the name of the mesh to create
  25069. * @param xmin set the ground minimum X coordinate
  25070. * @param zmin set the ground minimum Y coordinate
  25071. * @param xmax set the ground maximum X coordinate
  25072. * @param zmax set the ground maximum Z coordinate
  25073. * @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
  25074. * @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
  25075. * @param scene defines the hosting scene
  25076. * @param updatable defines if the mesh must be flagged as updatable
  25077. * @returns a new Mesh
  25078. */
  25079. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25080. w: number;
  25081. h: number;
  25082. }, precision: {
  25083. w: number;
  25084. h: number;
  25085. }, scene: Scene, updatable?: boolean): Mesh;
  25086. /**
  25087. * Creates a ground mesh from a height map.
  25088. * Please consider using the same method from the MeshBuilder class instead
  25089. * @see http://doc.babylonjs.com/babylon101/height_map
  25090. * @param name defines the name of the mesh to create
  25091. * @param url sets the URL of the height map image resource
  25092. * @param width set the ground width size
  25093. * @param height set the ground height size
  25094. * @param subdivisions sets the number of subdivision per side
  25095. * @param minHeight is the minimum altitude on the ground
  25096. * @param maxHeight is the maximum altitude on the ground
  25097. * @param scene defines the hosting scene
  25098. * @param updatable defines if the mesh must be flagged as updatable
  25099. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25100. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25101. * @returns a new Mesh
  25102. */
  25103. 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;
  25104. /**
  25105. * Creates a tube mesh.
  25106. * The tube is a parametric shape.
  25107. * It has no predefined shape. Its final shape will depend on the input parameters.
  25108. * Please consider using the same method from the MeshBuilder class instead
  25109. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25110. * @param name defines the name of the mesh to create
  25111. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25112. * @param radius sets the tube radius size
  25113. * @param tessellation is the number of sides on the tubular surface
  25114. * @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
  25115. * @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
  25116. * @param scene defines the hosting scene
  25117. * @param updatable defines if the mesh must be flagged as updatable
  25118. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25119. * @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)
  25120. * @returns a new Mesh
  25121. */
  25122. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25123. (i: number, distance: number): number;
  25124. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25125. /**
  25126. * Creates a polyhedron mesh.
  25127. * Please consider using the same method from the MeshBuilder class instead.
  25128. * * 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
  25129. * * The parameter `size` (positive float, default 1) sets the polygon size
  25130. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25131. * * 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`
  25132. * * 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
  25133. * * 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)`)
  25134. * * 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
  25135. * * 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
  25136. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25137. * * 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
  25138. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25139. * @param name defines the name of the mesh to create
  25140. * @param options defines the options used to create the mesh
  25141. * @param scene defines the hosting scene
  25142. * @returns a new Mesh
  25143. */
  25144. static CreatePolyhedron(name: string, options: {
  25145. type?: number;
  25146. size?: number;
  25147. sizeX?: number;
  25148. sizeY?: number;
  25149. sizeZ?: number;
  25150. custom?: any;
  25151. faceUV?: Vector4[];
  25152. faceColors?: Color4[];
  25153. updatable?: boolean;
  25154. sideOrientation?: number;
  25155. }, scene: Scene): Mesh;
  25156. /**
  25157. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25158. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25159. * * 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`)
  25160. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25161. * * 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
  25162. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25163. * * 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
  25164. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25165. * @param name defines the name of the mesh
  25166. * @param options defines the options used to create the mesh
  25167. * @param scene defines the hosting scene
  25168. * @returns a new Mesh
  25169. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25170. */
  25171. static CreateIcoSphere(name: string, options: {
  25172. radius?: number;
  25173. flat?: boolean;
  25174. subdivisions?: number;
  25175. sideOrientation?: number;
  25176. updatable?: boolean;
  25177. }, scene: Scene): Mesh;
  25178. /**
  25179. * Creates a decal mesh.
  25180. * Please consider using the same method from the MeshBuilder class instead.
  25181. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25182. * @param name defines the name of the mesh
  25183. * @param sourceMesh defines the mesh receiving the decal
  25184. * @param position sets the position of the decal in world coordinates
  25185. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25186. * @param size sets the decal scaling
  25187. * @param angle sets the angle to rotate the decal
  25188. * @returns a new Mesh
  25189. */
  25190. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25191. /**
  25192. * Prepare internal position array for software CPU skinning
  25193. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25194. */
  25195. setPositionsForCPUSkinning(): Float32Array;
  25196. /**
  25197. * Prepare internal normal array for software CPU skinning
  25198. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25199. */
  25200. setNormalsForCPUSkinning(): Float32Array;
  25201. /**
  25202. * Updates the vertex buffer by applying transformation from the bones
  25203. * @param skeleton defines the skeleton to apply to current mesh
  25204. * @returns the current mesh
  25205. */
  25206. applySkeleton(skeleton: Skeleton): Mesh;
  25207. /**
  25208. * 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
  25209. * @param meshes defines the list of meshes to scan
  25210. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25211. */
  25212. static MinMax(meshes: AbstractMesh[]): {
  25213. min: Vector3;
  25214. max: Vector3;
  25215. };
  25216. /**
  25217. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25218. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25219. * @returns a vector3
  25220. */
  25221. static Center(meshesOrMinMaxVector: {
  25222. min: Vector3;
  25223. max: Vector3;
  25224. } | AbstractMesh[]): Vector3;
  25225. /**
  25226. * Merge the array of meshes into a single mesh for performance reasons.
  25227. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25228. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25229. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25230. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25231. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25232. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25233. * @returns a new mesh
  25234. */
  25235. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25236. /** @hidden */
  25237. addInstance(instance: InstancedMesh): void;
  25238. /** @hidden */
  25239. removeInstance(instance: InstancedMesh): void;
  25240. }
  25241. }
  25242. declare module BABYLON {
  25243. /**
  25244. * This is the base class of all the camera used in the application.
  25245. * @see http://doc.babylonjs.com/features/cameras
  25246. */
  25247. export class Camera extends Node {
  25248. /** @hidden */
  25249. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25250. /**
  25251. * This is the default projection mode used by the cameras.
  25252. * It helps recreating a feeling of perspective and better appreciate depth.
  25253. * This is the best way to simulate real life cameras.
  25254. */
  25255. static readonly PERSPECTIVE_CAMERA: number;
  25256. /**
  25257. * This helps creating camera with an orthographic mode.
  25258. * 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.
  25259. */
  25260. static readonly ORTHOGRAPHIC_CAMERA: number;
  25261. /**
  25262. * This is the default FOV mode for perspective cameras.
  25263. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25264. */
  25265. static readonly FOVMODE_VERTICAL_FIXED: number;
  25266. /**
  25267. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25268. */
  25269. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25270. /**
  25271. * This specifies ther is no need for a camera rig.
  25272. * Basically only one eye is rendered corresponding to the camera.
  25273. */
  25274. static readonly RIG_MODE_NONE: number;
  25275. /**
  25276. * Simulates a camera Rig with one blue eye and one red eye.
  25277. * This can be use with 3d blue and red glasses.
  25278. */
  25279. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25280. /**
  25281. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25282. */
  25283. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25284. /**
  25285. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25286. */
  25287. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25288. /**
  25289. * Defines that both eyes of the camera will be rendered over under each other.
  25290. */
  25291. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25292. /**
  25293. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25294. */
  25295. static readonly RIG_MODE_VR: number;
  25296. /**
  25297. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25298. */
  25299. static readonly RIG_MODE_WEBVR: number;
  25300. /**
  25301. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25302. */
  25303. static readonly RIG_MODE_CUSTOM: number;
  25304. /**
  25305. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25306. */
  25307. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25308. /**
  25309. * Define the input manager associated with the camera.
  25310. */
  25311. inputs: CameraInputsManager<Camera>;
  25312. /** @hidden */
  25313. _position: Vector3;
  25314. /**
  25315. * Define the current local position of the camera in the scene
  25316. */
  25317. get position(): Vector3;
  25318. set position(newPosition: Vector3);
  25319. /**
  25320. * The vector the camera should consider as up.
  25321. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25322. */
  25323. upVector: Vector3;
  25324. /**
  25325. * Define the current limit on the left side for an orthographic camera
  25326. * In scene unit
  25327. */
  25328. orthoLeft: Nullable<number>;
  25329. /**
  25330. * Define the current limit on the right side for an orthographic camera
  25331. * In scene unit
  25332. */
  25333. orthoRight: Nullable<number>;
  25334. /**
  25335. * Define the current limit on the bottom side for an orthographic camera
  25336. * In scene unit
  25337. */
  25338. orthoBottom: Nullable<number>;
  25339. /**
  25340. * Define the current limit on the top side for an orthographic camera
  25341. * In scene unit
  25342. */
  25343. orthoTop: Nullable<number>;
  25344. /**
  25345. * Field Of View is set in Radians. (default is 0.8)
  25346. */
  25347. fov: number;
  25348. /**
  25349. * Define the minimum distance the camera can see from.
  25350. * This is important to note that the depth buffer are not infinite and the closer it starts
  25351. * the more your scene might encounter depth fighting issue.
  25352. */
  25353. minZ: number;
  25354. /**
  25355. * Define the maximum distance the camera can see to.
  25356. * This is important to note that the depth buffer are not infinite and the further it end
  25357. * the more your scene might encounter depth fighting issue.
  25358. */
  25359. maxZ: number;
  25360. /**
  25361. * Define the default inertia of the camera.
  25362. * This helps giving a smooth feeling to the camera movement.
  25363. */
  25364. inertia: number;
  25365. /**
  25366. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25367. */
  25368. mode: number;
  25369. /**
  25370. * Define wether the camera is intermediate.
  25371. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25372. */
  25373. isIntermediate: boolean;
  25374. /**
  25375. * Define the viewport of the camera.
  25376. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25377. */
  25378. viewport: Viewport;
  25379. /**
  25380. * Restricts the camera to viewing objects with the same layerMask.
  25381. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25382. */
  25383. layerMask: number;
  25384. /**
  25385. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25386. */
  25387. fovMode: number;
  25388. /**
  25389. * Rig mode of the camera.
  25390. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25391. * This is normally controlled byt the camera themselves as internal use.
  25392. */
  25393. cameraRigMode: number;
  25394. /**
  25395. * Defines the distance between both "eyes" in case of a RIG
  25396. */
  25397. interaxialDistance: number;
  25398. /**
  25399. * Defines if stereoscopic rendering is done side by side or over under.
  25400. */
  25401. isStereoscopicSideBySide: boolean;
  25402. /**
  25403. * 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
  25404. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25405. * else in the scene. (Eg. security camera)
  25406. *
  25407. * 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)
  25408. */
  25409. customRenderTargets: RenderTargetTexture[];
  25410. /**
  25411. * When set, the camera will render to this render target instead of the default canvas
  25412. *
  25413. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25414. */
  25415. outputRenderTarget: Nullable<RenderTargetTexture>;
  25416. /**
  25417. * Observable triggered when the camera view matrix has changed.
  25418. */
  25419. onViewMatrixChangedObservable: Observable<Camera>;
  25420. /**
  25421. * Observable triggered when the camera Projection matrix has changed.
  25422. */
  25423. onProjectionMatrixChangedObservable: Observable<Camera>;
  25424. /**
  25425. * Observable triggered when the inputs have been processed.
  25426. */
  25427. onAfterCheckInputsObservable: Observable<Camera>;
  25428. /**
  25429. * Observable triggered when reset has been called and applied to the camera.
  25430. */
  25431. onRestoreStateObservable: Observable<Camera>;
  25432. /** @hidden */
  25433. _cameraRigParams: any;
  25434. /** @hidden */
  25435. _rigCameras: Camera[];
  25436. /** @hidden */
  25437. _rigPostProcess: Nullable<PostProcess>;
  25438. protected _webvrViewMatrix: Matrix;
  25439. /** @hidden */
  25440. _skipRendering: boolean;
  25441. /** @hidden */
  25442. _projectionMatrix: Matrix;
  25443. /** @hidden */
  25444. _postProcesses: Nullable<PostProcess>[];
  25445. /** @hidden */
  25446. _activeMeshes: SmartArray<AbstractMesh>;
  25447. protected _globalPosition: Vector3;
  25448. /** @hidden */
  25449. _computedViewMatrix: Matrix;
  25450. private _doNotComputeProjectionMatrix;
  25451. private _transformMatrix;
  25452. private _frustumPlanes;
  25453. private _refreshFrustumPlanes;
  25454. private _storedFov;
  25455. private _stateStored;
  25456. /**
  25457. * Instantiates a new camera object.
  25458. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25459. * @see http://doc.babylonjs.com/features/cameras
  25460. * @param name Defines the name of the camera in the scene
  25461. * @param position Defines the position of the camera
  25462. * @param scene Defines the scene the camera belongs too
  25463. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25464. */
  25465. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25466. /**
  25467. * Store current camera state (fov, position, etc..)
  25468. * @returns the camera
  25469. */
  25470. storeState(): Camera;
  25471. /**
  25472. * Restores the camera state values if it has been stored. You must call storeState() first
  25473. */
  25474. protected _restoreStateValues(): boolean;
  25475. /**
  25476. * Restored camera state. You must call storeState() first.
  25477. * @returns true if restored and false otherwise
  25478. */
  25479. restoreState(): boolean;
  25480. /**
  25481. * Gets the class name of the camera.
  25482. * @returns the class name
  25483. */
  25484. getClassName(): string;
  25485. /** @hidden */
  25486. readonly _isCamera: boolean;
  25487. /**
  25488. * Gets a string representation of the camera useful for debug purpose.
  25489. * @param fullDetails Defines that a more verboe level of logging is required
  25490. * @returns the string representation
  25491. */
  25492. toString(fullDetails?: boolean): string;
  25493. /**
  25494. * Gets the current world space position of the camera.
  25495. */
  25496. get globalPosition(): Vector3;
  25497. /**
  25498. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25499. * @returns the active meshe list
  25500. */
  25501. getActiveMeshes(): SmartArray<AbstractMesh>;
  25502. /**
  25503. * Check wether a mesh is part of the current active mesh list of the camera
  25504. * @param mesh Defines the mesh to check
  25505. * @returns true if active, false otherwise
  25506. */
  25507. isActiveMesh(mesh: Mesh): boolean;
  25508. /**
  25509. * Is this camera ready to be used/rendered
  25510. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25511. * @return true if the camera is ready
  25512. */
  25513. isReady(completeCheck?: boolean): boolean;
  25514. /** @hidden */
  25515. _initCache(): void;
  25516. /** @hidden */
  25517. _updateCache(ignoreParentClass?: boolean): void;
  25518. /** @hidden */
  25519. _isSynchronized(): boolean;
  25520. /** @hidden */
  25521. _isSynchronizedViewMatrix(): boolean;
  25522. /** @hidden */
  25523. _isSynchronizedProjectionMatrix(): boolean;
  25524. /**
  25525. * Attach the input controls to a specific dom element to get the input from.
  25526. * @param element Defines the element the controls should be listened from
  25527. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25528. */
  25529. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25530. /**
  25531. * Detach the current controls from the specified dom element.
  25532. * @param element Defines the element to stop listening the inputs from
  25533. */
  25534. detachControl(element: HTMLElement): void;
  25535. /**
  25536. * Update the camera state according to the different inputs gathered during the frame.
  25537. */
  25538. update(): void;
  25539. /** @hidden */
  25540. _checkInputs(): void;
  25541. /** @hidden */
  25542. get rigCameras(): Camera[];
  25543. /**
  25544. * Gets the post process used by the rig cameras
  25545. */
  25546. get rigPostProcess(): Nullable<PostProcess>;
  25547. /**
  25548. * Internal, gets the first post proces.
  25549. * @returns the first post process to be run on this camera.
  25550. */
  25551. _getFirstPostProcess(): Nullable<PostProcess>;
  25552. private _cascadePostProcessesToRigCams;
  25553. /**
  25554. * Attach a post process to the camera.
  25555. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25556. * @param postProcess The post process to attach to the camera
  25557. * @param insertAt The position of the post process in case several of them are in use in the scene
  25558. * @returns the position the post process has been inserted at
  25559. */
  25560. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25561. /**
  25562. * Detach a post process to the camera.
  25563. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25564. * @param postProcess The post process to detach from the camera
  25565. */
  25566. detachPostProcess(postProcess: PostProcess): void;
  25567. /**
  25568. * Gets the current world matrix of the camera
  25569. */
  25570. getWorldMatrix(): Matrix;
  25571. /** @hidden */
  25572. _getViewMatrix(): Matrix;
  25573. /**
  25574. * Gets the current view matrix of the camera.
  25575. * @param force forces the camera to recompute the matrix without looking at the cached state
  25576. * @returns the view matrix
  25577. */
  25578. getViewMatrix(force?: boolean): Matrix;
  25579. /**
  25580. * Freeze the projection matrix.
  25581. * It will prevent the cache check of the camera projection compute and can speed up perf
  25582. * if no parameter of the camera are meant to change
  25583. * @param projection Defines manually a projection if necessary
  25584. */
  25585. freezeProjectionMatrix(projection?: Matrix): void;
  25586. /**
  25587. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25588. */
  25589. unfreezeProjectionMatrix(): void;
  25590. /**
  25591. * Gets the current projection matrix of the camera.
  25592. * @param force forces the camera to recompute the matrix without looking at the cached state
  25593. * @returns the projection matrix
  25594. */
  25595. getProjectionMatrix(force?: boolean): Matrix;
  25596. /**
  25597. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25598. * @returns a Matrix
  25599. */
  25600. getTransformationMatrix(): Matrix;
  25601. private _updateFrustumPlanes;
  25602. /**
  25603. * Checks if a cullable object (mesh...) is in the camera frustum
  25604. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25605. * @param target The object to check
  25606. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25607. * @returns true if the object is in frustum otherwise false
  25608. */
  25609. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25610. /**
  25611. * Checks if a cullable object (mesh...) is in the camera frustum
  25612. * Unlike isInFrustum this cheks the full bounding box
  25613. * @param target The object to check
  25614. * @returns true if the object is in frustum otherwise false
  25615. */
  25616. isCompletelyInFrustum(target: ICullable): boolean;
  25617. /**
  25618. * Gets a ray in the forward direction from the camera.
  25619. * @param length Defines the length of the ray to create
  25620. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25621. * @param origin Defines the start point of the ray which defaults to the camera position
  25622. * @returns the forward ray
  25623. */
  25624. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25625. /**
  25626. * Releases resources associated with this node.
  25627. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25628. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25629. */
  25630. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25631. /** @hidden */
  25632. _isLeftCamera: boolean;
  25633. /**
  25634. * Gets the left camera of a rig setup in case of Rigged Camera
  25635. */
  25636. get isLeftCamera(): boolean;
  25637. /** @hidden */
  25638. _isRightCamera: boolean;
  25639. /**
  25640. * Gets the right camera of a rig setup in case of Rigged Camera
  25641. */
  25642. get isRightCamera(): boolean;
  25643. /**
  25644. * Gets the left camera of a rig setup in case of Rigged Camera
  25645. */
  25646. get leftCamera(): Nullable<FreeCamera>;
  25647. /**
  25648. * Gets the right camera of a rig setup in case of Rigged Camera
  25649. */
  25650. get rightCamera(): Nullable<FreeCamera>;
  25651. /**
  25652. * Gets the left camera target of a rig setup in case of Rigged Camera
  25653. * @returns the target position
  25654. */
  25655. getLeftTarget(): Nullable<Vector3>;
  25656. /**
  25657. * Gets the right camera target of a rig setup in case of Rigged Camera
  25658. * @returns the target position
  25659. */
  25660. getRightTarget(): Nullable<Vector3>;
  25661. /**
  25662. * @hidden
  25663. */
  25664. setCameraRigMode(mode: number, rigParams: any): void;
  25665. /** @hidden */
  25666. static _setStereoscopicRigMode(camera: Camera): void;
  25667. /** @hidden */
  25668. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25669. /** @hidden */
  25670. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25671. /** @hidden */
  25672. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25673. /** @hidden */
  25674. _getVRProjectionMatrix(): Matrix;
  25675. protected _updateCameraRotationMatrix(): void;
  25676. protected _updateWebVRCameraRotationMatrix(): void;
  25677. /**
  25678. * This function MUST be overwritten by the different WebVR cameras available.
  25679. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25680. * @hidden
  25681. */
  25682. _getWebVRProjectionMatrix(): Matrix;
  25683. /**
  25684. * This function MUST be overwritten by the different WebVR cameras available.
  25685. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25686. * @hidden
  25687. */
  25688. _getWebVRViewMatrix(): Matrix;
  25689. /** @hidden */
  25690. setCameraRigParameter(name: string, value: any): void;
  25691. /**
  25692. * needs to be overridden by children so sub has required properties to be copied
  25693. * @hidden
  25694. */
  25695. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25696. /**
  25697. * May need to be overridden by children
  25698. * @hidden
  25699. */
  25700. _updateRigCameras(): void;
  25701. /** @hidden */
  25702. _setupInputs(): void;
  25703. /**
  25704. * Serialiaze the camera setup to a json represention
  25705. * @returns the JSON representation
  25706. */
  25707. serialize(): any;
  25708. /**
  25709. * Clones the current camera.
  25710. * @param name The cloned camera name
  25711. * @returns the cloned camera
  25712. */
  25713. clone(name: string): Camera;
  25714. /**
  25715. * Gets the direction of the camera relative to a given local axis.
  25716. * @param localAxis Defines the reference axis to provide a relative direction.
  25717. * @return the direction
  25718. */
  25719. getDirection(localAxis: Vector3): Vector3;
  25720. /**
  25721. * Returns the current camera absolute rotation
  25722. */
  25723. get absoluteRotation(): Quaternion;
  25724. /**
  25725. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25726. * @param localAxis Defines the reference axis to provide a relative direction.
  25727. * @param result Defines the vector to store the result in
  25728. */
  25729. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25730. /**
  25731. * Gets a camera constructor for a given camera type
  25732. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25733. * @param name The name of the camera the result will be able to instantiate
  25734. * @param scene The scene the result will construct the camera in
  25735. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25736. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25737. * @returns a factory method to construc the camera
  25738. */
  25739. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25740. /**
  25741. * Compute the world matrix of the camera.
  25742. * @returns the camera world matrix
  25743. */
  25744. computeWorldMatrix(): Matrix;
  25745. /**
  25746. * Parse a JSON and creates the camera from the parsed information
  25747. * @param parsedCamera The JSON to parse
  25748. * @param scene The scene to instantiate the camera in
  25749. * @returns the newly constructed camera
  25750. */
  25751. static Parse(parsedCamera: any, scene: Scene): Camera;
  25752. }
  25753. }
  25754. declare module BABYLON {
  25755. /**
  25756. * Class containing static functions to help procedurally build meshes
  25757. */
  25758. export class DiscBuilder {
  25759. /**
  25760. * Creates a plane polygonal mesh. By default, this is a disc
  25761. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25762. * * 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
  25763. * * 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
  25764. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25765. * * 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
  25766. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25767. * @param name defines the name of the mesh
  25768. * @param options defines the options used to create the mesh
  25769. * @param scene defines the hosting scene
  25770. * @returns the plane polygonal mesh
  25771. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25772. */
  25773. static CreateDisc(name: string, options: {
  25774. radius?: number;
  25775. tessellation?: number;
  25776. arc?: number;
  25777. updatable?: boolean;
  25778. sideOrientation?: number;
  25779. frontUVs?: Vector4;
  25780. backUVs?: Vector4;
  25781. }, scene?: Nullable<Scene>): Mesh;
  25782. }
  25783. }
  25784. declare module BABYLON {
  25785. /**
  25786. * This represents all the required information to add a fresnel effect on a material:
  25787. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25788. */
  25789. export class FresnelParameters {
  25790. private _isEnabled;
  25791. /**
  25792. * Define if the fresnel effect is enable or not.
  25793. */
  25794. get isEnabled(): boolean;
  25795. set isEnabled(value: boolean);
  25796. /**
  25797. * Define the color used on edges (grazing angle)
  25798. */
  25799. leftColor: Color3;
  25800. /**
  25801. * Define the color used on center
  25802. */
  25803. rightColor: Color3;
  25804. /**
  25805. * Define bias applied to computed fresnel term
  25806. */
  25807. bias: number;
  25808. /**
  25809. * Defined the power exponent applied to fresnel term
  25810. */
  25811. power: number;
  25812. /**
  25813. * Clones the current fresnel and its valuues
  25814. * @returns a clone fresnel configuration
  25815. */
  25816. clone(): FresnelParameters;
  25817. /**
  25818. * Serializes the current fresnel parameters to a JSON representation.
  25819. * @return the JSON serialization
  25820. */
  25821. serialize(): any;
  25822. /**
  25823. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  25824. * @param parsedFresnelParameters Define the JSON representation
  25825. * @returns the parsed parameters
  25826. */
  25827. static Parse(parsedFresnelParameters: any): FresnelParameters;
  25828. }
  25829. }
  25830. declare module BABYLON {
  25831. /**
  25832. * Base class of materials working in push mode in babylon JS
  25833. * @hidden
  25834. */
  25835. export class PushMaterial extends Material {
  25836. protected _activeEffect: Effect;
  25837. protected _normalMatrix: Matrix;
  25838. /**
  25839. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  25840. * This means that the material can keep using a previous shader while a new one is being compiled.
  25841. * This is mostly used when shader parallel compilation is supported (true by default)
  25842. */
  25843. allowShaderHotSwapping: boolean;
  25844. constructor(name: string, scene: Scene);
  25845. getEffect(): Effect;
  25846. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  25847. /**
  25848. * Binds the given world matrix to the active effect
  25849. *
  25850. * @param world the matrix to bind
  25851. */
  25852. bindOnlyWorldMatrix(world: Matrix): void;
  25853. /**
  25854. * Binds the given normal matrix to the active effect
  25855. *
  25856. * @param normalMatrix the matrix to bind
  25857. */
  25858. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  25859. bind(world: Matrix, mesh?: Mesh): void;
  25860. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  25861. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  25862. }
  25863. }
  25864. declare module BABYLON {
  25865. /**
  25866. * This groups all the flags used to control the materials channel.
  25867. */
  25868. export class MaterialFlags {
  25869. private static _DiffuseTextureEnabled;
  25870. /**
  25871. * Are diffuse textures enabled in the application.
  25872. */
  25873. static get DiffuseTextureEnabled(): boolean;
  25874. static set DiffuseTextureEnabled(value: boolean);
  25875. private static _AmbientTextureEnabled;
  25876. /**
  25877. * Are ambient textures enabled in the application.
  25878. */
  25879. static get AmbientTextureEnabled(): boolean;
  25880. static set AmbientTextureEnabled(value: boolean);
  25881. private static _OpacityTextureEnabled;
  25882. /**
  25883. * Are opacity textures enabled in the application.
  25884. */
  25885. static get OpacityTextureEnabled(): boolean;
  25886. static set OpacityTextureEnabled(value: boolean);
  25887. private static _ReflectionTextureEnabled;
  25888. /**
  25889. * Are reflection textures enabled in the application.
  25890. */
  25891. static get ReflectionTextureEnabled(): boolean;
  25892. static set ReflectionTextureEnabled(value: boolean);
  25893. private static _EmissiveTextureEnabled;
  25894. /**
  25895. * Are emissive textures enabled in the application.
  25896. */
  25897. static get EmissiveTextureEnabled(): boolean;
  25898. static set EmissiveTextureEnabled(value: boolean);
  25899. private static _SpecularTextureEnabled;
  25900. /**
  25901. * Are specular textures enabled in the application.
  25902. */
  25903. static get SpecularTextureEnabled(): boolean;
  25904. static set SpecularTextureEnabled(value: boolean);
  25905. private static _BumpTextureEnabled;
  25906. /**
  25907. * Are bump textures enabled in the application.
  25908. */
  25909. static get BumpTextureEnabled(): boolean;
  25910. static set BumpTextureEnabled(value: boolean);
  25911. private static _LightmapTextureEnabled;
  25912. /**
  25913. * Are lightmap textures enabled in the application.
  25914. */
  25915. static get LightmapTextureEnabled(): boolean;
  25916. static set LightmapTextureEnabled(value: boolean);
  25917. private static _RefractionTextureEnabled;
  25918. /**
  25919. * Are refraction textures enabled in the application.
  25920. */
  25921. static get RefractionTextureEnabled(): boolean;
  25922. static set RefractionTextureEnabled(value: boolean);
  25923. private static _ColorGradingTextureEnabled;
  25924. /**
  25925. * Are color grading textures enabled in the application.
  25926. */
  25927. static get ColorGradingTextureEnabled(): boolean;
  25928. static set ColorGradingTextureEnabled(value: boolean);
  25929. private static _FresnelEnabled;
  25930. /**
  25931. * Are fresnels enabled in the application.
  25932. */
  25933. static get FresnelEnabled(): boolean;
  25934. static set FresnelEnabled(value: boolean);
  25935. private static _ClearCoatTextureEnabled;
  25936. /**
  25937. * Are clear coat textures enabled in the application.
  25938. */
  25939. static get ClearCoatTextureEnabled(): boolean;
  25940. static set ClearCoatTextureEnabled(value: boolean);
  25941. private static _ClearCoatBumpTextureEnabled;
  25942. /**
  25943. * Are clear coat bump textures enabled in the application.
  25944. */
  25945. static get ClearCoatBumpTextureEnabled(): boolean;
  25946. static set ClearCoatBumpTextureEnabled(value: boolean);
  25947. private static _ClearCoatTintTextureEnabled;
  25948. /**
  25949. * Are clear coat tint textures enabled in the application.
  25950. */
  25951. static get ClearCoatTintTextureEnabled(): boolean;
  25952. static set ClearCoatTintTextureEnabled(value: boolean);
  25953. private static _SheenTextureEnabled;
  25954. /**
  25955. * Are sheen textures enabled in the application.
  25956. */
  25957. static get SheenTextureEnabled(): boolean;
  25958. static set SheenTextureEnabled(value: boolean);
  25959. private static _AnisotropicTextureEnabled;
  25960. /**
  25961. * Are anisotropic textures enabled in the application.
  25962. */
  25963. static get AnisotropicTextureEnabled(): boolean;
  25964. static set AnisotropicTextureEnabled(value: boolean);
  25965. private static _ThicknessTextureEnabled;
  25966. /**
  25967. * Are thickness textures enabled in the application.
  25968. */
  25969. static get ThicknessTextureEnabled(): boolean;
  25970. static set ThicknessTextureEnabled(value: boolean);
  25971. }
  25972. }
  25973. declare module BABYLON {
  25974. /** @hidden */
  25975. export var defaultFragmentDeclaration: {
  25976. name: string;
  25977. shader: string;
  25978. };
  25979. }
  25980. declare module BABYLON {
  25981. /** @hidden */
  25982. export var defaultUboDeclaration: {
  25983. name: string;
  25984. shader: string;
  25985. };
  25986. }
  25987. declare module BABYLON {
  25988. /** @hidden */
  25989. export var lightFragmentDeclaration: {
  25990. name: string;
  25991. shader: string;
  25992. };
  25993. }
  25994. declare module BABYLON {
  25995. /** @hidden */
  25996. export var lightUboDeclaration: {
  25997. name: string;
  25998. shader: string;
  25999. };
  26000. }
  26001. declare module BABYLON {
  26002. /** @hidden */
  26003. export var lightsFragmentFunctions: {
  26004. name: string;
  26005. shader: string;
  26006. };
  26007. }
  26008. declare module BABYLON {
  26009. /** @hidden */
  26010. export var shadowsFragmentFunctions: {
  26011. name: string;
  26012. shader: string;
  26013. };
  26014. }
  26015. declare module BABYLON {
  26016. /** @hidden */
  26017. export var fresnelFunction: {
  26018. name: string;
  26019. shader: string;
  26020. };
  26021. }
  26022. declare module BABYLON {
  26023. /** @hidden */
  26024. export var reflectionFunction: {
  26025. name: string;
  26026. shader: string;
  26027. };
  26028. }
  26029. declare module BABYLON {
  26030. /** @hidden */
  26031. export var bumpFragmentFunctions: {
  26032. name: string;
  26033. shader: string;
  26034. };
  26035. }
  26036. declare module BABYLON {
  26037. /** @hidden */
  26038. export var logDepthDeclaration: {
  26039. name: string;
  26040. shader: string;
  26041. };
  26042. }
  26043. declare module BABYLON {
  26044. /** @hidden */
  26045. export var bumpFragment: {
  26046. name: string;
  26047. shader: string;
  26048. };
  26049. }
  26050. declare module BABYLON {
  26051. /** @hidden */
  26052. export var depthPrePass: {
  26053. name: string;
  26054. shader: string;
  26055. };
  26056. }
  26057. declare module BABYLON {
  26058. /** @hidden */
  26059. export var lightFragment: {
  26060. name: string;
  26061. shader: string;
  26062. };
  26063. }
  26064. declare module BABYLON {
  26065. /** @hidden */
  26066. export var logDepthFragment: {
  26067. name: string;
  26068. shader: string;
  26069. };
  26070. }
  26071. declare module BABYLON {
  26072. /** @hidden */
  26073. export var defaultPixelShader: {
  26074. name: string;
  26075. shader: string;
  26076. };
  26077. }
  26078. declare module BABYLON {
  26079. /** @hidden */
  26080. export var defaultVertexDeclaration: {
  26081. name: string;
  26082. shader: string;
  26083. };
  26084. }
  26085. declare module BABYLON {
  26086. /** @hidden */
  26087. export var bumpVertexDeclaration: {
  26088. name: string;
  26089. shader: string;
  26090. };
  26091. }
  26092. declare module BABYLON {
  26093. /** @hidden */
  26094. export var bumpVertex: {
  26095. name: string;
  26096. shader: string;
  26097. };
  26098. }
  26099. declare module BABYLON {
  26100. /** @hidden */
  26101. export var fogVertex: {
  26102. name: string;
  26103. shader: string;
  26104. };
  26105. }
  26106. declare module BABYLON {
  26107. /** @hidden */
  26108. export var shadowsVertex: {
  26109. name: string;
  26110. shader: string;
  26111. };
  26112. }
  26113. declare module BABYLON {
  26114. /** @hidden */
  26115. export var pointCloudVertex: {
  26116. name: string;
  26117. shader: string;
  26118. };
  26119. }
  26120. declare module BABYLON {
  26121. /** @hidden */
  26122. export var logDepthVertex: {
  26123. name: string;
  26124. shader: string;
  26125. };
  26126. }
  26127. declare module BABYLON {
  26128. /** @hidden */
  26129. export var defaultVertexShader: {
  26130. name: string;
  26131. shader: string;
  26132. };
  26133. }
  26134. declare module BABYLON {
  26135. /** @hidden */
  26136. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26137. MAINUV1: boolean;
  26138. MAINUV2: boolean;
  26139. DIFFUSE: boolean;
  26140. DIFFUSEDIRECTUV: number;
  26141. AMBIENT: boolean;
  26142. AMBIENTDIRECTUV: number;
  26143. OPACITY: boolean;
  26144. OPACITYDIRECTUV: number;
  26145. OPACITYRGB: boolean;
  26146. REFLECTION: boolean;
  26147. EMISSIVE: boolean;
  26148. EMISSIVEDIRECTUV: number;
  26149. SPECULAR: boolean;
  26150. SPECULARDIRECTUV: number;
  26151. BUMP: boolean;
  26152. BUMPDIRECTUV: number;
  26153. PARALLAX: boolean;
  26154. PARALLAXOCCLUSION: boolean;
  26155. SPECULAROVERALPHA: boolean;
  26156. CLIPPLANE: boolean;
  26157. CLIPPLANE2: boolean;
  26158. CLIPPLANE3: boolean;
  26159. CLIPPLANE4: boolean;
  26160. CLIPPLANE5: boolean;
  26161. CLIPPLANE6: boolean;
  26162. ALPHATEST: boolean;
  26163. DEPTHPREPASS: boolean;
  26164. ALPHAFROMDIFFUSE: boolean;
  26165. POINTSIZE: boolean;
  26166. FOG: boolean;
  26167. SPECULARTERM: boolean;
  26168. DIFFUSEFRESNEL: boolean;
  26169. OPACITYFRESNEL: boolean;
  26170. REFLECTIONFRESNEL: boolean;
  26171. REFRACTIONFRESNEL: boolean;
  26172. EMISSIVEFRESNEL: boolean;
  26173. FRESNEL: boolean;
  26174. NORMAL: boolean;
  26175. UV1: boolean;
  26176. UV2: boolean;
  26177. VERTEXCOLOR: boolean;
  26178. VERTEXALPHA: boolean;
  26179. NUM_BONE_INFLUENCERS: number;
  26180. BonesPerMesh: number;
  26181. BONETEXTURE: boolean;
  26182. INSTANCES: boolean;
  26183. GLOSSINESS: boolean;
  26184. ROUGHNESS: boolean;
  26185. EMISSIVEASILLUMINATION: boolean;
  26186. LINKEMISSIVEWITHDIFFUSE: boolean;
  26187. REFLECTIONFRESNELFROMSPECULAR: boolean;
  26188. LIGHTMAP: boolean;
  26189. LIGHTMAPDIRECTUV: number;
  26190. OBJECTSPACE_NORMALMAP: boolean;
  26191. USELIGHTMAPASSHADOWMAP: boolean;
  26192. REFLECTIONMAP_3D: boolean;
  26193. REFLECTIONMAP_SPHERICAL: boolean;
  26194. REFLECTIONMAP_PLANAR: boolean;
  26195. REFLECTIONMAP_CUBIC: boolean;
  26196. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26197. REFLECTIONMAP_PROJECTION: boolean;
  26198. REFLECTIONMAP_SKYBOX: boolean;
  26199. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  26200. REFLECTIONMAP_EXPLICIT: boolean;
  26201. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26202. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26203. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26204. INVERTCUBICMAP: boolean;
  26205. LOGARITHMICDEPTH: boolean;
  26206. REFRACTION: boolean;
  26207. REFRACTIONMAP_3D: boolean;
  26208. REFLECTIONOVERALPHA: boolean;
  26209. TWOSIDEDLIGHTING: boolean;
  26210. SHADOWFLOAT: boolean;
  26211. MORPHTARGETS: boolean;
  26212. MORPHTARGETS_NORMAL: boolean;
  26213. MORPHTARGETS_TANGENT: boolean;
  26214. MORPHTARGETS_UV: boolean;
  26215. NUM_MORPH_INFLUENCERS: number;
  26216. NONUNIFORMSCALING: boolean;
  26217. PREMULTIPLYALPHA: boolean;
  26218. IMAGEPROCESSING: boolean;
  26219. VIGNETTE: boolean;
  26220. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26221. VIGNETTEBLENDMODEOPAQUE: boolean;
  26222. TONEMAPPING: boolean;
  26223. TONEMAPPING_ACES: boolean;
  26224. CONTRAST: boolean;
  26225. COLORCURVES: boolean;
  26226. COLORGRADING: boolean;
  26227. COLORGRADING3D: boolean;
  26228. SAMPLER3DGREENDEPTH: boolean;
  26229. SAMPLER3DBGRMAP: boolean;
  26230. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26231. MULTIVIEW: boolean;
  26232. /**
  26233. * If the reflection texture on this material is in linear color space
  26234. * @hidden
  26235. */
  26236. IS_REFLECTION_LINEAR: boolean;
  26237. /**
  26238. * If the refraction texture on this material is in linear color space
  26239. * @hidden
  26240. */
  26241. IS_REFRACTION_LINEAR: boolean;
  26242. EXPOSURE: boolean;
  26243. constructor();
  26244. setReflectionMode(modeToEnable: string): void;
  26245. }
  26246. /**
  26247. * This is the default material used in Babylon. It is the best trade off between quality
  26248. * and performances.
  26249. * @see http://doc.babylonjs.com/babylon101/materials
  26250. */
  26251. export class StandardMaterial extends PushMaterial {
  26252. private _diffuseTexture;
  26253. /**
  26254. * The basic texture of the material as viewed under a light.
  26255. */
  26256. diffuseTexture: Nullable<BaseTexture>;
  26257. private _ambientTexture;
  26258. /**
  26259. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  26260. */
  26261. ambientTexture: Nullable<BaseTexture>;
  26262. private _opacityTexture;
  26263. /**
  26264. * Define the transparency of the material from a texture.
  26265. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  26266. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  26267. */
  26268. opacityTexture: Nullable<BaseTexture>;
  26269. private _reflectionTexture;
  26270. /**
  26271. * Define the texture used to display the reflection.
  26272. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26273. */
  26274. reflectionTexture: Nullable<BaseTexture>;
  26275. private _emissiveTexture;
  26276. /**
  26277. * Define texture of the material as if self lit.
  26278. * This will be mixed in the final result even in the absence of light.
  26279. */
  26280. emissiveTexture: Nullable<BaseTexture>;
  26281. private _specularTexture;
  26282. /**
  26283. * Define how the color and intensity of the highlight given by the light in the material.
  26284. */
  26285. specularTexture: Nullable<BaseTexture>;
  26286. private _bumpTexture;
  26287. /**
  26288. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  26289. * 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.
  26290. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  26291. */
  26292. bumpTexture: Nullable<BaseTexture>;
  26293. private _lightmapTexture;
  26294. /**
  26295. * Complex lighting can be computationally expensive to compute at runtime.
  26296. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  26297. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  26298. */
  26299. lightmapTexture: Nullable<BaseTexture>;
  26300. private _refractionTexture;
  26301. /**
  26302. * Define the texture used to display the refraction.
  26303. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26304. */
  26305. refractionTexture: Nullable<BaseTexture>;
  26306. /**
  26307. * The color of the material lit by the environmental background lighting.
  26308. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  26309. */
  26310. ambientColor: Color3;
  26311. /**
  26312. * The basic color of the material as viewed under a light.
  26313. */
  26314. diffuseColor: Color3;
  26315. /**
  26316. * Define how the color and intensity of the highlight given by the light in the material.
  26317. */
  26318. specularColor: Color3;
  26319. /**
  26320. * Define the color of the material as if self lit.
  26321. * This will be mixed in the final result even in the absence of light.
  26322. */
  26323. emissiveColor: Color3;
  26324. /**
  26325. * Defines how sharp are the highlights in the material.
  26326. * The bigger the value the sharper giving a more glossy feeling to the result.
  26327. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  26328. */
  26329. specularPower: number;
  26330. private _useAlphaFromDiffuseTexture;
  26331. /**
  26332. * Does the transparency come from the diffuse texture alpha channel.
  26333. */
  26334. useAlphaFromDiffuseTexture: boolean;
  26335. private _useEmissiveAsIllumination;
  26336. /**
  26337. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  26338. */
  26339. useEmissiveAsIllumination: boolean;
  26340. private _linkEmissiveWithDiffuse;
  26341. /**
  26342. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  26343. * the emissive level when the final color is close to one.
  26344. */
  26345. linkEmissiveWithDiffuse: boolean;
  26346. private _useSpecularOverAlpha;
  26347. /**
  26348. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  26349. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26350. */
  26351. useSpecularOverAlpha: boolean;
  26352. private _useReflectionOverAlpha;
  26353. /**
  26354. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26355. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26356. */
  26357. useReflectionOverAlpha: boolean;
  26358. private _disableLighting;
  26359. /**
  26360. * Does lights from the scene impacts this material.
  26361. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  26362. */
  26363. disableLighting: boolean;
  26364. private _useObjectSpaceNormalMap;
  26365. /**
  26366. * Allows using an object space normal map (instead of tangent space).
  26367. */
  26368. useObjectSpaceNormalMap: boolean;
  26369. private _useParallax;
  26370. /**
  26371. * Is parallax enabled or not.
  26372. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26373. */
  26374. useParallax: boolean;
  26375. private _useParallaxOcclusion;
  26376. /**
  26377. * Is parallax occlusion enabled or not.
  26378. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  26379. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26380. */
  26381. useParallaxOcclusion: boolean;
  26382. /**
  26383. * 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.
  26384. */
  26385. parallaxScaleBias: number;
  26386. private _roughness;
  26387. /**
  26388. * Helps to define how blurry the reflections should appears in the material.
  26389. */
  26390. roughness: number;
  26391. /**
  26392. * In case of refraction, define the value of the index of refraction.
  26393. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26394. */
  26395. indexOfRefraction: number;
  26396. /**
  26397. * Invert the refraction texture alongside the y axis.
  26398. * It can be useful with procedural textures or probe for instance.
  26399. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26400. */
  26401. invertRefractionY: boolean;
  26402. /**
  26403. * Defines the alpha limits in alpha test mode.
  26404. */
  26405. alphaCutOff: number;
  26406. private _useLightmapAsShadowmap;
  26407. /**
  26408. * In case of light mapping, define whether the map contains light or shadow informations.
  26409. */
  26410. useLightmapAsShadowmap: boolean;
  26411. private _diffuseFresnelParameters;
  26412. /**
  26413. * Define the diffuse fresnel parameters of the material.
  26414. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26415. */
  26416. diffuseFresnelParameters: FresnelParameters;
  26417. private _opacityFresnelParameters;
  26418. /**
  26419. * Define the opacity fresnel parameters of the material.
  26420. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26421. */
  26422. opacityFresnelParameters: FresnelParameters;
  26423. private _reflectionFresnelParameters;
  26424. /**
  26425. * Define the reflection fresnel parameters of the material.
  26426. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26427. */
  26428. reflectionFresnelParameters: FresnelParameters;
  26429. private _refractionFresnelParameters;
  26430. /**
  26431. * Define the refraction fresnel parameters of the material.
  26432. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26433. */
  26434. refractionFresnelParameters: FresnelParameters;
  26435. private _emissiveFresnelParameters;
  26436. /**
  26437. * Define the emissive fresnel parameters of the material.
  26438. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26439. */
  26440. emissiveFresnelParameters: FresnelParameters;
  26441. private _useReflectionFresnelFromSpecular;
  26442. /**
  26443. * If true automatically deducts the fresnels values from the material specularity.
  26444. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26445. */
  26446. useReflectionFresnelFromSpecular: boolean;
  26447. private _useGlossinessFromSpecularMapAlpha;
  26448. /**
  26449. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  26450. */
  26451. useGlossinessFromSpecularMapAlpha: boolean;
  26452. private _maxSimultaneousLights;
  26453. /**
  26454. * Defines the maximum number of lights that can be used in the material
  26455. */
  26456. maxSimultaneousLights: number;
  26457. private _invertNormalMapX;
  26458. /**
  26459. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  26460. */
  26461. invertNormalMapX: boolean;
  26462. private _invertNormalMapY;
  26463. /**
  26464. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  26465. */
  26466. invertNormalMapY: boolean;
  26467. private _twoSidedLighting;
  26468. /**
  26469. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26470. */
  26471. twoSidedLighting: boolean;
  26472. /**
  26473. * Default configuration related to image processing available in the standard Material.
  26474. */
  26475. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  26476. /**
  26477. * Gets the image processing configuration used either in this material.
  26478. */
  26479. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  26480. /**
  26481. * Sets the Default image processing configuration used either in the this material.
  26482. *
  26483. * If sets to null, the scene one is in use.
  26484. */
  26485. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  26486. /**
  26487. * Keep track of the image processing observer to allow dispose and replace.
  26488. */
  26489. private _imageProcessingObserver;
  26490. /**
  26491. * Attaches a new image processing configuration to the Standard Material.
  26492. * @param configuration
  26493. */
  26494. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  26495. /**
  26496. * Gets wether the color curves effect is enabled.
  26497. */
  26498. get cameraColorCurvesEnabled(): boolean;
  26499. /**
  26500. * Sets wether the color curves effect is enabled.
  26501. */
  26502. set cameraColorCurvesEnabled(value: boolean);
  26503. /**
  26504. * Gets wether the color grading effect is enabled.
  26505. */
  26506. get cameraColorGradingEnabled(): boolean;
  26507. /**
  26508. * Gets wether the color grading effect is enabled.
  26509. */
  26510. set cameraColorGradingEnabled(value: boolean);
  26511. /**
  26512. * Gets wether tonemapping is enabled or not.
  26513. */
  26514. get cameraToneMappingEnabled(): boolean;
  26515. /**
  26516. * Sets wether tonemapping is enabled or not
  26517. */
  26518. set cameraToneMappingEnabled(value: boolean);
  26519. /**
  26520. * The camera exposure used on this material.
  26521. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26522. * This corresponds to a photographic exposure.
  26523. */
  26524. get cameraExposure(): number;
  26525. /**
  26526. * The camera exposure used on this material.
  26527. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26528. * This corresponds to a photographic exposure.
  26529. */
  26530. set cameraExposure(value: number);
  26531. /**
  26532. * Gets The camera contrast used on this material.
  26533. */
  26534. get cameraContrast(): number;
  26535. /**
  26536. * Sets The camera contrast used on this material.
  26537. */
  26538. set cameraContrast(value: number);
  26539. /**
  26540. * Gets the Color Grading 2D Lookup Texture.
  26541. */
  26542. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  26543. /**
  26544. * Sets the Color Grading 2D Lookup Texture.
  26545. */
  26546. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  26547. /**
  26548. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26549. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26550. * 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;
  26551. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26552. */
  26553. get cameraColorCurves(): Nullable<ColorCurves>;
  26554. /**
  26555. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26556. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26557. * 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;
  26558. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26559. */
  26560. set cameraColorCurves(value: Nullable<ColorCurves>);
  26561. /**
  26562. * Custom callback helping to override the default shader used in the material.
  26563. */
  26564. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  26565. protected _renderTargets: SmartArray<RenderTargetTexture>;
  26566. protected _worldViewProjectionMatrix: Matrix;
  26567. protected _globalAmbientColor: Color3;
  26568. protected _useLogarithmicDepth: boolean;
  26569. protected _rebuildInParallel: boolean;
  26570. /**
  26571. * Instantiates a new standard material.
  26572. * This is the default material used in Babylon. It is the best trade off between quality
  26573. * and performances.
  26574. * @see http://doc.babylonjs.com/babylon101/materials
  26575. * @param name Define the name of the material in the scene
  26576. * @param scene Define the scene the material belong to
  26577. */
  26578. constructor(name: string, scene: Scene);
  26579. /**
  26580. * Gets a boolean indicating that current material needs to register RTT
  26581. */
  26582. get hasRenderTargetTextures(): boolean;
  26583. /**
  26584. * Gets the current class name of the material e.g. "StandardMaterial"
  26585. * Mainly use in serialization.
  26586. * @returns the class name
  26587. */
  26588. getClassName(): string;
  26589. /**
  26590. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  26591. * You can try switching to logarithmic depth.
  26592. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  26593. */
  26594. get useLogarithmicDepth(): boolean;
  26595. set useLogarithmicDepth(value: boolean);
  26596. /**
  26597. * Specifies if the material will require alpha blending
  26598. * @returns a boolean specifying if alpha blending is needed
  26599. */
  26600. needAlphaBlending(): boolean;
  26601. /**
  26602. * Specifies if this material should be rendered in alpha test mode
  26603. * @returns a boolean specifying if an alpha test is needed.
  26604. */
  26605. needAlphaTesting(): boolean;
  26606. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  26607. /**
  26608. * Get the texture used for alpha test purpose.
  26609. * @returns the diffuse texture in case of the standard material.
  26610. */
  26611. getAlphaTestTexture(): Nullable<BaseTexture>;
  26612. /**
  26613. * Get if the submesh is ready to be used and all its information available.
  26614. * Child classes can use it to update shaders
  26615. * @param mesh defines the mesh to check
  26616. * @param subMesh defines which submesh to check
  26617. * @param useInstances specifies that instances should be used
  26618. * @returns a boolean indicating that the submesh is ready or not
  26619. */
  26620. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26621. /**
  26622. * Builds the material UBO layouts.
  26623. * Used internally during the effect preparation.
  26624. */
  26625. buildUniformLayout(): void;
  26626. /**
  26627. * Unbinds the material from the mesh
  26628. */
  26629. unbind(): void;
  26630. /**
  26631. * Binds the submesh to this material by preparing the effect and shader to draw
  26632. * @param world defines the world transformation matrix
  26633. * @param mesh defines the mesh containing the submesh
  26634. * @param subMesh defines the submesh to bind the material to
  26635. */
  26636. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  26637. /**
  26638. * Get the list of animatables in the material.
  26639. * @returns the list of animatables object used in the material
  26640. */
  26641. getAnimatables(): IAnimatable[];
  26642. /**
  26643. * Gets the active textures from the material
  26644. * @returns an array of textures
  26645. */
  26646. getActiveTextures(): BaseTexture[];
  26647. /**
  26648. * Specifies if the material uses a texture
  26649. * @param texture defines the texture to check against the material
  26650. * @returns a boolean specifying if the material uses the texture
  26651. */
  26652. hasTexture(texture: BaseTexture): boolean;
  26653. /**
  26654. * Disposes the material
  26655. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  26656. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  26657. */
  26658. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  26659. /**
  26660. * Makes a duplicate of the material, and gives it a new name
  26661. * @param name defines the new name for the duplicated material
  26662. * @returns the cloned material
  26663. */
  26664. clone(name: string): StandardMaterial;
  26665. /**
  26666. * Serializes this material in a JSON representation
  26667. * @returns the serialized material object
  26668. */
  26669. serialize(): any;
  26670. /**
  26671. * Creates a standard material from parsed material data
  26672. * @param source defines the JSON representation of the material
  26673. * @param scene defines the hosting scene
  26674. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  26675. * @returns a new standard material
  26676. */
  26677. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  26678. /**
  26679. * Are diffuse textures enabled in the application.
  26680. */
  26681. static get DiffuseTextureEnabled(): boolean;
  26682. static set DiffuseTextureEnabled(value: boolean);
  26683. /**
  26684. * Are ambient textures enabled in the application.
  26685. */
  26686. static get AmbientTextureEnabled(): boolean;
  26687. static set AmbientTextureEnabled(value: boolean);
  26688. /**
  26689. * Are opacity textures enabled in the application.
  26690. */
  26691. static get OpacityTextureEnabled(): boolean;
  26692. static set OpacityTextureEnabled(value: boolean);
  26693. /**
  26694. * Are reflection textures enabled in the application.
  26695. */
  26696. static get ReflectionTextureEnabled(): boolean;
  26697. static set ReflectionTextureEnabled(value: boolean);
  26698. /**
  26699. * Are emissive textures enabled in the application.
  26700. */
  26701. static get EmissiveTextureEnabled(): boolean;
  26702. static set EmissiveTextureEnabled(value: boolean);
  26703. /**
  26704. * Are specular textures enabled in the application.
  26705. */
  26706. static get SpecularTextureEnabled(): boolean;
  26707. static set SpecularTextureEnabled(value: boolean);
  26708. /**
  26709. * Are bump textures enabled in the application.
  26710. */
  26711. static get BumpTextureEnabled(): boolean;
  26712. static set BumpTextureEnabled(value: boolean);
  26713. /**
  26714. * Are lightmap textures enabled in the application.
  26715. */
  26716. static get LightmapTextureEnabled(): boolean;
  26717. static set LightmapTextureEnabled(value: boolean);
  26718. /**
  26719. * Are refraction textures enabled in the application.
  26720. */
  26721. static get RefractionTextureEnabled(): boolean;
  26722. static set RefractionTextureEnabled(value: boolean);
  26723. /**
  26724. * Are color grading textures enabled in the application.
  26725. */
  26726. static get ColorGradingTextureEnabled(): boolean;
  26727. static set ColorGradingTextureEnabled(value: boolean);
  26728. /**
  26729. * Are fresnels enabled in the application.
  26730. */
  26731. static get FresnelEnabled(): boolean;
  26732. static set FresnelEnabled(value: boolean);
  26733. }
  26734. }
  26735. declare module BABYLON {
  26736. /**
  26737. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  26738. *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.
  26739. * The SPS is also a particle system. It provides some methods to manage the particles.
  26740. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  26741. *
  26742. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  26743. */
  26744. export class SolidParticleSystem implements IDisposable {
  26745. /**
  26746. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  26747. * Example : var p = SPS.particles[i];
  26748. */
  26749. particles: SolidParticle[];
  26750. /**
  26751. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  26752. */
  26753. nbParticles: number;
  26754. /**
  26755. * If the particles must ever face the camera (default false). Useful for planar particles.
  26756. */
  26757. billboard: boolean;
  26758. /**
  26759. * Recompute normals when adding a shape
  26760. */
  26761. recomputeNormals: boolean;
  26762. /**
  26763. * This a counter ofr your own usage. It's not set by any SPS functions.
  26764. */
  26765. counter: number;
  26766. /**
  26767. * The SPS name. This name is also given to the underlying mesh.
  26768. */
  26769. name: string;
  26770. /**
  26771. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  26772. */
  26773. mesh: Mesh;
  26774. /**
  26775. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  26776. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  26777. */
  26778. vars: any;
  26779. /**
  26780. * This array is populated when the SPS is set as 'pickable'.
  26781. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  26782. * Each element of this array is an object `{idx: int, faceId: int}`.
  26783. * `idx` is the picked particle index in the `SPS.particles` array
  26784. * `faceId` is the picked face index counted within this particle.
  26785. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  26786. */
  26787. pickedParticles: {
  26788. idx: number;
  26789. faceId: number;
  26790. }[];
  26791. /**
  26792. * This array is populated when `enableDepthSort` is set to true.
  26793. * Each element of this array is an instance of the class DepthSortedParticle.
  26794. */
  26795. depthSortedParticles: DepthSortedParticle[];
  26796. /**
  26797. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  26798. * @hidden
  26799. */
  26800. _bSphereOnly: boolean;
  26801. /**
  26802. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  26803. * @hidden
  26804. */
  26805. _bSphereRadiusFactor: number;
  26806. private _scene;
  26807. private _positions;
  26808. private _indices;
  26809. private _normals;
  26810. private _colors;
  26811. private _uvs;
  26812. private _indices32;
  26813. private _positions32;
  26814. private _normals32;
  26815. private _fixedNormal32;
  26816. private _colors32;
  26817. private _uvs32;
  26818. private _index;
  26819. private _updatable;
  26820. private _pickable;
  26821. private _isVisibilityBoxLocked;
  26822. private _alwaysVisible;
  26823. private _depthSort;
  26824. private _expandable;
  26825. private _shapeCounter;
  26826. private _copy;
  26827. private _color;
  26828. private _computeParticleColor;
  26829. private _computeParticleTexture;
  26830. private _computeParticleRotation;
  26831. private _computeParticleVertex;
  26832. private _computeBoundingBox;
  26833. private _depthSortParticles;
  26834. private _camera;
  26835. private _mustUnrotateFixedNormals;
  26836. private _particlesIntersect;
  26837. private _needs32Bits;
  26838. private _isNotBuilt;
  26839. private _lastParticleId;
  26840. private _idxOfId;
  26841. private _multimaterialEnabled;
  26842. private _useModelMaterial;
  26843. private _indicesByMaterial;
  26844. private _materialIndexes;
  26845. private _depthSortFunction;
  26846. private _materialSortFunction;
  26847. private _materials;
  26848. private _multimaterial;
  26849. private _materialIndexesById;
  26850. private _defaultMaterial;
  26851. private _autoUpdateSubMeshes;
  26852. /**
  26853. * Creates a SPS (Solid Particle System) object.
  26854. * @param name (String) is the SPS name, this will be the underlying mesh name.
  26855. * @param scene (Scene) is the scene in which the SPS is added.
  26856. * @param options defines the options of the sps e.g.
  26857. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  26858. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  26859. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  26860. * * 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.
  26861. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  26862. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  26863. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  26864. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  26865. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  26866. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  26867. */
  26868. constructor(name: string, scene: Scene, options?: {
  26869. updatable?: boolean;
  26870. isPickable?: boolean;
  26871. enableDepthSort?: boolean;
  26872. particleIntersection?: boolean;
  26873. boundingSphereOnly?: boolean;
  26874. bSphereRadiusFactor?: number;
  26875. expandable?: boolean;
  26876. useModelMaterial?: boolean;
  26877. enableMultiMaterial?: boolean;
  26878. });
  26879. /**
  26880. * Builds the SPS underlying mesh. Returns a standard Mesh.
  26881. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  26882. * @returns the created mesh
  26883. */
  26884. buildMesh(): Mesh;
  26885. /**
  26886. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  26887. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  26888. * Thus the particles generated from `digest()` have their property `position` set yet.
  26889. * @param mesh ( Mesh ) is the mesh to be digested
  26890. * @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
  26891. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  26892. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  26893. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  26894. * @returns the current SPS
  26895. */
  26896. digest(mesh: Mesh, options?: {
  26897. facetNb?: number;
  26898. number?: number;
  26899. delta?: number;
  26900. storage?: [];
  26901. }): SolidParticleSystem;
  26902. /**
  26903. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  26904. * @hidden
  26905. */
  26906. private _unrotateFixedNormals;
  26907. /**
  26908. * Resets the temporary working copy particle
  26909. * @hidden
  26910. */
  26911. private _resetCopy;
  26912. /**
  26913. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  26914. * @param p the current index in the positions array to be updated
  26915. * @param ind the current index in the indices array
  26916. * @param shape a Vector3 array, the shape geometry
  26917. * @param positions the positions array to be updated
  26918. * @param meshInd the shape indices array
  26919. * @param indices the indices array to be updated
  26920. * @param meshUV the shape uv array
  26921. * @param uvs the uv array to be updated
  26922. * @param meshCol the shape color array
  26923. * @param colors the color array to be updated
  26924. * @param meshNor the shape normals array
  26925. * @param normals the normals array to be updated
  26926. * @param idx the particle index
  26927. * @param idxInShape the particle index in its shape
  26928. * @param options the addShape() method passed options
  26929. * @model the particle model
  26930. * @hidden
  26931. */
  26932. private _meshBuilder;
  26933. /**
  26934. * Returns a shape Vector3 array from positions float array
  26935. * @param positions float array
  26936. * @returns a vector3 array
  26937. * @hidden
  26938. */
  26939. private _posToShape;
  26940. /**
  26941. * Returns a shapeUV array from a float uvs (array deep copy)
  26942. * @param uvs as a float array
  26943. * @returns a shapeUV array
  26944. * @hidden
  26945. */
  26946. private _uvsToShapeUV;
  26947. /**
  26948. * Adds a new particle object in the particles array
  26949. * @param idx particle index in particles array
  26950. * @param id particle id
  26951. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  26952. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  26953. * @param model particle ModelShape object
  26954. * @param shapeId model shape identifier
  26955. * @param idxInShape index of the particle in the current model
  26956. * @param bInfo model bounding info object
  26957. * @param storage target storage array, if any
  26958. * @hidden
  26959. */
  26960. private _addParticle;
  26961. /**
  26962. * Adds some particles to the SPS from the model shape. Returns the shape id.
  26963. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  26964. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  26965. * @param nb (positive integer) the number of particles to be created from this model
  26966. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  26967. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  26968. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  26969. * @returns the number of shapes in the system
  26970. */
  26971. addShape(mesh: Mesh, nb: number, options?: {
  26972. positionFunction?: any;
  26973. vertexFunction?: any;
  26974. storage?: [];
  26975. }): number;
  26976. /**
  26977. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  26978. * @hidden
  26979. */
  26980. private _rebuildParticle;
  26981. /**
  26982. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  26983. * @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.
  26984. * @returns the SPS.
  26985. */
  26986. rebuildMesh(reset?: boolean): SolidParticleSystem;
  26987. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  26988. * Returns an array with the removed particles.
  26989. * 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.
  26990. * The SPS can't be empty so at least one particle needs to remain in place.
  26991. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  26992. * @param start index of the first particle to remove
  26993. * @param end index of the last particle to remove (included)
  26994. * @returns an array populated with the removed particles
  26995. */
  26996. removeParticles(start: number, end: number): SolidParticle[];
  26997. /**
  26998. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  26999. * @param solidParticleArray an array populated with Solid Particles objects
  27000. * @returns the SPS
  27001. */
  27002. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27003. /**
  27004. * Creates a new particle and modifies the SPS mesh geometry :
  27005. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27006. * - calls _addParticle() to populate the particle array
  27007. * factorized code from addShape() and insertParticlesFromArray()
  27008. * @param idx particle index in the particles array
  27009. * @param i particle index in its shape
  27010. * @param modelShape particle ModelShape object
  27011. * @param shape shape vertex array
  27012. * @param meshInd shape indices array
  27013. * @param meshUV shape uv array
  27014. * @param meshCol shape color array
  27015. * @param meshNor shape normals array
  27016. * @param bbInfo shape bounding info
  27017. * @param storage target particle storage
  27018. * @options addShape() passed options
  27019. * @hidden
  27020. */
  27021. private _insertNewParticle;
  27022. /**
  27023. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  27024. * This method calls `updateParticle()` for each particle of the SPS.
  27025. * For an animated SPS, it is usually called within the render loop.
  27026. * 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.
  27027. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  27028. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  27029. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  27030. * @returns the SPS.
  27031. */
  27032. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  27033. /**
  27034. * Disposes the SPS.
  27035. */
  27036. dispose(): void;
  27037. /**
  27038. * Returns a SolidParticle object from its identifier : particle.id
  27039. * @param id (integer) the particle Id
  27040. * @returns the searched particle or null if not found in the SPS.
  27041. */
  27042. getParticleById(id: number): Nullable<SolidParticle>;
  27043. /**
  27044. * Returns a new array populated with the particles having the passed shapeId.
  27045. * @param shapeId (integer) the shape identifier
  27046. * @returns a new solid particle array
  27047. */
  27048. getParticlesByShapeId(shapeId: number): SolidParticle[];
  27049. /**
  27050. * Populates the passed array "ref" with the particles having the passed shapeId.
  27051. * @param shapeId the shape identifier
  27052. * @returns the SPS
  27053. * @param ref
  27054. */
  27055. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  27056. /**
  27057. * Computes the required SubMeshes according the materials assigned to the particles.
  27058. * @returns the solid particle system.
  27059. * Does nothing if called before the SPS mesh is built.
  27060. */
  27061. computeSubMeshes(): SolidParticleSystem;
  27062. /**
  27063. * Sorts the solid particles by material when MultiMaterial is enabled.
  27064. * Updates the indices32 array.
  27065. * Updates the indicesByMaterial array.
  27066. * Updates the mesh indices array.
  27067. * @returns the SPS
  27068. * @hidden
  27069. */
  27070. private _sortParticlesByMaterial;
  27071. /**
  27072. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  27073. * @hidden
  27074. */
  27075. private _setMaterialIndexesById;
  27076. /**
  27077. * Returns an array with unique values of Materials from the passed array
  27078. * @param array the material array to be checked and filtered
  27079. * @hidden
  27080. */
  27081. private _filterUniqueMaterialId;
  27082. /**
  27083. * Sets a new Standard Material as _defaultMaterial if not already set.
  27084. * @hidden
  27085. */
  27086. private _setDefaultMaterial;
  27087. /**
  27088. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27089. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27090. * @returns the SPS.
  27091. */
  27092. refreshVisibleSize(): SolidParticleSystem;
  27093. /**
  27094. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27095. * @param size the size (float) of the visibility box
  27096. * note : this doesn't lock the SPS mesh bounding box.
  27097. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27098. */
  27099. setVisibilityBox(size: number): void;
  27100. /**
  27101. * Gets whether the SPS as always visible or not
  27102. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27103. */
  27104. get isAlwaysVisible(): boolean;
  27105. /**
  27106. * Sets the SPS as always visible or not
  27107. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27108. */
  27109. set isAlwaysVisible(val: boolean);
  27110. /**
  27111. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27112. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27113. */
  27114. set isVisibilityBoxLocked(val: boolean);
  27115. /**
  27116. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27117. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27118. */
  27119. get isVisibilityBoxLocked(): boolean;
  27120. /**
  27121. * Tells to `setParticles()` to compute the particle rotations or not.
  27122. * Default value : true. The SPS is faster when it's set to false.
  27123. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27124. */
  27125. set computeParticleRotation(val: boolean);
  27126. /**
  27127. * Tells to `setParticles()` to compute the particle colors or not.
  27128. * Default value : true. The SPS is faster when it's set to false.
  27129. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27130. */
  27131. set computeParticleColor(val: boolean);
  27132. set computeParticleTexture(val: boolean);
  27133. /**
  27134. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27135. * Default value : false. The SPS is faster when it's set to false.
  27136. * Note : the particle custom vertex positions aren't stored values.
  27137. */
  27138. set computeParticleVertex(val: boolean);
  27139. /**
  27140. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27141. */
  27142. set computeBoundingBox(val: boolean);
  27143. /**
  27144. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27145. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27146. * Default : `true`
  27147. */
  27148. set depthSortParticles(val: boolean);
  27149. /**
  27150. * Gets if `setParticles()` computes the particle rotations or not.
  27151. * Default value : true. The SPS is faster when it's set to false.
  27152. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27153. */
  27154. get computeParticleRotation(): boolean;
  27155. /**
  27156. * Gets if `setParticles()` computes the particle colors or not.
  27157. * Default value : true. The SPS is faster when it's set to false.
  27158. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27159. */
  27160. get computeParticleColor(): boolean;
  27161. /**
  27162. * Gets if `setParticles()` computes the particle textures or not.
  27163. * Default value : true. The SPS is faster when it's set to false.
  27164. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  27165. */
  27166. get computeParticleTexture(): boolean;
  27167. /**
  27168. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  27169. * Default value : false. The SPS is faster when it's set to false.
  27170. * Note : the particle custom vertex positions aren't stored values.
  27171. */
  27172. get computeParticleVertex(): boolean;
  27173. /**
  27174. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  27175. */
  27176. get computeBoundingBox(): boolean;
  27177. /**
  27178. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  27179. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27180. * Default : `true`
  27181. */
  27182. get depthSortParticles(): boolean;
  27183. /**
  27184. * Gets if the SPS is created as expandable at construction time.
  27185. * Default : `false`
  27186. */
  27187. get expandable(): boolean;
  27188. /**
  27189. * Gets if the SPS supports the Multi Materials
  27190. */
  27191. get multimaterialEnabled(): boolean;
  27192. /**
  27193. * Gets if the SPS uses the model materials for its own multimaterial.
  27194. */
  27195. get useModelMaterial(): boolean;
  27196. /**
  27197. * The SPS used material array.
  27198. */
  27199. get materials(): Material[];
  27200. /**
  27201. * Sets the SPS MultiMaterial from the passed materials.
  27202. * Note : the passed array is internally copied and not used then by reference.
  27203. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  27204. */
  27205. setMultiMaterial(materials: Material[]): void;
  27206. /**
  27207. * The SPS computed multimaterial object
  27208. */
  27209. get multimaterial(): MultiMaterial;
  27210. set multimaterial(mm: MultiMaterial);
  27211. /**
  27212. * If the subMeshes must be updated on the next call to setParticles()
  27213. */
  27214. get autoUpdateSubMeshes(): boolean;
  27215. set autoUpdateSubMeshes(val: boolean);
  27216. /**
  27217. * This function does nothing. It may be overwritten to set all the particle first values.
  27218. * The SPS doesn't call this function, you may have to call it by your own.
  27219. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27220. */
  27221. initParticles(): void;
  27222. /**
  27223. * This function does nothing. It may be overwritten to recycle a particle.
  27224. * The SPS doesn't call this function, you may have to call it by your own.
  27225. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27226. * @param particle The particle to recycle
  27227. * @returns the recycled particle
  27228. */
  27229. recycleParticle(particle: SolidParticle): SolidParticle;
  27230. /**
  27231. * Updates a particle : this function should be overwritten by the user.
  27232. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  27233. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27234. * @example : just set a particle position or velocity and recycle conditions
  27235. * @param particle The particle to update
  27236. * @returns the updated particle
  27237. */
  27238. updateParticle(particle: SolidParticle): SolidParticle;
  27239. /**
  27240. * Updates a vertex of a particle : it can be overwritten by the user.
  27241. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  27242. * @param particle the current particle
  27243. * @param vertex the current index of the current particle
  27244. * @param pt the index of the current vertex in the particle shape
  27245. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  27246. * @example : just set a vertex particle position
  27247. * @returns the updated vertex
  27248. */
  27249. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  27250. /**
  27251. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  27252. * This does nothing and may be overwritten by the user.
  27253. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27254. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27255. * @param update the boolean update value actually passed to setParticles()
  27256. */
  27257. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27258. /**
  27259. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  27260. * This will be passed three parameters.
  27261. * This does nothing and may be overwritten by the user.
  27262. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27263. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27264. * @param update the boolean update value actually passed to setParticles()
  27265. */
  27266. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27267. }
  27268. }
  27269. declare module BABYLON {
  27270. /**
  27271. * Represents one particle of a solid particle system.
  27272. */
  27273. export class SolidParticle {
  27274. /**
  27275. * particle global index
  27276. */
  27277. idx: number;
  27278. /**
  27279. * particle identifier
  27280. */
  27281. id: number;
  27282. /**
  27283. * The color of the particle
  27284. */
  27285. color: Nullable<Color4>;
  27286. /**
  27287. * The world space position of the particle.
  27288. */
  27289. position: Vector3;
  27290. /**
  27291. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  27292. */
  27293. rotation: Vector3;
  27294. /**
  27295. * The world space rotation quaternion of the particle.
  27296. */
  27297. rotationQuaternion: Nullable<Quaternion>;
  27298. /**
  27299. * The scaling of the particle.
  27300. */
  27301. scaling: Vector3;
  27302. /**
  27303. * The uvs of the particle.
  27304. */
  27305. uvs: Vector4;
  27306. /**
  27307. * The current speed of the particle.
  27308. */
  27309. velocity: Vector3;
  27310. /**
  27311. * The pivot point in the particle local space.
  27312. */
  27313. pivot: Vector3;
  27314. /**
  27315. * Must the particle be translated from its pivot point in its local space ?
  27316. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  27317. * Default : false
  27318. */
  27319. translateFromPivot: boolean;
  27320. /**
  27321. * Is the particle active or not ?
  27322. */
  27323. alive: boolean;
  27324. /**
  27325. * Is the particle visible or not ?
  27326. */
  27327. isVisible: boolean;
  27328. /**
  27329. * Index of this particle in the global "positions" array (Internal use)
  27330. * @hidden
  27331. */
  27332. _pos: number;
  27333. /**
  27334. * @hidden Index of this particle in the global "indices" array (Internal use)
  27335. */
  27336. _ind: number;
  27337. /**
  27338. * @hidden ModelShape of this particle (Internal use)
  27339. */
  27340. _model: ModelShape;
  27341. /**
  27342. * ModelShape id of this particle
  27343. */
  27344. shapeId: number;
  27345. /**
  27346. * Index of the particle in its shape id
  27347. */
  27348. idxInShape: number;
  27349. /**
  27350. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  27351. */
  27352. _modelBoundingInfo: BoundingInfo;
  27353. /**
  27354. * @hidden Particle BoundingInfo object (Internal use)
  27355. */
  27356. _boundingInfo: BoundingInfo;
  27357. /**
  27358. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  27359. */
  27360. _sps: SolidParticleSystem;
  27361. /**
  27362. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  27363. */
  27364. _stillInvisible: boolean;
  27365. /**
  27366. * @hidden Last computed particle rotation matrix
  27367. */
  27368. _rotationMatrix: number[];
  27369. /**
  27370. * Parent particle Id, if any.
  27371. * Default null.
  27372. */
  27373. parentId: Nullable<number>;
  27374. /**
  27375. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  27376. */
  27377. materialIndex: Nullable<number>;
  27378. /**
  27379. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  27380. * The possible values are :
  27381. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27382. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27383. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27384. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27385. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27386. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  27387. * */
  27388. cullingStrategy: number;
  27389. /**
  27390. * @hidden Internal global position in the SPS.
  27391. */
  27392. _globalPosition: Vector3;
  27393. /**
  27394. * Creates a Solid Particle object.
  27395. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  27396. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  27397. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  27398. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  27399. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  27400. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  27401. * @param shapeId (integer) is the model shape identifier in the SPS.
  27402. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  27403. * @param sps defines the sps it is associated to
  27404. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  27405. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  27406. */
  27407. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  27408. /**
  27409. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  27410. * @param target the particle target
  27411. * @returns the current particle
  27412. */
  27413. copyToRef(target: SolidParticle): SolidParticle;
  27414. /**
  27415. * Legacy support, changed scale to scaling
  27416. */
  27417. get scale(): Vector3;
  27418. /**
  27419. * Legacy support, changed scale to scaling
  27420. */
  27421. set scale(scale: Vector3);
  27422. /**
  27423. * Legacy support, changed quaternion to rotationQuaternion
  27424. */
  27425. get quaternion(): Nullable<Quaternion>;
  27426. /**
  27427. * Legacy support, changed quaternion to rotationQuaternion
  27428. */
  27429. set quaternion(q: Nullable<Quaternion>);
  27430. /**
  27431. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  27432. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  27433. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  27434. * @returns true if it intersects
  27435. */
  27436. intersectsMesh(target: Mesh | SolidParticle): boolean;
  27437. /**
  27438. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  27439. * A particle is in the frustum if its bounding box intersects the frustum
  27440. * @param frustumPlanes defines the frustum to test
  27441. * @returns true if the particle is in the frustum planes
  27442. */
  27443. isInFrustum(frustumPlanes: Plane[]): boolean;
  27444. /**
  27445. * get the rotation matrix of the particle
  27446. * @hidden
  27447. */
  27448. getRotationMatrix(m: Matrix): void;
  27449. }
  27450. /**
  27451. * Represents the shape of the model used by one particle of a solid particle system.
  27452. * SPS internal tool, don't use it manually.
  27453. */
  27454. export class ModelShape {
  27455. /**
  27456. * The shape id
  27457. * @hidden
  27458. */
  27459. shapeID: number;
  27460. /**
  27461. * flat array of model positions (internal use)
  27462. * @hidden
  27463. */
  27464. _shape: Vector3[];
  27465. /**
  27466. * flat array of model UVs (internal use)
  27467. * @hidden
  27468. */
  27469. _shapeUV: number[];
  27470. /**
  27471. * color array of the model
  27472. * @hidden
  27473. */
  27474. _shapeColors: number[];
  27475. /**
  27476. * indices array of the model
  27477. * @hidden
  27478. */
  27479. _indices: number[];
  27480. /**
  27481. * normals array of the model
  27482. * @hidden
  27483. */
  27484. _normals: number[];
  27485. /**
  27486. * length of the shape in the model indices array (internal use)
  27487. * @hidden
  27488. */
  27489. _indicesLength: number;
  27490. /**
  27491. * Custom position function (internal use)
  27492. * @hidden
  27493. */
  27494. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  27495. /**
  27496. * Custom vertex function (internal use)
  27497. * @hidden
  27498. */
  27499. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  27500. /**
  27501. * Model material (internal use)
  27502. * @hidden
  27503. */
  27504. _material: Nullable<Material>;
  27505. /**
  27506. * 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.
  27507. * SPS internal tool, don't use it manually.
  27508. * @hidden
  27509. */
  27510. 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>);
  27511. }
  27512. /**
  27513. * Represents a Depth Sorted Particle in the solid particle system.
  27514. * @hidden
  27515. */
  27516. export class DepthSortedParticle {
  27517. /**
  27518. * Index of the particle in the "indices" array
  27519. */
  27520. ind: number;
  27521. /**
  27522. * Length of the particle shape in the "indices" array
  27523. */
  27524. indicesLength: number;
  27525. /**
  27526. * Squared distance from the particle to the camera
  27527. */
  27528. sqDistance: number;
  27529. /**
  27530. * Material index when used with MultiMaterials
  27531. */
  27532. materialIndex: number;
  27533. /**
  27534. * Creates a new sorted particle
  27535. * @param materialIndex
  27536. */
  27537. constructor(ind: number, indLength: number, materialIndex: number);
  27538. }
  27539. }
  27540. declare module BABYLON {
  27541. /**
  27542. * @hidden
  27543. */
  27544. export class _MeshCollisionData {
  27545. _checkCollisions: boolean;
  27546. _collisionMask: number;
  27547. _collisionGroup: number;
  27548. _collider: Nullable<Collider>;
  27549. _oldPositionForCollisions: Vector3;
  27550. _diffPositionForCollisions: Vector3;
  27551. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  27552. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  27553. }
  27554. }
  27555. declare module BABYLON {
  27556. /** @hidden */
  27557. class _FacetDataStorage {
  27558. facetPositions: Vector3[];
  27559. facetNormals: Vector3[];
  27560. facetPartitioning: number[][];
  27561. facetNb: number;
  27562. partitioningSubdivisions: number;
  27563. partitioningBBoxRatio: number;
  27564. facetDataEnabled: boolean;
  27565. facetParameters: any;
  27566. bbSize: Vector3;
  27567. subDiv: {
  27568. max: number;
  27569. X: number;
  27570. Y: number;
  27571. Z: number;
  27572. };
  27573. facetDepthSort: boolean;
  27574. facetDepthSortEnabled: boolean;
  27575. depthSortedIndices: IndicesArray;
  27576. depthSortedFacets: {
  27577. ind: number;
  27578. sqDistance: number;
  27579. }[];
  27580. facetDepthSortFunction: (f1: {
  27581. ind: number;
  27582. sqDistance: number;
  27583. }, f2: {
  27584. ind: number;
  27585. sqDistance: number;
  27586. }) => number;
  27587. facetDepthSortFrom: Vector3;
  27588. facetDepthSortOrigin: Vector3;
  27589. invertedMatrix: Matrix;
  27590. }
  27591. /**
  27592. * @hidden
  27593. **/
  27594. class _InternalAbstractMeshDataInfo {
  27595. _hasVertexAlpha: boolean;
  27596. _useVertexColors: boolean;
  27597. _numBoneInfluencers: number;
  27598. _applyFog: boolean;
  27599. _receiveShadows: boolean;
  27600. _facetData: _FacetDataStorage;
  27601. _visibility: number;
  27602. _skeleton: Nullable<Skeleton>;
  27603. _layerMask: number;
  27604. _computeBonesUsingShaders: boolean;
  27605. _isActive: boolean;
  27606. _onlyForInstances: boolean;
  27607. _isActiveIntermediate: boolean;
  27608. _onlyForInstancesIntermediate: boolean;
  27609. _actAsRegularMesh: boolean;
  27610. }
  27611. /**
  27612. * Class used to store all common mesh properties
  27613. */
  27614. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  27615. /** No occlusion */
  27616. static OCCLUSION_TYPE_NONE: number;
  27617. /** Occlusion set to optimisitic */
  27618. static OCCLUSION_TYPE_OPTIMISTIC: number;
  27619. /** Occlusion set to strict */
  27620. static OCCLUSION_TYPE_STRICT: number;
  27621. /** Use an accurante occlusion algorithm */
  27622. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  27623. /** Use a conservative occlusion algorithm */
  27624. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  27625. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  27626. * Test order :
  27627. * Is the bounding sphere outside the frustum ?
  27628. * If not, are the bounding box vertices outside the frustum ?
  27629. * It not, then the cullable object is in the frustum.
  27630. */
  27631. static readonly CULLINGSTRATEGY_STANDARD: number;
  27632. /** Culling strategy : Bounding Sphere Only.
  27633. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  27634. * It's also less accurate than the standard because some not visible objects can still be selected.
  27635. * Test : is the bounding sphere outside the frustum ?
  27636. * If not, then the cullable object is in the frustum.
  27637. */
  27638. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  27639. /** Culling strategy : Optimistic Inclusion.
  27640. * This in an inclusion test first, then the standard exclusion test.
  27641. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  27642. * 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.
  27643. * Anyway, it's as accurate as the standard strategy.
  27644. * Test :
  27645. * Is the cullable object bounding sphere center in the frustum ?
  27646. * If not, apply the default culling strategy.
  27647. */
  27648. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  27649. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  27650. * This in an inclusion test first, then the bounding sphere only exclusion test.
  27651. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  27652. * 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.
  27653. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  27654. * Test :
  27655. * Is the cullable object bounding sphere center in the frustum ?
  27656. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  27657. */
  27658. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  27659. /**
  27660. * No billboard
  27661. */
  27662. static get BILLBOARDMODE_NONE(): number;
  27663. /** Billboard on X axis */
  27664. static get BILLBOARDMODE_X(): number;
  27665. /** Billboard on Y axis */
  27666. static get BILLBOARDMODE_Y(): number;
  27667. /** Billboard on Z axis */
  27668. static get BILLBOARDMODE_Z(): number;
  27669. /** Billboard on all axes */
  27670. static get BILLBOARDMODE_ALL(): number;
  27671. /** Billboard on using position instead of orientation */
  27672. static get BILLBOARDMODE_USE_POSITION(): number;
  27673. /** @hidden */
  27674. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  27675. /**
  27676. * The culling strategy to use to check whether the mesh must be rendered or not.
  27677. * This value can be changed at any time and will be used on the next render mesh selection.
  27678. * The possible values are :
  27679. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27680. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27681. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27682. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27683. * Please read each static variable documentation to get details about the culling process.
  27684. * */
  27685. cullingStrategy: number;
  27686. /**
  27687. * Gets the number of facets in the mesh
  27688. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27689. */
  27690. get facetNb(): number;
  27691. /**
  27692. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  27693. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27694. */
  27695. get partitioningSubdivisions(): number;
  27696. set partitioningSubdivisions(nb: number);
  27697. /**
  27698. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  27699. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  27700. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27701. */
  27702. get partitioningBBoxRatio(): number;
  27703. set partitioningBBoxRatio(ratio: number);
  27704. /**
  27705. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  27706. * Works only for updatable meshes.
  27707. * Doesn't work with multi-materials
  27708. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27709. */
  27710. get mustDepthSortFacets(): boolean;
  27711. set mustDepthSortFacets(sort: boolean);
  27712. /**
  27713. * The location (Vector3) where the facet depth sort must be computed from.
  27714. * By default, the active camera position.
  27715. * Used only when facet depth sort is enabled
  27716. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27717. */
  27718. get facetDepthSortFrom(): Vector3;
  27719. set facetDepthSortFrom(location: Vector3);
  27720. /**
  27721. * gets a boolean indicating if facetData is enabled
  27722. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27723. */
  27724. get isFacetDataEnabled(): boolean;
  27725. /** @hidden */
  27726. _updateNonUniformScalingState(value: boolean): boolean;
  27727. /**
  27728. * An event triggered when this mesh collides with another one
  27729. */
  27730. onCollideObservable: Observable<AbstractMesh>;
  27731. /** Set a function to call when this mesh collides with another one */
  27732. set onCollide(callback: () => void);
  27733. /**
  27734. * An event triggered when the collision's position changes
  27735. */
  27736. onCollisionPositionChangeObservable: Observable<Vector3>;
  27737. /** Set a function to call when the collision's position changes */
  27738. set onCollisionPositionChange(callback: () => void);
  27739. /**
  27740. * An event triggered when material is changed
  27741. */
  27742. onMaterialChangedObservable: Observable<AbstractMesh>;
  27743. /**
  27744. * Gets or sets the orientation for POV movement & rotation
  27745. */
  27746. definedFacingForward: boolean;
  27747. /** @hidden */
  27748. _occlusionQuery: Nullable<WebGLQuery>;
  27749. /** @hidden */
  27750. _renderingGroup: Nullable<RenderingGroup>;
  27751. /**
  27752. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27753. */
  27754. get visibility(): number;
  27755. /**
  27756. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27757. */
  27758. set visibility(value: number);
  27759. /** Gets or sets the alpha index used to sort transparent meshes
  27760. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  27761. */
  27762. alphaIndex: number;
  27763. /**
  27764. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  27765. */
  27766. isVisible: boolean;
  27767. /**
  27768. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  27769. */
  27770. isPickable: boolean;
  27771. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  27772. showSubMeshesBoundingBox: boolean;
  27773. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  27774. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  27775. */
  27776. isBlocker: boolean;
  27777. /**
  27778. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  27779. */
  27780. enablePointerMoveEvents: boolean;
  27781. /**
  27782. * Specifies the rendering group id for this mesh (0 by default)
  27783. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  27784. */
  27785. renderingGroupId: number;
  27786. private _material;
  27787. /** Gets or sets current material */
  27788. get material(): Nullable<Material>;
  27789. set material(value: Nullable<Material>);
  27790. /**
  27791. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  27792. * @see http://doc.babylonjs.com/babylon101/shadows
  27793. */
  27794. get receiveShadows(): boolean;
  27795. set receiveShadows(value: boolean);
  27796. /** Defines color to use when rendering outline */
  27797. outlineColor: Color3;
  27798. /** Define width to use when rendering outline */
  27799. outlineWidth: number;
  27800. /** Defines color to use when rendering overlay */
  27801. overlayColor: Color3;
  27802. /** Defines alpha to use when rendering overlay */
  27803. overlayAlpha: number;
  27804. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  27805. get hasVertexAlpha(): boolean;
  27806. set hasVertexAlpha(value: boolean);
  27807. /** 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) */
  27808. get useVertexColors(): boolean;
  27809. set useVertexColors(value: boolean);
  27810. /**
  27811. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  27812. */
  27813. get computeBonesUsingShaders(): boolean;
  27814. set computeBonesUsingShaders(value: boolean);
  27815. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  27816. get numBoneInfluencers(): number;
  27817. set numBoneInfluencers(value: number);
  27818. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  27819. get applyFog(): boolean;
  27820. set applyFog(value: boolean);
  27821. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  27822. useOctreeForRenderingSelection: boolean;
  27823. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  27824. useOctreeForPicking: boolean;
  27825. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  27826. useOctreeForCollisions: boolean;
  27827. /**
  27828. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  27829. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  27830. */
  27831. get layerMask(): number;
  27832. set layerMask(value: number);
  27833. /**
  27834. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  27835. */
  27836. alwaysSelectAsActiveMesh: boolean;
  27837. /**
  27838. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  27839. */
  27840. doNotSyncBoundingInfo: boolean;
  27841. /**
  27842. * Gets or sets the current action manager
  27843. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27844. */
  27845. actionManager: Nullable<AbstractActionManager>;
  27846. private _meshCollisionData;
  27847. /**
  27848. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  27849. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27850. */
  27851. ellipsoid: Vector3;
  27852. /**
  27853. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  27854. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27855. */
  27856. ellipsoidOffset: Vector3;
  27857. /**
  27858. * Gets or sets a collision mask used to mask collisions (default is -1).
  27859. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  27860. */
  27861. get collisionMask(): number;
  27862. set collisionMask(mask: number);
  27863. /**
  27864. * Gets or sets the current collision group mask (-1 by default).
  27865. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  27866. */
  27867. get collisionGroup(): number;
  27868. set collisionGroup(mask: number);
  27869. /**
  27870. * Defines edge width used when edgesRenderer is enabled
  27871. * @see https://www.babylonjs-playground.com/#10OJSG#13
  27872. */
  27873. edgesWidth: number;
  27874. /**
  27875. * Defines edge color used when edgesRenderer is enabled
  27876. * @see https://www.babylonjs-playground.com/#10OJSG#13
  27877. */
  27878. edgesColor: Color4;
  27879. /** @hidden */
  27880. _edgesRenderer: Nullable<IEdgesRenderer>;
  27881. /** @hidden */
  27882. _masterMesh: Nullable<AbstractMesh>;
  27883. /** @hidden */
  27884. _boundingInfo: Nullable<BoundingInfo>;
  27885. /** @hidden */
  27886. _renderId: number;
  27887. /**
  27888. * Gets or sets the list of subMeshes
  27889. * @see http://doc.babylonjs.com/how_to/multi_materials
  27890. */
  27891. subMeshes: SubMesh[];
  27892. /** @hidden */
  27893. _intersectionsInProgress: AbstractMesh[];
  27894. /** @hidden */
  27895. _unIndexed: boolean;
  27896. /** @hidden */
  27897. _lightSources: Light[];
  27898. /** Gets the list of lights affecting that mesh */
  27899. get lightSources(): Light[];
  27900. /** @hidden */
  27901. get _positions(): Nullable<Vector3[]>;
  27902. /** @hidden */
  27903. _waitingData: {
  27904. lods: Nullable<any>;
  27905. actions: Nullable<any>;
  27906. freezeWorldMatrix: Nullable<boolean>;
  27907. };
  27908. /** @hidden */
  27909. _bonesTransformMatrices: Nullable<Float32Array>;
  27910. /** @hidden */
  27911. _transformMatrixTexture: Nullable<RawTexture>;
  27912. /**
  27913. * Gets or sets a skeleton to apply skining transformations
  27914. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  27915. */
  27916. set skeleton(value: Nullable<Skeleton>);
  27917. get skeleton(): Nullable<Skeleton>;
  27918. /**
  27919. * An event triggered when the mesh is rebuilt.
  27920. */
  27921. onRebuildObservable: Observable<AbstractMesh>;
  27922. /**
  27923. * Creates a new AbstractMesh
  27924. * @param name defines the name of the mesh
  27925. * @param scene defines the hosting scene
  27926. */
  27927. constructor(name: string, scene?: Nullable<Scene>);
  27928. /**
  27929. * Returns the string "AbstractMesh"
  27930. * @returns "AbstractMesh"
  27931. */
  27932. getClassName(): string;
  27933. /**
  27934. * Gets a string representation of the current mesh
  27935. * @param fullDetails defines a boolean indicating if full details must be included
  27936. * @returns a string representation of the current mesh
  27937. */
  27938. toString(fullDetails?: boolean): string;
  27939. /**
  27940. * @hidden
  27941. */
  27942. protected _getEffectiveParent(): Nullable<Node>;
  27943. /** @hidden */
  27944. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27945. /** @hidden */
  27946. _rebuild(): void;
  27947. /** @hidden */
  27948. _resyncLightSources(): void;
  27949. /** @hidden */
  27950. _resyncLightSource(light: Light): void;
  27951. /** @hidden */
  27952. _unBindEffect(): void;
  27953. /** @hidden */
  27954. _removeLightSource(light: Light, dispose: boolean): void;
  27955. private _markSubMeshesAsDirty;
  27956. /** @hidden */
  27957. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  27958. /** @hidden */
  27959. _markSubMeshesAsAttributesDirty(): void;
  27960. /** @hidden */
  27961. _markSubMeshesAsMiscDirty(): void;
  27962. /**
  27963. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  27964. */
  27965. get scaling(): Vector3;
  27966. set scaling(newScaling: Vector3);
  27967. /**
  27968. * Returns true if the mesh is blocked. Implemented by child classes
  27969. */
  27970. get isBlocked(): boolean;
  27971. /**
  27972. * Returns the mesh itself by default. Implemented by child classes
  27973. * @param camera defines the camera to use to pick the right LOD level
  27974. * @returns the currentAbstractMesh
  27975. */
  27976. getLOD(camera: Camera): Nullable<AbstractMesh>;
  27977. /**
  27978. * Returns 0 by default. Implemented by child classes
  27979. * @returns an integer
  27980. */
  27981. getTotalVertices(): number;
  27982. /**
  27983. * Returns a positive integer : the total number of indices in this mesh geometry.
  27984. * @returns the numner of indices or zero if the mesh has no geometry.
  27985. */
  27986. getTotalIndices(): number;
  27987. /**
  27988. * Returns null by default. Implemented by child classes
  27989. * @returns null
  27990. */
  27991. getIndices(): Nullable<IndicesArray>;
  27992. /**
  27993. * Returns the array of the requested vertex data kind. Implemented by child classes
  27994. * @param kind defines the vertex data kind to use
  27995. * @returns null
  27996. */
  27997. getVerticesData(kind: string): Nullable<FloatArray>;
  27998. /**
  27999. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28000. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28001. * Note that a new underlying VertexBuffer object is created each call.
  28002. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28003. * @param kind defines vertex data kind:
  28004. * * VertexBuffer.PositionKind
  28005. * * VertexBuffer.UVKind
  28006. * * VertexBuffer.UV2Kind
  28007. * * VertexBuffer.UV3Kind
  28008. * * VertexBuffer.UV4Kind
  28009. * * VertexBuffer.UV5Kind
  28010. * * VertexBuffer.UV6Kind
  28011. * * VertexBuffer.ColorKind
  28012. * * VertexBuffer.MatricesIndicesKind
  28013. * * VertexBuffer.MatricesIndicesExtraKind
  28014. * * VertexBuffer.MatricesWeightsKind
  28015. * * VertexBuffer.MatricesWeightsExtraKind
  28016. * @param data defines the data source
  28017. * @param updatable defines if the data must be flagged as updatable (or static)
  28018. * @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
  28019. * @returns the current mesh
  28020. */
  28021. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28022. /**
  28023. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28024. * If the mesh has no geometry, it is simply returned as it is.
  28025. * @param kind defines vertex data kind:
  28026. * * VertexBuffer.PositionKind
  28027. * * VertexBuffer.UVKind
  28028. * * VertexBuffer.UV2Kind
  28029. * * VertexBuffer.UV3Kind
  28030. * * VertexBuffer.UV4Kind
  28031. * * VertexBuffer.UV5Kind
  28032. * * VertexBuffer.UV6Kind
  28033. * * VertexBuffer.ColorKind
  28034. * * VertexBuffer.MatricesIndicesKind
  28035. * * VertexBuffer.MatricesIndicesExtraKind
  28036. * * VertexBuffer.MatricesWeightsKind
  28037. * * VertexBuffer.MatricesWeightsExtraKind
  28038. * @param data defines the data source
  28039. * @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
  28040. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  28041. * @returns the current mesh
  28042. */
  28043. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28044. /**
  28045. * Sets the mesh indices,
  28046. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28047. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  28048. * @param totalVertices Defines the total number of vertices
  28049. * @returns the current mesh
  28050. */
  28051. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  28052. /**
  28053. * Gets a boolean indicating if specific vertex data is present
  28054. * @param kind defines the vertex data kind to use
  28055. * @returns true is data kind is present
  28056. */
  28057. isVerticesDataPresent(kind: string): boolean;
  28058. /**
  28059. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  28060. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  28061. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  28062. * @returns a BoundingInfo
  28063. */
  28064. getBoundingInfo(): BoundingInfo;
  28065. /**
  28066. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  28067. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  28068. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  28069. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28070. * @returns the current mesh
  28071. */
  28072. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  28073. /**
  28074. * Overwrite the current bounding info
  28075. * @param boundingInfo defines the new bounding info
  28076. * @returns the current mesh
  28077. */
  28078. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  28079. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  28080. get useBones(): boolean;
  28081. /** @hidden */
  28082. _preActivate(): void;
  28083. /** @hidden */
  28084. _preActivateForIntermediateRendering(renderId: number): void;
  28085. /** @hidden */
  28086. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28087. /** @hidden */
  28088. _postActivate(): void;
  28089. /** @hidden */
  28090. _freeze(): void;
  28091. /** @hidden */
  28092. _unFreeze(): void;
  28093. /**
  28094. * Gets the current world matrix
  28095. * @returns a Matrix
  28096. */
  28097. getWorldMatrix(): Matrix;
  28098. /** @hidden */
  28099. _getWorldMatrixDeterminant(): number;
  28100. /**
  28101. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28102. */
  28103. get isAnInstance(): boolean;
  28104. /**
  28105. * Gets a boolean indicating if this mesh has instances
  28106. */
  28107. get hasInstances(): boolean;
  28108. /**
  28109. * Perform relative position change from the point of view of behind the front of the mesh.
  28110. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28111. * Supports definition of mesh facing forward or backward
  28112. * @param amountRight defines the distance on the right axis
  28113. * @param amountUp defines the distance on the up axis
  28114. * @param amountForward defines the distance on the forward axis
  28115. * @returns the current mesh
  28116. */
  28117. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  28118. /**
  28119. * Calculate relative position change from the point of view of behind the front of the mesh.
  28120. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28121. * Supports definition of mesh facing forward or backward
  28122. * @param amountRight defines the distance on the right axis
  28123. * @param amountUp defines the distance on the up axis
  28124. * @param amountForward defines the distance on the forward axis
  28125. * @returns the new displacement vector
  28126. */
  28127. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  28128. /**
  28129. * Perform relative rotation change from the point of view of behind the front of the mesh.
  28130. * Supports definition of mesh facing forward or backward
  28131. * @param flipBack defines the flip
  28132. * @param twirlClockwise defines the twirl
  28133. * @param tiltRight defines the tilt
  28134. * @returns the current mesh
  28135. */
  28136. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  28137. /**
  28138. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  28139. * Supports definition of mesh facing forward or backward.
  28140. * @param flipBack defines the flip
  28141. * @param twirlClockwise defines the twirl
  28142. * @param tiltRight defines the tilt
  28143. * @returns the new rotation vector
  28144. */
  28145. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  28146. /**
  28147. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28148. * This means the mesh underlying bounding box and sphere are recomputed.
  28149. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28150. * @returns the current mesh
  28151. */
  28152. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  28153. /** @hidden */
  28154. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  28155. /** @hidden */
  28156. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  28157. /** @hidden */
  28158. _updateBoundingInfo(): AbstractMesh;
  28159. /** @hidden */
  28160. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  28161. /** @hidden */
  28162. protected _afterComputeWorldMatrix(): void;
  28163. /** @hidden */
  28164. get _effectiveMesh(): AbstractMesh;
  28165. /**
  28166. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28167. * A mesh is in the frustum if its bounding box intersects the frustum
  28168. * @param frustumPlanes defines the frustum to test
  28169. * @returns true if the mesh is in the frustum planes
  28170. */
  28171. isInFrustum(frustumPlanes: Plane[]): boolean;
  28172. /**
  28173. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  28174. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  28175. * @param frustumPlanes defines the frustum to test
  28176. * @returns true if the mesh is completely in the frustum planes
  28177. */
  28178. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28179. /**
  28180. * True if the mesh intersects another mesh or a SolidParticle object
  28181. * @param mesh defines a target mesh or SolidParticle to test
  28182. * @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)
  28183. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  28184. * @returns true if there is an intersection
  28185. */
  28186. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  28187. /**
  28188. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  28189. * @param point defines the point to test
  28190. * @returns true if there is an intersection
  28191. */
  28192. intersectsPoint(point: Vector3): boolean;
  28193. /**
  28194. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  28195. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28196. */
  28197. get checkCollisions(): boolean;
  28198. set checkCollisions(collisionEnabled: boolean);
  28199. /**
  28200. * Gets Collider object used to compute collisions (not physics)
  28201. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28202. */
  28203. get collider(): Nullable<Collider>;
  28204. /**
  28205. * Move the mesh using collision engine
  28206. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28207. * @param displacement defines the requested displacement vector
  28208. * @returns the current mesh
  28209. */
  28210. moveWithCollisions(displacement: Vector3): AbstractMesh;
  28211. private _onCollisionPositionChange;
  28212. /** @hidden */
  28213. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  28214. /** @hidden */
  28215. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  28216. /** @hidden */
  28217. _checkCollision(collider: Collider): AbstractMesh;
  28218. /** @hidden */
  28219. _generatePointsArray(): boolean;
  28220. /**
  28221. * Checks if the passed Ray intersects with the mesh
  28222. * @param ray defines the ray to use
  28223. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  28224. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  28225. * @returns the picking info
  28226. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  28227. */
  28228. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  28229. /**
  28230. * Clones the current mesh
  28231. * @param name defines the mesh name
  28232. * @param newParent defines the new mesh parent
  28233. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  28234. * @returns the new mesh
  28235. */
  28236. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  28237. /**
  28238. * Disposes all the submeshes of the current meshnp
  28239. * @returns the current mesh
  28240. */
  28241. releaseSubMeshes(): AbstractMesh;
  28242. /**
  28243. * Releases resources associated with this abstract mesh.
  28244. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28245. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28246. */
  28247. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28248. /**
  28249. * Adds the passed mesh as a child to the current mesh
  28250. * @param mesh defines the child mesh
  28251. * @returns the current mesh
  28252. */
  28253. addChild(mesh: AbstractMesh): AbstractMesh;
  28254. /**
  28255. * Removes the passed mesh from the current mesh children list
  28256. * @param mesh defines the child mesh
  28257. * @returns the current mesh
  28258. */
  28259. removeChild(mesh: AbstractMesh): AbstractMesh;
  28260. /** @hidden */
  28261. private _initFacetData;
  28262. /**
  28263. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  28264. * This method can be called within the render loop.
  28265. * 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
  28266. * @returns the current mesh
  28267. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28268. */
  28269. updateFacetData(): AbstractMesh;
  28270. /**
  28271. * Returns the facetLocalNormals array.
  28272. * The normals are expressed in the mesh local spac
  28273. * @returns an array of Vector3
  28274. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28275. */
  28276. getFacetLocalNormals(): Vector3[];
  28277. /**
  28278. * Returns the facetLocalPositions array.
  28279. * The facet positions are expressed in the mesh local space
  28280. * @returns an array of Vector3
  28281. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28282. */
  28283. getFacetLocalPositions(): Vector3[];
  28284. /**
  28285. * Returns the facetLocalPartioning array
  28286. * @returns an array of array of numbers
  28287. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28288. */
  28289. getFacetLocalPartitioning(): number[][];
  28290. /**
  28291. * Returns the i-th facet position in the world system.
  28292. * This method allocates a new Vector3 per call
  28293. * @param i defines the facet index
  28294. * @returns a new Vector3
  28295. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28296. */
  28297. getFacetPosition(i: number): Vector3;
  28298. /**
  28299. * Sets the reference Vector3 with the i-th facet position in the world system
  28300. * @param i defines the facet index
  28301. * @param ref defines the target vector
  28302. * @returns the current mesh
  28303. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28304. */
  28305. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  28306. /**
  28307. * Returns the i-th facet normal in the world system.
  28308. * This method allocates a new Vector3 per call
  28309. * @param i defines the facet index
  28310. * @returns a new Vector3
  28311. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28312. */
  28313. getFacetNormal(i: number): Vector3;
  28314. /**
  28315. * Sets the reference Vector3 with the i-th facet normal in the world system
  28316. * @param i defines the facet index
  28317. * @param ref defines the target vector
  28318. * @returns the current mesh
  28319. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28320. */
  28321. getFacetNormalToRef(i: number, ref: Vector3): this;
  28322. /**
  28323. * 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)
  28324. * @param x defines x coordinate
  28325. * @param y defines y coordinate
  28326. * @param z defines z coordinate
  28327. * @returns the array of facet indexes
  28328. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28329. */
  28330. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  28331. /**
  28332. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  28333. * @param projected sets as the (x,y,z) world projection on the facet
  28334. * @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
  28335. * @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
  28336. * @param x defines x coordinate
  28337. * @param y defines y coordinate
  28338. * @param z defines z coordinate
  28339. * @returns the face index if found (or null instead)
  28340. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28341. */
  28342. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28343. /**
  28344. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  28345. * @param projected sets as the (x,y,z) local projection on the facet
  28346. * @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
  28347. * @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
  28348. * @param x defines x coordinate
  28349. * @param y defines y coordinate
  28350. * @param z defines z coordinate
  28351. * @returns the face index if found (or null instead)
  28352. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28353. */
  28354. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28355. /**
  28356. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  28357. * @returns the parameters
  28358. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28359. */
  28360. getFacetDataParameters(): any;
  28361. /**
  28362. * Disables the feature FacetData and frees the related memory
  28363. * @returns the current mesh
  28364. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28365. */
  28366. disableFacetData(): AbstractMesh;
  28367. /**
  28368. * Updates the AbstractMesh indices array
  28369. * @param indices defines the data source
  28370. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28371. * @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)
  28372. * @returns the current mesh
  28373. */
  28374. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28375. /**
  28376. * Creates new normals data for the mesh
  28377. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  28378. * @returns the current mesh
  28379. */
  28380. createNormals(updatable: boolean): AbstractMesh;
  28381. /**
  28382. * Align the mesh with a normal
  28383. * @param normal defines the normal to use
  28384. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  28385. * @returns the current mesh
  28386. */
  28387. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  28388. /** @hidden */
  28389. _checkOcclusionQuery(): boolean;
  28390. /**
  28391. * Disables the mesh edge rendering mode
  28392. * @returns the currentAbstractMesh
  28393. */
  28394. disableEdgesRendering(): AbstractMesh;
  28395. /**
  28396. * Enables the edge rendering mode on the mesh.
  28397. * This mode makes the mesh edges visible
  28398. * @param epsilon defines the maximal distance between two angles to detect a face
  28399. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28400. * @returns the currentAbstractMesh
  28401. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28402. */
  28403. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28404. }
  28405. }
  28406. declare module BABYLON {
  28407. /**
  28408. * Interface used to define ActionEvent
  28409. */
  28410. export interface IActionEvent {
  28411. /** The mesh or sprite that triggered the action */
  28412. source: any;
  28413. /** The X mouse cursor position at the time of the event */
  28414. pointerX: number;
  28415. /** The Y mouse cursor position at the time of the event */
  28416. pointerY: number;
  28417. /** The mesh that is currently pointed at (can be null) */
  28418. meshUnderPointer: Nullable<AbstractMesh>;
  28419. /** the original (browser) event that triggered the ActionEvent */
  28420. sourceEvent?: any;
  28421. /** additional data for the event */
  28422. additionalData?: any;
  28423. }
  28424. /**
  28425. * ActionEvent is the event being sent when an action is triggered.
  28426. */
  28427. export class ActionEvent implements IActionEvent {
  28428. /** The mesh or sprite that triggered the action */
  28429. source: any;
  28430. /** The X mouse cursor position at the time of the event */
  28431. pointerX: number;
  28432. /** The Y mouse cursor position at the time of the event */
  28433. pointerY: number;
  28434. /** The mesh that is currently pointed at (can be null) */
  28435. meshUnderPointer: Nullable<AbstractMesh>;
  28436. /** the original (browser) event that triggered the ActionEvent */
  28437. sourceEvent?: any;
  28438. /** additional data for the event */
  28439. additionalData?: any;
  28440. /**
  28441. * Creates a new ActionEvent
  28442. * @param source The mesh or sprite that triggered the action
  28443. * @param pointerX The X mouse cursor position at the time of the event
  28444. * @param pointerY The Y mouse cursor position at the time of the event
  28445. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  28446. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  28447. * @param additionalData additional data for the event
  28448. */
  28449. constructor(
  28450. /** The mesh or sprite that triggered the action */
  28451. source: any,
  28452. /** The X mouse cursor position at the time of the event */
  28453. pointerX: number,
  28454. /** The Y mouse cursor position at the time of the event */
  28455. pointerY: number,
  28456. /** The mesh that is currently pointed at (can be null) */
  28457. meshUnderPointer: Nullable<AbstractMesh>,
  28458. /** the original (browser) event that triggered the ActionEvent */
  28459. sourceEvent?: any,
  28460. /** additional data for the event */
  28461. additionalData?: any);
  28462. /**
  28463. * Helper function to auto-create an ActionEvent from a source mesh.
  28464. * @param source The source mesh that triggered the event
  28465. * @param evt The original (browser) event
  28466. * @param additionalData additional data for the event
  28467. * @returns the new ActionEvent
  28468. */
  28469. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  28470. /**
  28471. * Helper function to auto-create an ActionEvent from a source sprite
  28472. * @param source The source sprite that triggered the event
  28473. * @param scene Scene associated with the sprite
  28474. * @param evt The original (browser) event
  28475. * @param additionalData additional data for the event
  28476. * @returns the new ActionEvent
  28477. */
  28478. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  28479. /**
  28480. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  28481. * @param scene the scene where the event occurred
  28482. * @param evt The original (browser) event
  28483. * @returns the new ActionEvent
  28484. */
  28485. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  28486. /**
  28487. * Helper function to auto-create an ActionEvent from a primitive
  28488. * @param prim defines the target primitive
  28489. * @param pointerPos defines the pointer position
  28490. * @param evt The original (browser) event
  28491. * @param additionalData additional data for the event
  28492. * @returns the new ActionEvent
  28493. */
  28494. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  28495. }
  28496. }
  28497. declare module BABYLON {
  28498. /**
  28499. * Abstract class used to decouple action Manager from scene and meshes.
  28500. * Do not instantiate.
  28501. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28502. */
  28503. export abstract class AbstractActionManager implements IDisposable {
  28504. /** Gets the list of active triggers */
  28505. static Triggers: {
  28506. [key: string]: number;
  28507. };
  28508. /** Gets the cursor to use when hovering items */
  28509. hoverCursor: string;
  28510. /** Gets the list of actions */
  28511. actions: IAction[];
  28512. /**
  28513. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  28514. */
  28515. isRecursive: boolean;
  28516. /**
  28517. * Releases all associated resources
  28518. */
  28519. abstract dispose(): void;
  28520. /**
  28521. * Does this action manager has pointer triggers
  28522. */
  28523. abstract get hasPointerTriggers(): boolean;
  28524. /**
  28525. * Does this action manager has pick triggers
  28526. */
  28527. abstract get hasPickTriggers(): boolean;
  28528. /**
  28529. * Process a specific trigger
  28530. * @param trigger defines the trigger to process
  28531. * @param evt defines the event details to be processed
  28532. */
  28533. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  28534. /**
  28535. * Does this action manager handles actions of any of the given triggers
  28536. * @param triggers defines the triggers to be tested
  28537. * @return a boolean indicating whether one (or more) of the triggers is handled
  28538. */
  28539. abstract hasSpecificTriggers(triggers: number[]): boolean;
  28540. /**
  28541. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  28542. * speed.
  28543. * @param triggerA defines the trigger to be tested
  28544. * @param triggerB defines the trigger to be tested
  28545. * @return a boolean indicating whether one (or more) of the triggers is handled
  28546. */
  28547. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  28548. /**
  28549. * Does this action manager handles actions of a given trigger
  28550. * @param trigger defines the trigger to be tested
  28551. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  28552. * @return whether the trigger is handled
  28553. */
  28554. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  28555. /**
  28556. * Serialize this manager to a JSON object
  28557. * @param name defines the property name to store this manager
  28558. * @returns a JSON representation of this manager
  28559. */
  28560. abstract serialize(name: string): any;
  28561. /**
  28562. * Registers an action to this action manager
  28563. * @param action defines the action to be registered
  28564. * @return the action amended (prepared) after registration
  28565. */
  28566. abstract registerAction(action: IAction): Nullable<IAction>;
  28567. /**
  28568. * Unregisters an action to this action manager
  28569. * @param action defines the action to be unregistered
  28570. * @return a boolean indicating whether the action has been unregistered
  28571. */
  28572. abstract unregisterAction(action: IAction): Boolean;
  28573. /**
  28574. * Does exist one action manager with at least one trigger
  28575. **/
  28576. static get HasTriggers(): boolean;
  28577. /**
  28578. * Does exist one action manager with at least one pick trigger
  28579. **/
  28580. static get HasPickTriggers(): boolean;
  28581. /**
  28582. * Does exist one action manager that handles actions of a given trigger
  28583. * @param trigger defines the trigger to be tested
  28584. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  28585. **/
  28586. static HasSpecificTrigger(trigger: number): boolean;
  28587. }
  28588. }
  28589. declare module BABYLON {
  28590. /**
  28591. * Defines how a node can be built from a string name.
  28592. */
  28593. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  28594. /**
  28595. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  28596. */
  28597. export class Node implements IBehaviorAware<Node> {
  28598. /** @hidden */
  28599. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  28600. private static _NodeConstructors;
  28601. /**
  28602. * Add a new node constructor
  28603. * @param type defines the type name of the node to construct
  28604. * @param constructorFunc defines the constructor function
  28605. */
  28606. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  28607. /**
  28608. * Returns a node constructor based on type name
  28609. * @param type defines the type name
  28610. * @param name defines the new node name
  28611. * @param scene defines the hosting scene
  28612. * @param options defines optional options to transmit to constructors
  28613. * @returns the new constructor or null
  28614. */
  28615. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  28616. /**
  28617. * Gets or sets the name of the node
  28618. */
  28619. name: string;
  28620. /**
  28621. * Gets or sets the id of the node
  28622. */
  28623. id: string;
  28624. /**
  28625. * Gets or sets the unique id of the node
  28626. */
  28627. uniqueId: number;
  28628. /**
  28629. * Gets or sets a string used to store user defined state for the node
  28630. */
  28631. state: string;
  28632. /**
  28633. * Gets or sets an object used to store user defined information for the node
  28634. */
  28635. metadata: any;
  28636. /**
  28637. * For internal use only. Please do not use.
  28638. */
  28639. reservedDataStore: any;
  28640. /**
  28641. * List of inspectable custom properties (used by the Inspector)
  28642. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28643. */
  28644. inspectableCustomProperties: IInspectable[];
  28645. private _doNotSerialize;
  28646. /**
  28647. * Gets or sets a boolean used to define if the node must be serialized
  28648. */
  28649. get doNotSerialize(): boolean;
  28650. set doNotSerialize(value: boolean);
  28651. /** @hidden */
  28652. _isDisposed: boolean;
  28653. /**
  28654. * Gets a list of Animations associated with the node
  28655. */
  28656. animations: Animation[];
  28657. protected _ranges: {
  28658. [name: string]: Nullable<AnimationRange>;
  28659. };
  28660. /**
  28661. * Callback raised when the node is ready to be used
  28662. */
  28663. onReady: Nullable<(node: Node) => void>;
  28664. private _isEnabled;
  28665. private _isParentEnabled;
  28666. private _isReady;
  28667. /** @hidden */
  28668. _currentRenderId: number;
  28669. private _parentUpdateId;
  28670. /** @hidden */
  28671. _childUpdateId: number;
  28672. /** @hidden */
  28673. _waitingParentId: Nullable<string>;
  28674. /** @hidden */
  28675. _scene: Scene;
  28676. /** @hidden */
  28677. _cache: any;
  28678. private _parentNode;
  28679. private _children;
  28680. /** @hidden */
  28681. _worldMatrix: Matrix;
  28682. /** @hidden */
  28683. _worldMatrixDeterminant: number;
  28684. /** @hidden */
  28685. _worldMatrixDeterminantIsDirty: boolean;
  28686. /** @hidden */
  28687. private _sceneRootNodesIndex;
  28688. /**
  28689. * Gets a boolean indicating if the node has been disposed
  28690. * @returns true if the node was disposed
  28691. */
  28692. isDisposed(): boolean;
  28693. /**
  28694. * Gets or sets the parent of the node (without keeping the current position in the scene)
  28695. * @see https://doc.babylonjs.com/how_to/parenting
  28696. */
  28697. set parent(parent: Nullable<Node>);
  28698. get parent(): Nullable<Node>;
  28699. /** @hidden */
  28700. _addToSceneRootNodes(): void;
  28701. /** @hidden */
  28702. _removeFromSceneRootNodes(): void;
  28703. private _animationPropertiesOverride;
  28704. /**
  28705. * Gets or sets the animation properties override
  28706. */
  28707. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  28708. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  28709. /**
  28710. * Gets a string idenfifying the name of the class
  28711. * @returns "Node" string
  28712. */
  28713. getClassName(): string;
  28714. /** @hidden */
  28715. readonly _isNode: boolean;
  28716. /**
  28717. * An event triggered when the mesh is disposed
  28718. */
  28719. onDisposeObservable: Observable<Node>;
  28720. private _onDisposeObserver;
  28721. /**
  28722. * Sets a callback that will be raised when the node will be disposed
  28723. */
  28724. set onDispose(callback: () => void);
  28725. /**
  28726. * Creates a new Node
  28727. * @param name the name and id to be given to this node
  28728. * @param scene the scene this node will be added to
  28729. */
  28730. constructor(name: string, scene?: Nullable<Scene>);
  28731. /**
  28732. * Gets the scene of the node
  28733. * @returns a scene
  28734. */
  28735. getScene(): Scene;
  28736. /**
  28737. * Gets the engine of the node
  28738. * @returns a Engine
  28739. */
  28740. getEngine(): Engine;
  28741. private _behaviors;
  28742. /**
  28743. * Attach a behavior to the node
  28744. * @see http://doc.babylonjs.com/features/behaviour
  28745. * @param behavior defines the behavior to attach
  28746. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  28747. * @returns the current Node
  28748. */
  28749. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  28750. /**
  28751. * Remove an attached behavior
  28752. * @see http://doc.babylonjs.com/features/behaviour
  28753. * @param behavior defines the behavior to attach
  28754. * @returns the current Node
  28755. */
  28756. removeBehavior(behavior: Behavior<Node>): Node;
  28757. /**
  28758. * Gets the list of attached behaviors
  28759. * @see http://doc.babylonjs.com/features/behaviour
  28760. */
  28761. get behaviors(): Behavior<Node>[];
  28762. /**
  28763. * Gets an attached behavior by name
  28764. * @param name defines the name of the behavior to look for
  28765. * @see http://doc.babylonjs.com/features/behaviour
  28766. * @returns null if behavior was not found else the requested behavior
  28767. */
  28768. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  28769. /**
  28770. * Returns the latest update of the World matrix
  28771. * @returns a Matrix
  28772. */
  28773. getWorldMatrix(): Matrix;
  28774. /** @hidden */
  28775. _getWorldMatrixDeterminant(): number;
  28776. /**
  28777. * Returns directly the latest state of the mesh World matrix.
  28778. * A Matrix is returned.
  28779. */
  28780. get worldMatrixFromCache(): Matrix;
  28781. /** @hidden */
  28782. _initCache(): void;
  28783. /** @hidden */
  28784. updateCache(force?: boolean): void;
  28785. /** @hidden */
  28786. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28787. /** @hidden */
  28788. _updateCache(ignoreParentClass?: boolean): void;
  28789. /** @hidden */
  28790. _isSynchronized(): boolean;
  28791. /** @hidden */
  28792. _markSyncedWithParent(): void;
  28793. /** @hidden */
  28794. isSynchronizedWithParent(): boolean;
  28795. /** @hidden */
  28796. isSynchronized(): boolean;
  28797. /**
  28798. * Is this node ready to be used/rendered
  28799. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28800. * @return true if the node is ready
  28801. */
  28802. isReady(completeCheck?: boolean): boolean;
  28803. /**
  28804. * Is this node enabled?
  28805. * 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
  28806. * @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
  28807. * @return whether this node (and its parent) is enabled
  28808. */
  28809. isEnabled(checkAncestors?: boolean): boolean;
  28810. /** @hidden */
  28811. protected _syncParentEnabledState(): void;
  28812. /**
  28813. * Set the enabled state of this node
  28814. * @param value defines the new enabled state
  28815. */
  28816. setEnabled(value: boolean): void;
  28817. /**
  28818. * Is this node a descendant of the given node?
  28819. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  28820. * @param ancestor defines the parent node to inspect
  28821. * @returns a boolean indicating if this node is a descendant of the given node
  28822. */
  28823. isDescendantOf(ancestor: Node): boolean;
  28824. /** @hidden */
  28825. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  28826. /**
  28827. * Will return all nodes that have this node as ascendant
  28828. * @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
  28829. * @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
  28830. * @return all children nodes of all types
  28831. */
  28832. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  28833. /**
  28834. * Get all child-meshes of this node
  28835. * @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)
  28836. * @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
  28837. * @returns an array of AbstractMesh
  28838. */
  28839. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  28840. /**
  28841. * Get all direct children of this node
  28842. * @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
  28843. * @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)
  28844. * @returns an array of Node
  28845. */
  28846. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  28847. /** @hidden */
  28848. _setReady(state: boolean): void;
  28849. /**
  28850. * Get an animation by name
  28851. * @param name defines the name of the animation to look for
  28852. * @returns null if not found else the requested animation
  28853. */
  28854. getAnimationByName(name: string): Nullable<Animation>;
  28855. /**
  28856. * Creates an animation range for this node
  28857. * @param name defines the name of the range
  28858. * @param from defines the starting key
  28859. * @param to defines the end key
  28860. */
  28861. createAnimationRange(name: string, from: number, to: number): void;
  28862. /**
  28863. * Delete a specific animation range
  28864. * @param name defines the name of the range to delete
  28865. * @param deleteFrames defines if animation frames from the range must be deleted as well
  28866. */
  28867. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  28868. /**
  28869. * Get an animation range by name
  28870. * @param name defines the name of the animation range to look for
  28871. * @returns null if not found else the requested animation range
  28872. */
  28873. getAnimationRange(name: string): Nullable<AnimationRange>;
  28874. /**
  28875. * Gets the list of all animation ranges defined on this node
  28876. * @returns an array
  28877. */
  28878. getAnimationRanges(): Nullable<AnimationRange>[];
  28879. /**
  28880. * Will start the animation sequence
  28881. * @param name defines the range frames for animation sequence
  28882. * @param loop defines if the animation should loop (false by default)
  28883. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  28884. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  28885. * @returns the object created for this animation. If range does not exist, it will return null
  28886. */
  28887. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  28888. /**
  28889. * Serialize animation ranges into a JSON compatible object
  28890. * @returns serialization object
  28891. */
  28892. serializeAnimationRanges(): any;
  28893. /**
  28894. * Computes the world matrix of the node
  28895. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  28896. * @returns the world matrix
  28897. */
  28898. computeWorldMatrix(force?: boolean): Matrix;
  28899. /**
  28900. * Releases resources associated with this node.
  28901. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28902. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28903. */
  28904. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28905. /**
  28906. * Parse animation range data from a serialization object and store them into a given node
  28907. * @param node defines where to store the animation ranges
  28908. * @param parsedNode defines the serialization object to read data from
  28909. * @param scene defines the hosting scene
  28910. */
  28911. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  28912. /**
  28913. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  28914. * @param includeDescendants Include bounding info from descendants as well (true by default)
  28915. * @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
  28916. * @returns the new bounding vectors
  28917. */
  28918. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  28919. min: Vector3;
  28920. max: Vector3;
  28921. };
  28922. }
  28923. }
  28924. declare module BABYLON {
  28925. /**
  28926. * @hidden
  28927. */
  28928. export class _IAnimationState {
  28929. key: number;
  28930. repeatCount: number;
  28931. workValue?: any;
  28932. loopMode?: number;
  28933. offsetValue?: any;
  28934. highLimitValue?: any;
  28935. }
  28936. /**
  28937. * Class used to store any kind of animation
  28938. */
  28939. export class Animation {
  28940. /**Name of the animation */
  28941. name: string;
  28942. /**Property to animate */
  28943. targetProperty: string;
  28944. /**The frames per second of the animation */
  28945. framePerSecond: number;
  28946. /**The data type of the animation */
  28947. dataType: number;
  28948. /**The loop mode of the animation */
  28949. loopMode?: number | undefined;
  28950. /**Specifies if blending should be enabled */
  28951. enableBlending?: boolean | undefined;
  28952. /**
  28953. * Use matrix interpolation instead of using direct key value when animating matrices
  28954. */
  28955. static AllowMatricesInterpolation: boolean;
  28956. /**
  28957. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  28958. */
  28959. static AllowMatrixDecomposeForInterpolation: boolean;
  28960. /**
  28961. * Stores the key frames of the animation
  28962. */
  28963. private _keys;
  28964. /**
  28965. * Stores the easing function of the animation
  28966. */
  28967. private _easingFunction;
  28968. /**
  28969. * @hidden Internal use only
  28970. */
  28971. _runtimeAnimations: RuntimeAnimation[];
  28972. /**
  28973. * The set of event that will be linked to this animation
  28974. */
  28975. private _events;
  28976. /**
  28977. * Stores an array of target property paths
  28978. */
  28979. targetPropertyPath: string[];
  28980. /**
  28981. * Stores the blending speed of the animation
  28982. */
  28983. blendingSpeed: number;
  28984. /**
  28985. * Stores the animation ranges for the animation
  28986. */
  28987. private _ranges;
  28988. /**
  28989. * @hidden Internal use
  28990. */
  28991. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  28992. /**
  28993. * Sets up an animation
  28994. * @param property The property to animate
  28995. * @param animationType The animation type to apply
  28996. * @param framePerSecond The frames per second of the animation
  28997. * @param easingFunction The easing function used in the animation
  28998. * @returns The created animation
  28999. */
  29000. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  29001. /**
  29002. * Create and start an animation on a node
  29003. * @param name defines the name of the global animation that will be run on all nodes
  29004. * @param node defines the root node where the animation will take place
  29005. * @param targetProperty defines property to animate
  29006. * @param framePerSecond defines the number of frame per second yo use
  29007. * @param totalFrame defines the number of frames in total
  29008. * @param from defines the initial value
  29009. * @param to defines the final value
  29010. * @param loopMode defines which loop mode you want to use (off by default)
  29011. * @param easingFunction defines the easing function to use (linear by default)
  29012. * @param onAnimationEnd defines the callback to call when animation end
  29013. * @returns the animatable created for this animation
  29014. */
  29015. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29016. /**
  29017. * Create and start an animation on a node and its descendants
  29018. * @param name defines the name of the global animation that will be run on all nodes
  29019. * @param node defines the root node where the animation will take place
  29020. * @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
  29021. * @param targetProperty defines property to animate
  29022. * @param framePerSecond defines the number of frame per second to use
  29023. * @param totalFrame defines the number of frames in total
  29024. * @param from defines the initial value
  29025. * @param to defines the final value
  29026. * @param loopMode defines which loop mode you want to use (off by default)
  29027. * @param easingFunction defines the easing function to use (linear by default)
  29028. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  29029. * @returns the list of animatables created for all nodes
  29030. * @example https://www.babylonjs-playground.com/#MH0VLI
  29031. */
  29032. 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[]>;
  29033. /**
  29034. * Creates a new animation, merges it with the existing animations and starts it
  29035. * @param name Name of the animation
  29036. * @param node Node which contains the scene that begins the animations
  29037. * @param targetProperty Specifies which property to animate
  29038. * @param framePerSecond The frames per second of the animation
  29039. * @param totalFrame The total number of frames
  29040. * @param from The frame at the beginning of the animation
  29041. * @param to The frame at the end of the animation
  29042. * @param loopMode Specifies the loop mode of the animation
  29043. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  29044. * @param onAnimationEnd Callback to run once the animation is complete
  29045. * @returns Nullable animation
  29046. */
  29047. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29048. /**
  29049. * Transition property of an host to the target Value
  29050. * @param property The property to transition
  29051. * @param targetValue The target Value of the property
  29052. * @param host The object where the property to animate belongs
  29053. * @param scene Scene used to run the animation
  29054. * @param frameRate Framerate (in frame/s) to use
  29055. * @param transition The transition type we want to use
  29056. * @param duration The duration of the animation, in milliseconds
  29057. * @param onAnimationEnd Callback trigger at the end of the animation
  29058. * @returns Nullable animation
  29059. */
  29060. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  29061. /**
  29062. * Return the array of runtime animations currently using this animation
  29063. */
  29064. get runtimeAnimations(): RuntimeAnimation[];
  29065. /**
  29066. * Specifies if any of the runtime animations are currently running
  29067. */
  29068. get hasRunningRuntimeAnimations(): boolean;
  29069. /**
  29070. * Initializes the animation
  29071. * @param name Name of the animation
  29072. * @param targetProperty Property to animate
  29073. * @param framePerSecond The frames per second of the animation
  29074. * @param dataType The data type of the animation
  29075. * @param loopMode The loop mode of the animation
  29076. * @param enableBlending Specifies if blending should be enabled
  29077. */
  29078. constructor(
  29079. /**Name of the animation */
  29080. name: string,
  29081. /**Property to animate */
  29082. targetProperty: string,
  29083. /**The frames per second of the animation */
  29084. framePerSecond: number,
  29085. /**The data type of the animation */
  29086. dataType: number,
  29087. /**The loop mode of the animation */
  29088. loopMode?: number | undefined,
  29089. /**Specifies if blending should be enabled */
  29090. enableBlending?: boolean | undefined);
  29091. /**
  29092. * Converts the animation to a string
  29093. * @param fullDetails support for multiple levels of logging within scene loading
  29094. * @returns String form of the animation
  29095. */
  29096. toString(fullDetails?: boolean): string;
  29097. /**
  29098. * Add an event to this animation
  29099. * @param event Event to add
  29100. */
  29101. addEvent(event: AnimationEvent): void;
  29102. /**
  29103. * Remove all events found at the given frame
  29104. * @param frame The frame to remove events from
  29105. */
  29106. removeEvents(frame: number): void;
  29107. /**
  29108. * Retrieves all the events from the animation
  29109. * @returns Events from the animation
  29110. */
  29111. getEvents(): AnimationEvent[];
  29112. /**
  29113. * Creates an animation range
  29114. * @param name Name of the animation range
  29115. * @param from Starting frame of the animation range
  29116. * @param to Ending frame of the animation
  29117. */
  29118. createRange(name: string, from: number, to: number): void;
  29119. /**
  29120. * Deletes an animation range by name
  29121. * @param name Name of the animation range to delete
  29122. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  29123. */
  29124. deleteRange(name: string, deleteFrames?: boolean): void;
  29125. /**
  29126. * Gets the animation range by name, or null if not defined
  29127. * @param name Name of the animation range
  29128. * @returns Nullable animation range
  29129. */
  29130. getRange(name: string): Nullable<AnimationRange>;
  29131. /**
  29132. * Gets the key frames from the animation
  29133. * @returns The key frames of the animation
  29134. */
  29135. getKeys(): Array<IAnimationKey>;
  29136. /**
  29137. * Gets the highest frame rate of the animation
  29138. * @returns Highest frame rate of the animation
  29139. */
  29140. getHighestFrame(): number;
  29141. /**
  29142. * Gets the easing function of the animation
  29143. * @returns Easing function of the animation
  29144. */
  29145. getEasingFunction(): IEasingFunction;
  29146. /**
  29147. * Sets the easing function of the animation
  29148. * @param easingFunction A custom mathematical formula for animation
  29149. */
  29150. setEasingFunction(easingFunction: EasingFunction): void;
  29151. /**
  29152. * Interpolates a scalar linearly
  29153. * @param startValue Start value of the animation curve
  29154. * @param endValue End value of the animation curve
  29155. * @param gradient Scalar amount to interpolate
  29156. * @returns Interpolated scalar value
  29157. */
  29158. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  29159. /**
  29160. * Interpolates a scalar cubically
  29161. * @param startValue Start value of the animation curve
  29162. * @param outTangent End tangent of the animation
  29163. * @param endValue End value of the animation curve
  29164. * @param inTangent Start tangent of the animation curve
  29165. * @param gradient Scalar amount to interpolate
  29166. * @returns Interpolated scalar value
  29167. */
  29168. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  29169. /**
  29170. * Interpolates a quaternion using a spherical linear interpolation
  29171. * @param startValue Start value of the animation curve
  29172. * @param endValue End value of the animation curve
  29173. * @param gradient Scalar amount to interpolate
  29174. * @returns Interpolated quaternion value
  29175. */
  29176. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  29177. /**
  29178. * Interpolates a quaternion cubically
  29179. * @param startValue Start value of the animation curve
  29180. * @param outTangent End tangent of the animation curve
  29181. * @param endValue End value of the animation curve
  29182. * @param inTangent Start tangent of the animation curve
  29183. * @param gradient Scalar amount to interpolate
  29184. * @returns Interpolated quaternion value
  29185. */
  29186. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  29187. /**
  29188. * Interpolates a Vector3 linearl
  29189. * @param startValue Start value of the animation curve
  29190. * @param endValue End value of the animation curve
  29191. * @param gradient Scalar amount to interpolate
  29192. * @returns Interpolated scalar value
  29193. */
  29194. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  29195. /**
  29196. * Interpolates a Vector3 cubically
  29197. * @param startValue Start value of the animation curve
  29198. * @param outTangent End tangent of the animation
  29199. * @param endValue End value of the animation curve
  29200. * @param inTangent Start tangent of the animation curve
  29201. * @param gradient Scalar amount to interpolate
  29202. * @returns InterpolatedVector3 value
  29203. */
  29204. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  29205. /**
  29206. * Interpolates a Vector2 linearly
  29207. * @param startValue Start value of the animation curve
  29208. * @param endValue End value of the animation curve
  29209. * @param gradient Scalar amount to interpolate
  29210. * @returns Interpolated Vector2 value
  29211. */
  29212. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  29213. /**
  29214. * Interpolates a Vector2 cubically
  29215. * @param startValue Start value of the animation curve
  29216. * @param outTangent End tangent of the animation
  29217. * @param endValue End value of the animation curve
  29218. * @param inTangent Start tangent of the animation curve
  29219. * @param gradient Scalar amount to interpolate
  29220. * @returns Interpolated Vector2 value
  29221. */
  29222. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  29223. /**
  29224. * Interpolates a size linearly
  29225. * @param startValue Start value of the animation curve
  29226. * @param endValue End value of the animation curve
  29227. * @param gradient Scalar amount to interpolate
  29228. * @returns Interpolated Size value
  29229. */
  29230. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  29231. /**
  29232. * Interpolates a Color3 linearly
  29233. * @param startValue Start value of the animation curve
  29234. * @param endValue End value of the animation curve
  29235. * @param gradient Scalar amount to interpolate
  29236. * @returns Interpolated Color3 value
  29237. */
  29238. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  29239. /**
  29240. * Interpolates a Color4 linearly
  29241. * @param startValue Start value of the animation curve
  29242. * @param endValue End value of the animation curve
  29243. * @param gradient Scalar amount to interpolate
  29244. * @returns Interpolated Color3 value
  29245. */
  29246. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  29247. /**
  29248. * @hidden Internal use only
  29249. */
  29250. _getKeyValue(value: any): any;
  29251. /**
  29252. * @hidden Internal use only
  29253. */
  29254. _interpolate(currentFrame: number, state: _IAnimationState): any;
  29255. /**
  29256. * Defines the function to use to interpolate matrices
  29257. * @param startValue defines the start matrix
  29258. * @param endValue defines the end matrix
  29259. * @param gradient defines the gradient between both matrices
  29260. * @param result defines an optional target matrix where to store the interpolation
  29261. * @returns the interpolated matrix
  29262. */
  29263. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  29264. /**
  29265. * Makes a copy of the animation
  29266. * @returns Cloned animation
  29267. */
  29268. clone(): Animation;
  29269. /**
  29270. * Sets the key frames of the animation
  29271. * @param values The animation key frames to set
  29272. */
  29273. setKeys(values: Array<IAnimationKey>): void;
  29274. /**
  29275. * Serializes the animation to an object
  29276. * @returns Serialized object
  29277. */
  29278. serialize(): any;
  29279. /**
  29280. * Float animation type
  29281. */
  29282. static readonly ANIMATIONTYPE_FLOAT: number;
  29283. /**
  29284. * Vector3 animation type
  29285. */
  29286. static readonly ANIMATIONTYPE_VECTOR3: number;
  29287. /**
  29288. * Quaternion animation type
  29289. */
  29290. static readonly ANIMATIONTYPE_QUATERNION: number;
  29291. /**
  29292. * Matrix animation type
  29293. */
  29294. static readonly ANIMATIONTYPE_MATRIX: number;
  29295. /**
  29296. * Color3 animation type
  29297. */
  29298. static readonly ANIMATIONTYPE_COLOR3: number;
  29299. /**
  29300. * Color3 animation type
  29301. */
  29302. static readonly ANIMATIONTYPE_COLOR4: number;
  29303. /**
  29304. * Vector2 animation type
  29305. */
  29306. static readonly ANIMATIONTYPE_VECTOR2: number;
  29307. /**
  29308. * Size animation type
  29309. */
  29310. static readonly ANIMATIONTYPE_SIZE: number;
  29311. /**
  29312. * Relative Loop Mode
  29313. */
  29314. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  29315. /**
  29316. * Cycle Loop Mode
  29317. */
  29318. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  29319. /**
  29320. * Constant Loop Mode
  29321. */
  29322. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  29323. /** @hidden */
  29324. static _UniversalLerp(left: any, right: any, amount: number): any;
  29325. /**
  29326. * Parses an animation object and creates an animation
  29327. * @param parsedAnimation Parsed animation object
  29328. * @returns Animation object
  29329. */
  29330. static Parse(parsedAnimation: any): Animation;
  29331. /**
  29332. * Appends the serialized animations from the source animations
  29333. * @param source Source containing the animations
  29334. * @param destination Target to store the animations
  29335. */
  29336. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29337. }
  29338. }
  29339. declare module BABYLON {
  29340. /**
  29341. * Interface containing an array of animations
  29342. */
  29343. export interface IAnimatable {
  29344. /**
  29345. * Array of animations
  29346. */
  29347. animations: Nullable<Array<Animation>>;
  29348. }
  29349. }
  29350. declare module BABYLON {
  29351. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29352. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29353. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29354. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29355. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29356. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29357. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29358. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29359. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29360. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29361. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29362. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29363. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29364. /**
  29365. * Decorator used to define property that can be serialized as reference to a camera
  29366. * @param sourceName defines the name of the property to decorate
  29367. */
  29368. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29369. /**
  29370. * Class used to help serialization objects
  29371. */
  29372. export class SerializationHelper {
  29373. /** @hidden */
  29374. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  29375. /** @hidden */
  29376. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  29377. /** @hidden */
  29378. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  29379. /** @hidden */
  29380. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  29381. /**
  29382. * Appends the serialized animations from the source animations
  29383. * @param source Source containing the animations
  29384. * @param destination Target to store the animations
  29385. */
  29386. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29387. /**
  29388. * Static function used to serialized a specific entity
  29389. * @param entity defines the entity to serialize
  29390. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29391. * @returns a JSON compatible object representing the serialization of the entity
  29392. */
  29393. static Serialize<T>(entity: T, serializationObject?: any): any;
  29394. /**
  29395. * Creates a new entity from a serialization data object
  29396. * @param creationFunction defines a function used to instanciated the new entity
  29397. * @param source defines the source serialization data
  29398. * @param scene defines the hosting scene
  29399. * @param rootUrl defines the root url for resources
  29400. * @returns a new entity
  29401. */
  29402. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29403. /**
  29404. * Clones an object
  29405. * @param creationFunction defines the function used to instanciate the new object
  29406. * @param source defines the source object
  29407. * @returns the cloned object
  29408. */
  29409. static Clone<T>(creationFunction: () => T, source: T): T;
  29410. /**
  29411. * Instanciates a new object based on a source one (some data will be shared between both object)
  29412. * @param creationFunction defines the function used to instanciate the new object
  29413. * @param source defines the source object
  29414. * @returns the new object
  29415. */
  29416. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29417. }
  29418. }
  29419. declare module BABYLON {
  29420. /**
  29421. * Class used to manipulate GUIDs
  29422. */
  29423. export class GUID {
  29424. /**
  29425. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29426. * Be aware Math.random() could cause collisions, but:
  29427. * "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"
  29428. * @returns a pseudo random id
  29429. */
  29430. static RandomId(): string;
  29431. }
  29432. }
  29433. declare module BABYLON {
  29434. /**
  29435. * Base class of all the textures in babylon.
  29436. * It groups all the common properties the materials, post process, lights... might need
  29437. * in order to make a correct use of the texture.
  29438. */
  29439. export class BaseTexture implements IAnimatable {
  29440. /**
  29441. * Default anisotropic filtering level for the application.
  29442. * It is set to 4 as a good tradeoff between perf and quality.
  29443. */
  29444. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  29445. /**
  29446. * Gets or sets the unique id of the texture
  29447. */
  29448. uniqueId: number;
  29449. /**
  29450. * Define the name of the texture.
  29451. */
  29452. name: string;
  29453. /**
  29454. * Gets or sets an object used to store user defined information.
  29455. */
  29456. metadata: any;
  29457. /**
  29458. * For internal use only. Please do not use.
  29459. */
  29460. reservedDataStore: any;
  29461. private _hasAlpha;
  29462. /**
  29463. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  29464. */
  29465. set hasAlpha(value: boolean);
  29466. get hasAlpha(): boolean;
  29467. /**
  29468. * Defines if the alpha value should be determined via the rgb values.
  29469. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  29470. */
  29471. getAlphaFromRGB: boolean;
  29472. /**
  29473. * Intensity or strength of the texture.
  29474. * It is commonly used by materials to fine tune the intensity of the texture
  29475. */
  29476. level: number;
  29477. /**
  29478. * Define the UV chanel to use starting from 0 and defaulting to 0.
  29479. * This is part of the texture as textures usually maps to one uv set.
  29480. */
  29481. coordinatesIndex: number;
  29482. private _coordinatesMode;
  29483. /**
  29484. * How a texture is mapped.
  29485. *
  29486. * | Value | Type | Description |
  29487. * | ----- | ----------------------------------- | ----------- |
  29488. * | 0 | EXPLICIT_MODE | |
  29489. * | 1 | SPHERICAL_MODE | |
  29490. * | 2 | PLANAR_MODE | |
  29491. * | 3 | CUBIC_MODE | |
  29492. * | 4 | PROJECTION_MODE | |
  29493. * | 5 | SKYBOX_MODE | |
  29494. * | 6 | INVCUBIC_MODE | |
  29495. * | 7 | EQUIRECTANGULAR_MODE | |
  29496. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  29497. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  29498. */
  29499. set coordinatesMode(value: number);
  29500. get coordinatesMode(): number;
  29501. /**
  29502. * | Value | Type | Description |
  29503. * | ----- | ------------------ | ----------- |
  29504. * | 0 | CLAMP_ADDRESSMODE | |
  29505. * | 1 | WRAP_ADDRESSMODE | |
  29506. * | 2 | MIRROR_ADDRESSMODE | |
  29507. */
  29508. wrapU: number;
  29509. /**
  29510. * | Value | Type | Description |
  29511. * | ----- | ------------------ | ----------- |
  29512. * | 0 | CLAMP_ADDRESSMODE | |
  29513. * | 1 | WRAP_ADDRESSMODE | |
  29514. * | 2 | MIRROR_ADDRESSMODE | |
  29515. */
  29516. wrapV: number;
  29517. /**
  29518. * | Value | Type | Description |
  29519. * | ----- | ------------------ | ----------- |
  29520. * | 0 | CLAMP_ADDRESSMODE | |
  29521. * | 1 | WRAP_ADDRESSMODE | |
  29522. * | 2 | MIRROR_ADDRESSMODE | |
  29523. */
  29524. wrapR: number;
  29525. /**
  29526. * With compliant hardware and browser (supporting anisotropic filtering)
  29527. * this defines the level of anisotropic filtering in the texture.
  29528. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  29529. */
  29530. anisotropicFilteringLevel: number;
  29531. /**
  29532. * Define if the texture is a cube texture or if false a 2d texture.
  29533. */
  29534. get isCube(): boolean;
  29535. set isCube(value: boolean);
  29536. /**
  29537. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  29538. */
  29539. get is3D(): boolean;
  29540. set is3D(value: boolean);
  29541. /**
  29542. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  29543. */
  29544. get is2DArray(): boolean;
  29545. set is2DArray(value: boolean);
  29546. /**
  29547. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  29548. * HDR texture are usually stored in linear space.
  29549. * This only impacts the PBR and Background materials
  29550. */
  29551. gammaSpace: boolean;
  29552. /**
  29553. * Gets or sets whether or not the texture contains RGBD data.
  29554. */
  29555. get isRGBD(): boolean;
  29556. set isRGBD(value: boolean);
  29557. /**
  29558. * Is Z inverted in the texture (useful in a cube texture).
  29559. */
  29560. invertZ: boolean;
  29561. /**
  29562. * Are mip maps generated for this texture or not.
  29563. */
  29564. get noMipmap(): boolean;
  29565. /**
  29566. * @hidden
  29567. */
  29568. lodLevelInAlpha: boolean;
  29569. /**
  29570. * With prefiltered texture, defined the offset used during the prefiltering steps.
  29571. */
  29572. get lodGenerationOffset(): number;
  29573. set lodGenerationOffset(value: number);
  29574. /**
  29575. * With prefiltered texture, defined the scale used during the prefiltering steps.
  29576. */
  29577. get lodGenerationScale(): number;
  29578. set lodGenerationScale(value: number);
  29579. /**
  29580. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  29581. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  29582. * average roughness values.
  29583. */
  29584. get linearSpecularLOD(): boolean;
  29585. set linearSpecularLOD(value: boolean);
  29586. /**
  29587. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  29588. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  29589. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  29590. */
  29591. get irradianceTexture(): Nullable<BaseTexture>;
  29592. set irradianceTexture(value: Nullable<BaseTexture>);
  29593. /**
  29594. * Define if the texture is a render target.
  29595. */
  29596. isRenderTarget: boolean;
  29597. /**
  29598. * Define the unique id of the texture in the scene.
  29599. */
  29600. get uid(): string;
  29601. /**
  29602. * Return a string representation of the texture.
  29603. * @returns the texture as a string
  29604. */
  29605. toString(): string;
  29606. /**
  29607. * Get the class name of the texture.
  29608. * @returns "BaseTexture"
  29609. */
  29610. getClassName(): string;
  29611. /**
  29612. * Define the list of animation attached to the texture.
  29613. */
  29614. animations: Animation[];
  29615. /**
  29616. * An event triggered when the texture is disposed.
  29617. */
  29618. onDisposeObservable: Observable<BaseTexture>;
  29619. private _onDisposeObserver;
  29620. /**
  29621. * Callback triggered when the texture has been disposed.
  29622. * Kept for back compatibility, you can use the onDisposeObservable instead.
  29623. */
  29624. set onDispose(callback: () => void);
  29625. /**
  29626. * Define the current state of the loading sequence when in delayed load mode.
  29627. */
  29628. delayLoadState: number;
  29629. private _scene;
  29630. /** @hidden */
  29631. _texture: Nullable<InternalTexture>;
  29632. private _uid;
  29633. /**
  29634. * Define if the texture is preventinga material to render or not.
  29635. * If not and the texture is not ready, the engine will use a default black texture instead.
  29636. */
  29637. get isBlocking(): boolean;
  29638. /**
  29639. * Instantiates a new BaseTexture.
  29640. * Base class of all the textures in babylon.
  29641. * It groups all the common properties the materials, post process, lights... might need
  29642. * in order to make a correct use of the texture.
  29643. * @param scene Define the scene the texture blongs to
  29644. */
  29645. constructor(scene: Nullable<Scene>);
  29646. /**
  29647. * Get the scene the texture belongs to.
  29648. * @returns the scene or null if undefined
  29649. */
  29650. getScene(): Nullable<Scene>;
  29651. /**
  29652. * Get the texture transform matrix used to offset tile the texture for istance.
  29653. * @returns the transformation matrix
  29654. */
  29655. getTextureMatrix(): Matrix;
  29656. /**
  29657. * Get the texture reflection matrix used to rotate/transform the reflection.
  29658. * @returns the reflection matrix
  29659. */
  29660. getReflectionTextureMatrix(): Matrix;
  29661. /**
  29662. * Get the underlying lower level texture from Babylon.
  29663. * @returns the insternal texture
  29664. */
  29665. getInternalTexture(): Nullable<InternalTexture>;
  29666. /**
  29667. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  29668. * @returns true if ready or not blocking
  29669. */
  29670. isReadyOrNotBlocking(): boolean;
  29671. /**
  29672. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  29673. * @returns true if fully ready
  29674. */
  29675. isReady(): boolean;
  29676. private _cachedSize;
  29677. /**
  29678. * Get the size of the texture.
  29679. * @returns the texture size.
  29680. */
  29681. getSize(): ISize;
  29682. /**
  29683. * Get the base size of the texture.
  29684. * It can be different from the size if the texture has been resized for POT for instance
  29685. * @returns the base size
  29686. */
  29687. getBaseSize(): ISize;
  29688. /**
  29689. * Update the sampling mode of the texture.
  29690. * Default is Trilinear mode.
  29691. *
  29692. * | Value | Type | Description |
  29693. * | ----- | ------------------ | ----------- |
  29694. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  29695. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  29696. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  29697. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  29698. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  29699. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  29700. * | 7 | NEAREST_LINEAR | |
  29701. * | 8 | NEAREST_NEAREST | |
  29702. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  29703. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  29704. * | 11 | LINEAR_LINEAR | |
  29705. * | 12 | LINEAR_NEAREST | |
  29706. *
  29707. * > _mag_: magnification filter (close to the viewer)
  29708. * > _min_: minification filter (far from the viewer)
  29709. * > _mip_: filter used between mip map levels
  29710. *@param samplingMode Define the new sampling mode of the texture
  29711. */
  29712. updateSamplingMode(samplingMode: number): void;
  29713. /**
  29714. * Scales the texture if is `canRescale()`
  29715. * @param ratio the resize factor we want to use to rescale
  29716. */
  29717. scale(ratio: number): void;
  29718. /**
  29719. * Get if the texture can rescale.
  29720. */
  29721. get canRescale(): boolean;
  29722. /** @hidden */
  29723. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  29724. /** @hidden */
  29725. _rebuild(): void;
  29726. /**
  29727. * Triggers the load sequence in delayed load mode.
  29728. */
  29729. delayLoad(): void;
  29730. /**
  29731. * Clones the texture.
  29732. * @returns the cloned texture
  29733. */
  29734. clone(): Nullable<BaseTexture>;
  29735. /**
  29736. * Get the texture underlying type (INT, FLOAT...)
  29737. */
  29738. get textureType(): number;
  29739. /**
  29740. * Get the texture underlying format (RGB, RGBA...)
  29741. */
  29742. get textureFormat(): number;
  29743. /**
  29744. * Indicates that textures need to be re-calculated for all materials
  29745. */
  29746. protected _markAllSubMeshesAsTexturesDirty(): void;
  29747. /**
  29748. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  29749. * This will returns an RGBA array buffer containing either in values (0-255) or
  29750. * float values (0-1) depending of the underlying buffer type.
  29751. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  29752. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  29753. * @param buffer defines a user defined buffer to fill with data (can be null)
  29754. * @returns The Array buffer containing the pixels data.
  29755. */
  29756. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  29757. /**
  29758. * Release and destroy the underlying lower level texture aka internalTexture.
  29759. */
  29760. releaseInternalTexture(): void;
  29761. /** @hidden */
  29762. get _lodTextureHigh(): Nullable<BaseTexture>;
  29763. /** @hidden */
  29764. get _lodTextureMid(): Nullable<BaseTexture>;
  29765. /** @hidden */
  29766. get _lodTextureLow(): Nullable<BaseTexture>;
  29767. /**
  29768. * Dispose the texture and release its associated resources.
  29769. */
  29770. dispose(): void;
  29771. /**
  29772. * Serialize the texture into a JSON representation that can be parsed later on.
  29773. * @returns the JSON representation of the texture
  29774. */
  29775. serialize(): any;
  29776. /**
  29777. * Helper function to be called back once a list of texture contains only ready textures.
  29778. * @param textures Define the list of textures to wait for
  29779. * @param callback Define the callback triggered once the entire list will be ready
  29780. */
  29781. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  29782. }
  29783. }
  29784. declare module BABYLON {
  29785. /**
  29786. * Options to be used when creating an effect.
  29787. */
  29788. export interface IEffectCreationOptions {
  29789. /**
  29790. * Atrributes that will be used in the shader.
  29791. */
  29792. attributes: string[];
  29793. /**
  29794. * Uniform varible names that will be set in the shader.
  29795. */
  29796. uniformsNames: string[];
  29797. /**
  29798. * Uniform buffer variable names that will be set in the shader.
  29799. */
  29800. uniformBuffersNames: string[];
  29801. /**
  29802. * Sampler texture variable names that will be set in the shader.
  29803. */
  29804. samplers: string[];
  29805. /**
  29806. * Define statements that will be set in the shader.
  29807. */
  29808. defines: any;
  29809. /**
  29810. * Possible fallbacks for this effect to improve performance when needed.
  29811. */
  29812. fallbacks: Nullable<IEffectFallbacks>;
  29813. /**
  29814. * Callback that will be called when the shader is compiled.
  29815. */
  29816. onCompiled: Nullable<(effect: Effect) => void>;
  29817. /**
  29818. * Callback that will be called if an error occurs during shader compilation.
  29819. */
  29820. onError: Nullable<(effect: Effect, errors: string) => void>;
  29821. /**
  29822. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29823. */
  29824. indexParameters?: any;
  29825. /**
  29826. * Max number of lights that can be used in the shader.
  29827. */
  29828. maxSimultaneousLights?: number;
  29829. /**
  29830. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29831. */
  29832. transformFeedbackVaryings?: Nullable<string[]>;
  29833. }
  29834. /**
  29835. * Effect containing vertex and fragment shader that can be executed on an object.
  29836. */
  29837. export class Effect implements IDisposable {
  29838. /**
  29839. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29840. */
  29841. static ShadersRepository: string;
  29842. /**
  29843. * Name of the effect.
  29844. */
  29845. name: any;
  29846. /**
  29847. * String container all the define statements that should be set on the shader.
  29848. */
  29849. defines: string;
  29850. /**
  29851. * Callback that will be called when the shader is compiled.
  29852. */
  29853. onCompiled: Nullable<(effect: Effect) => void>;
  29854. /**
  29855. * Callback that will be called if an error occurs during shader compilation.
  29856. */
  29857. onError: Nullable<(effect: Effect, errors: string) => void>;
  29858. /**
  29859. * Callback that will be called when effect is bound.
  29860. */
  29861. onBind: Nullable<(effect: Effect) => void>;
  29862. /**
  29863. * Unique ID of the effect.
  29864. */
  29865. uniqueId: number;
  29866. /**
  29867. * Observable that will be called when the shader is compiled.
  29868. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29869. */
  29870. onCompileObservable: Observable<Effect>;
  29871. /**
  29872. * Observable that will be called if an error occurs during shader compilation.
  29873. */
  29874. onErrorObservable: Observable<Effect>;
  29875. /** @hidden */
  29876. _onBindObservable: Nullable<Observable<Effect>>;
  29877. /**
  29878. * @hidden
  29879. * Specifies if the effect was previously ready
  29880. */
  29881. _wasPreviouslyReady: boolean;
  29882. /**
  29883. * Observable that will be called when effect is bound.
  29884. */
  29885. get onBindObservable(): Observable<Effect>;
  29886. /** @hidden */
  29887. _bonesComputationForcedToCPU: boolean;
  29888. private static _uniqueIdSeed;
  29889. private _engine;
  29890. private _uniformBuffersNames;
  29891. private _uniformsNames;
  29892. private _samplerList;
  29893. private _samplers;
  29894. private _isReady;
  29895. private _compilationError;
  29896. private _allFallbacksProcessed;
  29897. private _attributesNames;
  29898. private _attributes;
  29899. private _attributeLocationByName;
  29900. private _uniforms;
  29901. /**
  29902. * Key for the effect.
  29903. * @hidden
  29904. */
  29905. _key: string;
  29906. private _indexParameters;
  29907. private _fallbacks;
  29908. private _vertexSourceCode;
  29909. private _fragmentSourceCode;
  29910. private _vertexSourceCodeOverride;
  29911. private _fragmentSourceCodeOverride;
  29912. private _transformFeedbackVaryings;
  29913. /**
  29914. * Compiled shader to webGL program.
  29915. * @hidden
  29916. */
  29917. _pipelineContext: Nullable<IPipelineContext>;
  29918. private _valueCache;
  29919. private static _baseCache;
  29920. /**
  29921. * Instantiates an effect.
  29922. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29923. * @param baseName Name of the effect.
  29924. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29925. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29926. * @param samplers List of sampler variables that will be passed to the shader.
  29927. * @param engine Engine to be used to render the effect
  29928. * @param defines Define statements to be added to the shader.
  29929. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29930. * @param onCompiled Callback that will be called when the shader is compiled.
  29931. * @param onError Callback that will be called if an error occurs during shader compilation.
  29932. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29933. */
  29934. 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);
  29935. private _useFinalCode;
  29936. /**
  29937. * Unique key for this effect
  29938. */
  29939. get key(): string;
  29940. /**
  29941. * If the effect has been compiled and prepared.
  29942. * @returns if the effect is compiled and prepared.
  29943. */
  29944. isReady(): boolean;
  29945. private _isReadyInternal;
  29946. /**
  29947. * The engine the effect was initialized with.
  29948. * @returns the engine.
  29949. */
  29950. getEngine(): Engine;
  29951. /**
  29952. * The pipeline context for this effect
  29953. * @returns the associated pipeline context
  29954. */
  29955. getPipelineContext(): Nullable<IPipelineContext>;
  29956. /**
  29957. * The set of names of attribute variables for the shader.
  29958. * @returns An array of attribute names.
  29959. */
  29960. getAttributesNames(): string[];
  29961. /**
  29962. * Returns the attribute at the given index.
  29963. * @param index The index of the attribute.
  29964. * @returns The location of the attribute.
  29965. */
  29966. getAttributeLocation(index: number): number;
  29967. /**
  29968. * Returns the attribute based on the name of the variable.
  29969. * @param name of the attribute to look up.
  29970. * @returns the attribute location.
  29971. */
  29972. getAttributeLocationByName(name: string): number;
  29973. /**
  29974. * The number of attributes.
  29975. * @returns the numnber of attributes.
  29976. */
  29977. getAttributesCount(): number;
  29978. /**
  29979. * Gets the index of a uniform variable.
  29980. * @param uniformName of the uniform to look up.
  29981. * @returns the index.
  29982. */
  29983. getUniformIndex(uniformName: string): number;
  29984. /**
  29985. * Returns the attribute based on the name of the variable.
  29986. * @param uniformName of the uniform to look up.
  29987. * @returns the location of the uniform.
  29988. */
  29989. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29990. /**
  29991. * Returns an array of sampler variable names
  29992. * @returns The array of sampler variable neames.
  29993. */
  29994. getSamplers(): string[];
  29995. /**
  29996. * The error from the last compilation.
  29997. * @returns the error string.
  29998. */
  29999. getCompilationError(): string;
  30000. /**
  30001. * Gets a boolean indicating that all fallbacks were used during compilation
  30002. * @returns true if all fallbacks were used
  30003. */
  30004. allFallbacksProcessed(): boolean;
  30005. /**
  30006. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30007. * @param func The callback to be used.
  30008. */
  30009. executeWhenCompiled(func: (effect: Effect) => void): void;
  30010. private _checkIsReady;
  30011. private _loadShader;
  30012. /**
  30013. * Recompiles the webGL program
  30014. * @param vertexSourceCode The source code for the vertex shader.
  30015. * @param fragmentSourceCode The source code for the fragment shader.
  30016. * @param onCompiled Callback called when completed.
  30017. * @param onError Callback called on error.
  30018. * @hidden
  30019. */
  30020. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30021. /**
  30022. * Prepares the effect
  30023. * @hidden
  30024. */
  30025. _prepareEffect(): void;
  30026. private _processCompilationErrors;
  30027. /**
  30028. * Checks if the effect is supported. (Must be called after compilation)
  30029. */
  30030. get isSupported(): boolean;
  30031. /**
  30032. * Binds a texture to the engine to be used as output of the shader.
  30033. * @param channel Name of the output variable.
  30034. * @param texture Texture to bind.
  30035. * @hidden
  30036. */
  30037. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  30038. /**
  30039. * Sets a texture on the engine to be used in the shader.
  30040. * @param channel Name of the sampler variable.
  30041. * @param texture Texture to set.
  30042. */
  30043. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30044. /**
  30045. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30046. * @param channel Name of the sampler variable.
  30047. * @param texture Texture to set.
  30048. */
  30049. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30050. /**
  30051. * Sets an array of textures on the engine to be used in the shader.
  30052. * @param channel Name of the variable.
  30053. * @param textures Textures to set.
  30054. */
  30055. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30056. /**
  30057. * 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)
  30058. * @param channel Name of the sampler variable.
  30059. * @param postProcess Post process to get the input texture from.
  30060. */
  30061. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30062. /**
  30063. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30064. * 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)
  30065. * @param channel Name of the sampler variable.
  30066. * @param postProcess Post process to get the output texture from.
  30067. */
  30068. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30069. /** @hidden */
  30070. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  30071. /** @hidden */
  30072. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30073. /** @hidden */
  30074. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30075. /** @hidden */
  30076. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30077. /**
  30078. * Binds a buffer to a uniform.
  30079. * @param buffer Buffer to bind.
  30080. * @param name Name of the uniform variable to bind to.
  30081. */
  30082. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30083. /**
  30084. * Binds block to a uniform.
  30085. * @param blockName Name of the block to bind.
  30086. * @param index Index to bind.
  30087. */
  30088. bindUniformBlock(blockName: string, index: number): void;
  30089. /**
  30090. * Sets an interger value on a uniform variable.
  30091. * @param uniformName Name of the variable.
  30092. * @param value Value to be set.
  30093. * @returns this effect.
  30094. */
  30095. setInt(uniformName: string, value: number): Effect;
  30096. /**
  30097. * Sets an int array on a uniform variable.
  30098. * @param uniformName Name of the variable.
  30099. * @param array array to be set.
  30100. * @returns this effect.
  30101. */
  30102. setIntArray(uniformName: string, array: Int32Array): Effect;
  30103. /**
  30104. * 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)
  30105. * @param uniformName Name of the variable.
  30106. * @param array array to be set.
  30107. * @returns this effect.
  30108. */
  30109. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30110. /**
  30111. * 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)
  30112. * @param uniformName Name of the variable.
  30113. * @param array array to be set.
  30114. * @returns this effect.
  30115. */
  30116. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30117. /**
  30118. * 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)
  30119. * @param uniformName Name of the variable.
  30120. * @param array array to be set.
  30121. * @returns this effect.
  30122. */
  30123. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30124. /**
  30125. * Sets an float array on a uniform variable.
  30126. * @param uniformName Name of the variable.
  30127. * @param array array to be set.
  30128. * @returns this effect.
  30129. */
  30130. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30131. /**
  30132. * 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)
  30133. * @param uniformName Name of the variable.
  30134. * @param array array to be set.
  30135. * @returns this effect.
  30136. */
  30137. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30138. /**
  30139. * 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)
  30140. * @param uniformName Name of the variable.
  30141. * @param array array to be set.
  30142. * @returns this effect.
  30143. */
  30144. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30145. /**
  30146. * 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)
  30147. * @param uniformName Name of the variable.
  30148. * @param array array to be set.
  30149. * @returns this effect.
  30150. */
  30151. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30152. /**
  30153. * Sets an array on a uniform variable.
  30154. * @param uniformName Name of the variable.
  30155. * @param array array to be set.
  30156. * @returns this effect.
  30157. */
  30158. setArray(uniformName: string, array: number[]): Effect;
  30159. /**
  30160. * 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)
  30161. * @param uniformName Name of the variable.
  30162. * @param array array to be set.
  30163. * @returns this effect.
  30164. */
  30165. setArray2(uniformName: string, array: number[]): Effect;
  30166. /**
  30167. * 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)
  30168. * @param uniformName Name of the variable.
  30169. * @param array array to be set.
  30170. * @returns this effect.
  30171. */
  30172. setArray3(uniformName: string, array: number[]): Effect;
  30173. /**
  30174. * 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)
  30175. * @param uniformName Name of the variable.
  30176. * @param array array to be set.
  30177. * @returns this effect.
  30178. */
  30179. setArray4(uniformName: string, array: number[]): Effect;
  30180. /**
  30181. * Sets matrices on a uniform variable.
  30182. * @param uniformName Name of the variable.
  30183. * @param matrices matrices to be set.
  30184. * @returns this effect.
  30185. */
  30186. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30187. /**
  30188. * Sets matrix on a uniform variable.
  30189. * @param uniformName Name of the variable.
  30190. * @param matrix matrix to be set.
  30191. * @returns this effect.
  30192. */
  30193. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  30194. /**
  30195. * 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)
  30196. * @param uniformName Name of the variable.
  30197. * @param matrix matrix to be set.
  30198. * @returns this effect.
  30199. */
  30200. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30201. /**
  30202. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30203. * @param uniformName Name of the variable.
  30204. * @param matrix matrix to be set.
  30205. * @returns this effect.
  30206. */
  30207. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30208. /**
  30209. * Sets a float on a uniform variable.
  30210. * @param uniformName Name of the variable.
  30211. * @param value value to be set.
  30212. * @returns this effect.
  30213. */
  30214. setFloat(uniformName: string, value: number): Effect;
  30215. /**
  30216. * Sets a boolean on a uniform variable.
  30217. * @param uniformName Name of the variable.
  30218. * @param bool value to be set.
  30219. * @returns this effect.
  30220. */
  30221. setBool(uniformName: string, bool: boolean): Effect;
  30222. /**
  30223. * Sets a Vector2 on a uniform variable.
  30224. * @param uniformName Name of the variable.
  30225. * @param vector2 vector2 to be set.
  30226. * @returns this effect.
  30227. */
  30228. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  30229. /**
  30230. * Sets a float2 on a uniform variable.
  30231. * @param uniformName Name of the variable.
  30232. * @param x First float in float2.
  30233. * @param y Second float in float2.
  30234. * @returns this effect.
  30235. */
  30236. setFloat2(uniformName: string, x: number, y: number): Effect;
  30237. /**
  30238. * Sets a Vector3 on a uniform variable.
  30239. * @param uniformName Name of the variable.
  30240. * @param vector3 Value to be set.
  30241. * @returns this effect.
  30242. */
  30243. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  30244. /**
  30245. * Sets a float3 on a uniform variable.
  30246. * @param uniformName Name of the variable.
  30247. * @param x First float in float3.
  30248. * @param y Second float in float3.
  30249. * @param z Third float in float3.
  30250. * @returns this effect.
  30251. */
  30252. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30253. /**
  30254. * Sets a Vector4 on a uniform variable.
  30255. * @param uniformName Name of the variable.
  30256. * @param vector4 Value to be set.
  30257. * @returns this effect.
  30258. */
  30259. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  30260. /**
  30261. * Sets a float4 on a uniform variable.
  30262. * @param uniformName Name of the variable.
  30263. * @param x First float in float4.
  30264. * @param y Second float in float4.
  30265. * @param z Third float in float4.
  30266. * @param w Fourth float in float4.
  30267. * @returns this effect.
  30268. */
  30269. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30270. /**
  30271. * Sets a Color3 on a uniform variable.
  30272. * @param uniformName Name of the variable.
  30273. * @param color3 Value to be set.
  30274. * @returns this effect.
  30275. */
  30276. setColor3(uniformName: string, color3: IColor3Like): Effect;
  30277. /**
  30278. * Sets a Color4 on a uniform variable.
  30279. * @param uniformName Name of the variable.
  30280. * @param color3 Value to be set.
  30281. * @param alpha Alpha value to be set.
  30282. * @returns this effect.
  30283. */
  30284. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  30285. /**
  30286. * Sets a Color4 on a uniform variable
  30287. * @param uniformName defines the name of the variable
  30288. * @param color4 defines the value to be set
  30289. * @returns this effect.
  30290. */
  30291. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  30292. /** Release all associated resources */
  30293. dispose(): void;
  30294. /**
  30295. * This function will add a new shader to the shader store
  30296. * @param name the name of the shader
  30297. * @param pixelShader optional pixel shader content
  30298. * @param vertexShader optional vertex shader content
  30299. */
  30300. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30301. /**
  30302. * Store of each shader (The can be looked up using effect.key)
  30303. */
  30304. static ShadersStore: {
  30305. [key: string]: string;
  30306. };
  30307. /**
  30308. * Store of each included file for a shader (The can be looked up using effect.key)
  30309. */
  30310. static IncludesShadersStore: {
  30311. [key: string]: string;
  30312. };
  30313. /**
  30314. * Resets the cache of effects.
  30315. */
  30316. static ResetCache(): void;
  30317. }
  30318. }
  30319. declare module BABYLON {
  30320. /**
  30321. * Interface used to describe the capabilities of the engine relatively to the current browser
  30322. */
  30323. export interface EngineCapabilities {
  30324. /** Maximum textures units per fragment shader */
  30325. maxTexturesImageUnits: number;
  30326. /** Maximum texture units per vertex shader */
  30327. maxVertexTextureImageUnits: number;
  30328. /** Maximum textures units in the entire pipeline */
  30329. maxCombinedTexturesImageUnits: number;
  30330. /** Maximum texture size */
  30331. maxTextureSize: number;
  30332. /** Maximum texture samples */
  30333. maxSamples?: number;
  30334. /** Maximum cube texture size */
  30335. maxCubemapTextureSize: number;
  30336. /** Maximum render texture size */
  30337. maxRenderTextureSize: number;
  30338. /** Maximum number of vertex attributes */
  30339. maxVertexAttribs: number;
  30340. /** Maximum number of varyings */
  30341. maxVaryingVectors: number;
  30342. /** Maximum number of uniforms per vertex shader */
  30343. maxVertexUniformVectors: number;
  30344. /** Maximum number of uniforms per fragment shader */
  30345. maxFragmentUniformVectors: number;
  30346. /** Defines if standard derivates (dx/dy) are supported */
  30347. standardDerivatives: boolean;
  30348. /** Defines if s3tc texture compression is supported */
  30349. s3tc?: WEBGL_compressed_texture_s3tc;
  30350. /** Defines if pvrtc texture compression is supported */
  30351. pvrtc: any;
  30352. /** Defines if etc1 texture compression is supported */
  30353. etc1: any;
  30354. /** Defines if etc2 texture compression is supported */
  30355. etc2: any;
  30356. /** Defines if astc texture compression is supported */
  30357. astc: any;
  30358. /** Defines if float textures are supported */
  30359. textureFloat: boolean;
  30360. /** Defines if vertex array objects are supported */
  30361. vertexArrayObject: boolean;
  30362. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30363. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  30364. /** Gets the maximum level of anisotropy supported */
  30365. maxAnisotropy: number;
  30366. /** Defines if instancing is supported */
  30367. instancedArrays: boolean;
  30368. /** Defines if 32 bits indices are supported */
  30369. uintIndices: boolean;
  30370. /** Defines if high precision shaders are supported */
  30371. highPrecisionShaderSupported: boolean;
  30372. /** Defines if depth reading in the fragment shader is supported */
  30373. fragmentDepthSupported: boolean;
  30374. /** Defines if float texture linear filtering is supported*/
  30375. textureFloatLinearFiltering: boolean;
  30376. /** Defines if rendering to float textures is supported */
  30377. textureFloatRender: boolean;
  30378. /** Defines if half float textures are supported*/
  30379. textureHalfFloat: boolean;
  30380. /** Defines if half float texture linear filtering is supported*/
  30381. textureHalfFloatLinearFiltering: boolean;
  30382. /** Defines if rendering to half float textures is supported */
  30383. textureHalfFloatRender: boolean;
  30384. /** Defines if textureLOD shader command is supported */
  30385. textureLOD: boolean;
  30386. /** Defines if draw buffers extension is supported */
  30387. drawBuffersExtension: boolean;
  30388. /** Defines if depth textures are supported */
  30389. depthTextureExtension: boolean;
  30390. /** Defines if float color buffer are supported */
  30391. colorBufferFloat: boolean;
  30392. /** Gets disjoint timer query extension (null if not supported) */
  30393. timerQuery?: EXT_disjoint_timer_query;
  30394. /** Defines if timestamp can be used with timer query */
  30395. canUseTimestampForTimerQuery: boolean;
  30396. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30397. multiview?: any;
  30398. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  30399. oculusMultiview?: any;
  30400. /** Function used to let the system compiles shaders in background */
  30401. parallelShaderCompile?: {
  30402. COMPLETION_STATUS_KHR: number;
  30403. };
  30404. /** Max number of texture samples for MSAA */
  30405. maxMSAASamples: number;
  30406. /** Defines if the blend min max extension is supported */
  30407. blendMinMax: boolean;
  30408. }
  30409. }
  30410. declare module BABYLON {
  30411. /**
  30412. * @hidden
  30413. **/
  30414. export class DepthCullingState {
  30415. private _isDepthTestDirty;
  30416. private _isDepthMaskDirty;
  30417. private _isDepthFuncDirty;
  30418. private _isCullFaceDirty;
  30419. private _isCullDirty;
  30420. private _isZOffsetDirty;
  30421. private _isFrontFaceDirty;
  30422. private _depthTest;
  30423. private _depthMask;
  30424. private _depthFunc;
  30425. private _cull;
  30426. private _cullFace;
  30427. private _zOffset;
  30428. private _frontFace;
  30429. /**
  30430. * Initializes the state.
  30431. */
  30432. constructor();
  30433. get isDirty(): boolean;
  30434. get zOffset(): number;
  30435. set zOffset(value: number);
  30436. get cullFace(): Nullable<number>;
  30437. set cullFace(value: Nullable<number>);
  30438. get cull(): Nullable<boolean>;
  30439. set cull(value: Nullable<boolean>);
  30440. get depthFunc(): Nullable<number>;
  30441. set depthFunc(value: Nullable<number>);
  30442. get depthMask(): boolean;
  30443. set depthMask(value: boolean);
  30444. get depthTest(): boolean;
  30445. set depthTest(value: boolean);
  30446. get frontFace(): Nullable<number>;
  30447. set frontFace(value: Nullable<number>);
  30448. reset(): void;
  30449. apply(gl: WebGLRenderingContext): void;
  30450. }
  30451. }
  30452. declare module BABYLON {
  30453. /**
  30454. * @hidden
  30455. **/
  30456. export class StencilState {
  30457. /** 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 */
  30458. static readonly ALWAYS: number;
  30459. /** Passed to stencilOperation to specify that stencil value must be kept */
  30460. static readonly KEEP: number;
  30461. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30462. static readonly REPLACE: number;
  30463. private _isStencilTestDirty;
  30464. private _isStencilMaskDirty;
  30465. private _isStencilFuncDirty;
  30466. private _isStencilOpDirty;
  30467. private _stencilTest;
  30468. private _stencilMask;
  30469. private _stencilFunc;
  30470. private _stencilFuncRef;
  30471. private _stencilFuncMask;
  30472. private _stencilOpStencilFail;
  30473. private _stencilOpDepthFail;
  30474. private _stencilOpStencilDepthPass;
  30475. get isDirty(): boolean;
  30476. get stencilFunc(): number;
  30477. set stencilFunc(value: number);
  30478. get stencilFuncRef(): number;
  30479. set stencilFuncRef(value: number);
  30480. get stencilFuncMask(): number;
  30481. set stencilFuncMask(value: number);
  30482. get stencilOpStencilFail(): number;
  30483. set stencilOpStencilFail(value: number);
  30484. get stencilOpDepthFail(): number;
  30485. set stencilOpDepthFail(value: number);
  30486. get stencilOpStencilDepthPass(): number;
  30487. set stencilOpStencilDepthPass(value: number);
  30488. get stencilMask(): number;
  30489. set stencilMask(value: number);
  30490. get stencilTest(): boolean;
  30491. set stencilTest(value: boolean);
  30492. constructor();
  30493. reset(): void;
  30494. apply(gl: WebGLRenderingContext): void;
  30495. }
  30496. }
  30497. declare module BABYLON {
  30498. /**
  30499. * @hidden
  30500. **/
  30501. export class AlphaState {
  30502. private _isAlphaBlendDirty;
  30503. private _isBlendFunctionParametersDirty;
  30504. private _isBlendEquationParametersDirty;
  30505. private _isBlendConstantsDirty;
  30506. private _alphaBlend;
  30507. private _blendFunctionParameters;
  30508. private _blendEquationParameters;
  30509. private _blendConstants;
  30510. /**
  30511. * Initializes the state.
  30512. */
  30513. constructor();
  30514. get isDirty(): boolean;
  30515. get alphaBlend(): boolean;
  30516. set alphaBlend(value: boolean);
  30517. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  30518. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  30519. setAlphaEquationParameters(rgb: number, alpha: number): void;
  30520. reset(): void;
  30521. apply(gl: WebGLRenderingContext): void;
  30522. }
  30523. }
  30524. declare module BABYLON {
  30525. /** @hidden */
  30526. export class WebGL2ShaderProcessor implements IShaderProcessor {
  30527. attributeProcessor(attribute: string): string;
  30528. varyingProcessor(varying: string, isFragment: boolean): string;
  30529. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  30530. }
  30531. }
  30532. declare module BABYLON {
  30533. /**
  30534. * Interface for attribute information associated with buffer instanciation
  30535. */
  30536. export interface InstancingAttributeInfo {
  30537. /**
  30538. * Name of the GLSL attribute
  30539. * if attribute index is not specified, this is used to retrieve the index from the effect
  30540. */
  30541. attributeName: string;
  30542. /**
  30543. * Index/offset of the attribute in the vertex shader
  30544. * if not specified, this will be computes from the name.
  30545. */
  30546. index?: number;
  30547. /**
  30548. * size of the attribute, 1, 2, 3 or 4
  30549. */
  30550. attributeSize: number;
  30551. /**
  30552. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30553. */
  30554. offset: number;
  30555. /**
  30556. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  30557. * default to 1
  30558. */
  30559. divisor?: number;
  30560. /**
  30561. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30562. * default is FLOAT
  30563. */
  30564. attributeType?: number;
  30565. /**
  30566. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30567. */
  30568. normalized?: boolean;
  30569. }
  30570. }
  30571. declare module BABYLON {
  30572. interface ThinEngine {
  30573. /**
  30574. * Update a video texture
  30575. * @param texture defines the texture to update
  30576. * @param video defines the video element to use
  30577. * @param invertY defines if data must be stored with Y axis inverted
  30578. */
  30579. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  30580. }
  30581. }
  30582. declare module BABYLON {
  30583. /**
  30584. * Settings for finer control over video usage
  30585. */
  30586. export interface VideoTextureSettings {
  30587. /**
  30588. * Applies `autoplay` to video, if specified
  30589. */
  30590. autoPlay?: boolean;
  30591. /**
  30592. * Applies `loop` to video, if specified
  30593. */
  30594. loop?: boolean;
  30595. /**
  30596. * Automatically updates internal texture from video at every frame in the render loop
  30597. */
  30598. autoUpdateTexture: boolean;
  30599. /**
  30600. * Image src displayed during the video loading or until the user interacts with the video.
  30601. */
  30602. poster?: string;
  30603. }
  30604. /**
  30605. * If you want to display a video in your scene, this is the special texture for that.
  30606. * This special texture works similar to other textures, with the exception of a few parameters.
  30607. * @see https://doc.babylonjs.com/how_to/video_texture
  30608. */
  30609. export class VideoTexture extends Texture {
  30610. /**
  30611. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30612. */
  30613. readonly autoUpdateTexture: boolean;
  30614. /**
  30615. * The video instance used by the texture internally
  30616. */
  30617. readonly video: HTMLVideoElement;
  30618. private _onUserActionRequestedObservable;
  30619. /**
  30620. * Event triggerd when a dom action is required by the user to play the video.
  30621. * This happens due to recent changes in browser policies preventing video to auto start.
  30622. */
  30623. get onUserActionRequestedObservable(): Observable<Texture>;
  30624. private _generateMipMaps;
  30625. private _engine;
  30626. private _stillImageCaptured;
  30627. private _displayingPosterTexture;
  30628. private _settings;
  30629. private _createInternalTextureOnEvent;
  30630. private _frameId;
  30631. private _currentSrc;
  30632. /**
  30633. * Creates a video texture.
  30634. * If you want to display a video in your scene, this is the special texture for that.
  30635. * This special texture works similar to other textures, with the exception of a few parameters.
  30636. * @see https://doc.babylonjs.com/how_to/video_texture
  30637. * @param name optional name, will detect from video source, if not defined
  30638. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30639. * @param scene is obviously the current scene.
  30640. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30641. * @param invertY is false by default but can be used to invert video on Y axis
  30642. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30643. * @param settings allows finer control over video usage
  30644. */
  30645. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30646. private _getName;
  30647. private _getVideo;
  30648. private _createInternalTexture;
  30649. private reset;
  30650. /**
  30651. * @hidden Internal method to initiate `update`.
  30652. */
  30653. _rebuild(): void;
  30654. /**
  30655. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30656. */
  30657. update(): void;
  30658. /**
  30659. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30660. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30661. */
  30662. updateTexture(isVisible: boolean): void;
  30663. protected _updateInternalTexture: () => void;
  30664. /**
  30665. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30666. * @param url New url.
  30667. */
  30668. updateURL(url: string): void;
  30669. /**
  30670. * Clones the texture.
  30671. * @returns the cloned texture
  30672. */
  30673. clone(): VideoTexture;
  30674. /**
  30675. * Dispose the texture and release its associated resources.
  30676. */
  30677. dispose(): void;
  30678. /**
  30679. * Creates a video texture straight from a stream.
  30680. * @param scene Define the scene the texture should be created in
  30681. * @param stream Define the stream the texture should be created from
  30682. * @returns The created video texture as a promise
  30683. */
  30684. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30685. /**
  30686. * Creates a video texture straight from your WebCam video feed.
  30687. * @param scene Define the scene the texture should be created in
  30688. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30689. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30690. * @returns The created video texture as a promise
  30691. */
  30692. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30693. minWidth: number;
  30694. maxWidth: number;
  30695. minHeight: number;
  30696. maxHeight: number;
  30697. deviceId: string;
  30698. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): 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 onReady Define a callback to triggered once the texture will be ready
  30703. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30704. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30705. */
  30706. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30707. minWidth: number;
  30708. maxWidth: number;
  30709. minHeight: number;
  30710. maxHeight: number;
  30711. deviceId: string;
  30712. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30713. }
  30714. }
  30715. declare module BABYLON {
  30716. /**
  30717. * Defines the interface used by objects working like Scene
  30718. * @hidden
  30719. */
  30720. interface ISceneLike {
  30721. _addPendingData(data: any): void;
  30722. _removePendingData(data: any): void;
  30723. offlineProvider: IOfflineProvider;
  30724. }
  30725. /** Interface defining initialization parameters for Engine class */
  30726. export interface EngineOptions extends WebGLContextAttributes {
  30727. /**
  30728. * Defines if the engine should no exceed a specified device ratio
  30729. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30730. */
  30731. limitDeviceRatio?: number;
  30732. /**
  30733. * Defines if webvr should be enabled automatically
  30734. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30735. */
  30736. autoEnableWebVR?: boolean;
  30737. /**
  30738. * Defines if webgl2 should be turned off even if supported
  30739. * @see http://doc.babylonjs.com/features/webgl2
  30740. */
  30741. disableWebGL2Support?: boolean;
  30742. /**
  30743. * Defines if webaudio should be initialized as well
  30744. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30745. */
  30746. audioEngine?: boolean;
  30747. /**
  30748. * Defines if animations should run using a deterministic lock step
  30749. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30750. */
  30751. deterministicLockstep?: boolean;
  30752. /** Defines the maximum steps to use with deterministic lock step mode */
  30753. lockstepMaxSteps?: number;
  30754. /** Defines the seconds between each deterministic lock step */
  30755. timeStep?: number;
  30756. /**
  30757. * Defines that engine should ignore context lost events
  30758. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30759. */
  30760. doNotHandleContextLost?: boolean;
  30761. /**
  30762. * Defines that engine should ignore modifying touch action attribute and style
  30763. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30764. */
  30765. doNotHandleTouchAction?: boolean;
  30766. /**
  30767. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30768. */
  30769. useHighPrecisionFloats?: boolean;
  30770. }
  30771. /**
  30772. * The base engine class (root of all engines)
  30773. */
  30774. export class ThinEngine {
  30775. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30776. static ExceptionList: ({
  30777. key: string;
  30778. capture: string;
  30779. captureConstraint: number;
  30780. targets: string[];
  30781. } | {
  30782. key: string;
  30783. capture: null;
  30784. captureConstraint: null;
  30785. targets: string[];
  30786. })[];
  30787. /** @hidden */
  30788. static _TextureLoaders: IInternalTextureLoader[];
  30789. /**
  30790. * Returns the current npm package of the sdk
  30791. */
  30792. static get NpmPackage(): string;
  30793. /**
  30794. * Returns the current version of the framework
  30795. */
  30796. static get Version(): string;
  30797. /**
  30798. * Returns a string describing the current engine
  30799. */
  30800. get description(): string;
  30801. /**
  30802. * Gets or sets the epsilon value used by collision engine
  30803. */
  30804. static CollisionsEpsilon: number;
  30805. /**
  30806. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30807. */
  30808. static get ShadersRepository(): string;
  30809. static set ShadersRepository(value: string);
  30810. /**
  30811. * Gets or sets the textures that the engine should not attempt to load as compressed
  30812. */
  30813. protected _excludedCompressedTextures: string[];
  30814. /**
  30815. * Filters the compressed texture formats to only include
  30816. * files that are not included in the skippable list
  30817. *
  30818. * @param url the current extension
  30819. * @param textureFormatInUse the current compressed texture format
  30820. * @returns "format" string
  30821. */
  30822. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  30823. /** @hidden */
  30824. _shaderProcessor: IShaderProcessor;
  30825. /**
  30826. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30827. */
  30828. forcePOTTextures: boolean;
  30829. /**
  30830. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30831. */
  30832. isFullscreen: boolean;
  30833. /**
  30834. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30835. */
  30836. cullBackFaces: boolean;
  30837. /**
  30838. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30839. */
  30840. renderEvenInBackground: boolean;
  30841. /**
  30842. * Gets or sets a boolean indicating that cache can be kept between frames
  30843. */
  30844. preventCacheWipeBetweenFrames: boolean;
  30845. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30846. validateShaderPrograms: boolean;
  30847. /**
  30848. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  30849. * This can provide greater z depth for distant objects.
  30850. */
  30851. useReverseDepthBuffer: boolean;
  30852. /**
  30853. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30854. */
  30855. disableUniformBuffers: boolean;
  30856. /** @hidden */
  30857. _uniformBuffers: UniformBuffer[];
  30858. /**
  30859. * Gets a boolean indicating that the engine supports uniform buffers
  30860. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30861. */
  30862. get supportsUniformBuffers(): boolean;
  30863. /** @hidden */
  30864. _gl: WebGLRenderingContext;
  30865. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  30866. protected _windowIsBackground: boolean;
  30867. protected _webGLVersion: number;
  30868. protected _creationOptions: EngineOptions;
  30869. protected _highPrecisionShadersAllowed: boolean;
  30870. /** @hidden */
  30871. get _shouldUseHighPrecisionShader(): boolean;
  30872. /**
  30873. * Gets a boolean indicating that only power of 2 textures are supported
  30874. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30875. */
  30876. get needPOTTextures(): boolean;
  30877. /** @hidden */
  30878. _badOS: boolean;
  30879. /** @hidden */
  30880. _badDesktopOS: boolean;
  30881. private _hardwareScalingLevel;
  30882. /** @hidden */
  30883. _caps: EngineCapabilities;
  30884. private _isStencilEnable;
  30885. private _glVersion;
  30886. private _glRenderer;
  30887. private _glVendor;
  30888. /** @hidden */
  30889. _videoTextureSupported: boolean;
  30890. protected _renderingQueueLaunched: boolean;
  30891. protected _activeRenderLoops: (() => void)[];
  30892. /**
  30893. * Observable signaled when a context lost event is raised
  30894. */
  30895. onContextLostObservable: Observable<ThinEngine>;
  30896. /**
  30897. * Observable signaled when a context restored event is raised
  30898. */
  30899. onContextRestoredObservable: Observable<ThinEngine>;
  30900. private _onContextLost;
  30901. private _onContextRestored;
  30902. protected _contextWasLost: boolean;
  30903. /** @hidden */
  30904. _doNotHandleContextLost: boolean;
  30905. /**
  30906. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30907. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30908. */
  30909. get doNotHandleContextLost(): boolean;
  30910. set doNotHandleContextLost(value: boolean);
  30911. /**
  30912. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30913. */
  30914. disableVertexArrayObjects: boolean;
  30915. /** @hidden */
  30916. protected _colorWrite: boolean;
  30917. /** @hidden */
  30918. protected _colorWriteChanged: boolean;
  30919. /** @hidden */
  30920. protected _depthCullingState: DepthCullingState;
  30921. /** @hidden */
  30922. protected _stencilState: StencilState;
  30923. /** @hidden */
  30924. _alphaState: AlphaState;
  30925. /** @hidden */
  30926. _alphaMode: number;
  30927. /** @hidden */
  30928. _alphaEquation: number;
  30929. /** @hidden */
  30930. _internalTexturesCache: InternalTexture[];
  30931. /** @hidden */
  30932. protected _activeChannel: number;
  30933. private _currentTextureChannel;
  30934. /** @hidden */
  30935. protected _boundTexturesCache: {
  30936. [key: string]: Nullable<InternalTexture>;
  30937. };
  30938. /** @hidden */
  30939. protected _currentEffect: Nullable<Effect>;
  30940. /** @hidden */
  30941. protected _currentProgram: Nullable<WebGLProgram>;
  30942. private _compiledEffects;
  30943. private _vertexAttribArraysEnabled;
  30944. /** @hidden */
  30945. protected _cachedViewport: Nullable<IViewportLike>;
  30946. private _cachedVertexArrayObject;
  30947. /** @hidden */
  30948. protected _cachedVertexBuffers: any;
  30949. /** @hidden */
  30950. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  30951. /** @hidden */
  30952. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  30953. /** @hidden */
  30954. _currentRenderTarget: Nullable<InternalTexture>;
  30955. private _uintIndicesCurrentlySet;
  30956. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  30957. /** @hidden */
  30958. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  30959. private _currentBufferPointers;
  30960. private _currentInstanceLocations;
  30961. private _currentInstanceBuffers;
  30962. private _textureUnits;
  30963. /** @hidden */
  30964. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  30965. /** @hidden */
  30966. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  30967. /** @hidden */
  30968. _boundRenderFunction: any;
  30969. private _vaoRecordInProgress;
  30970. private _mustWipeVertexAttributes;
  30971. private _emptyTexture;
  30972. private _emptyCubeTexture;
  30973. private _emptyTexture3D;
  30974. private _emptyTexture2DArray;
  30975. /** @hidden */
  30976. _frameHandler: number;
  30977. private _nextFreeTextureSlots;
  30978. private _maxSimultaneousTextures;
  30979. private _activeRequests;
  30980. protected _texturesSupported: string[];
  30981. /** @hidden */
  30982. _textureFormatInUse: Nullable<string>;
  30983. protected get _supportsHardwareTextureRescaling(): boolean;
  30984. /**
  30985. * Gets the list of texture formats supported
  30986. */
  30987. get texturesSupported(): Array<string>;
  30988. /**
  30989. * Gets the list of texture formats in use
  30990. */
  30991. get textureFormatInUse(): Nullable<string>;
  30992. /**
  30993. * Gets the current viewport
  30994. */
  30995. get currentViewport(): Nullable<IViewportLike>;
  30996. /**
  30997. * Gets the default empty texture
  30998. */
  30999. get emptyTexture(): InternalTexture;
  31000. /**
  31001. * Gets the default empty 3D texture
  31002. */
  31003. get emptyTexture3D(): InternalTexture;
  31004. /**
  31005. * Gets the default empty 2D array texture
  31006. */
  31007. get emptyTexture2DArray(): InternalTexture;
  31008. /**
  31009. * Gets the default empty cube texture
  31010. */
  31011. get emptyCubeTexture(): InternalTexture;
  31012. /**
  31013. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31014. */
  31015. readonly premultipliedAlpha: boolean;
  31016. /**
  31017. * Observable event triggered before each texture is initialized
  31018. */
  31019. onBeforeTextureInitObservable: Observable<Texture>;
  31020. /**
  31021. * Creates a new engine
  31022. * @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
  31023. * @param antialias defines enable antialiasing (default: false)
  31024. * @param options defines further options to be sent to the getContext() function
  31025. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31026. */
  31027. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31028. private _rebuildInternalTextures;
  31029. private _rebuildEffects;
  31030. /**
  31031. * Gets a boolean indicating if all created effects are ready
  31032. * @returns true if all effects are ready
  31033. */
  31034. areAllEffectsReady(): boolean;
  31035. protected _rebuildBuffers(): void;
  31036. private _initGLContext;
  31037. /**
  31038. * Gets version of the current webGL context
  31039. */
  31040. get webGLVersion(): number;
  31041. /**
  31042. * Gets a string idenfifying the name of the class
  31043. * @returns "Engine" string
  31044. */
  31045. getClassName(): string;
  31046. /**
  31047. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31048. */
  31049. get isStencilEnable(): boolean;
  31050. /** @hidden */
  31051. _prepareWorkingCanvas(): void;
  31052. /**
  31053. * Reset the texture cache to empty state
  31054. */
  31055. resetTextureCache(): void;
  31056. /**
  31057. * Gets an object containing information about the current webGL context
  31058. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31059. */
  31060. getGlInfo(): {
  31061. vendor: string;
  31062. renderer: string;
  31063. version: string;
  31064. };
  31065. /**
  31066. * Defines the hardware scaling level.
  31067. * By default the hardware scaling level is computed from the window device ratio.
  31068. * 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.
  31069. * @param level defines the level to use
  31070. */
  31071. setHardwareScalingLevel(level: number): void;
  31072. /**
  31073. * Gets the current hardware scaling level.
  31074. * By default the hardware scaling level is computed from the window device ratio.
  31075. * 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.
  31076. * @returns a number indicating the current hardware scaling level
  31077. */
  31078. getHardwareScalingLevel(): number;
  31079. /**
  31080. * Gets the list of loaded textures
  31081. * @returns an array containing all loaded textures
  31082. */
  31083. getLoadedTexturesCache(): InternalTexture[];
  31084. /**
  31085. * Gets the object containing all engine capabilities
  31086. * @returns the EngineCapabilities object
  31087. */
  31088. getCaps(): EngineCapabilities;
  31089. /**
  31090. * stop executing a render loop function and remove it from the execution array
  31091. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31092. */
  31093. stopRenderLoop(renderFunction?: () => void): void;
  31094. /** @hidden */
  31095. _renderLoop(): void;
  31096. /**
  31097. * Gets the HTML canvas attached with the current webGL context
  31098. * @returns a HTML canvas
  31099. */
  31100. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31101. /**
  31102. * Gets host window
  31103. * @returns the host window object
  31104. */
  31105. getHostWindow(): Nullable<Window>;
  31106. /**
  31107. * Gets the current render width
  31108. * @param useScreen defines if screen size must be used (or the current render target if any)
  31109. * @returns a number defining the current render width
  31110. */
  31111. getRenderWidth(useScreen?: boolean): number;
  31112. /**
  31113. * Gets the current render height
  31114. * @param useScreen defines if screen size must be used (or the current render target if any)
  31115. * @returns a number defining the current render height
  31116. */
  31117. getRenderHeight(useScreen?: boolean): number;
  31118. /**
  31119. * Can be used to override the current requestAnimationFrame requester.
  31120. * @hidden
  31121. */
  31122. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31123. /**
  31124. * Register and execute a render loop. The engine can have more than one render function
  31125. * @param renderFunction defines the function to continuously execute
  31126. */
  31127. runRenderLoop(renderFunction: () => void): void;
  31128. /**
  31129. * Clear the current render buffer or the current render target (if any is set up)
  31130. * @param color defines the color to use
  31131. * @param backBuffer defines if the back buffer must be cleared
  31132. * @param depth defines if the depth buffer must be cleared
  31133. * @param stencil defines if the stencil buffer must be cleared
  31134. */
  31135. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31136. private _viewportCached;
  31137. /** @hidden */
  31138. _viewport(x: number, y: number, width: number, height: number): void;
  31139. /**
  31140. * Set the WebGL's viewport
  31141. * @param viewport defines the viewport element to be used
  31142. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31143. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31144. */
  31145. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31146. /**
  31147. * Begin a new frame
  31148. */
  31149. beginFrame(): void;
  31150. /**
  31151. * Enf the current frame
  31152. */
  31153. endFrame(): void;
  31154. /**
  31155. * Resize the view according to the canvas' size
  31156. */
  31157. resize(): void;
  31158. /**
  31159. * Force a specific size of the canvas
  31160. * @param width defines the new canvas' width
  31161. * @param height defines the new canvas' height
  31162. */
  31163. setSize(width: number, height: number): void;
  31164. /**
  31165. * Binds the frame buffer to the specified texture.
  31166. * @param texture The texture to render to or null for the default canvas
  31167. * @param faceIndex The face of the texture to render to in case of cube texture
  31168. * @param requiredWidth The width of the target to render to
  31169. * @param requiredHeight The height of the target to render to
  31170. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31171. * @param lodLevel defines the lod level to bind to the frame buffer
  31172. * @param layer defines the 2d array index to bind to frame buffer to
  31173. */
  31174. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  31175. /** @hidden */
  31176. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31177. /**
  31178. * Unbind the current render target texture from the webGL context
  31179. * @param texture defines the render target texture to unbind
  31180. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31181. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31182. */
  31183. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31184. /**
  31185. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31186. */
  31187. flushFramebuffer(): void;
  31188. /**
  31189. * Unbind the current render target and bind the default framebuffer
  31190. */
  31191. restoreDefaultFramebuffer(): void;
  31192. /** @hidden */
  31193. protected _resetVertexBufferBinding(): void;
  31194. /**
  31195. * Creates a vertex buffer
  31196. * @param data the data for the vertex buffer
  31197. * @returns the new WebGL static buffer
  31198. */
  31199. createVertexBuffer(data: DataArray): DataBuffer;
  31200. private _createVertexBuffer;
  31201. /**
  31202. * Creates a dynamic vertex buffer
  31203. * @param data the data for the dynamic vertex buffer
  31204. * @returns the new WebGL dynamic buffer
  31205. */
  31206. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31207. protected _resetIndexBufferBinding(): void;
  31208. /**
  31209. * Creates a new index buffer
  31210. * @param indices defines the content of the index buffer
  31211. * @param updatable defines if the index buffer must be updatable
  31212. * @returns a new webGL buffer
  31213. */
  31214. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31215. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31216. /**
  31217. * Bind a webGL buffer to the webGL context
  31218. * @param buffer defines the buffer to bind
  31219. */
  31220. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31221. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  31222. private bindBuffer;
  31223. /**
  31224. * update the bound buffer with the given data
  31225. * @param data defines the data to update
  31226. */
  31227. updateArrayBuffer(data: Float32Array): void;
  31228. private _vertexAttribPointer;
  31229. private _bindIndexBufferWithCache;
  31230. private _bindVertexBuffersAttributes;
  31231. /**
  31232. * Records a vertex array object
  31233. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31234. * @param vertexBuffers defines the list of vertex buffers to store
  31235. * @param indexBuffer defines the index buffer to store
  31236. * @param effect defines the effect to store
  31237. * @returns the new vertex array object
  31238. */
  31239. recordVertexArrayObject(vertexBuffers: {
  31240. [key: string]: VertexBuffer;
  31241. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31242. /**
  31243. * Bind a specific vertex array object
  31244. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31245. * @param vertexArrayObject defines the vertex array object to bind
  31246. * @param indexBuffer defines the index buffer to bind
  31247. */
  31248. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31249. /**
  31250. * Bind webGl buffers directly to the webGL context
  31251. * @param vertexBuffer defines the vertex buffer to bind
  31252. * @param indexBuffer defines the index buffer to bind
  31253. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31254. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31255. * @param effect defines the effect associated with the vertex buffer
  31256. */
  31257. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31258. private _unbindVertexArrayObject;
  31259. /**
  31260. * Bind a list of vertex buffers to the webGL context
  31261. * @param vertexBuffers defines the list of vertex buffers to bind
  31262. * @param indexBuffer defines the index buffer to bind
  31263. * @param effect defines the effect associated with the vertex buffers
  31264. */
  31265. bindBuffers(vertexBuffers: {
  31266. [key: string]: Nullable<VertexBuffer>;
  31267. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31268. /**
  31269. * Unbind all instance attributes
  31270. */
  31271. unbindInstanceAttributes(): void;
  31272. /**
  31273. * Release and free the memory of a vertex array object
  31274. * @param vao defines the vertex array object to delete
  31275. */
  31276. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31277. /** @hidden */
  31278. _releaseBuffer(buffer: DataBuffer): boolean;
  31279. protected _deleteBuffer(buffer: DataBuffer): void;
  31280. /**
  31281. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31282. * @param instancesBuffer defines the webGL buffer to update and bind
  31283. * @param data defines the data to store in the buffer
  31284. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31285. */
  31286. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31287. /**
  31288. * Bind the content of a webGL buffer used with instanciation
  31289. * @param instancesBuffer defines the webGL buffer to bind
  31290. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  31291. * @param computeStride defines Wether to compute the strides from the info or use the default 0
  31292. */
  31293. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  31294. /**
  31295. * Disable the instance attribute corresponding to the name in parameter
  31296. * @param name defines the name of the attribute to disable
  31297. */
  31298. disableInstanceAttributeByName(name: string): void;
  31299. /**
  31300. * Disable the instance attribute corresponding to the location in parameter
  31301. * @param attributeLocation defines the attribute location of the attribute to disable
  31302. */
  31303. disableInstanceAttribute(attributeLocation: number): void;
  31304. /**
  31305. * Disable the attribute corresponding to the location in parameter
  31306. * @param attributeLocation defines the attribute location of the attribute to disable
  31307. */
  31308. disableAttributeByIndex(attributeLocation: number): void;
  31309. /**
  31310. * Send a draw order
  31311. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31312. * @param indexStart defines the starting index
  31313. * @param indexCount defines the number of index to draw
  31314. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31315. */
  31316. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31317. /**
  31318. * Draw a list of points
  31319. * @param verticesStart defines the index of first vertex to draw
  31320. * @param verticesCount defines the count of vertices to draw
  31321. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31322. */
  31323. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31324. /**
  31325. * Draw a list of unindexed primitives
  31326. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31327. * @param verticesStart defines the index of first vertex to draw
  31328. * @param verticesCount defines the count of vertices to draw
  31329. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31330. */
  31331. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31332. /**
  31333. * Draw a list of indexed primitives
  31334. * @param fillMode defines the primitive to use
  31335. * @param indexStart defines the starting index
  31336. * @param indexCount defines the number of index to draw
  31337. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31338. */
  31339. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31340. /**
  31341. * Draw a list of unindexed primitives
  31342. * @param fillMode defines the primitive to use
  31343. * @param verticesStart defines the index of first vertex to draw
  31344. * @param verticesCount defines the count of vertices to draw
  31345. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31346. */
  31347. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31348. private _drawMode;
  31349. /** @hidden */
  31350. protected _reportDrawCall(): void;
  31351. /** @hidden */
  31352. _releaseEffect(effect: Effect): void;
  31353. /** @hidden */
  31354. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31355. /**
  31356. * Create a new effect (used to store vertex/fragment shaders)
  31357. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31358. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  31359. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31360. * @param samplers defines an array of string used to represent textures
  31361. * @param defines defines the string containing the defines to use to compile the shaders
  31362. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31363. * @param onCompiled defines a function to call when the effect creation is successful
  31364. * @param onError defines a function to call when the effect creation has failed
  31365. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31366. * @returns the new Effect
  31367. */
  31368. 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;
  31369. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  31370. private _compileShader;
  31371. private _compileRawShader;
  31372. /**
  31373. * Directly creates a webGL program
  31374. * @param pipelineContext defines the pipeline context to attach to
  31375. * @param vertexCode defines the vertex shader code to use
  31376. * @param fragmentCode defines the fragment shader code to use
  31377. * @param context defines the webGL context to use (if not set, the current one will be used)
  31378. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31379. * @returns the new webGL program
  31380. */
  31381. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31382. /**
  31383. * Creates a webGL program
  31384. * @param pipelineContext defines the pipeline context to attach to
  31385. * @param vertexCode defines the vertex shader code to use
  31386. * @param fragmentCode defines the fragment shader code to use
  31387. * @param defines defines the string containing the defines to use to compile the shaders
  31388. * @param context defines the webGL context to use (if not set, the current one will be used)
  31389. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31390. * @returns the new webGL program
  31391. */
  31392. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31393. /**
  31394. * Creates a new pipeline context
  31395. * @returns the new pipeline
  31396. */
  31397. createPipelineContext(): IPipelineContext;
  31398. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31399. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  31400. /** @hidden */
  31401. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31402. /** @hidden */
  31403. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31404. /** @hidden */
  31405. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31406. /**
  31407. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31408. * @param pipelineContext defines the pipeline context to use
  31409. * @param uniformsNames defines the list of uniform names
  31410. * @returns an array of webGL uniform locations
  31411. */
  31412. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31413. /**
  31414. * Gets the lsit of active attributes for a given webGL program
  31415. * @param pipelineContext defines the pipeline context to use
  31416. * @param attributesNames defines the list of attribute names to get
  31417. * @returns an array of indices indicating the offset of each attribute
  31418. */
  31419. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31420. /**
  31421. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31422. * @param effect defines the effect to activate
  31423. */
  31424. enableEffect(effect: Nullable<Effect>): void;
  31425. /**
  31426. * Set the value of an uniform to a number (int)
  31427. * @param uniform defines the webGL uniform location where to store the value
  31428. * @param value defines the int number to store
  31429. */
  31430. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31431. /**
  31432. * Set the value of an uniform to an array of int32
  31433. * @param uniform defines the webGL uniform location where to store the value
  31434. * @param array defines the array of int32 to store
  31435. */
  31436. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31437. /**
  31438. * Set the value of an uniform to an array of int32 (stored as vec2)
  31439. * @param uniform defines the webGL uniform location where to store the value
  31440. * @param array defines the array of int32 to store
  31441. */
  31442. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31443. /**
  31444. * Set the value of an uniform to an array of int32 (stored as vec3)
  31445. * @param uniform defines the webGL uniform location where to store the value
  31446. * @param array defines the array of int32 to store
  31447. */
  31448. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31449. /**
  31450. * Set the value of an uniform to an array of int32 (stored as vec4)
  31451. * @param uniform defines the webGL uniform location where to store the value
  31452. * @param array defines the array of int32 to store
  31453. */
  31454. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31455. /**
  31456. * Set the value of an uniform to an array of number
  31457. * @param uniform defines the webGL uniform location where to store the value
  31458. * @param array defines the array of number to store
  31459. */
  31460. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31461. /**
  31462. * Set the value of an uniform to an array of number (stored as vec2)
  31463. * @param uniform defines the webGL uniform location where to store the value
  31464. * @param array defines the array of number to store
  31465. */
  31466. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31467. /**
  31468. * Set the value of an uniform to an array of number (stored as vec3)
  31469. * @param uniform defines the webGL uniform location where to store the value
  31470. * @param array defines the array of number to store
  31471. */
  31472. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31473. /**
  31474. * Set the value of an uniform to an array of number (stored as vec4)
  31475. * @param uniform defines the webGL uniform location where to store the value
  31476. * @param array defines the array of number to store
  31477. */
  31478. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31479. /**
  31480. * Set the value of an uniform to an array of float32 (stored as matrices)
  31481. * @param uniform defines the webGL uniform location where to store the value
  31482. * @param matrices defines the array of float32 to store
  31483. */
  31484. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31485. /**
  31486. * Set the value of an uniform to a matrix (3x3)
  31487. * @param uniform defines the webGL uniform location where to store the value
  31488. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31489. */
  31490. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31491. /**
  31492. * Set the value of an uniform to a matrix (2x2)
  31493. * @param uniform defines the webGL uniform location where to store the value
  31494. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31495. */
  31496. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31497. /**
  31498. * Set the value of an uniform to a number (float)
  31499. * @param uniform defines the webGL uniform location where to store the value
  31500. * @param value defines the float number to store
  31501. */
  31502. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31503. /**
  31504. * Set the value of an uniform to a vec2
  31505. * @param uniform defines the webGL uniform location where to store the value
  31506. * @param x defines the 1st component of the value
  31507. * @param y defines the 2nd component of the value
  31508. */
  31509. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31510. /**
  31511. * Set the value of an uniform to a vec3
  31512. * @param uniform defines the webGL uniform location where to store the value
  31513. * @param x defines the 1st component of the value
  31514. * @param y defines the 2nd component of the value
  31515. * @param z defines the 3rd component of the value
  31516. */
  31517. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31518. /**
  31519. * Set the value of an uniform to a vec4
  31520. * @param uniform defines the webGL uniform location where to store the value
  31521. * @param x defines the 1st component of the value
  31522. * @param y defines the 2nd component of the value
  31523. * @param z defines the 3rd component of the value
  31524. * @param w defines the 4th component of the value
  31525. */
  31526. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31527. /**
  31528. * Apply all cached states (depth, culling, stencil and alpha)
  31529. */
  31530. applyStates(): void;
  31531. /**
  31532. * Enable or disable color writing
  31533. * @param enable defines the state to set
  31534. */
  31535. setColorWrite(enable: boolean): void;
  31536. /**
  31537. * Gets a boolean indicating if color writing is enabled
  31538. * @returns the current color writing state
  31539. */
  31540. getColorWrite(): boolean;
  31541. /**
  31542. * Gets the depth culling state manager
  31543. */
  31544. get depthCullingState(): DepthCullingState;
  31545. /**
  31546. * Gets the alpha state manager
  31547. */
  31548. get alphaState(): AlphaState;
  31549. /**
  31550. * Gets the stencil state manager
  31551. */
  31552. get stencilState(): StencilState;
  31553. /**
  31554. * Clears the list of texture accessible through engine.
  31555. * This can help preventing texture load conflict due to name collision.
  31556. */
  31557. clearInternalTexturesCache(): void;
  31558. /**
  31559. * Force the entire cache to be cleared
  31560. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31561. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31562. */
  31563. wipeCaches(bruteForce?: boolean): void;
  31564. /** @hidden */
  31565. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  31566. min: number;
  31567. mag: number;
  31568. };
  31569. /** @hidden */
  31570. _createTexture(): WebGLTexture;
  31571. /**
  31572. * Usually called from Texture.ts.
  31573. * Passed information to create a WebGLTexture
  31574. * @param urlArg defines a value which contains one of the following:
  31575. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31576. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31577. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31578. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31579. * @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)
  31580. * @param scene needed for loading to the correct scene
  31581. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31582. * @param onLoad optional callback to be called upon successful completion
  31583. * @param onError optional callback to be called upon failure
  31584. * @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
  31585. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31586. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31587. * @param forcedExtension defines the extension to use to pick the right loader
  31588. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  31589. * @param mimeType defines an optional mime type
  31590. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31591. */
  31592. 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;
  31593. /**
  31594. * Loads an image as an HTMLImageElement.
  31595. * @param input url string, ArrayBuffer, or Blob to load
  31596. * @param onLoad callback called when the image successfully loads
  31597. * @param onError callback called when the image fails to load
  31598. * @param offlineProvider offline provider for caching
  31599. * @param mimeType optional mime type
  31600. * @returns the HTMLImageElement of the loaded image
  31601. * @hidden
  31602. */
  31603. 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>;
  31604. /**
  31605. * @hidden
  31606. */
  31607. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  31608. /**
  31609. * Creates a raw texture
  31610. * @param data defines the data to store in the texture
  31611. * @param width defines the width of the texture
  31612. * @param height defines the height of the texture
  31613. * @param format defines the format of the data
  31614. * @param generateMipMaps defines if the engine should generate the mip levels
  31615. * @param invertY defines if data must be stored with Y axis inverted
  31616. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31617. * @param compression defines the compression used (null by default)
  31618. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31619. * @returns the raw texture inside an InternalTexture
  31620. */
  31621. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  31622. /**
  31623. * Creates a new raw cube texture
  31624. * @param data defines the array of data to use to create each face
  31625. * @param size defines the size of the textures
  31626. * @param format defines the format of the data
  31627. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  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 (like Texture.NEAREST_SAMPLINGMODE)
  31631. * @param compression defines the compression used (null by default)
  31632. * @returns the cube texture as an InternalTexture
  31633. */
  31634. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  31635. /**
  31636. * Creates a new raw 3D texture
  31637. * @param data defines the data used to create the texture
  31638. * @param width defines the width of the texture
  31639. * @param height defines the height of the texture
  31640. * @param depth defines the depth of the texture
  31641. * @param format defines the format of the texture
  31642. * @param generateMipMaps defines if the engine must generate 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 compressed used (can be null)
  31646. * @param textureType defines the compressed used (can be null)
  31647. * @returns a new raw 3D texture (stored in an InternalTexture)
  31648. */
  31649. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31650. /**
  31651. * Creates a new raw 2D array texture
  31652. * @param data defines the data used to create the texture
  31653. * @param width defines the width of the texture
  31654. * @param height defines the height of the texture
  31655. * @param depth defines the number of layers of the texture
  31656. * @param format defines the format of the texture
  31657. * @param generateMipMaps defines if the engine must generate mip levels
  31658. * @param invertY defines if data must be stored with Y axis inverted
  31659. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31660. * @param compression defines the compressed used (can be null)
  31661. * @param textureType defines the compressed used (can be null)
  31662. * @returns a new raw 2D array texture (stored in an InternalTexture)
  31663. */
  31664. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31665. private _unpackFlipYCached;
  31666. /**
  31667. * In case you are sharing the context with other applications, it might
  31668. * be interested to not cache the unpack flip y state to ensure a consistent
  31669. * value would be set.
  31670. */
  31671. enableUnpackFlipYCached: boolean;
  31672. /** @hidden */
  31673. _unpackFlipY(value: boolean): void;
  31674. /** @hidden */
  31675. _getUnpackAlignement(): number;
  31676. private _getTextureTarget;
  31677. /**
  31678. * Update the sampling mode of a given texture
  31679. * @param samplingMode defines the required sampling mode
  31680. * @param texture defines the texture to update
  31681. * @param generateMipMaps defines whether to generate mipmaps for the texture
  31682. */
  31683. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  31684. /**
  31685. * Update the sampling mode of a given texture
  31686. * @param texture defines the texture to update
  31687. * @param wrapU defines the texture wrap mode of the u coordinates
  31688. * @param wrapV defines the texture wrap mode of the v coordinates
  31689. * @param wrapR defines the texture wrap mode of the r coordinates
  31690. */
  31691. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  31692. /** @hidden */
  31693. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  31694. width: number;
  31695. height: number;
  31696. layers?: number;
  31697. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  31698. /** @hidden */
  31699. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31700. /** @hidden */
  31701. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  31702. /**
  31703. * Update a portion of an internal texture
  31704. * @param texture defines the texture to update
  31705. * @param imageData defines the data to store into the texture
  31706. * @param xOffset defines the x coordinates of the update rectangle
  31707. * @param yOffset defines the y coordinates of the update rectangle
  31708. * @param width defines the width of the update rectangle
  31709. * @param height defines the height of the update rectangle
  31710. * @param faceIndex defines the face index if texture is a cube (0 by default)
  31711. * @param lod defines the lod level to update (0 by default)
  31712. */
  31713. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  31714. /** @hidden */
  31715. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31716. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  31717. private _prepareWebGLTexture;
  31718. /** @hidden */
  31719. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  31720. private _getDepthStencilBuffer;
  31721. /** @hidden */
  31722. _releaseFramebufferObjects(texture: InternalTexture): void;
  31723. /** @hidden */
  31724. _releaseTexture(texture: InternalTexture): void;
  31725. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  31726. protected _setProgram(program: WebGLProgram): void;
  31727. protected _boundUniforms: {
  31728. [key: number]: WebGLUniformLocation;
  31729. };
  31730. /**
  31731. * Binds an effect to the webGL context
  31732. * @param effect defines the effect to bind
  31733. */
  31734. bindSamplers(effect: Effect): void;
  31735. private _activateCurrentTexture;
  31736. /** @hidden */
  31737. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  31738. /** @hidden */
  31739. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  31740. /**
  31741. * Unbind all textures from the webGL context
  31742. */
  31743. unbindAllTextures(): void;
  31744. /**
  31745. * Sets a texture to the according uniform.
  31746. * @param channel The texture channel
  31747. * @param uniform The uniform to set
  31748. * @param texture The texture to apply
  31749. */
  31750. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  31751. private _bindSamplerUniformToChannel;
  31752. private _getTextureWrapMode;
  31753. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  31754. /**
  31755. * Sets an array of texture to the webGL context
  31756. * @param channel defines the channel where the texture array must be set
  31757. * @param uniform defines the associated uniform location
  31758. * @param textures defines the array of textures to bind
  31759. */
  31760. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  31761. /** @hidden */
  31762. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  31763. private _setTextureParameterFloat;
  31764. private _setTextureParameterInteger;
  31765. /**
  31766. * Unbind all vertex attributes from the webGL context
  31767. */
  31768. unbindAllAttributes(): void;
  31769. /**
  31770. * 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
  31771. */
  31772. releaseEffects(): void;
  31773. /**
  31774. * Dispose and release all associated resources
  31775. */
  31776. dispose(): void;
  31777. /**
  31778. * Attach a new callback raised when context lost event is fired
  31779. * @param callback defines the callback to call
  31780. */
  31781. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31782. /**
  31783. * Attach a new callback raised when context restored event is fired
  31784. * @param callback defines the callback to call
  31785. */
  31786. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31787. /**
  31788. * Get the current error code of the webGL context
  31789. * @returns the error code
  31790. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31791. */
  31792. getError(): number;
  31793. private _canRenderToFloatFramebuffer;
  31794. private _canRenderToHalfFloatFramebuffer;
  31795. private _canRenderToFramebuffer;
  31796. /** @hidden */
  31797. _getWebGLTextureType(type: number): number;
  31798. /** @hidden */
  31799. _getInternalFormat(format: number): number;
  31800. /** @hidden */
  31801. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31802. /** @hidden */
  31803. _getRGBAMultiSampleBufferFormat(type: number): number;
  31804. /** @hidden */
  31805. _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;
  31806. /**
  31807. * Loads a file from a url
  31808. * @param url url to load
  31809. * @param onSuccess callback called when the file successfully loads
  31810. * @param onProgress callback called while file is loading (if the server supports this mode)
  31811. * @param offlineProvider defines the offline provider for caching
  31812. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31813. * @param onError callback called when the file fails to load
  31814. * @returns a file request object
  31815. * @hidden
  31816. */
  31817. 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;
  31818. /**
  31819. * Reads pixels from the current frame buffer. Please note that this function can be slow
  31820. * @param x defines the x coordinate of the rectangle where pixels must be read
  31821. * @param y defines the y coordinate of the rectangle where pixels must be read
  31822. * @param width defines the width of the rectangle where pixels must be read
  31823. * @param height defines the height of the rectangle where pixels must be read
  31824. * @param hasAlpha defines wether the output should have alpha or not (defaults to true)
  31825. * @returns a Uint8Array containing RGBA colors
  31826. */
  31827. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  31828. private static _isSupported;
  31829. /**
  31830. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  31831. * @returns true if the engine can be created
  31832. * @ignorenaming
  31833. */
  31834. static isSupported(): boolean;
  31835. /**
  31836. * Find the next highest power of two.
  31837. * @param x Number to start search from.
  31838. * @return Next highest power of two.
  31839. */
  31840. static CeilingPOT(x: number): number;
  31841. /**
  31842. * Find the next lowest power of two.
  31843. * @param x Number to start search from.
  31844. * @return Next lowest power of two.
  31845. */
  31846. static FloorPOT(x: number): number;
  31847. /**
  31848. * Find the nearest power of two.
  31849. * @param x Number to start search from.
  31850. * @return Next nearest power of two.
  31851. */
  31852. static NearestPOT(x: number): number;
  31853. /**
  31854. * Get the closest exponent of two
  31855. * @param value defines the value to approximate
  31856. * @param max defines the maximum value to return
  31857. * @param mode defines how to define the closest value
  31858. * @returns closest exponent of two of the given value
  31859. */
  31860. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31861. /**
  31862. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31863. * @param func - the function to be called
  31864. * @param requester - the object that will request the next frame. Falls back to window.
  31865. * @returns frame number
  31866. */
  31867. static QueueNewFrame(func: () => void, requester?: any): number;
  31868. /**
  31869. * Gets host document
  31870. * @returns the host document object
  31871. */
  31872. getHostDocument(): Nullable<Document>;
  31873. }
  31874. }
  31875. declare module BABYLON {
  31876. /**
  31877. * Class representing spherical harmonics coefficients to the 3rd degree
  31878. */
  31879. export class SphericalHarmonics {
  31880. /**
  31881. * Defines whether or not the harmonics have been prescaled for rendering.
  31882. */
  31883. preScaled: boolean;
  31884. /**
  31885. * The l0,0 coefficients of the spherical harmonics
  31886. */
  31887. l00: Vector3;
  31888. /**
  31889. * The l1,-1 coefficients of the spherical harmonics
  31890. */
  31891. l1_1: Vector3;
  31892. /**
  31893. * The l1,0 coefficients of the spherical harmonics
  31894. */
  31895. l10: Vector3;
  31896. /**
  31897. * The l1,1 coefficients of the spherical harmonics
  31898. */
  31899. l11: Vector3;
  31900. /**
  31901. * The l2,-2 coefficients of the spherical harmonics
  31902. */
  31903. l2_2: Vector3;
  31904. /**
  31905. * The l2,-1 coefficients of the spherical harmonics
  31906. */
  31907. l2_1: Vector3;
  31908. /**
  31909. * The l2,0 coefficients of the spherical harmonics
  31910. */
  31911. l20: Vector3;
  31912. /**
  31913. * The l2,1 coefficients of the spherical harmonics
  31914. */
  31915. l21: Vector3;
  31916. /**
  31917. * The l2,2 coefficients of the spherical harmonics
  31918. */
  31919. l22: Vector3;
  31920. /**
  31921. * Adds a light to the spherical harmonics
  31922. * @param direction the direction of the light
  31923. * @param color the color of the light
  31924. * @param deltaSolidAngle the delta solid angle of the light
  31925. */
  31926. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  31927. /**
  31928. * Scales the spherical harmonics by the given amount
  31929. * @param scale the amount to scale
  31930. */
  31931. scaleInPlace(scale: number): void;
  31932. /**
  31933. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  31934. *
  31935. * ```
  31936. * E_lm = A_l * L_lm
  31937. * ```
  31938. *
  31939. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  31940. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  31941. * the scaling factors are given in equation 9.
  31942. */
  31943. convertIncidentRadianceToIrradiance(): void;
  31944. /**
  31945. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  31946. *
  31947. * ```
  31948. * L = (1/pi) * E * rho
  31949. * ```
  31950. *
  31951. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  31952. */
  31953. convertIrradianceToLambertianRadiance(): void;
  31954. /**
  31955. * Integrates the reconstruction coefficients directly in to the SH preventing further
  31956. * required operations at run time.
  31957. *
  31958. * This is simply done by scaling back the SH with Ylm constants parameter.
  31959. * The trigonometric part being applied by the shader at run time.
  31960. */
  31961. preScaleForRendering(): void;
  31962. /**
  31963. * Constructs a spherical harmonics from an array.
  31964. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  31965. * @returns the spherical harmonics
  31966. */
  31967. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  31968. /**
  31969. * Gets the spherical harmonics from polynomial
  31970. * @param polynomial the spherical polynomial
  31971. * @returns the spherical harmonics
  31972. */
  31973. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  31974. }
  31975. /**
  31976. * Class representing spherical polynomial coefficients to the 3rd degree
  31977. */
  31978. export class SphericalPolynomial {
  31979. private _harmonics;
  31980. /**
  31981. * The spherical harmonics used to create the polynomials.
  31982. */
  31983. get preScaledHarmonics(): SphericalHarmonics;
  31984. /**
  31985. * The x coefficients of the spherical polynomial
  31986. */
  31987. x: Vector3;
  31988. /**
  31989. * The y coefficients of the spherical polynomial
  31990. */
  31991. y: Vector3;
  31992. /**
  31993. * The z coefficients of the spherical polynomial
  31994. */
  31995. z: Vector3;
  31996. /**
  31997. * The xx coefficients of the spherical polynomial
  31998. */
  31999. xx: Vector3;
  32000. /**
  32001. * The yy coefficients of the spherical polynomial
  32002. */
  32003. yy: Vector3;
  32004. /**
  32005. * The zz coefficients of the spherical polynomial
  32006. */
  32007. zz: Vector3;
  32008. /**
  32009. * The xy coefficients of the spherical polynomial
  32010. */
  32011. xy: Vector3;
  32012. /**
  32013. * The yz coefficients of the spherical polynomial
  32014. */
  32015. yz: Vector3;
  32016. /**
  32017. * The zx coefficients of the spherical polynomial
  32018. */
  32019. zx: Vector3;
  32020. /**
  32021. * Adds an ambient color to the spherical polynomial
  32022. * @param color the color to add
  32023. */
  32024. addAmbient(color: Color3): void;
  32025. /**
  32026. * Scales the spherical polynomial by the given amount
  32027. * @param scale the amount to scale
  32028. */
  32029. scaleInPlace(scale: number): void;
  32030. /**
  32031. * Gets the spherical polynomial from harmonics
  32032. * @param harmonics the spherical harmonics
  32033. * @returns the spherical polynomial
  32034. */
  32035. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  32036. /**
  32037. * Constructs a spherical polynomial from an array.
  32038. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  32039. * @returns the spherical polynomial
  32040. */
  32041. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  32042. }
  32043. }
  32044. declare module BABYLON {
  32045. /**
  32046. * Defines the source of the internal texture
  32047. */
  32048. export enum InternalTextureSource {
  32049. /**
  32050. * The source of the texture data is unknown
  32051. */
  32052. Unknown = 0,
  32053. /**
  32054. * Texture data comes from an URL
  32055. */
  32056. Url = 1,
  32057. /**
  32058. * Texture data is only used for temporary storage
  32059. */
  32060. Temp = 2,
  32061. /**
  32062. * Texture data comes from raw data (ArrayBuffer)
  32063. */
  32064. Raw = 3,
  32065. /**
  32066. * Texture content is dynamic (video or dynamic texture)
  32067. */
  32068. Dynamic = 4,
  32069. /**
  32070. * Texture content is generated by rendering to it
  32071. */
  32072. RenderTarget = 5,
  32073. /**
  32074. * Texture content is part of a multi render target process
  32075. */
  32076. MultiRenderTarget = 6,
  32077. /**
  32078. * Texture data comes from a cube data file
  32079. */
  32080. Cube = 7,
  32081. /**
  32082. * Texture data comes from a raw cube data
  32083. */
  32084. CubeRaw = 8,
  32085. /**
  32086. * Texture data come from a prefiltered cube data file
  32087. */
  32088. CubePrefiltered = 9,
  32089. /**
  32090. * Texture content is raw 3D data
  32091. */
  32092. Raw3D = 10,
  32093. /**
  32094. * Texture content is raw 2D array data
  32095. */
  32096. Raw2DArray = 11,
  32097. /**
  32098. * Texture content is a depth texture
  32099. */
  32100. Depth = 12,
  32101. /**
  32102. * Texture data comes from a raw cube data encoded with RGBD
  32103. */
  32104. CubeRawRGBD = 13
  32105. }
  32106. /**
  32107. * Class used to store data associated with WebGL texture data for the engine
  32108. * This class should not be used directly
  32109. */
  32110. export class InternalTexture {
  32111. /** @hidden */
  32112. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  32113. /**
  32114. * Defines if the texture is ready
  32115. */
  32116. isReady: boolean;
  32117. /**
  32118. * Defines if the texture is a cube texture
  32119. */
  32120. isCube: boolean;
  32121. /**
  32122. * Defines if the texture contains 3D data
  32123. */
  32124. is3D: boolean;
  32125. /**
  32126. * Defines if the texture contains 2D array data
  32127. */
  32128. is2DArray: boolean;
  32129. /**
  32130. * Defines if the texture contains multiview data
  32131. */
  32132. isMultiview: boolean;
  32133. /**
  32134. * Gets the URL used to load this texture
  32135. */
  32136. url: string;
  32137. /**
  32138. * Gets the sampling mode of the texture
  32139. */
  32140. samplingMode: number;
  32141. /**
  32142. * Gets a boolean indicating if the texture needs mipmaps generation
  32143. */
  32144. generateMipMaps: boolean;
  32145. /**
  32146. * Gets the number of samples used by the texture (WebGL2+ only)
  32147. */
  32148. samples: number;
  32149. /**
  32150. * Gets the type of the texture (int, float...)
  32151. */
  32152. type: number;
  32153. /**
  32154. * Gets the format of the texture (RGB, RGBA...)
  32155. */
  32156. format: number;
  32157. /**
  32158. * Observable called when the texture is loaded
  32159. */
  32160. onLoadedObservable: Observable<InternalTexture>;
  32161. /**
  32162. * Gets the width of the texture
  32163. */
  32164. width: number;
  32165. /**
  32166. * Gets the height of the texture
  32167. */
  32168. height: number;
  32169. /**
  32170. * Gets the depth of the texture
  32171. */
  32172. depth: number;
  32173. /**
  32174. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  32175. */
  32176. baseWidth: number;
  32177. /**
  32178. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  32179. */
  32180. baseHeight: number;
  32181. /**
  32182. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  32183. */
  32184. baseDepth: number;
  32185. /**
  32186. * Gets a boolean indicating if the texture is inverted on Y axis
  32187. */
  32188. invertY: boolean;
  32189. /** @hidden */
  32190. _invertVScale: boolean;
  32191. /** @hidden */
  32192. _associatedChannel: number;
  32193. /** @hidden */
  32194. _source: InternalTextureSource;
  32195. /** @hidden */
  32196. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  32197. /** @hidden */
  32198. _bufferView: Nullable<ArrayBufferView>;
  32199. /** @hidden */
  32200. _bufferViewArray: Nullable<ArrayBufferView[]>;
  32201. /** @hidden */
  32202. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  32203. /** @hidden */
  32204. _size: number;
  32205. /** @hidden */
  32206. _extension: string;
  32207. /** @hidden */
  32208. _files: Nullable<string[]>;
  32209. /** @hidden */
  32210. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32211. /** @hidden */
  32212. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32213. /** @hidden */
  32214. _framebuffer: Nullable<WebGLFramebuffer>;
  32215. /** @hidden */
  32216. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  32217. /** @hidden */
  32218. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  32219. /** @hidden */
  32220. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  32221. /** @hidden */
  32222. _attachments: Nullable<number[]>;
  32223. /** @hidden */
  32224. _cachedCoordinatesMode: Nullable<number>;
  32225. /** @hidden */
  32226. _cachedWrapU: Nullable<number>;
  32227. /** @hidden */
  32228. _cachedWrapV: Nullable<number>;
  32229. /** @hidden */
  32230. _cachedWrapR: Nullable<number>;
  32231. /** @hidden */
  32232. _cachedAnisotropicFilteringLevel: Nullable<number>;
  32233. /** @hidden */
  32234. _isDisabled: boolean;
  32235. /** @hidden */
  32236. _compression: Nullable<string>;
  32237. /** @hidden */
  32238. _generateStencilBuffer: boolean;
  32239. /** @hidden */
  32240. _generateDepthBuffer: boolean;
  32241. /** @hidden */
  32242. _comparisonFunction: number;
  32243. /** @hidden */
  32244. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  32245. /** @hidden */
  32246. _lodGenerationScale: number;
  32247. /** @hidden */
  32248. _lodGenerationOffset: number;
  32249. /** @hidden */
  32250. _depthStencilTexture: Nullable<InternalTexture>;
  32251. /** @hidden */
  32252. _colorTextureArray: Nullable<WebGLTexture>;
  32253. /** @hidden */
  32254. _depthStencilTextureArray: Nullable<WebGLTexture>;
  32255. /** @hidden */
  32256. _lodTextureHigh: Nullable<BaseTexture>;
  32257. /** @hidden */
  32258. _lodTextureMid: Nullable<BaseTexture>;
  32259. /** @hidden */
  32260. _lodTextureLow: Nullable<BaseTexture>;
  32261. /** @hidden */
  32262. _isRGBD: boolean;
  32263. /** @hidden */
  32264. _linearSpecularLOD: boolean;
  32265. /** @hidden */
  32266. _irradianceTexture: Nullable<BaseTexture>;
  32267. /** @hidden */
  32268. _webGLTexture: Nullable<WebGLTexture>;
  32269. /** @hidden */
  32270. _references: number;
  32271. private _engine;
  32272. /**
  32273. * Gets the Engine the texture belongs to.
  32274. * @returns The babylon engine
  32275. */
  32276. getEngine(): ThinEngine;
  32277. /**
  32278. * Gets the data source type of the texture
  32279. */
  32280. get source(): InternalTextureSource;
  32281. /**
  32282. * Creates a new InternalTexture
  32283. * @param engine defines the engine to use
  32284. * @param source defines the type of data that will be used
  32285. * @param delayAllocation if the texture allocation should be delayed (default: false)
  32286. */
  32287. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  32288. /**
  32289. * Increments the number of references (ie. the number of Texture that point to it)
  32290. */
  32291. incrementReferences(): void;
  32292. /**
  32293. * Change the size of the texture (not the size of the content)
  32294. * @param width defines the new width
  32295. * @param height defines the new height
  32296. * @param depth defines the new depth (1 by default)
  32297. */
  32298. updateSize(width: int, height: int, depth?: int): void;
  32299. /** @hidden */
  32300. _rebuild(): void;
  32301. /** @hidden */
  32302. _swapAndDie(target: InternalTexture): void;
  32303. /**
  32304. * Dispose the current allocated resources
  32305. */
  32306. dispose(): void;
  32307. }
  32308. }
  32309. declare module BABYLON {
  32310. /**
  32311. * Class used to work with sound analyzer using fast fourier transform (FFT)
  32312. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32313. */
  32314. export class Analyser {
  32315. /**
  32316. * Gets or sets the smoothing
  32317. * @ignorenaming
  32318. */
  32319. SMOOTHING: number;
  32320. /**
  32321. * Gets or sets the FFT table size
  32322. * @ignorenaming
  32323. */
  32324. FFT_SIZE: number;
  32325. /**
  32326. * Gets or sets the bar graph amplitude
  32327. * @ignorenaming
  32328. */
  32329. BARGRAPHAMPLITUDE: number;
  32330. /**
  32331. * Gets or sets the position of the debug canvas
  32332. * @ignorenaming
  32333. */
  32334. DEBUGCANVASPOS: {
  32335. x: number;
  32336. y: number;
  32337. };
  32338. /**
  32339. * Gets or sets the debug canvas size
  32340. * @ignorenaming
  32341. */
  32342. DEBUGCANVASSIZE: {
  32343. width: number;
  32344. height: number;
  32345. };
  32346. private _byteFreqs;
  32347. private _byteTime;
  32348. private _floatFreqs;
  32349. private _webAudioAnalyser;
  32350. private _debugCanvas;
  32351. private _debugCanvasContext;
  32352. private _scene;
  32353. private _registerFunc;
  32354. private _audioEngine;
  32355. /**
  32356. * Creates a new analyser
  32357. * @param scene defines hosting scene
  32358. */
  32359. constructor(scene: Scene);
  32360. /**
  32361. * Get the number of data values you will have to play with for the visualization
  32362. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  32363. * @returns a number
  32364. */
  32365. getFrequencyBinCount(): number;
  32366. /**
  32367. * Gets the current frequency data as a byte array
  32368. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32369. * @returns a Uint8Array
  32370. */
  32371. getByteFrequencyData(): Uint8Array;
  32372. /**
  32373. * Gets the current waveform as a byte array
  32374. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  32375. * @returns a Uint8Array
  32376. */
  32377. getByteTimeDomainData(): Uint8Array;
  32378. /**
  32379. * Gets the current frequency data as a float array
  32380. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32381. * @returns a Float32Array
  32382. */
  32383. getFloatFrequencyData(): Float32Array;
  32384. /**
  32385. * Renders the debug canvas
  32386. */
  32387. drawDebugCanvas(): void;
  32388. /**
  32389. * Stops rendering the debug canvas and removes it
  32390. */
  32391. stopDebugCanvas(): void;
  32392. /**
  32393. * Connects two audio nodes
  32394. * @param inputAudioNode defines first node to connect
  32395. * @param outputAudioNode defines second node to connect
  32396. */
  32397. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  32398. /**
  32399. * Releases all associated resources
  32400. */
  32401. dispose(): void;
  32402. }
  32403. }
  32404. declare module BABYLON {
  32405. /**
  32406. * This represents an audio engine and it is responsible
  32407. * to play, synchronize and analyse sounds throughout the application.
  32408. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32409. */
  32410. export interface IAudioEngine extends IDisposable {
  32411. /**
  32412. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32413. */
  32414. readonly canUseWebAudio: boolean;
  32415. /**
  32416. * Gets the current AudioContext if available.
  32417. */
  32418. readonly audioContext: Nullable<AudioContext>;
  32419. /**
  32420. * The master gain node defines the global audio volume of your audio engine.
  32421. */
  32422. readonly masterGain: GainNode;
  32423. /**
  32424. * Gets whether or not mp3 are supported by your browser.
  32425. */
  32426. readonly isMP3supported: boolean;
  32427. /**
  32428. * Gets whether or not ogg are supported by your browser.
  32429. */
  32430. readonly isOGGsupported: boolean;
  32431. /**
  32432. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32433. * @ignoreNaming
  32434. */
  32435. WarnedWebAudioUnsupported: boolean;
  32436. /**
  32437. * Defines if the audio engine relies on a custom unlocked button.
  32438. * In this case, the embedded button will not be displayed.
  32439. */
  32440. useCustomUnlockedButton: boolean;
  32441. /**
  32442. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  32443. */
  32444. readonly unlocked: boolean;
  32445. /**
  32446. * Event raised when audio has been unlocked on the browser.
  32447. */
  32448. onAudioUnlockedObservable: Observable<AudioEngine>;
  32449. /**
  32450. * Event raised when audio has been locked on the browser.
  32451. */
  32452. onAudioLockedObservable: Observable<AudioEngine>;
  32453. /**
  32454. * Flags the audio engine in Locked state.
  32455. * This happens due to new browser policies preventing audio to autoplay.
  32456. */
  32457. lock(): void;
  32458. /**
  32459. * Unlocks the audio engine once a user action has been done on the dom.
  32460. * This is helpful to resume play once browser policies have been satisfied.
  32461. */
  32462. unlock(): void;
  32463. }
  32464. /**
  32465. * This represents the default audio engine used in babylon.
  32466. * It is responsible to play, synchronize and analyse sounds throughout the application.
  32467. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32468. */
  32469. export class AudioEngine implements IAudioEngine {
  32470. private _audioContext;
  32471. private _audioContextInitialized;
  32472. private _muteButton;
  32473. private _hostElement;
  32474. /**
  32475. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32476. */
  32477. canUseWebAudio: boolean;
  32478. /**
  32479. * The master gain node defines the global audio volume of your audio engine.
  32480. */
  32481. masterGain: GainNode;
  32482. /**
  32483. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32484. * @ignoreNaming
  32485. */
  32486. WarnedWebAudioUnsupported: boolean;
  32487. /**
  32488. * Gets whether or not mp3 are supported by your browser.
  32489. */
  32490. isMP3supported: boolean;
  32491. /**
  32492. * Gets whether or not ogg are supported by your browser.
  32493. */
  32494. isOGGsupported: boolean;
  32495. /**
  32496. * Gets whether audio has been unlocked on the device.
  32497. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  32498. * a user interaction has happened.
  32499. */
  32500. unlocked: boolean;
  32501. /**
  32502. * Defines if the audio engine relies on a custom unlocked button.
  32503. * In this case, the embedded button will not be displayed.
  32504. */
  32505. useCustomUnlockedButton: boolean;
  32506. /**
  32507. * Event raised when audio has been unlocked on the browser.
  32508. */
  32509. onAudioUnlockedObservable: Observable<AudioEngine>;
  32510. /**
  32511. * Event raised when audio has been locked on the browser.
  32512. */
  32513. onAudioLockedObservable: Observable<AudioEngine>;
  32514. /**
  32515. * Gets the current AudioContext if available.
  32516. */
  32517. get audioContext(): Nullable<AudioContext>;
  32518. private _connectedAnalyser;
  32519. /**
  32520. * Instantiates a new audio engine.
  32521. *
  32522. * There should be only one per page as some browsers restrict the number
  32523. * of audio contexts you can create.
  32524. * @param hostElement defines the host element where to display the mute icon if necessary
  32525. */
  32526. constructor(hostElement?: Nullable<HTMLElement>);
  32527. /**
  32528. * Flags the audio engine in Locked state.
  32529. * This happens due to new browser policies preventing audio to autoplay.
  32530. */
  32531. lock(): void;
  32532. /**
  32533. * Unlocks the audio engine once a user action has been done on the dom.
  32534. * This is helpful to resume play once browser policies have been satisfied.
  32535. */
  32536. unlock(): void;
  32537. private _resumeAudioContext;
  32538. private _initializeAudioContext;
  32539. private _tryToRun;
  32540. private _triggerRunningState;
  32541. private _triggerSuspendedState;
  32542. private _displayMuteButton;
  32543. private _moveButtonToTopLeft;
  32544. private _onResize;
  32545. private _hideMuteButton;
  32546. /**
  32547. * Destroy and release the resources associated with the audio ccontext.
  32548. */
  32549. dispose(): void;
  32550. /**
  32551. * Gets the global volume sets on the master gain.
  32552. * @returns the global volume if set or -1 otherwise
  32553. */
  32554. getGlobalVolume(): number;
  32555. /**
  32556. * Sets the global volume of your experience (sets on the master gain).
  32557. * @param newVolume Defines the new global volume of the application
  32558. */
  32559. setGlobalVolume(newVolume: number): void;
  32560. /**
  32561. * Connect the audio engine to an audio analyser allowing some amazing
  32562. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  32563. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  32564. * @param analyser The analyser to connect to the engine
  32565. */
  32566. connectToAnalyser(analyser: Analyser): void;
  32567. }
  32568. }
  32569. declare module BABYLON {
  32570. /**
  32571. * Interface used to present a loading screen while loading a scene
  32572. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32573. */
  32574. export interface ILoadingScreen {
  32575. /**
  32576. * Function called to display the loading screen
  32577. */
  32578. displayLoadingUI: () => void;
  32579. /**
  32580. * Function called to hide the loading screen
  32581. */
  32582. hideLoadingUI: () => void;
  32583. /**
  32584. * Gets or sets the color to use for the background
  32585. */
  32586. loadingUIBackgroundColor: string;
  32587. /**
  32588. * Gets or sets the text to display while loading
  32589. */
  32590. loadingUIText: string;
  32591. }
  32592. /**
  32593. * Class used for the default loading screen
  32594. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32595. */
  32596. export class DefaultLoadingScreen implements ILoadingScreen {
  32597. private _renderingCanvas;
  32598. private _loadingText;
  32599. private _loadingDivBackgroundColor;
  32600. private _loadingDiv;
  32601. private _loadingTextDiv;
  32602. /** Gets or sets the logo url to use for the default loading screen */
  32603. static DefaultLogoUrl: string;
  32604. /** Gets or sets the spinner url to use for the default loading screen */
  32605. static DefaultSpinnerUrl: string;
  32606. /**
  32607. * Creates a new default loading screen
  32608. * @param _renderingCanvas defines the canvas used to render the scene
  32609. * @param _loadingText defines the default text to display
  32610. * @param _loadingDivBackgroundColor defines the default background color
  32611. */
  32612. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  32613. /**
  32614. * Function called to display the loading screen
  32615. */
  32616. displayLoadingUI(): void;
  32617. /**
  32618. * Function called to hide the loading screen
  32619. */
  32620. hideLoadingUI(): void;
  32621. /**
  32622. * Gets or sets the text to display while loading
  32623. */
  32624. set loadingUIText(text: string);
  32625. get loadingUIText(): string;
  32626. /**
  32627. * Gets or sets the color to use for the background
  32628. */
  32629. get loadingUIBackgroundColor(): string;
  32630. set loadingUIBackgroundColor(color: string);
  32631. private _resizeLoadingUI;
  32632. }
  32633. }
  32634. declare module BABYLON {
  32635. /**
  32636. * Interface for any object that can request an animation frame
  32637. */
  32638. export interface ICustomAnimationFrameRequester {
  32639. /**
  32640. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  32641. */
  32642. renderFunction?: Function;
  32643. /**
  32644. * Called to request the next frame to render to
  32645. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  32646. */
  32647. requestAnimationFrame: Function;
  32648. /**
  32649. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  32650. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  32651. */
  32652. requestID?: number;
  32653. }
  32654. }
  32655. declare module BABYLON {
  32656. /**
  32657. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  32658. */
  32659. export class PerformanceMonitor {
  32660. private _enabled;
  32661. private _rollingFrameTime;
  32662. private _lastFrameTimeMs;
  32663. /**
  32664. * constructor
  32665. * @param frameSampleSize The number of samples required to saturate the sliding window
  32666. */
  32667. constructor(frameSampleSize?: number);
  32668. /**
  32669. * Samples current frame
  32670. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  32671. */
  32672. sampleFrame(timeMs?: number): void;
  32673. /**
  32674. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32675. */
  32676. get averageFrameTime(): number;
  32677. /**
  32678. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32679. */
  32680. get averageFrameTimeVariance(): number;
  32681. /**
  32682. * Returns the frame time of the most recent frame
  32683. */
  32684. get instantaneousFrameTime(): number;
  32685. /**
  32686. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  32687. */
  32688. get averageFPS(): number;
  32689. /**
  32690. * Returns the average framerate in frames per second using the most recent frame time
  32691. */
  32692. get instantaneousFPS(): number;
  32693. /**
  32694. * Returns true if enough samples have been taken to completely fill the sliding window
  32695. */
  32696. get isSaturated(): boolean;
  32697. /**
  32698. * Enables contributions to the sliding window sample set
  32699. */
  32700. enable(): void;
  32701. /**
  32702. * Disables contributions to the sliding window sample set
  32703. * Samples will not be interpolated over the disabled period
  32704. */
  32705. disable(): void;
  32706. /**
  32707. * Returns true if sampling is enabled
  32708. */
  32709. get isEnabled(): boolean;
  32710. /**
  32711. * Resets performance monitor
  32712. */
  32713. reset(): void;
  32714. }
  32715. /**
  32716. * RollingAverage
  32717. *
  32718. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  32719. */
  32720. export class RollingAverage {
  32721. /**
  32722. * Current average
  32723. */
  32724. average: number;
  32725. /**
  32726. * Current variance
  32727. */
  32728. variance: number;
  32729. protected _samples: Array<number>;
  32730. protected _sampleCount: number;
  32731. protected _pos: number;
  32732. protected _m2: number;
  32733. /**
  32734. * constructor
  32735. * @param length The number of samples required to saturate the sliding window
  32736. */
  32737. constructor(length: number);
  32738. /**
  32739. * Adds a sample to the sample set
  32740. * @param v The sample value
  32741. */
  32742. add(v: number): void;
  32743. /**
  32744. * Returns previously added values or null if outside of history or outside the sliding window domain
  32745. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  32746. * @return Value previously recorded with add() or null if outside of range
  32747. */
  32748. history(i: number): number;
  32749. /**
  32750. * Returns true if enough samples have been taken to completely fill the sliding window
  32751. * @return true if sample-set saturated
  32752. */
  32753. isSaturated(): boolean;
  32754. /**
  32755. * Resets the rolling average (equivalent to 0 samples taken so far)
  32756. */
  32757. reset(): void;
  32758. /**
  32759. * Wraps a value around the sample range boundaries
  32760. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  32761. * @return Wrapped position in sample range
  32762. */
  32763. protected _wrapPosition(i: number): number;
  32764. }
  32765. }
  32766. declare module BABYLON {
  32767. /**
  32768. * This class is used to track a performance counter which is number based.
  32769. * The user has access to many properties which give statistics of different nature.
  32770. *
  32771. * The implementer can track two kinds of Performance Counter: time and count.
  32772. * 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.
  32773. * 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.
  32774. */
  32775. export class PerfCounter {
  32776. /**
  32777. * Gets or sets a global boolean to turn on and off all the counters
  32778. */
  32779. static Enabled: boolean;
  32780. /**
  32781. * Returns the smallest value ever
  32782. */
  32783. get min(): number;
  32784. /**
  32785. * Returns the biggest value ever
  32786. */
  32787. get max(): number;
  32788. /**
  32789. * Returns the average value since the performance counter is running
  32790. */
  32791. get average(): number;
  32792. /**
  32793. * Returns the average value of the last second the counter was monitored
  32794. */
  32795. get lastSecAverage(): number;
  32796. /**
  32797. * Returns the current value
  32798. */
  32799. get current(): number;
  32800. /**
  32801. * Gets the accumulated total
  32802. */
  32803. get total(): number;
  32804. /**
  32805. * Gets the total value count
  32806. */
  32807. get count(): number;
  32808. /**
  32809. * Creates a new counter
  32810. */
  32811. constructor();
  32812. /**
  32813. * Call this method to start monitoring a new frame.
  32814. * 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.
  32815. */
  32816. fetchNewFrame(): void;
  32817. /**
  32818. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32819. * @param newCount the count value to add to the monitored count
  32820. * @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.
  32821. */
  32822. addCount(newCount: number, fetchResult: boolean): void;
  32823. /**
  32824. * Start monitoring this performance counter
  32825. */
  32826. beginMonitoring(): void;
  32827. /**
  32828. * Compute the time lapsed since the previous beginMonitoring() call.
  32829. * @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
  32830. */
  32831. endMonitoring(newFrame?: boolean): void;
  32832. private _fetchResult;
  32833. private _startMonitoringTime;
  32834. private _min;
  32835. private _max;
  32836. private _average;
  32837. private _current;
  32838. private _totalValueCount;
  32839. private _totalAccumulated;
  32840. private _lastSecAverage;
  32841. private _lastSecAccumulated;
  32842. private _lastSecTime;
  32843. private _lastSecValueCount;
  32844. }
  32845. }
  32846. declare module BABYLON {
  32847. interface ThinEngine {
  32848. /**
  32849. * Sets alpha constants used by some alpha blending modes
  32850. * @param r defines the red component
  32851. * @param g defines the green component
  32852. * @param b defines the blue component
  32853. * @param a defines the alpha component
  32854. */
  32855. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32856. /**
  32857. * Sets the current alpha mode
  32858. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32859. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32860. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32861. */
  32862. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32863. /**
  32864. * Gets the current alpha mode
  32865. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32866. * @returns the current alpha mode
  32867. */
  32868. getAlphaMode(): number;
  32869. /**
  32870. * Sets the current alpha equation
  32871. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  32872. */
  32873. setAlphaEquation(equation: number): void;
  32874. /**
  32875. * Gets the current alpha equation.
  32876. * @returns the current alpha equation
  32877. */
  32878. getAlphaEquation(): number;
  32879. }
  32880. }
  32881. declare module BABYLON {
  32882. /**
  32883. * Defines the interface used by display changed events
  32884. */
  32885. export interface IDisplayChangedEventArgs {
  32886. /** Gets the vrDisplay object (if any) */
  32887. vrDisplay: Nullable<any>;
  32888. /** Gets a boolean indicating if webVR is supported */
  32889. vrSupported: boolean;
  32890. }
  32891. /**
  32892. * Defines the interface used by objects containing a viewport (like a camera)
  32893. */
  32894. interface IViewportOwnerLike {
  32895. /**
  32896. * Gets or sets the viewport
  32897. */
  32898. viewport: IViewportLike;
  32899. }
  32900. /**
  32901. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  32902. */
  32903. export class Engine extends ThinEngine {
  32904. /** Defines that alpha blending is disabled */
  32905. static readonly ALPHA_DISABLE: number;
  32906. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  32907. static readonly ALPHA_ADD: number;
  32908. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  32909. static readonly ALPHA_COMBINE: number;
  32910. /** Defines that alpha blending to DEST - SRC * DEST */
  32911. static readonly ALPHA_SUBTRACT: number;
  32912. /** Defines that alpha blending to SRC * DEST */
  32913. static readonly ALPHA_MULTIPLY: number;
  32914. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  32915. static readonly ALPHA_MAXIMIZED: number;
  32916. /** Defines that alpha blending to SRC + DEST */
  32917. static readonly ALPHA_ONEONE: number;
  32918. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  32919. static readonly ALPHA_PREMULTIPLIED: number;
  32920. /**
  32921. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  32922. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  32923. */
  32924. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  32925. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  32926. static readonly ALPHA_INTERPOLATE: number;
  32927. /**
  32928. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  32929. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  32930. */
  32931. static readonly ALPHA_SCREENMODE: number;
  32932. /** Defines that the ressource is not delayed*/
  32933. static readonly DELAYLOADSTATE_NONE: number;
  32934. /** Defines that the ressource was successfully delay loaded */
  32935. static readonly DELAYLOADSTATE_LOADED: number;
  32936. /** Defines that the ressource is currently delay loading */
  32937. static readonly DELAYLOADSTATE_LOADING: number;
  32938. /** Defines that the ressource is delayed and has not started loading */
  32939. static readonly DELAYLOADSTATE_NOTLOADED: number;
  32940. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  32941. static readonly NEVER: number;
  32942. /** 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 */
  32943. static readonly ALWAYS: number;
  32944. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  32945. static readonly LESS: number;
  32946. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  32947. static readonly EQUAL: number;
  32948. /** 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 */
  32949. static readonly LEQUAL: number;
  32950. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  32951. static readonly GREATER: number;
  32952. /** 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 */
  32953. static readonly GEQUAL: number;
  32954. /** 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 */
  32955. static readonly NOTEQUAL: number;
  32956. /** Passed to stencilOperation to specify that stencil value must be kept */
  32957. static readonly KEEP: number;
  32958. /** Passed to stencilOperation to specify that stencil value must be replaced */
  32959. static readonly REPLACE: number;
  32960. /** Passed to stencilOperation to specify that stencil value must be incremented */
  32961. static readonly INCR: number;
  32962. /** Passed to stencilOperation to specify that stencil value must be decremented */
  32963. static readonly DECR: number;
  32964. /** Passed to stencilOperation to specify that stencil value must be inverted */
  32965. static readonly INVERT: number;
  32966. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  32967. static readonly INCR_WRAP: number;
  32968. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  32969. static readonly DECR_WRAP: number;
  32970. /** Texture is not repeating outside of 0..1 UVs */
  32971. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  32972. /** Texture is repeating outside of 0..1 UVs */
  32973. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  32974. /** Texture is repeating and mirrored */
  32975. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  32976. /** ALPHA */
  32977. static readonly TEXTUREFORMAT_ALPHA: number;
  32978. /** LUMINANCE */
  32979. static readonly TEXTUREFORMAT_LUMINANCE: number;
  32980. /** LUMINANCE_ALPHA */
  32981. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  32982. /** RGB */
  32983. static readonly TEXTUREFORMAT_RGB: number;
  32984. /** RGBA */
  32985. static readonly TEXTUREFORMAT_RGBA: number;
  32986. /** RED */
  32987. static readonly TEXTUREFORMAT_RED: number;
  32988. /** RED (2nd reference) */
  32989. static readonly TEXTUREFORMAT_R: number;
  32990. /** RG */
  32991. static readonly TEXTUREFORMAT_RG: number;
  32992. /** RED_INTEGER */
  32993. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  32994. /** RED_INTEGER (2nd reference) */
  32995. static readonly TEXTUREFORMAT_R_INTEGER: number;
  32996. /** RG_INTEGER */
  32997. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  32998. /** RGB_INTEGER */
  32999. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  33000. /** RGBA_INTEGER */
  33001. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  33002. /** UNSIGNED_BYTE */
  33003. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  33004. /** UNSIGNED_BYTE (2nd reference) */
  33005. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  33006. /** FLOAT */
  33007. static readonly TEXTURETYPE_FLOAT: number;
  33008. /** HALF_FLOAT */
  33009. static readonly TEXTURETYPE_HALF_FLOAT: number;
  33010. /** BYTE */
  33011. static readonly TEXTURETYPE_BYTE: number;
  33012. /** SHORT */
  33013. static readonly TEXTURETYPE_SHORT: number;
  33014. /** UNSIGNED_SHORT */
  33015. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  33016. /** INT */
  33017. static readonly TEXTURETYPE_INT: number;
  33018. /** UNSIGNED_INT */
  33019. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  33020. /** UNSIGNED_SHORT_4_4_4_4 */
  33021. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  33022. /** UNSIGNED_SHORT_5_5_5_1 */
  33023. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  33024. /** UNSIGNED_SHORT_5_6_5 */
  33025. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  33026. /** UNSIGNED_INT_2_10_10_10_REV */
  33027. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  33028. /** UNSIGNED_INT_24_8 */
  33029. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  33030. /** UNSIGNED_INT_10F_11F_11F_REV */
  33031. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  33032. /** UNSIGNED_INT_5_9_9_9_REV */
  33033. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  33034. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  33035. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  33036. /** nearest is mag = nearest and min = nearest and mip = linear */
  33037. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  33038. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33039. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  33040. /** Trilinear is mag = linear and min = linear and mip = linear */
  33041. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  33042. /** nearest is mag = nearest and min = nearest and mip = linear */
  33043. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  33044. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33045. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  33046. /** Trilinear is mag = linear and min = linear and mip = linear */
  33047. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  33048. /** mag = nearest and min = nearest and mip = nearest */
  33049. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  33050. /** mag = nearest and min = linear and mip = nearest */
  33051. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  33052. /** mag = nearest and min = linear and mip = linear */
  33053. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  33054. /** mag = nearest and min = linear and mip = none */
  33055. static readonly TEXTURE_NEAREST_LINEAR: number;
  33056. /** mag = nearest and min = nearest and mip = none */
  33057. static readonly TEXTURE_NEAREST_NEAREST: number;
  33058. /** mag = linear and min = nearest and mip = nearest */
  33059. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  33060. /** mag = linear and min = nearest and mip = linear */
  33061. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  33062. /** mag = linear and min = linear and mip = none */
  33063. static readonly TEXTURE_LINEAR_LINEAR: number;
  33064. /** mag = linear and min = nearest and mip = none */
  33065. static readonly TEXTURE_LINEAR_NEAREST: number;
  33066. /** Explicit coordinates mode */
  33067. static readonly TEXTURE_EXPLICIT_MODE: number;
  33068. /** Spherical coordinates mode */
  33069. static readonly TEXTURE_SPHERICAL_MODE: number;
  33070. /** Planar coordinates mode */
  33071. static readonly TEXTURE_PLANAR_MODE: number;
  33072. /** Cubic coordinates mode */
  33073. static readonly TEXTURE_CUBIC_MODE: number;
  33074. /** Projection coordinates mode */
  33075. static readonly TEXTURE_PROJECTION_MODE: number;
  33076. /** Skybox coordinates mode */
  33077. static readonly TEXTURE_SKYBOX_MODE: number;
  33078. /** Inverse Cubic coordinates mode */
  33079. static readonly TEXTURE_INVCUBIC_MODE: number;
  33080. /** Equirectangular coordinates mode */
  33081. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  33082. /** Equirectangular Fixed coordinates mode */
  33083. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  33084. /** Equirectangular Fixed Mirrored coordinates mode */
  33085. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  33086. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  33087. static readonly SCALEMODE_FLOOR: number;
  33088. /** Defines that texture rescaling will look for the nearest power of 2 size */
  33089. static readonly SCALEMODE_NEAREST: number;
  33090. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  33091. static readonly SCALEMODE_CEILING: number;
  33092. /**
  33093. * Returns the current npm package of the sdk
  33094. */
  33095. static get NpmPackage(): string;
  33096. /**
  33097. * Returns the current version of the framework
  33098. */
  33099. static get Version(): string;
  33100. /** Gets the list of created engines */
  33101. static get Instances(): Engine[];
  33102. /**
  33103. * Gets the latest created engine
  33104. */
  33105. static get LastCreatedEngine(): Nullable<Engine>;
  33106. /**
  33107. * Gets the latest created scene
  33108. */
  33109. static get LastCreatedScene(): Nullable<Scene>;
  33110. /**
  33111. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  33112. * @param flag defines which part of the materials must be marked as dirty
  33113. * @param predicate defines a predicate used to filter which materials should be affected
  33114. */
  33115. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33116. /**
  33117. * Method called to create the default loading screen.
  33118. * This can be overriden in your own app.
  33119. * @param canvas The rendering canvas element
  33120. * @returns The loading screen
  33121. */
  33122. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  33123. /**
  33124. * Method called to create the default rescale post process on each engine.
  33125. */
  33126. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  33127. /**
  33128. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  33129. **/
  33130. enableOfflineSupport: boolean;
  33131. /**
  33132. * 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)
  33133. **/
  33134. disableManifestCheck: boolean;
  33135. /**
  33136. * Gets the list of created scenes
  33137. */
  33138. scenes: Scene[];
  33139. /**
  33140. * Event raised when a new scene is created
  33141. */
  33142. onNewSceneAddedObservable: Observable<Scene>;
  33143. /**
  33144. * Gets the list of created postprocesses
  33145. */
  33146. postProcesses: PostProcess[];
  33147. /**
  33148. * Gets a boolean indicating if the pointer is currently locked
  33149. */
  33150. isPointerLock: boolean;
  33151. /**
  33152. * Observable event triggered each time the rendering canvas is resized
  33153. */
  33154. onResizeObservable: Observable<Engine>;
  33155. /**
  33156. * Observable event triggered each time the canvas loses focus
  33157. */
  33158. onCanvasBlurObservable: Observable<Engine>;
  33159. /**
  33160. * Observable event triggered each time the canvas gains focus
  33161. */
  33162. onCanvasFocusObservable: Observable<Engine>;
  33163. /**
  33164. * Observable event triggered each time the canvas receives pointerout event
  33165. */
  33166. onCanvasPointerOutObservable: Observable<PointerEvent>;
  33167. /**
  33168. * Observable raised when the engine begins a new frame
  33169. */
  33170. onBeginFrameObservable: Observable<Engine>;
  33171. /**
  33172. * If set, will be used to request the next animation frame for the render loop
  33173. */
  33174. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  33175. /**
  33176. * Observable raised when the engine ends the current frame
  33177. */
  33178. onEndFrameObservable: Observable<Engine>;
  33179. /**
  33180. * Observable raised when the engine is about to compile a shader
  33181. */
  33182. onBeforeShaderCompilationObservable: Observable<Engine>;
  33183. /**
  33184. * Observable raised when the engine has jsut compiled a shader
  33185. */
  33186. onAfterShaderCompilationObservable: Observable<Engine>;
  33187. /**
  33188. * Gets the audio engine
  33189. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33190. * @ignorenaming
  33191. */
  33192. static audioEngine: IAudioEngine;
  33193. /**
  33194. * Default AudioEngine factory responsible of creating the Audio Engine.
  33195. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  33196. */
  33197. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  33198. /**
  33199. * Default offline support factory responsible of creating a tool used to store data locally.
  33200. * By default, this will create a Database object if the workload has been embedded.
  33201. */
  33202. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  33203. private _loadingScreen;
  33204. private _pointerLockRequested;
  33205. private _dummyFramebuffer;
  33206. private _rescalePostProcess;
  33207. private _deterministicLockstep;
  33208. private _lockstepMaxSteps;
  33209. private _timeStep;
  33210. protected get _supportsHardwareTextureRescaling(): boolean;
  33211. private _fps;
  33212. private _deltaTime;
  33213. /** @hidden */
  33214. _drawCalls: PerfCounter;
  33215. /**
  33216. * Turn this value on if you want to pause FPS computation when in background
  33217. */
  33218. disablePerformanceMonitorInBackground: boolean;
  33219. private _performanceMonitor;
  33220. /**
  33221. * Gets the performance monitor attached to this engine
  33222. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  33223. */
  33224. get performanceMonitor(): PerformanceMonitor;
  33225. private _onFocus;
  33226. private _onBlur;
  33227. private _onCanvasPointerOut;
  33228. private _onCanvasBlur;
  33229. private _onCanvasFocus;
  33230. private _onFullscreenChange;
  33231. private _onPointerLockChange;
  33232. /**
  33233. * Gets the HTML element used to attach event listeners
  33234. * @returns a HTML element
  33235. */
  33236. getInputElement(): Nullable<HTMLElement>;
  33237. /**
  33238. * Creates a new engine
  33239. * @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
  33240. * @param antialias defines enable antialiasing (default: false)
  33241. * @param options defines further options to be sent to the getContext() function
  33242. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  33243. */
  33244. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  33245. /**
  33246. * Gets current aspect ratio
  33247. * @param viewportOwner defines the camera to use to get the aspect ratio
  33248. * @param useScreen defines if screen size must be used (or the current render target if any)
  33249. * @returns a number defining the aspect ratio
  33250. */
  33251. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  33252. /**
  33253. * Gets current screen aspect ratio
  33254. * @returns a number defining the aspect ratio
  33255. */
  33256. getScreenAspectRatio(): number;
  33257. /**
  33258. * Gets the client rect of the HTML canvas attached with the current webGL context
  33259. * @returns a client rectanglee
  33260. */
  33261. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  33262. /**
  33263. * Gets the client rect of the HTML element used for events
  33264. * @returns a client rectanglee
  33265. */
  33266. getInputElementClientRect(): Nullable<ClientRect>;
  33267. /**
  33268. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  33269. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33270. * @returns true if engine is in deterministic lock step mode
  33271. */
  33272. isDeterministicLockStep(): boolean;
  33273. /**
  33274. * Gets the max steps when engine is running in deterministic lock step
  33275. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33276. * @returns the max steps
  33277. */
  33278. getLockstepMaxSteps(): number;
  33279. /**
  33280. * Returns the time in ms between steps when using deterministic lock step.
  33281. * @returns time step in (ms)
  33282. */
  33283. getTimeStep(): number;
  33284. /**
  33285. * Force the mipmap generation for the given render target texture
  33286. * @param texture defines the render target texture to use
  33287. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  33288. */
  33289. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  33290. /** States */
  33291. /**
  33292. * Set various states to the webGL context
  33293. * @param culling defines backface culling state
  33294. * @param zOffset defines the value to apply to zOffset (0 by default)
  33295. * @param force defines if states must be applied even if cache is up to date
  33296. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  33297. */
  33298. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  33299. /**
  33300. * Set the z offset to apply to current rendering
  33301. * @param value defines the offset to apply
  33302. */
  33303. setZOffset(value: number): void;
  33304. /**
  33305. * Gets the current value of the zOffset
  33306. * @returns the current zOffset state
  33307. */
  33308. getZOffset(): number;
  33309. /**
  33310. * Enable or disable depth buffering
  33311. * @param enable defines the state to set
  33312. */
  33313. setDepthBuffer(enable: boolean): void;
  33314. /**
  33315. * Gets a boolean indicating if depth writing is enabled
  33316. * @returns the current depth writing state
  33317. */
  33318. getDepthWrite(): boolean;
  33319. /**
  33320. * Enable or disable depth writing
  33321. * @param enable defines the state to set
  33322. */
  33323. setDepthWrite(enable: boolean): void;
  33324. /**
  33325. * Gets a boolean indicating if stencil buffer is enabled
  33326. * @returns the current stencil buffer state
  33327. */
  33328. getStencilBuffer(): boolean;
  33329. /**
  33330. * Enable or disable the stencil buffer
  33331. * @param enable defines if the stencil buffer must be enabled or disabled
  33332. */
  33333. setStencilBuffer(enable: boolean): void;
  33334. /**
  33335. * Gets the current stencil mask
  33336. * @returns a number defining the new stencil mask to use
  33337. */
  33338. getStencilMask(): number;
  33339. /**
  33340. * Sets the current stencil mask
  33341. * @param mask defines the new stencil mask to use
  33342. */
  33343. setStencilMask(mask: number): void;
  33344. /**
  33345. * Gets the current stencil function
  33346. * @returns a number defining the stencil function to use
  33347. */
  33348. getStencilFunction(): number;
  33349. /**
  33350. * Gets the current stencil reference value
  33351. * @returns a number defining the stencil reference value to use
  33352. */
  33353. getStencilFunctionReference(): number;
  33354. /**
  33355. * Gets the current stencil mask
  33356. * @returns a number defining the stencil mask to use
  33357. */
  33358. getStencilFunctionMask(): number;
  33359. /**
  33360. * Sets the current stencil function
  33361. * @param stencilFunc defines the new stencil function to use
  33362. */
  33363. setStencilFunction(stencilFunc: number): void;
  33364. /**
  33365. * Sets the current stencil reference
  33366. * @param reference defines the new stencil reference to use
  33367. */
  33368. setStencilFunctionReference(reference: number): void;
  33369. /**
  33370. * Sets the current stencil mask
  33371. * @param mask defines the new stencil mask to use
  33372. */
  33373. setStencilFunctionMask(mask: number): void;
  33374. /**
  33375. * Gets the current stencil operation when stencil fails
  33376. * @returns a number defining stencil operation to use when stencil fails
  33377. */
  33378. getStencilOperationFail(): number;
  33379. /**
  33380. * Gets the current stencil operation when depth fails
  33381. * @returns a number defining stencil operation to use when depth fails
  33382. */
  33383. getStencilOperationDepthFail(): number;
  33384. /**
  33385. * Gets the current stencil operation when stencil passes
  33386. * @returns a number defining stencil operation to use when stencil passes
  33387. */
  33388. getStencilOperationPass(): number;
  33389. /**
  33390. * Sets the stencil operation to use when stencil fails
  33391. * @param operation defines the stencil operation to use when stencil fails
  33392. */
  33393. setStencilOperationFail(operation: number): void;
  33394. /**
  33395. * Sets the stencil operation to use when depth fails
  33396. * @param operation defines the stencil operation to use when depth fails
  33397. */
  33398. setStencilOperationDepthFail(operation: number): void;
  33399. /**
  33400. * Sets the stencil operation to use when stencil passes
  33401. * @param operation defines the stencil operation to use when stencil passes
  33402. */
  33403. setStencilOperationPass(operation: number): void;
  33404. /**
  33405. * Sets a boolean indicating if the dithering state is enabled or disabled
  33406. * @param value defines the dithering state
  33407. */
  33408. setDitheringState(value: boolean): void;
  33409. /**
  33410. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  33411. * @param value defines the rasterizer state
  33412. */
  33413. setRasterizerState(value: boolean): void;
  33414. /**
  33415. * Gets the current depth function
  33416. * @returns a number defining the depth function
  33417. */
  33418. getDepthFunction(): Nullable<number>;
  33419. /**
  33420. * Sets the current depth function
  33421. * @param depthFunc defines the function to use
  33422. */
  33423. setDepthFunction(depthFunc: number): void;
  33424. /**
  33425. * Sets the current depth function to GREATER
  33426. */
  33427. setDepthFunctionToGreater(): void;
  33428. /**
  33429. * Sets the current depth function to GEQUAL
  33430. */
  33431. setDepthFunctionToGreaterOrEqual(): void;
  33432. /**
  33433. * Sets the current depth function to LESS
  33434. */
  33435. setDepthFunctionToLess(): void;
  33436. /**
  33437. * Sets the current depth function to LEQUAL
  33438. */
  33439. setDepthFunctionToLessOrEqual(): void;
  33440. private _cachedStencilBuffer;
  33441. private _cachedStencilFunction;
  33442. private _cachedStencilMask;
  33443. private _cachedStencilOperationPass;
  33444. private _cachedStencilOperationFail;
  33445. private _cachedStencilOperationDepthFail;
  33446. private _cachedStencilReference;
  33447. /**
  33448. * Caches the the state of the stencil buffer
  33449. */
  33450. cacheStencilState(): void;
  33451. /**
  33452. * Restores the state of the stencil buffer
  33453. */
  33454. restoreStencilState(): void;
  33455. /**
  33456. * Directly set the WebGL Viewport
  33457. * @param x defines the x coordinate of the viewport (in screen space)
  33458. * @param y defines the y coordinate of the viewport (in screen space)
  33459. * @param width defines the width of the viewport (in screen space)
  33460. * @param height defines the height of the viewport (in screen space)
  33461. * @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
  33462. */
  33463. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  33464. /**
  33465. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  33466. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33467. * @param y defines the y-coordinate of the corner of the clear rectangle
  33468. * @param width defines the width of the clear rectangle
  33469. * @param height defines the height of the clear rectangle
  33470. * @param clearColor defines the clear color
  33471. */
  33472. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  33473. /**
  33474. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  33475. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33476. * @param y defines the y-coordinate of the corner of the clear rectangle
  33477. * @param width defines the width of the clear rectangle
  33478. * @param height defines the height of the clear rectangle
  33479. */
  33480. enableScissor(x: number, y: number, width: number, height: number): void;
  33481. /**
  33482. * Disable previously set scissor test rectangle
  33483. */
  33484. disableScissor(): void;
  33485. protected _reportDrawCall(): void;
  33486. /**
  33487. * Initializes a webVR display and starts listening to display change events
  33488. * The onVRDisplayChangedObservable will be notified upon these changes
  33489. * @returns The onVRDisplayChangedObservable
  33490. */
  33491. initWebVR(): Observable<IDisplayChangedEventArgs>;
  33492. /** @hidden */
  33493. _prepareVRComponent(): void;
  33494. /** @hidden */
  33495. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  33496. /** @hidden */
  33497. _submitVRFrame(): void;
  33498. /**
  33499. * Call this function to leave webVR mode
  33500. * Will do nothing if webVR is not supported or if there is no webVR device
  33501. * @see http://doc.babylonjs.com/how_to/webvr_camera
  33502. */
  33503. disableVR(): void;
  33504. /**
  33505. * Gets a boolean indicating that the system is in VR mode and is presenting
  33506. * @returns true if VR mode is engaged
  33507. */
  33508. isVRPresenting(): boolean;
  33509. /** @hidden */
  33510. _requestVRFrame(): void;
  33511. /** @hidden */
  33512. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33513. /**
  33514. * Gets the source code of the vertex shader associated with a specific webGL program
  33515. * @param program defines the program to use
  33516. * @returns a string containing the source code of the vertex shader associated with the program
  33517. */
  33518. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  33519. /**
  33520. * Gets the source code of the fragment shader associated with a specific webGL program
  33521. * @param program defines the program to use
  33522. * @returns a string containing the source code of the fragment shader associated with the program
  33523. */
  33524. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  33525. /**
  33526. * Sets a depth stencil texture from a render target to the according uniform.
  33527. * @param channel The texture channel
  33528. * @param uniform The uniform to set
  33529. * @param texture The render target texture containing the depth stencil texture to apply
  33530. */
  33531. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  33532. /**
  33533. * Sets a texture to the webGL context from a postprocess
  33534. * @param channel defines the channel to use
  33535. * @param postProcess defines the source postprocess
  33536. */
  33537. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  33538. /**
  33539. * Binds the output of the passed in post process to the texture channel specified
  33540. * @param channel The channel the texture should be bound to
  33541. * @param postProcess The post process which's output should be bound
  33542. */
  33543. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  33544. /** @hidden */
  33545. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  33546. protected _rebuildBuffers(): void;
  33547. /** @hidden */
  33548. _renderFrame(): void;
  33549. _renderLoop(): void;
  33550. /** @hidden */
  33551. _renderViews(): boolean;
  33552. /**
  33553. * Toggle full screen mode
  33554. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33555. */
  33556. switchFullscreen(requestPointerLock: boolean): void;
  33557. /**
  33558. * Enters full screen mode
  33559. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33560. */
  33561. enterFullscreen(requestPointerLock: boolean): void;
  33562. /**
  33563. * Exits full screen mode
  33564. */
  33565. exitFullscreen(): void;
  33566. /**
  33567. * Enters Pointerlock mode
  33568. */
  33569. enterPointerlock(): void;
  33570. /**
  33571. * Exits Pointerlock mode
  33572. */
  33573. exitPointerlock(): void;
  33574. /**
  33575. * Begin a new frame
  33576. */
  33577. beginFrame(): void;
  33578. /**
  33579. * Enf the current frame
  33580. */
  33581. endFrame(): void;
  33582. resize(): void;
  33583. /**
  33584. * Set the compressed texture format to use, based on the formats you have, and the formats
  33585. * supported by the hardware / browser.
  33586. *
  33587. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  33588. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  33589. * to API arguments needed to compressed textures. This puts the burden on the container
  33590. * generator to house the arcane code for determining these for current & future formats.
  33591. *
  33592. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  33593. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  33594. *
  33595. * Note: The result of this call is not taken into account when a texture is base64.
  33596. *
  33597. * @param formatsAvailable defines the list of those format families you have created
  33598. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  33599. *
  33600. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  33601. * @returns The extension selected.
  33602. */
  33603. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  33604. /**
  33605. * Set the compressed texture extensions or file names to skip.
  33606. *
  33607. * @param skippedFiles defines the list of those texture files you want to skip
  33608. * Example: [".dds", ".env", "myfile.png"]
  33609. */
  33610. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  33611. /**
  33612. * Force a specific size of the canvas
  33613. * @param width defines the new canvas' width
  33614. * @param height defines the new canvas' height
  33615. */
  33616. setSize(width: number, height: number): void;
  33617. /**
  33618. * Updates a dynamic vertex buffer.
  33619. * @param vertexBuffer the vertex buffer to update
  33620. * @param data the data used to update the vertex buffer
  33621. * @param byteOffset the byte offset of the data
  33622. * @param byteLength the byte length of the data
  33623. */
  33624. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  33625. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  33626. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33627. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33628. _releaseTexture(texture: InternalTexture): void;
  33629. /**
  33630. * @hidden
  33631. * Rescales a texture
  33632. * @param source input texutre
  33633. * @param destination destination texture
  33634. * @param scene scene to use to render the resize
  33635. * @param internalFormat format to use when resizing
  33636. * @param onComplete callback to be called when resize has completed
  33637. */
  33638. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  33639. /**
  33640. * Gets the current framerate
  33641. * @returns a number representing the framerate
  33642. */
  33643. getFps(): number;
  33644. /**
  33645. * Gets the time spent between current and previous frame
  33646. * @returns a number representing the delta time in ms
  33647. */
  33648. getDeltaTime(): number;
  33649. private _measureFps;
  33650. /** @hidden */
  33651. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  33652. /**
  33653. * Update a dynamic index buffer
  33654. * @param indexBuffer defines the target index buffer
  33655. * @param indices defines the data to update
  33656. * @param offset defines the offset in the target index buffer where update should start
  33657. */
  33658. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  33659. /**
  33660. * Updates the sample count of a render target texture
  33661. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  33662. * @param texture defines the texture to update
  33663. * @param samples defines the sample count to set
  33664. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  33665. */
  33666. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  33667. /**
  33668. * Updates a depth texture Comparison Mode and Function.
  33669. * If the comparison Function is equal to 0, the mode will be set to none.
  33670. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  33671. * @param texture The texture to set the comparison function for
  33672. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  33673. */
  33674. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  33675. /**
  33676. * Creates a webGL buffer to use with instanciation
  33677. * @param capacity defines the size of the buffer
  33678. * @returns the webGL buffer
  33679. */
  33680. createInstancesBuffer(capacity: number): DataBuffer;
  33681. /**
  33682. * Delete a webGL buffer used with instanciation
  33683. * @param buffer defines the webGL buffer to delete
  33684. */
  33685. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  33686. /** @hidden */
  33687. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  33688. dispose(): void;
  33689. private _disableTouchAction;
  33690. /**
  33691. * Display the loading screen
  33692. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33693. */
  33694. displayLoadingUI(): void;
  33695. /**
  33696. * Hide the loading screen
  33697. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33698. */
  33699. hideLoadingUI(): void;
  33700. /**
  33701. * Gets the current loading screen object
  33702. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33703. */
  33704. get loadingScreen(): ILoadingScreen;
  33705. /**
  33706. * Sets the current loading screen object
  33707. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33708. */
  33709. set loadingScreen(loadingScreen: ILoadingScreen);
  33710. /**
  33711. * Sets the current loading screen text
  33712. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33713. */
  33714. set loadingUIText(text: string);
  33715. /**
  33716. * Sets the current loading screen background color
  33717. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33718. */
  33719. set loadingUIBackgroundColor(color: string);
  33720. /** Pointerlock and fullscreen */
  33721. /**
  33722. * Ask the browser to promote the current element to pointerlock mode
  33723. * @param element defines the DOM element to promote
  33724. */
  33725. static _RequestPointerlock(element: HTMLElement): void;
  33726. /**
  33727. * Asks the browser to exit pointerlock mode
  33728. */
  33729. static _ExitPointerlock(): void;
  33730. /**
  33731. * Ask the browser to promote the current element to fullscreen rendering mode
  33732. * @param element defines the DOM element to promote
  33733. */
  33734. static _RequestFullscreen(element: HTMLElement): void;
  33735. /**
  33736. * Asks the browser to exit fullscreen mode
  33737. */
  33738. static _ExitFullscreen(): void;
  33739. }
  33740. }
  33741. declare module BABYLON {
  33742. /**
  33743. * The engine store class is responsible to hold all the instances of Engine and Scene created
  33744. * during the life time of the application.
  33745. */
  33746. export class EngineStore {
  33747. /** Gets the list of created engines */
  33748. static Instances: Engine[];
  33749. /** @hidden */
  33750. static _LastCreatedScene: Nullable<Scene>;
  33751. /**
  33752. * Gets the latest created engine
  33753. */
  33754. static get LastCreatedEngine(): Nullable<Engine>;
  33755. /**
  33756. * Gets the latest created scene
  33757. */
  33758. static get LastCreatedScene(): Nullable<Scene>;
  33759. /**
  33760. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33761. * @ignorenaming
  33762. */
  33763. static UseFallbackTexture: boolean;
  33764. /**
  33765. * Texture content used if a texture cannot loaded
  33766. * @ignorenaming
  33767. */
  33768. static FallbackTexture: string;
  33769. }
  33770. }
  33771. declare module BABYLON {
  33772. /**
  33773. * Helper class that provides a small promise polyfill
  33774. */
  33775. export class PromisePolyfill {
  33776. /**
  33777. * Static function used to check if the polyfill is required
  33778. * If this is the case then the function will inject the polyfill to window.Promise
  33779. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  33780. */
  33781. static Apply(force?: boolean): void;
  33782. }
  33783. }
  33784. declare module BABYLON {
  33785. /**
  33786. * Interface for screenshot methods with describe argument called `size` as object with options
  33787. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  33788. */
  33789. export interface IScreenshotSize {
  33790. /**
  33791. * number in pixels for canvas height
  33792. */
  33793. height?: number;
  33794. /**
  33795. * multiplier allowing render at a higher or lower resolution
  33796. * If value is defined then height and width will be ignored and taken from camera
  33797. */
  33798. precision?: number;
  33799. /**
  33800. * number in pixels for canvas width
  33801. */
  33802. width?: number;
  33803. }
  33804. }
  33805. declare module BABYLON {
  33806. interface IColor4Like {
  33807. r: float;
  33808. g: float;
  33809. b: float;
  33810. a: float;
  33811. }
  33812. /**
  33813. * Class containing a set of static utilities functions
  33814. */
  33815. export class Tools {
  33816. /**
  33817. * Gets or sets the base URL to use to load assets
  33818. */
  33819. static get BaseUrl(): string;
  33820. static set BaseUrl(value: string);
  33821. /**
  33822. * Enable/Disable Custom HTTP Request Headers globally.
  33823. * default = false
  33824. * @see CustomRequestHeaders
  33825. */
  33826. static UseCustomRequestHeaders: boolean;
  33827. /**
  33828. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  33829. * i.e. when loading files, where the server/service expects an Authorization header
  33830. */
  33831. static CustomRequestHeaders: {
  33832. [key: string]: string;
  33833. };
  33834. /**
  33835. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  33836. */
  33837. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  33838. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  33839. /**
  33840. * Default behaviour for cors in the application.
  33841. * It can be a string if the expected behavior is identical in the entire app.
  33842. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  33843. */
  33844. static CorsBehavior: string | ((url: string | string[]) => string);
  33845. /**
  33846. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33847. * @ignorenaming
  33848. */
  33849. static get UseFallbackTexture(): boolean;
  33850. static set UseFallbackTexture(value: boolean);
  33851. /**
  33852. * Use this object to register external classes like custom textures or material
  33853. * to allow the laoders to instantiate them
  33854. */
  33855. static get RegisteredExternalClasses(): {
  33856. [key: string]: Object;
  33857. };
  33858. static set RegisteredExternalClasses(classes: {
  33859. [key: string]: Object;
  33860. });
  33861. /**
  33862. * Texture content used if a texture cannot loaded
  33863. * @ignorenaming
  33864. */
  33865. static get fallbackTexture(): string;
  33866. static set fallbackTexture(value: string);
  33867. /**
  33868. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  33869. * @param u defines the coordinate on X axis
  33870. * @param v defines the coordinate on Y axis
  33871. * @param width defines the width of the source data
  33872. * @param height defines the height of the source data
  33873. * @param pixels defines the source byte array
  33874. * @param color defines the output color
  33875. */
  33876. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  33877. /**
  33878. * Interpolates between a and b via alpha
  33879. * @param a The lower value (returned when alpha = 0)
  33880. * @param b The upper value (returned when alpha = 1)
  33881. * @param alpha The interpolation-factor
  33882. * @return The mixed value
  33883. */
  33884. static Mix(a: number, b: number, alpha: number): number;
  33885. /**
  33886. * Tries to instantiate a new object from a given class name
  33887. * @param className defines the class name to instantiate
  33888. * @returns the new object or null if the system was not able to do the instantiation
  33889. */
  33890. static Instantiate(className: string): any;
  33891. /**
  33892. * Provides a slice function that will work even on IE
  33893. * @param data defines the array to slice
  33894. * @param start defines the start of the data (optional)
  33895. * @param end defines the end of the data (optional)
  33896. * @returns the new sliced array
  33897. */
  33898. static Slice<T>(data: T, start?: number, end?: number): T;
  33899. /**
  33900. * Polyfill for setImmediate
  33901. * @param action defines the action to execute after the current execution block
  33902. */
  33903. static SetImmediate(action: () => void): void;
  33904. /**
  33905. * Function indicating if a number is an exponent of 2
  33906. * @param value defines the value to test
  33907. * @returns true if the value is an exponent of 2
  33908. */
  33909. static IsExponentOfTwo(value: number): boolean;
  33910. private static _tmpFloatArray;
  33911. /**
  33912. * Returns the nearest 32-bit single precision float representation of a Number
  33913. * @param value A Number. If the parameter is of a different type, it will get converted
  33914. * to a number or to NaN if it cannot be converted
  33915. * @returns number
  33916. */
  33917. static FloatRound(value: number): number;
  33918. /**
  33919. * Extracts the filename from a path
  33920. * @param path defines the path to use
  33921. * @returns the filename
  33922. */
  33923. static GetFilename(path: string): string;
  33924. /**
  33925. * Extracts the "folder" part of a path (everything before the filename).
  33926. * @param uri The URI to extract the info from
  33927. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  33928. * @returns The "folder" part of the path
  33929. */
  33930. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  33931. /**
  33932. * Extracts text content from a DOM element hierarchy
  33933. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  33934. */
  33935. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  33936. /**
  33937. * Convert an angle in radians to degrees
  33938. * @param angle defines the angle to convert
  33939. * @returns the angle in degrees
  33940. */
  33941. static ToDegrees(angle: number): number;
  33942. /**
  33943. * Convert an angle in degrees to radians
  33944. * @param angle defines the angle to convert
  33945. * @returns the angle in radians
  33946. */
  33947. static ToRadians(angle: number): number;
  33948. /**
  33949. * Returns an array if obj is not an array
  33950. * @param obj defines the object to evaluate as an array
  33951. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  33952. * @returns either obj directly if obj is an array or a new array containing obj
  33953. */
  33954. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  33955. /**
  33956. * Gets the pointer prefix to use
  33957. * @returns "pointer" if touch is enabled. Else returns "mouse"
  33958. */
  33959. static GetPointerPrefix(): string;
  33960. /**
  33961. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  33962. * @param url define the url we are trying
  33963. * @param element define the dom element where to configure the cors policy
  33964. */
  33965. static SetCorsBehavior(url: string | string[], element: {
  33966. crossOrigin: string | null;
  33967. }): void;
  33968. /**
  33969. * Removes unwanted characters from an url
  33970. * @param url defines the url to clean
  33971. * @returns the cleaned url
  33972. */
  33973. static CleanUrl(url: string): string;
  33974. /**
  33975. * Gets or sets a function used to pre-process url before using them to load assets
  33976. */
  33977. static get PreprocessUrl(): (url: string) => string;
  33978. static set PreprocessUrl(processor: (url: string) => string);
  33979. /**
  33980. * Loads an image as an HTMLImageElement.
  33981. * @param input url string, ArrayBuffer, or Blob to load
  33982. * @param onLoad callback called when the image successfully loads
  33983. * @param onError callback called when the image fails to load
  33984. * @param offlineProvider offline provider for caching
  33985. * @param mimeType optional mime type
  33986. * @returns the HTMLImageElement of the loaded image
  33987. */
  33988. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  33989. /**
  33990. * Loads a file from a url
  33991. * @param url url string, ArrayBuffer, or Blob to load
  33992. * @param onSuccess callback called when the file successfully loads
  33993. * @param onProgress callback called while file is loading (if the server supports this mode)
  33994. * @param offlineProvider defines the offline provider for caching
  33995. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  33996. * @param onError callback called when the file fails to load
  33997. * @returns a file request object
  33998. */
  33999. 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;
  34000. /**
  34001. * Loads a file from a url
  34002. * @param url the file url to load
  34003. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  34004. */
  34005. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  34006. /**
  34007. * Load a script (identified by an url). When the url returns, the
  34008. * content of this file is added into a new script element, attached to the DOM (body element)
  34009. * @param scriptUrl defines the url of the script to laod
  34010. * @param onSuccess defines the callback called when the script is loaded
  34011. * @param onError defines the callback to call if an error occurs
  34012. * @param scriptId defines the id of the script element
  34013. */
  34014. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  34015. /**
  34016. * Load an asynchronous script (identified by an url). When the url returns, the
  34017. * content of this file is added into a new script element, attached to the DOM (body element)
  34018. * @param scriptUrl defines the url of the script to laod
  34019. * @param scriptId defines the id of the script element
  34020. * @returns a promise request object
  34021. */
  34022. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  34023. /**
  34024. * Loads a file from a blob
  34025. * @param fileToLoad defines the blob to use
  34026. * @param callback defines the callback to call when data is loaded
  34027. * @param progressCallback defines the callback to call during loading process
  34028. * @returns a file request object
  34029. */
  34030. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  34031. /**
  34032. * Reads a file from a File object
  34033. * @param file defines the file to load
  34034. * @param onSuccess defines the callback to call when data is loaded
  34035. * @param onProgress defines the callback to call during loading process
  34036. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  34037. * @param onError defines the callback to call when an error occurs
  34038. * @returns a file request object
  34039. */
  34040. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  34041. /**
  34042. * Creates a data url from a given string content
  34043. * @param content defines the content to convert
  34044. * @returns the new data url link
  34045. */
  34046. static FileAsURL(content: string): string;
  34047. /**
  34048. * Format the given number to a specific decimal format
  34049. * @param value defines the number to format
  34050. * @param decimals defines the number of decimals to use
  34051. * @returns the formatted string
  34052. */
  34053. static Format(value: number, decimals?: number): string;
  34054. /**
  34055. * Tries to copy an object by duplicating every property
  34056. * @param source defines the source object
  34057. * @param destination defines the target object
  34058. * @param doNotCopyList defines a list of properties to avoid
  34059. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  34060. */
  34061. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  34062. /**
  34063. * Gets a boolean indicating if the given object has no own property
  34064. * @param obj defines the object to test
  34065. * @returns true if object has no own property
  34066. */
  34067. static IsEmpty(obj: any): boolean;
  34068. /**
  34069. * Function used to register events at window level
  34070. * @param windowElement defines the Window object to use
  34071. * @param events defines the events to register
  34072. */
  34073. static RegisterTopRootEvents(windowElement: Window, events: {
  34074. name: string;
  34075. handler: Nullable<(e: FocusEvent) => any>;
  34076. }[]): void;
  34077. /**
  34078. * Function used to unregister events from window level
  34079. * @param windowElement defines the Window object to use
  34080. * @param events defines the events to unregister
  34081. */
  34082. static UnregisterTopRootEvents(windowElement: Window, events: {
  34083. name: string;
  34084. handler: Nullable<(e: FocusEvent) => any>;
  34085. }[]): void;
  34086. /**
  34087. * @ignore
  34088. */
  34089. static _ScreenshotCanvas: HTMLCanvasElement;
  34090. /**
  34091. * Dumps the current bound framebuffer
  34092. * @param width defines the rendering width
  34093. * @param height defines the rendering height
  34094. * @param engine defines the hosting engine
  34095. * @param successCallback defines the callback triggered once the data are available
  34096. * @param mimeType defines the mime type of the result
  34097. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  34098. */
  34099. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34100. /**
  34101. * Converts the canvas data to blob.
  34102. * This acts as a polyfill for browsers not supporting the to blob function.
  34103. * @param canvas Defines the canvas to extract the data from
  34104. * @param successCallback Defines the callback triggered once the data are available
  34105. * @param mimeType Defines the mime type of the result
  34106. */
  34107. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  34108. /**
  34109. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  34110. * @param successCallback defines the callback triggered once the data are available
  34111. * @param mimeType defines the mime type of the result
  34112. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  34113. */
  34114. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34115. /**
  34116. * Downloads a blob in the browser
  34117. * @param blob defines the blob to download
  34118. * @param fileName defines the name of the downloaded file
  34119. */
  34120. static Download(blob: Blob, fileName: string): void;
  34121. /**
  34122. * Captures a screenshot of the current rendering
  34123. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34124. * @param engine defines the rendering engine
  34125. * @param camera defines the source camera
  34126. * @param size This parameter can be set to a single number or to an object with the
  34127. * following (optional) properties: precision, width, height. If a single number is passed,
  34128. * it will be used for both width and height. If an object is passed, the screenshot size
  34129. * will be derived from the parameters. The precision property is a multiplier allowing
  34130. * rendering at a higher or lower resolution
  34131. * @param successCallback defines the callback receives a single parameter which contains the
  34132. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34133. * src parameter of an <img> to display it
  34134. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34135. * Check your browser for supported MIME types
  34136. */
  34137. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  34138. /**
  34139. * Captures a screenshot of the current rendering
  34140. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34141. * @param engine defines the rendering engine
  34142. * @param camera defines the source camera
  34143. * @param size This parameter can be set to a single number or to an object with the
  34144. * following (optional) properties: precision, width, height. If a single number is passed,
  34145. * it will be used for both width and height. If an object is passed, the screenshot size
  34146. * will be derived from the parameters. The precision property is a multiplier allowing
  34147. * rendering at a higher or lower resolution
  34148. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34149. * Check your browser for supported MIME types
  34150. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34151. * to the src parameter of an <img> to display it
  34152. */
  34153. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  34154. /**
  34155. * Generates an image screenshot from the specified camera.
  34156. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34157. * @param engine The engine to use for rendering
  34158. * @param camera The camera to use for rendering
  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 successCallback The callback receives a single parameter which contains the
  34165. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34166. * src parameter of an <img> to display it
  34167. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34168. * Check your browser for supported MIME types
  34169. * @param samples Texture samples (default: 1)
  34170. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34171. * @param fileName A name for for the downloaded file.
  34172. */
  34173. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  34174. /**
  34175. * Generates an image screenshot from the specified camera.
  34176. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34177. * @param engine The engine to use for rendering
  34178. * @param camera The camera to use for rendering
  34179. * @param size This parameter can be set to a single number or to an object with the
  34180. * following (optional) properties: precision, width, height. If a single number is passed,
  34181. * it will be used for both width and height. If an object is passed, the screenshot size
  34182. * will be derived from the parameters. The precision property is a multiplier allowing
  34183. * rendering at a higher or lower resolution
  34184. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34185. * Check your browser for supported MIME types
  34186. * @param samples Texture samples (default: 1)
  34187. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34188. * @param fileName A name for for the downloaded file.
  34189. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34190. * to the src parameter of an <img> to display it
  34191. */
  34192. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  34193. /**
  34194. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  34195. * Be aware Math.random() could cause collisions, but:
  34196. * "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"
  34197. * @returns a pseudo random id
  34198. */
  34199. static RandomId(): string;
  34200. /**
  34201. * Test if the given uri is a base64 string
  34202. * @param uri The uri to test
  34203. * @return True if the uri is a base64 string or false otherwise
  34204. */
  34205. static IsBase64(uri: string): boolean;
  34206. /**
  34207. * Decode the given base64 uri.
  34208. * @param uri The uri to decode
  34209. * @return The decoded base64 data.
  34210. */
  34211. static DecodeBase64(uri: string): ArrayBuffer;
  34212. /**
  34213. * Gets the absolute url.
  34214. * @param url the input url
  34215. * @return the absolute url
  34216. */
  34217. static GetAbsoluteUrl(url: string): string;
  34218. /**
  34219. * No log
  34220. */
  34221. static readonly NoneLogLevel: number;
  34222. /**
  34223. * Only message logs
  34224. */
  34225. static readonly MessageLogLevel: number;
  34226. /**
  34227. * Only warning logs
  34228. */
  34229. static readonly WarningLogLevel: number;
  34230. /**
  34231. * Only error logs
  34232. */
  34233. static readonly ErrorLogLevel: number;
  34234. /**
  34235. * All logs
  34236. */
  34237. static readonly AllLogLevel: number;
  34238. /**
  34239. * Gets a value indicating the number of loading errors
  34240. * @ignorenaming
  34241. */
  34242. static get errorsCount(): number;
  34243. /**
  34244. * Callback called when a new log is added
  34245. */
  34246. static OnNewCacheEntry: (entry: string) => void;
  34247. /**
  34248. * Log a message to the console
  34249. * @param message defines the message to log
  34250. */
  34251. static Log(message: string): void;
  34252. /**
  34253. * Write a warning message to the console
  34254. * @param message defines the message to log
  34255. */
  34256. static Warn(message: string): void;
  34257. /**
  34258. * Write an error message to the console
  34259. * @param message defines the message to log
  34260. */
  34261. static Error(message: string): void;
  34262. /**
  34263. * Gets current log cache (list of logs)
  34264. */
  34265. static get LogCache(): string;
  34266. /**
  34267. * Clears the log cache
  34268. */
  34269. static ClearLogCache(): void;
  34270. /**
  34271. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  34272. */
  34273. static set LogLevels(level: number);
  34274. /**
  34275. * Checks if the window object exists
  34276. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  34277. */
  34278. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  34279. /**
  34280. * No performance log
  34281. */
  34282. static readonly PerformanceNoneLogLevel: number;
  34283. /**
  34284. * Use user marks to log performance
  34285. */
  34286. static readonly PerformanceUserMarkLogLevel: number;
  34287. /**
  34288. * Log performance to the console
  34289. */
  34290. static readonly PerformanceConsoleLogLevel: number;
  34291. private static _performance;
  34292. /**
  34293. * Sets the current performance log level
  34294. */
  34295. static set PerformanceLogLevel(level: number);
  34296. private static _StartPerformanceCounterDisabled;
  34297. private static _EndPerformanceCounterDisabled;
  34298. private static _StartUserMark;
  34299. private static _EndUserMark;
  34300. private static _StartPerformanceConsole;
  34301. private static _EndPerformanceConsole;
  34302. /**
  34303. * Starts a performance counter
  34304. */
  34305. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34306. /**
  34307. * Ends a specific performance coutner
  34308. */
  34309. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34310. /**
  34311. * Gets either window.performance.now() if supported or Date.now() else
  34312. */
  34313. static get Now(): number;
  34314. /**
  34315. * This method will return the name of the class used to create the instance of the given object.
  34316. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  34317. * @param object the object to get the class name from
  34318. * @param isType defines if the object is actually a type
  34319. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  34320. */
  34321. static GetClassName(object: any, isType?: boolean): string;
  34322. /**
  34323. * Gets the first element of an array satisfying a given predicate
  34324. * @param array defines the array to browse
  34325. * @param predicate defines the predicate to use
  34326. * @returns null if not found or the element
  34327. */
  34328. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  34329. /**
  34330. * This method will return the name of the full name of the class, including its owning module (if any).
  34331. * 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).
  34332. * @param object the object to get the class name from
  34333. * @param isType defines if the object is actually a type
  34334. * @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.
  34335. * @ignorenaming
  34336. */
  34337. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  34338. /**
  34339. * Returns a promise that resolves after the given amount of time.
  34340. * @param delay Number of milliseconds to delay
  34341. * @returns Promise that resolves after the given amount of time
  34342. */
  34343. static DelayAsync(delay: number): Promise<void>;
  34344. /**
  34345. * Utility function to detect if the current user agent is Safari
  34346. * @returns whether or not the current user agent is safari
  34347. */
  34348. static IsSafari(): boolean;
  34349. }
  34350. /**
  34351. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  34352. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  34353. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  34354. * @param name The name of the class, case should be preserved
  34355. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  34356. */
  34357. export function className(name: string, module?: string): (target: Object) => void;
  34358. /**
  34359. * An implementation of a loop for asynchronous functions.
  34360. */
  34361. export class AsyncLoop {
  34362. /**
  34363. * Defines the number of iterations for the loop
  34364. */
  34365. iterations: number;
  34366. /**
  34367. * Defines the current index of the loop.
  34368. */
  34369. index: number;
  34370. private _done;
  34371. private _fn;
  34372. private _successCallback;
  34373. /**
  34374. * Constructor.
  34375. * @param iterations the number of iterations.
  34376. * @param func the function to run each iteration
  34377. * @param successCallback the callback that will be called upon succesful execution
  34378. * @param offset starting offset.
  34379. */
  34380. constructor(
  34381. /**
  34382. * Defines the number of iterations for the loop
  34383. */
  34384. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  34385. /**
  34386. * Execute the next iteration. Must be called after the last iteration was finished.
  34387. */
  34388. executeNext(): void;
  34389. /**
  34390. * Break the loop and run the success callback.
  34391. */
  34392. breakLoop(): void;
  34393. /**
  34394. * Create and run an async loop.
  34395. * @param iterations the number of iterations.
  34396. * @param fn the function to run each iteration
  34397. * @param successCallback the callback that will be called upon succesful execution
  34398. * @param offset starting offset.
  34399. * @returns the created async loop object
  34400. */
  34401. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  34402. /**
  34403. * A for-loop that will run a given number of iterations synchronous and the rest async.
  34404. * @param iterations total number of iterations
  34405. * @param syncedIterations number of synchronous iterations in each async iteration.
  34406. * @param fn the function to call each iteration.
  34407. * @param callback a success call back that will be called when iterating stops.
  34408. * @param breakFunction a break condition (optional)
  34409. * @param timeout timeout settings for the setTimeout function. default - 0.
  34410. * @returns the created async loop object
  34411. */
  34412. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  34413. }
  34414. }
  34415. declare module BABYLON {
  34416. /**
  34417. * This class implement a typical dictionary using a string as key and the generic type T as value.
  34418. * The underlying implementation relies on an associative array to ensure the best performances.
  34419. * The value can be anything including 'null' but except 'undefined'
  34420. */
  34421. export class StringDictionary<T> {
  34422. /**
  34423. * This will clear this dictionary and copy the content from the 'source' one.
  34424. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  34425. * @param source the dictionary to take the content from and copy to this dictionary
  34426. */
  34427. copyFrom(source: StringDictionary<T>): void;
  34428. /**
  34429. * Get a value based from its key
  34430. * @param key the given key to get the matching value from
  34431. * @return the value if found, otherwise undefined is returned
  34432. */
  34433. get(key: string): T | undefined;
  34434. /**
  34435. * Get a value from its key or add it if it doesn't exist.
  34436. * This method will ensure you that a given key/data will be present in the dictionary.
  34437. * @param key the given key to get the matching value from
  34438. * @param factory the factory that will create the value if the key is not present in the dictionary.
  34439. * The factory will only be invoked if there's no data for the given key.
  34440. * @return the value corresponding to the key.
  34441. */
  34442. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  34443. /**
  34444. * Get a value from its key if present in the dictionary otherwise add it
  34445. * @param key the key to get the value from
  34446. * @param val if there's no such key/value pair in the dictionary add it with this value
  34447. * @return the value corresponding to the key
  34448. */
  34449. getOrAdd(key: string, val: T): T;
  34450. /**
  34451. * Check if there's a given key in the dictionary
  34452. * @param key the key to check for
  34453. * @return true if the key is present, false otherwise
  34454. */
  34455. contains(key: string): boolean;
  34456. /**
  34457. * Add a new key and its corresponding value
  34458. * @param key the key to add
  34459. * @param value the value corresponding to the key
  34460. * @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
  34461. */
  34462. add(key: string, value: T): boolean;
  34463. /**
  34464. * Update a specific value associated to a key
  34465. * @param key defines the key to use
  34466. * @param value defines the value to store
  34467. * @returns true if the value was updated (or false if the key was not found)
  34468. */
  34469. set(key: string, value: T): boolean;
  34470. /**
  34471. * Get the element of the given key and remove it from the dictionary
  34472. * @param key defines the key to search
  34473. * @returns the value associated with the key or null if not found
  34474. */
  34475. getAndRemove(key: string): Nullable<T>;
  34476. /**
  34477. * Remove a key/value from the dictionary.
  34478. * @param key the key to remove
  34479. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  34480. */
  34481. remove(key: string): boolean;
  34482. /**
  34483. * Clear the whole content of the dictionary
  34484. */
  34485. clear(): void;
  34486. /**
  34487. * Gets the current count
  34488. */
  34489. get count(): number;
  34490. /**
  34491. * Execute a callback on each key/val of the dictionary.
  34492. * Note that you can remove any element in this dictionary in the callback implementation
  34493. * @param callback the callback to execute on a given key/value pair
  34494. */
  34495. forEach(callback: (key: string, val: T) => void): void;
  34496. /**
  34497. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  34498. * If the callback returns null or undefined the method will iterate to the next key/value pair
  34499. * Note that you can remove any element in this dictionary in the callback implementation
  34500. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  34501. * @returns the first item
  34502. */
  34503. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  34504. private _count;
  34505. private _data;
  34506. }
  34507. }
  34508. declare module BABYLON {
  34509. /** @hidden */
  34510. export interface ICollisionCoordinator {
  34511. createCollider(): Collider;
  34512. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34513. init(scene: Scene): void;
  34514. }
  34515. /** @hidden */
  34516. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  34517. private _scene;
  34518. private _scaledPosition;
  34519. private _scaledVelocity;
  34520. private _finalPosition;
  34521. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34522. createCollider(): Collider;
  34523. init(scene: Scene): void;
  34524. private _collideWithWorld;
  34525. }
  34526. }
  34527. declare module BABYLON {
  34528. /**
  34529. * Class used to manage all inputs for the scene.
  34530. */
  34531. export class InputManager {
  34532. /** The distance in pixel that you have to move to prevent some events */
  34533. static DragMovementThreshold: number;
  34534. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  34535. static LongPressDelay: number;
  34536. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  34537. static DoubleClickDelay: number;
  34538. /** If you need to check double click without raising a single click at first click, enable this flag */
  34539. static ExclusiveDoubleClickMode: boolean;
  34540. private _wheelEventName;
  34541. private _onPointerMove;
  34542. private _onPointerDown;
  34543. private _onPointerUp;
  34544. private _initClickEvent;
  34545. private _initActionManager;
  34546. private _delayedSimpleClick;
  34547. private _delayedSimpleClickTimeout;
  34548. private _previousDelayedSimpleClickTimeout;
  34549. private _meshPickProceed;
  34550. private _previousButtonPressed;
  34551. private _currentPickResult;
  34552. private _previousPickResult;
  34553. private _totalPointersPressed;
  34554. private _doubleClickOccured;
  34555. private _pointerOverMesh;
  34556. private _pickedDownMesh;
  34557. private _pickedUpMesh;
  34558. private _pointerX;
  34559. private _pointerY;
  34560. private _unTranslatedPointerX;
  34561. private _unTranslatedPointerY;
  34562. private _startingPointerPosition;
  34563. private _previousStartingPointerPosition;
  34564. private _startingPointerTime;
  34565. private _previousStartingPointerTime;
  34566. private _pointerCaptures;
  34567. private _onKeyDown;
  34568. private _onKeyUp;
  34569. private _onCanvasFocusObserver;
  34570. private _onCanvasBlurObserver;
  34571. private _scene;
  34572. /**
  34573. * Creates a new InputManager
  34574. * @param scene defines the hosting scene
  34575. */
  34576. constructor(scene: Scene);
  34577. /**
  34578. * Gets the mesh that is currently under the pointer
  34579. */
  34580. get meshUnderPointer(): Nullable<AbstractMesh>;
  34581. /**
  34582. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  34583. */
  34584. get unTranslatedPointer(): Vector2;
  34585. /**
  34586. * Gets or sets the current on-screen X position of the pointer
  34587. */
  34588. get pointerX(): number;
  34589. set pointerX(value: number);
  34590. /**
  34591. * Gets or sets the current on-screen Y position of the pointer
  34592. */
  34593. get pointerY(): number;
  34594. set pointerY(value: number);
  34595. private _updatePointerPosition;
  34596. private _processPointerMove;
  34597. private _setRayOnPointerInfo;
  34598. private _checkPrePointerObservable;
  34599. /**
  34600. * Use this method to simulate a pointer move on a mesh
  34601. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34602. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34603. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34604. */
  34605. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34606. /**
  34607. * Use this method to simulate a pointer down on a mesh
  34608. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34609. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34610. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34611. */
  34612. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34613. private _processPointerDown;
  34614. /** @hidden */
  34615. _isPointerSwiping(): boolean;
  34616. /**
  34617. * Use this method to simulate a pointer up on a mesh
  34618. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34619. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34620. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34621. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34622. */
  34623. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  34624. private _processPointerUp;
  34625. /**
  34626. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34627. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34628. * @returns true if the pointer was captured
  34629. */
  34630. isPointerCaptured(pointerId?: number): boolean;
  34631. /**
  34632. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34633. * @param attachUp defines if you want to attach events to pointerup
  34634. * @param attachDown defines if you want to attach events to pointerdown
  34635. * @param attachMove defines if you want to attach events to pointermove
  34636. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  34637. */
  34638. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  34639. /**
  34640. * Detaches all event handlers
  34641. */
  34642. detachControl(): void;
  34643. /**
  34644. * Force the value of meshUnderPointer
  34645. * @param mesh defines the mesh to use
  34646. */
  34647. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34648. /**
  34649. * Gets the mesh under the pointer
  34650. * @returns a Mesh or null if no mesh is under the pointer
  34651. */
  34652. getPointerOverMesh(): Nullable<AbstractMesh>;
  34653. }
  34654. }
  34655. declare module BABYLON {
  34656. /**
  34657. * Helper class used to generate session unique ID
  34658. */
  34659. export class UniqueIdGenerator {
  34660. private static _UniqueIdCounter;
  34661. /**
  34662. * Gets an unique (relatively to the current scene) Id
  34663. */
  34664. static get UniqueId(): number;
  34665. }
  34666. }
  34667. declare module BABYLON {
  34668. /**
  34669. * This class defines the direct association between an animation and a target
  34670. */
  34671. export class TargetedAnimation {
  34672. /**
  34673. * Animation to perform
  34674. */
  34675. animation: Animation;
  34676. /**
  34677. * Target to animate
  34678. */
  34679. target: any;
  34680. /**
  34681. * Serialize the object
  34682. * @returns the JSON object representing the current entity
  34683. */
  34684. serialize(): any;
  34685. }
  34686. /**
  34687. * Use this class to create coordinated animations on multiple targets
  34688. */
  34689. export class AnimationGroup implements IDisposable {
  34690. /** The name of the animation group */
  34691. name: string;
  34692. private _scene;
  34693. private _targetedAnimations;
  34694. private _animatables;
  34695. private _from;
  34696. private _to;
  34697. private _isStarted;
  34698. private _isPaused;
  34699. private _speedRatio;
  34700. private _loopAnimation;
  34701. /**
  34702. * Gets or sets the unique id of the node
  34703. */
  34704. uniqueId: number;
  34705. /**
  34706. * This observable will notify when one animation have ended
  34707. */
  34708. onAnimationEndObservable: Observable<TargetedAnimation>;
  34709. /**
  34710. * Observer raised when one animation loops
  34711. */
  34712. onAnimationLoopObservable: Observable<TargetedAnimation>;
  34713. /**
  34714. * Observer raised when all animations have looped
  34715. */
  34716. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  34717. /**
  34718. * This observable will notify when all animations have ended.
  34719. */
  34720. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  34721. /**
  34722. * This observable will notify when all animations have paused.
  34723. */
  34724. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  34725. /**
  34726. * This observable will notify when all animations are playing.
  34727. */
  34728. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  34729. /**
  34730. * Gets the first frame
  34731. */
  34732. get from(): number;
  34733. /**
  34734. * Gets the last frame
  34735. */
  34736. get to(): number;
  34737. /**
  34738. * Define if the animations are started
  34739. */
  34740. get isStarted(): boolean;
  34741. /**
  34742. * Gets a value indicating that the current group is playing
  34743. */
  34744. get isPlaying(): boolean;
  34745. /**
  34746. * Gets or sets the speed ratio to use for all animations
  34747. */
  34748. get speedRatio(): number;
  34749. /**
  34750. * Gets or sets the speed ratio to use for all animations
  34751. */
  34752. set speedRatio(value: number);
  34753. /**
  34754. * Gets or sets if all animations should loop or not
  34755. */
  34756. get loopAnimation(): boolean;
  34757. set loopAnimation(value: boolean);
  34758. /**
  34759. * Gets the targeted animations for this animation group
  34760. */
  34761. get targetedAnimations(): Array<TargetedAnimation>;
  34762. /**
  34763. * returning the list of animatables controlled by this animation group.
  34764. */
  34765. get animatables(): Array<Animatable>;
  34766. /**
  34767. * Instantiates a new Animation Group.
  34768. * This helps managing several animations at once.
  34769. * @see http://doc.babylonjs.com/how_to/group
  34770. * @param name Defines the name of the group
  34771. * @param scene Defines the scene the group belongs to
  34772. */
  34773. constructor(
  34774. /** The name of the animation group */
  34775. name: string, scene?: Nullable<Scene>);
  34776. /**
  34777. * Add an animation (with its target) in the group
  34778. * @param animation defines the animation we want to add
  34779. * @param target defines the target of the animation
  34780. * @returns the TargetedAnimation object
  34781. */
  34782. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  34783. /**
  34784. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  34785. * It can add constant keys at begin or end
  34786. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  34787. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  34788. * @returns the animation group
  34789. */
  34790. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  34791. private _animationLoopCount;
  34792. private _animationLoopFlags;
  34793. private _processLoop;
  34794. /**
  34795. * Start all animations on given targets
  34796. * @param loop defines if animations must loop
  34797. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  34798. * @param from defines the from key (optional)
  34799. * @param to defines the to key (optional)
  34800. * @returns the current animation group
  34801. */
  34802. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  34803. /**
  34804. * Pause all animations
  34805. * @returns the animation group
  34806. */
  34807. pause(): AnimationGroup;
  34808. /**
  34809. * Play all animations to initial state
  34810. * This function will start() the animations if they were not started or will restart() them if they were paused
  34811. * @param loop defines if animations must loop
  34812. * @returns the animation group
  34813. */
  34814. play(loop?: boolean): AnimationGroup;
  34815. /**
  34816. * Reset all animations to initial state
  34817. * @returns the animation group
  34818. */
  34819. reset(): AnimationGroup;
  34820. /**
  34821. * Restart animations from key 0
  34822. * @returns the animation group
  34823. */
  34824. restart(): AnimationGroup;
  34825. /**
  34826. * Stop all animations
  34827. * @returns the animation group
  34828. */
  34829. stop(): AnimationGroup;
  34830. /**
  34831. * Set animation weight for all animatables
  34832. * @param weight defines the weight to use
  34833. * @return the animationGroup
  34834. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34835. */
  34836. setWeightForAllAnimatables(weight: number): AnimationGroup;
  34837. /**
  34838. * Synchronize and normalize all animatables with a source animatable
  34839. * @param root defines the root animatable to synchronize with
  34840. * @return the animationGroup
  34841. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34842. */
  34843. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  34844. /**
  34845. * Goes to a specific frame in this animation group
  34846. * @param frame the frame number to go to
  34847. * @return the animationGroup
  34848. */
  34849. goToFrame(frame: number): AnimationGroup;
  34850. /**
  34851. * Dispose all associated resources
  34852. */
  34853. dispose(): void;
  34854. private _checkAnimationGroupEnded;
  34855. /**
  34856. * Clone the current animation group and returns a copy
  34857. * @param newName defines the name of the new group
  34858. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  34859. * @returns the new aniamtion group
  34860. */
  34861. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  34862. /**
  34863. * Serializes the animationGroup to an object
  34864. * @returns Serialized object
  34865. */
  34866. serialize(): any;
  34867. /**
  34868. * Returns a new AnimationGroup object parsed from the source provided.
  34869. * @param parsedAnimationGroup defines the source
  34870. * @param scene defines the scene that will receive the animationGroup
  34871. * @returns a new AnimationGroup
  34872. */
  34873. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  34874. /**
  34875. * Returns the string "AnimationGroup"
  34876. * @returns "AnimationGroup"
  34877. */
  34878. getClassName(): string;
  34879. /**
  34880. * Creates a detailled string about the object
  34881. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  34882. * @returns a string representing the object
  34883. */
  34884. toString(fullDetails?: boolean): string;
  34885. }
  34886. }
  34887. declare module BABYLON {
  34888. /**
  34889. * Define an interface for all classes that will hold resources
  34890. */
  34891. export interface IDisposable {
  34892. /**
  34893. * Releases all held resources
  34894. */
  34895. dispose(): void;
  34896. }
  34897. /** Interface defining initialization parameters for Scene class */
  34898. export interface SceneOptions {
  34899. /**
  34900. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  34901. * It will improve performance when the number of geometries becomes important.
  34902. */
  34903. useGeometryUniqueIdsMap?: boolean;
  34904. /**
  34905. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  34906. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34907. */
  34908. useMaterialMeshMap?: boolean;
  34909. /**
  34910. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  34911. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34912. */
  34913. useClonedMeshMap?: boolean;
  34914. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  34915. virtual?: boolean;
  34916. }
  34917. /**
  34918. * Represents a scene to be rendered by the engine.
  34919. * @see http://doc.babylonjs.com/features/scene
  34920. */
  34921. export class Scene extends AbstractScene implements IAnimatable {
  34922. /** The fog is deactivated */
  34923. static readonly FOGMODE_NONE: number;
  34924. /** The fog density is following an exponential function */
  34925. static readonly FOGMODE_EXP: number;
  34926. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  34927. static readonly FOGMODE_EXP2: number;
  34928. /** The fog density is following a linear function. */
  34929. static readonly FOGMODE_LINEAR: number;
  34930. /**
  34931. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  34932. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34933. */
  34934. static MinDeltaTime: number;
  34935. /**
  34936. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  34937. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34938. */
  34939. static MaxDeltaTime: number;
  34940. /**
  34941. * Factory used to create the default material.
  34942. * @param name The name of the material to create
  34943. * @param scene The scene to create the material for
  34944. * @returns The default material
  34945. */
  34946. static DefaultMaterialFactory(scene: Scene): Material;
  34947. /**
  34948. * Factory used to create the a collision coordinator.
  34949. * @returns The collision coordinator
  34950. */
  34951. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  34952. /** @hidden */
  34953. _inputManager: InputManager;
  34954. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  34955. cameraToUseForPointers: Nullable<Camera>;
  34956. /** @hidden */
  34957. readonly _isScene: boolean;
  34958. /**
  34959. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  34960. */
  34961. autoClear: boolean;
  34962. /**
  34963. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  34964. */
  34965. autoClearDepthAndStencil: boolean;
  34966. /**
  34967. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  34968. */
  34969. clearColor: Color4;
  34970. /**
  34971. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  34972. */
  34973. ambientColor: Color3;
  34974. /**
  34975. * This is use to store the default BRDF lookup for PBR materials in your scene.
  34976. * It should only be one of the following (if not the default embedded one):
  34977. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  34978. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  34979. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  34980. * The material properties need to be setup according to the type of texture in use.
  34981. */
  34982. environmentBRDFTexture: BaseTexture;
  34983. /** @hidden */
  34984. protected _environmentTexture: Nullable<BaseTexture>;
  34985. /**
  34986. * Texture used in all pbr material as the reflection texture.
  34987. * As in the majority of the scene they are the same (exception for multi room and so on),
  34988. * this is easier to reference from here than from all the materials.
  34989. */
  34990. get environmentTexture(): Nullable<BaseTexture>;
  34991. /**
  34992. * Texture used in all pbr material as the reflection texture.
  34993. * As in the majority of the scene they are the same (exception for multi room and so on),
  34994. * this is easier to set here than in all the materials.
  34995. */
  34996. set environmentTexture(value: Nullable<BaseTexture>);
  34997. /** @hidden */
  34998. protected _environmentIntensity: number;
  34999. /**
  35000. * Intensity of the environment in all pbr material.
  35001. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35002. * As in the majority of the scene they are the same (exception for multi room and so on),
  35003. * this is easier to reference from here than from all the materials.
  35004. */
  35005. get environmentIntensity(): number;
  35006. /**
  35007. * Intensity of the environment in all pbr material.
  35008. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  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 environmentIntensity(value: number);
  35013. /** @hidden */
  35014. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35015. /**
  35016. * Default image processing configuration used either in the rendering
  35017. * Forward main pass or through the imageProcessingPostProcess if present.
  35018. * As in the majority of the scene they are the same (exception for multi camera),
  35019. * this is easier to reference from here than from all the materials and post process.
  35020. *
  35021. * No setter as we it is a shared configuration, you can set the values instead.
  35022. */
  35023. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  35024. private _forceWireframe;
  35025. /**
  35026. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  35027. */
  35028. set forceWireframe(value: boolean);
  35029. get forceWireframe(): boolean;
  35030. private _skipFrustumClipping;
  35031. /**
  35032. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  35033. */
  35034. set skipFrustumClipping(value: boolean);
  35035. get skipFrustumClipping(): boolean;
  35036. private _forcePointsCloud;
  35037. /**
  35038. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  35039. */
  35040. set forcePointsCloud(value: boolean);
  35041. get forcePointsCloud(): boolean;
  35042. /**
  35043. * Gets or sets the active clipplane 1
  35044. */
  35045. clipPlane: Nullable<Plane>;
  35046. /**
  35047. * Gets or sets the active clipplane 2
  35048. */
  35049. clipPlane2: Nullable<Plane>;
  35050. /**
  35051. * Gets or sets the active clipplane 3
  35052. */
  35053. clipPlane3: Nullable<Plane>;
  35054. /**
  35055. * Gets or sets the active clipplane 4
  35056. */
  35057. clipPlane4: Nullable<Plane>;
  35058. /**
  35059. * Gets or sets the active clipplane 5
  35060. */
  35061. clipPlane5: Nullable<Plane>;
  35062. /**
  35063. * Gets or sets the active clipplane 6
  35064. */
  35065. clipPlane6: Nullable<Plane>;
  35066. /**
  35067. * Gets or sets a boolean indicating if animations are enabled
  35068. */
  35069. animationsEnabled: boolean;
  35070. private _animationPropertiesOverride;
  35071. /**
  35072. * Gets or sets the animation properties override
  35073. */
  35074. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  35075. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  35076. /**
  35077. * Gets or sets a boolean indicating if a constant deltatime has to be used
  35078. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  35079. */
  35080. useConstantAnimationDeltaTime: boolean;
  35081. /**
  35082. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  35083. * Please note that it requires to run a ray cast through the scene on every frame
  35084. */
  35085. constantlyUpdateMeshUnderPointer: boolean;
  35086. /**
  35087. * Defines the HTML cursor to use when hovering over interactive elements
  35088. */
  35089. hoverCursor: string;
  35090. /**
  35091. * Defines the HTML default cursor to use (empty by default)
  35092. */
  35093. defaultCursor: string;
  35094. /**
  35095. * Defines wether cursors are handled by the scene.
  35096. */
  35097. doNotHandleCursors: boolean;
  35098. /**
  35099. * This is used to call preventDefault() on pointer down
  35100. * in order to block unwanted artifacts like system double clicks
  35101. */
  35102. preventDefaultOnPointerDown: boolean;
  35103. /**
  35104. * This is used to call preventDefault() on pointer up
  35105. * in order to block unwanted artifacts like system double clicks
  35106. */
  35107. preventDefaultOnPointerUp: boolean;
  35108. /**
  35109. * Gets or sets user defined metadata
  35110. */
  35111. metadata: any;
  35112. /**
  35113. * For internal use only. Please do not use.
  35114. */
  35115. reservedDataStore: any;
  35116. /**
  35117. * Gets the name of the plugin used to load this scene (null by default)
  35118. */
  35119. loadingPluginName: string;
  35120. /**
  35121. * Use this array to add regular expressions used to disable offline support for specific urls
  35122. */
  35123. disableOfflineSupportExceptionRules: RegExp[];
  35124. /**
  35125. * An event triggered when the scene is disposed.
  35126. */
  35127. onDisposeObservable: Observable<Scene>;
  35128. private _onDisposeObserver;
  35129. /** Sets a function to be executed when this scene is disposed. */
  35130. set onDispose(callback: () => void);
  35131. /**
  35132. * An event triggered before rendering the scene (right after animations and physics)
  35133. */
  35134. onBeforeRenderObservable: Observable<Scene>;
  35135. private _onBeforeRenderObserver;
  35136. /** Sets a function to be executed before rendering this scene */
  35137. set beforeRender(callback: Nullable<() => void>);
  35138. /**
  35139. * An event triggered after rendering the scene
  35140. */
  35141. onAfterRenderObservable: Observable<Scene>;
  35142. /**
  35143. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  35144. */
  35145. onAfterRenderCameraObservable: Observable<Camera>;
  35146. private _onAfterRenderObserver;
  35147. /** Sets a function to be executed after rendering this scene */
  35148. set afterRender(callback: Nullable<() => void>);
  35149. /**
  35150. * An event triggered before animating the scene
  35151. */
  35152. onBeforeAnimationsObservable: Observable<Scene>;
  35153. /**
  35154. * An event triggered after animations processing
  35155. */
  35156. onAfterAnimationsObservable: Observable<Scene>;
  35157. /**
  35158. * An event triggered before draw calls are ready to be sent
  35159. */
  35160. onBeforeDrawPhaseObservable: Observable<Scene>;
  35161. /**
  35162. * An event triggered after draw calls have been sent
  35163. */
  35164. onAfterDrawPhaseObservable: Observable<Scene>;
  35165. /**
  35166. * An event triggered when the scene is ready
  35167. */
  35168. onReadyObservable: Observable<Scene>;
  35169. /**
  35170. * An event triggered before rendering a camera
  35171. */
  35172. onBeforeCameraRenderObservable: Observable<Camera>;
  35173. private _onBeforeCameraRenderObserver;
  35174. /** Sets a function to be executed before rendering a camera*/
  35175. set beforeCameraRender(callback: () => void);
  35176. /**
  35177. * An event triggered after rendering a camera
  35178. */
  35179. onAfterCameraRenderObservable: Observable<Camera>;
  35180. private _onAfterCameraRenderObserver;
  35181. /** Sets a function to be executed after rendering a camera*/
  35182. set afterCameraRender(callback: () => void);
  35183. /**
  35184. * An event triggered when active meshes evaluation is about to start
  35185. */
  35186. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  35187. /**
  35188. * An event triggered when active meshes evaluation is done
  35189. */
  35190. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  35191. /**
  35192. * An event triggered when particles rendering is about to start
  35193. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35194. */
  35195. onBeforeParticlesRenderingObservable: Observable<Scene>;
  35196. /**
  35197. * An event triggered when particles rendering is done
  35198. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35199. */
  35200. onAfterParticlesRenderingObservable: Observable<Scene>;
  35201. /**
  35202. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  35203. */
  35204. onDataLoadedObservable: Observable<Scene>;
  35205. /**
  35206. * An event triggered when a camera is created
  35207. */
  35208. onNewCameraAddedObservable: Observable<Camera>;
  35209. /**
  35210. * An event triggered when a camera is removed
  35211. */
  35212. onCameraRemovedObservable: Observable<Camera>;
  35213. /**
  35214. * An event triggered when a light is created
  35215. */
  35216. onNewLightAddedObservable: Observable<Light>;
  35217. /**
  35218. * An event triggered when a light is removed
  35219. */
  35220. onLightRemovedObservable: Observable<Light>;
  35221. /**
  35222. * An event triggered when a geometry is created
  35223. */
  35224. onNewGeometryAddedObservable: Observable<Geometry>;
  35225. /**
  35226. * An event triggered when a geometry is removed
  35227. */
  35228. onGeometryRemovedObservable: Observable<Geometry>;
  35229. /**
  35230. * An event triggered when a transform node is created
  35231. */
  35232. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  35233. /**
  35234. * An event triggered when a transform node is removed
  35235. */
  35236. onTransformNodeRemovedObservable: Observable<TransformNode>;
  35237. /**
  35238. * An event triggered when a mesh is created
  35239. */
  35240. onNewMeshAddedObservable: Observable<AbstractMesh>;
  35241. /**
  35242. * An event triggered when a mesh is removed
  35243. */
  35244. onMeshRemovedObservable: Observable<AbstractMesh>;
  35245. /**
  35246. * An event triggered when a skeleton is created
  35247. */
  35248. onNewSkeletonAddedObservable: Observable<Skeleton>;
  35249. /**
  35250. * An event triggered when a skeleton is removed
  35251. */
  35252. onSkeletonRemovedObservable: Observable<Skeleton>;
  35253. /**
  35254. * An event triggered when a material is created
  35255. */
  35256. onNewMaterialAddedObservable: Observable<Material>;
  35257. /**
  35258. * An event triggered when a material is removed
  35259. */
  35260. onMaterialRemovedObservable: Observable<Material>;
  35261. /**
  35262. * An event triggered when a texture is created
  35263. */
  35264. onNewTextureAddedObservable: Observable<BaseTexture>;
  35265. /**
  35266. * An event triggered when a texture is removed
  35267. */
  35268. onTextureRemovedObservable: Observable<BaseTexture>;
  35269. /**
  35270. * An event triggered when render targets are about to be rendered
  35271. * Can happen multiple times per frame.
  35272. */
  35273. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  35274. /**
  35275. * An event triggered when render targets were rendered.
  35276. * Can happen multiple times per frame.
  35277. */
  35278. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  35279. /**
  35280. * An event triggered before calculating deterministic simulation step
  35281. */
  35282. onBeforeStepObservable: Observable<Scene>;
  35283. /**
  35284. * An event triggered after calculating deterministic simulation step
  35285. */
  35286. onAfterStepObservable: Observable<Scene>;
  35287. /**
  35288. * An event triggered when the activeCamera property is updated
  35289. */
  35290. onActiveCameraChanged: Observable<Scene>;
  35291. /**
  35292. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  35293. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35294. * 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)
  35295. */
  35296. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35297. /**
  35298. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  35299. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35300. * 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)
  35301. */
  35302. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35303. /**
  35304. * This Observable will when a mesh has been imported into the scene.
  35305. */
  35306. onMeshImportedObservable: Observable<AbstractMesh>;
  35307. /**
  35308. * This Observable will when an animation file has been imported into the scene.
  35309. */
  35310. onAnimationFileImportedObservable: Observable<Scene>;
  35311. /**
  35312. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  35313. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  35314. */
  35315. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  35316. /** @hidden */
  35317. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  35318. /**
  35319. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  35320. */
  35321. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  35322. /**
  35323. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  35324. */
  35325. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  35326. /**
  35327. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  35328. */
  35329. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  35330. /** Callback called when a pointer move is detected */
  35331. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35332. /** Callback called when a pointer down is detected */
  35333. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35334. /** Callback called when a pointer up is detected */
  35335. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  35336. /** Callback called when a pointer pick is detected */
  35337. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  35338. /**
  35339. * 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).
  35340. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  35341. */
  35342. onPrePointerObservable: Observable<PointerInfoPre>;
  35343. /**
  35344. * Observable event triggered each time an input event is received from the rendering canvas
  35345. */
  35346. onPointerObservable: Observable<PointerInfo>;
  35347. /**
  35348. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  35349. */
  35350. get unTranslatedPointer(): Vector2;
  35351. /**
  35352. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  35353. */
  35354. static get DragMovementThreshold(): number;
  35355. static set DragMovementThreshold(value: number);
  35356. /**
  35357. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  35358. */
  35359. static get LongPressDelay(): number;
  35360. static set LongPressDelay(value: number);
  35361. /**
  35362. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  35363. */
  35364. static get DoubleClickDelay(): number;
  35365. static set DoubleClickDelay(value: number);
  35366. /** If you need to check double click without raising a single click at first click, enable this flag */
  35367. static get ExclusiveDoubleClickMode(): boolean;
  35368. static set ExclusiveDoubleClickMode(value: boolean);
  35369. /** @hidden */
  35370. _mirroredCameraPosition: Nullable<Vector3>;
  35371. /**
  35372. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  35373. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  35374. */
  35375. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  35376. /**
  35377. * Observable event triggered each time an keyboard event is received from the hosting window
  35378. */
  35379. onKeyboardObservable: Observable<KeyboardInfo>;
  35380. private _useRightHandedSystem;
  35381. /**
  35382. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  35383. */
  35384. set useRightHandedSystem(value: boolean);
  35385. get useRightHandedSystem(): boolean;
  35386. private _timeAccumulator;
  35387. private _currentStepId;
  35388. private _currentInternalStep;
  35389. /**
  35390. * Sets the step Id used by deterministic lock step
  35391. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35392. * @param newStepId defines the step Id
  35393. */
  35394. setStepId(newStepId: number): void;
  35395. /**
  35396. * Gets the step Id used by deterministic lock step
  35397. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35398. * @returns the step Id
  35399. */
  35400. getStepId(): number;
  35401. /**
  35402. * Gets the internal step used by deterministic lock step
  35403. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35404. * @returns the internal step
  35405. */
  35406. getInternalStep(): number;
  35407. private _fogEnabled;
  35408. /**
  35409. * Gets or sets a boolean indicating if fog is enabled on this scene
  35410. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35411. * (Default is true)
  35412. */
  35413. set fogEnabled(value: boolean);
  35414. get fogEnabled(): boolean;
  35415. private _fogMode;
  35416. /**
  35417. * Gets or sets the fog mode to use
  35418. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35419. * | mode | value |
  35420. * | --- | --- |
  35421. * | FOGMODE_NONE | 0 |
  35422. * | FOGMODE_EXP | 1 |
  35423. * | FOGMODE_EXP2 | 2 |
  35424. * | FOGMODE_LINEAR | 3 |
  35425. */
  35426. set fogMode(value: number);
  35427. get fogMode(): number;
  35428. /**
  35429. * Gets or sets the fog color to use
  35430. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35431. * (Default is Color3(0.2, 0.2, 0.3))
  35432. */
  35433. fogColor: Color3;
  35434. /**
  35435. * Gets or sets the fog density to use
  35436. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35437. * (Default is 0.1)
  35438. */
  35439. fogDensity: number;
  35440. /**
  35441. * Gets or sets the fog start distance to use
  35442. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35443. * (Default is 0)
  35444. */
  35445. fogStart: number;
  35446. /**
  35447. * Gets or sets the fog end distance to use
  35448. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35449. * (Default is 1000)
  35450. */
  35451. fogEnd: number;
  35452. private _shadowsEnabled;
  35453. /**
  35454. * Gets or sets a boolean indicating if shadows are enabled on this scene
  35455. */
  35456. set shadowsEnabled(value: boolean);
  35457. get shadowsEnabled(): boolean;
  35458. private _lightsEnabled;
  35459. /**
  35460. * Gets or sets a boolean indicating if lights are enabled on this scene
  35461. */
  35462. set lightsEnabled(value: boolean);
  35463. get lightsEnabled(): boolean;
  35464. /** All of the active cameras added to this scene. */
  35465. activeCameras: Camera[];
  35466. /** @hidden */
  35467. _activeCamera: Nullable<Camera>;
  35468. /** Gets or sets the current active camera */
  35469. get activeCamera(): Nullable<Camera>;
  35470. set activeCamera(value: Nullable<Camera>);
  35471. private _defaultMaterial;
  35472. /** The default material used on meshes when no material is affected */
  35473. get defaultMaterial(): Material;
  35474. /** The default material used on meshes when no material is affected */
  35475. set defaultMaterial(value: Material);
  35476. private _texturesEnabled;
  35477. /**
  35478. * Gets or sets a boolean indicating if textures are enabled on this scene
  35479. */
  35480. set texturesEnabled(value: boolean);
  35481. get texturesEnabled(): boolean;
  35482. /**
  35483. * Gets or sets a boolean indicating if particles are enabled on this scene
  35484. */
  35485. particlesEnabled: boolean;
  35486. /**
  35487. * Gets or sets a boolean indicating if sprites are enabled on this scene
  35488. */
  35489. spritesEnabled: boolean;
  35490. private _skeletonsEnabled;
  35491. /**
  35492. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  35493. */
  35494. set skeletonsEnabled(value: boolean);
  35495. get skeletonsEnabled(): boolean;
  35496. /**
  35497. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  35498. */
  35499. lensFlaresEnabled: boolean;
  35500. /**
  35501. * Gets or sets a boolean indicating if collisions are enabled on this scene
  35502. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35503. */
  35504. collisionsEnabled: boolean;
  35505. private _collisionCoordinator;
  35506. /** @hidden */
  35507. get collisionCoordinator(): ICollisionCoordinator;
  35508. /**
  35509. * Defines the gravity applied to this scene (used only for collisions)
  35510. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35511. */
  35512. gravity: Vector3;
  35513. /**
  35514. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  35515. */
  35516. postProcessesEnabled: boolean;
  35517. /**
  35518. * The list of postprocesses added to the scene
  35519. */
  35520. postProcesses: PostProcess[];
  35521. /**
  35522. * Gets the current postprocess manager
  35523. */
  35524. postProcessManager: PostProcessManager;
  35525. /**
  35526. * Gets or sets a boolean indicating if render targets are enabled on this scene
  35527. */
  35528. renderTargetsEnabled: boolean;
  35529. /**
  35530. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  35531. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  35532. */
  35533. dumpNextRenderTargets: boolean;
  35534. /**
  35535. * The list of user defined render targets added to the scene
  35536. */
  35537. customRenderTargets: RenderTargetTexture[];
  35538. /**
  35539. * Defines if texture loading must be delayed
  35540. * If true, textures will only be loaded when they need to be rendered
  35541. */
  35542. useDelayedTextureLoading: boolean;
  35543. /**
  35544. * Gets the list of meshes imported to the scene through SceneLoader
  35545. */
  35546. importedMeshesFiles: String[];
  35547. /**
  35548. * Gets or sets a boolean indicating if probes are enabled on this scene
  35549. */
  35550. probesEnabled: boolean;
  35551. /**
  35552. * Gets or sets the current offline provider to use to store scene data
  35553. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  35554. */
  35555. offlineProvider: IOfflineProvider;
  35556. /**
  35557. * Gets or sets the action manager associated with the scene
  35558. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35559. */
  35560. actionManager: AbstractActionManager;
  35561. private _meshesForIntersections;
  35562. /**
  35563. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  35564. */
  35565. proceduralTexturesEnabled: boolean;
  35566. private _engine;
  35567. private _totalVertices;
  35568. /** @hidden */
  35569. _activeIndices: PerfCounter;
  35570. /** @hidden */
  35571. _activeParticles: PerfCounter;
  35572. /** @hidden */
  35573. _activeBones: PerfCounter;
  35574. private _animationRatio;
  35575. /** @hidden */
  35576. _animationTimeLast: number;
  35577. /** @hidden */
  35578. _animationTime: number;
  35579. /**
  35580. * Gets or sets a general scale for animation speed
  35581. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  35582. */
  35583. animationTimeScale: number;
  35584. /** @hidden */
  35585. _cachedMaterial: Nullable<Material>;
  35586. /** @hidden */
  35587. _cachedEffect: Nullable<Effect>;
  35588. /** @hidden */
  35589. _cachedVisibility: Nullable<number>;
  35590. private _renderId;
  35591. private _frameId;
  35592. private _executeWhenReadyTimeoutId;
  35593. private _intermediateRendering;
  35594. private _viewUpdateFlag;
  35595. private _projectionUpdateFlag;
  35596. /** @hidden */
  35597. _toBeDisposed: Nullable<IDisposable>[];
  35598. private _activeRequests;
  35599. /** @hidden */
  35600. _pendingData: any[];
  35601. private _isDisposed;
  35602. /**
  35603. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  35604. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  35605. */
  35606. dispatchAllSubMeshesOfActiveMeshes: boolean;
  35607. private _activeMeshes;
  35608. private _processedMaterials;
  35609. private _renderTargets;
  35610. /** @hidden */
  35611. _activeParticleSystems: SmartArray<IParticleSystem>;
  35612. private _activeSkeletons;
  35613. private _softwareSkinnedMeshes;
  35614. private _renderingManager;
  35615. /** @hidden */
  35616. _activeAnimatables: Animatable[];
  35617. private _transformMatrix;
  35618. private _sceneUbo;
  35619. /** @hidden */
  35620. _viewMatrix: Matrix;
  35621. private _projectionMatrix;
  35622. /** @hidden */
  35623. _forcedViewPosition: Nullable<Vector3>;
  35624. /** @hidden */
  35625. _frustumPlanes: Plane[];
  35626. /**
  35627. * Gets the list of frustum planes (built from the active camera)
  35628. */
  35629. get frustumPlanes(): Plane[];
  35630. /**
  35631. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  35632. * This is useful if there are more lights that the maximum simulteanous authorized
  35633. */
  35634. requireLightSorting: boolean;
  35635. /** @hidden */
  35636. readonly useMaterialMeshMap: boolean;
  35637. /** @hidden */
  35638. readonly useClonedMeshMap: boolean;
  35639. private _externalData;
  35640. private _uid;
  35641. /**
  35642. * @hidden
  35643. * Backing store of defined scene components.
  35644. */
  35645. _components: ISceneComponent[];
  35646. /**
  35647. * @hidden
  35648. * Backing store of defined scene components.
  35649. */
  35650. _serializableComponents: ISceneSerializableComponent[];
  35651. /**
  35652. * List of components to register on the next registration step.
  35653. */
  35654. private _transientComponents;
  35655. /**
  35656. * Registers the transient components if needed.
  35657. */
  35658. private _registerTransientComponents;
  35659. /**
  35660. * @hidden
  35661. * Add a component to the scene.
  35662. * Note that the ccomponent could be registered on th next frame if this is called after
  35663. * the register component stage.
  35664. * @param component Defines the component to add to the scene
  35665. */
  35666. _addComponent(component: ISceneComponent): void;
  35667. /**
  35668. * @hidden
  35669. * Gets a component from the scene.
  35670. * @param name defines the name of the component to retrieve
  35671. * @returns the component or null if not present
  35672. */
  35673. _getComponent(name: string): Nullable<ISceneComponent>;
  35674. /**
  35675. * @hidden
  35676. * Defines the actions happening before camera updates.
  35677. */
  35678. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  35679. /**
  35680. * @hidden
  35681. * Defines the actions happening before clear the canvas.
  35682. */
  35683. _beforeClearStage: Stage<SimpleStageAction>;
  35684. /**
  35685. * @hidden
  35686. * Defines the actions when collecting render targets for the frame.
  35687. */
  35688. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35689. /**
  35690. * @hidden
  35691. * Defines the actions happening for one camera in the frame.
  35692. */
  35693. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35694. /**
  35695. * @hidden
  35696. * Defines the actions happening during the per mesh ready checks.
  35697. */
  35698. _isReadyForMeshStage: Stage<MeshStageAction>;
  35699. /**
  35700. * @hidden
  35701. * Defines the actions happening before evaluate active mesh checks.
  35702. */
  35703. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  35704. /**
  35705. * @hidden
  35706. * Defines the actions happening during the evaluate sub mesh checks.
  35707. */
  35708. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  35709. /**
  35710. * @hidden
  35711. * Defines the actions happening during the active mesh stage.
  35712. */
  35713. _activeMeshStage: Stage<ActiveMeshStageAction>;
  35714. /**
  35715. * @hidden
  35716. * Defines the actions happening during the per camera render target step.
  35717. */
  35718. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  35719. /**
  35720. * @hidden
  35721. * Defines the actions happening just before the active camera is drawing.
  35722. */
  35723. _beforeCameraDrawStage: Stage<CameraStageAction>;
  35724. /**
  35725. * @hidden
  35726. * Defines the actions happening just before a render target is drawing.
  35727. */
  35728. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35729. /**
  35730. * @hidden
  35731. * Defines the actions happening just before a rendering group is drawing.
  35732. */
  35733. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35734. /**
  35735. * @hidden
  35736. * Defines the actions happening just before a mesh is drawing.
  35737. */
  35738. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35739. /**
  35740. * @hidden
  35741. * Defines the actions happening just after a mesh has been drawn.
  35742. */
  35743. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35744. /**
  35745. * @hidden
  35746. * Defines the actions happening just after a rendering group has been drawn.
  35747. */
  35748. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35749. /**
  35750. * @hidden
  35751. * Defines the actions happening just after the active camera has been drawn.
  35752. */
  35753. _afterCameraDrawStage: Stage<CameraStageAction>;
  35754. /**
  35755. * @hidden
  35756. * Defines the actions happening just after a render target has been drawn.
  35757. */
  35758. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35759. /**
  35760. * @hidden
  35761. * Defines the actions happening just after rendering all cameras and computing intersections.
  35762. */
  35763. _afterRenderStage: Stage<SimpleStageAction>;
  35764. /**
  35765. * @hidden
  35766. * Defines the actions happening when a pointer move event happens.
  35767. */
  35768. _pointerMoveStage: Stage<PointerMoveStageAction>;
  35769. /**
  35770. * @hidden
  35771. * Defines the actions happening when a pointer down event happens.
  35772. */
  35773. _pointerDownStage: Stage<PointerUpDownStageAction>;
  35774. /**
  35775. * @hidden
  35776. * Defines the actions happening when a pointer up event happens.
  35777. */
  35778. _pointerUpStage: Stage<PointerUpDownStageAction>;
  35779. /**
  35780. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  35781. */
  35782. private geometriesByUniqueId;
  35783. /**
  35784. * Creates a new Scene
  35785. * @param engine defines the engine to use to render this scene
  35786. * @param options defines the scene options
  35787. */
  35788. constructor(engine: Engine, options?: SceneOptions);
  35789. /**
  35790. * Gets a string idenfifying the name of the class
  35791. * @returns "Scene" string
  35792. */
  35793. getClassName(): string;
  35794. private _defaultMeshCandidates;
  35795. /**
  35796. * @hidden
  35797. */
  35798. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  35799. private _defaultSubMeshCandidates;
  35800. /**
  35801. * @hidden
  35802. */
  35803. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  35804. /**
  35805. * Sets the default candidate providers for the scene.
  35806. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  35807. * and getCollidingSubMeshCandidates to their default function
  35808. */
  35809. setDefaultCandidateProviders(): void;
  35810. /**
  35811. * Gets the mesh that is currently under the pointer
  35812. */
  35813. get meshUnderPointer(): Nullable<AbstractMesh>;
  35814. /**
  35815. * Gets or sets the current on-screen X position of the pointer
  35816. */
  35817. get pointerX(): number;
  35818. set pointerX(value: number);
  35819. /**
  35820. * Gets or sets the current on-screen Y position of the pointer
  35821. */
  35822. get pointerY(): number;
  35823. set pointerY(value: number);
  35824. /**
  35825. * Gets the cached material (ie. the latest rendered one)
  35826. * @returns the cached material
  35827. */
  35828. getCachedMaterial(): Nullable<Material>;
  35829. /**
  35830. * Gets the cached effect (ie. the latest rendered one)
  35831. * @returns the cached effect
  35832. */
  35833. getCachedEffect(): Nullable<Effect>;
  35834. /**
  35835. * Gets the cached visibility state (ie. the latest rendered one)
  35836. * @returns the cached visibility state
  35837. */
  35838. getCachedVisibility(): Nullable<number>;
  35839. /**
  35840. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  35841. * @param material defines the current material
  35842. * @param effect defines the current effect
  35843. * @param visibility defines the current visibility state
  35844. * @returns true if one parameter is not cached
  35845. */
  35846. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  35847. /**
  35848. * Gets the engine associated with the scene
  35849. * @returns an Engine
  35850. */
  35851. getEngine(): Engine;
  35852. /**
  35853. * Gets the total number of vertices rendered per frame
  35854. * @returns the total number of vertices rendered per frame
  35855. */
  35856. getTotalVertices(): number;
  35857. /**
  35858. * Gets the performance counter for total vertices
  35859. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35860. */
  35861. get totalVerticesPerfCounter(): PerfCounter;
  35862. /**
  35863. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  35864. * @returns the total number of active indices rendered per frame
  35865. */
  35866. getActiveIndices(): number;
  35867. /**
  35868. * Gets the performance counter for active indices
  35869. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35870. */
  35871. get totalActiveIndicesPerfCounter(): PerfCounter;
  35872. /**
  35873. * Gets the total number of active particles rendered per frame
  35874. * @returns the total number of active particles rendered per frame
  35875. */
  35876. getActiveParticles(): number;
  35877. /**
  35878. * Gets the performance counter for active particles
  35879. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35880. */
  35881. get activeParticlesPerfCounter(): PerfCounter;
  35882. /**
  35883. * Gets the total number of active bones rendered per frame
  35884. * @returns the total number of active bones rendered per frame
  35885. */
  35886. getActiveBones(): number;
  35887. /**
  35888. * Gets the performance counter for active bones
  35889. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  35890. */
  35891. get activeBonesPerfCounter(): PerfCounter;
  35892. /**
  35893. * Gets the array of active meshes
  35894. * @returns an array of AbstractMesh
  35895. */
  35896. getActiveMeshes(): SmartArray<AbstractMesh>;
  35897. /**
  35898. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  35899. * @returns a number
  35900. */
  35901. getAnimationRatio(): number;
  35902. /**
  35903. * Gets an unique Id for the current render phase
  35904. * @returns a number
  35905. */
  35906. getRenderId(): number;
  35907. /**
  35908. * Gets an unique Id for the current frame
  35909. * @returns a number
  35910. */
  35911. getFrameId(): number;
  35912. /** Call this function if you want to manually increment the render Id*/
  35913. incrementRenderId(): void;
  35914. private _createUbo;
  35915. /**
  35916. * Use this method to simulate a pointer move on a mesh
  35917. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35918. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35919. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35920. * @returns the current scene
  35921. */
  35922. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35923. /**
  35924. * Use this method to simulate a pointer down on a mesh
  35925. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35926. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35927. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35928. * @returns the current scene
  35929. */
  35930. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  35931. /**
  35932. * Use this method to simulate a pointer up 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. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35937. * @returns the current scene
  35938. */
  35939. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  35940. /**
  35941. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35942. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35943. * @returns true if the pointer was captured
  35944. */
  35945. isPointerCaptured(pointerId?: number): boolean;
  35946. /**
  35947. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35948. * @param attachUp defines if you want to attach events to pointerup
  35949. * @param attachDown defines if you want to attach events to pointerdown
  35950. * @param attachMove defines if you want to attach events to pointermove
  35951. */
  35952. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  35953. /** Detaches all event handlers*/
  35954. detachControl(): void;
  35955. /**
  35956. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  35957. * Delay loaded resources are not taking in account
  35958. * @return true if all required resources are ready
  35959. */
  35960. isReady(): boolean;
  35961. /** Resets all cached information relative to material (including effect and visibility) */
  35962. resetCachedMaterial(): void;
  35963. /**
  35964. * Registers a function to be called before every frame render
  35965. * @param func defines the function to register
  35966. */
  35967. registerBeforeRender(func: () => void): void;
  35968. /**
  35969. * Unregisters a function called before every frame render
  35970. * @param func defines the function to unregister
  35971. */
  35972. unregisterBeforeRender(func: () => void): void;
  35973. /**
  35974. * Registers a function to be called after every frame render
  35975. * @param func defines the function to register
  35976. */
  35977. registerAfterRender(func: () => void): void;
  35978. /**
  35979. * Unregisters a function called after every frame render
  35980. * @param func defines the function to unregister
  35981. */
  35982. unregisterAfterRender(func: () => void): void;
  35983. private _executeOnceBeforeRender;
  35984. /**
  35985. * The provided function will run before render once and will be disposed afterwards.
  35986. * A timeout delay can be provided so that the function will be executed in N ms.
  35987. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  35988. * @param func The function to be executed.
  35989. * @param timeout optional delay in ms
  35990. */
  35991. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  35992. /** @hidden */
  35993. _addPendingData(data: any): void;
  35994. /** @hidden */
  35995. _removePendingData(data: any): void;
  35996. /**
  35997. * Returns the number of items waiting to be loaded
  35998. * @returns the number of items waiting to be loaded
  35999. */
  36000. getWaitingItemsCount(): number;
  36001. /**
  36002. * Returns a boolean indicating if the scene is still loading data
  36003. */
  36004. get isLoading(): boolean;
  36005. /**
  36006. * Registers a function to be executed when the scene is ready
  36007. * @param {Function} func - the function to be executed
  36008. */
  36009. executeWhenReady(func: () => void): void;
  36010. /**
  36011. * Returns a promise that resolves when the scene is ready
  36012. * @returns A promise that resolves when the scene is ready
  36013. */
  36014. whenReadyAsync(): Promise<void>;
  36015. /** @hidden */
  36016. _checkIsReady(): void;
  36017. /**
  36018. * Gets all animatable attached to the scene
  36019. */
  36020. get animatables(): Animatable[];
  36021. /**
  36022. * Resets the last animation time frame.
  36023. * Useful to override when animations start running when loading a scene for the first time.
  36024. */
  36025. resetLastAnimationTimeFrame(): void;
  36026. /**
  36027. * Gets the current view matrix
  36028. * @returns a Matrix
  36029. */
  36030. getViewMatrix(): Matrix;
  36031. /**
  36032. * Gets the current projection matrix
  36033. * @returns a Matrix
  36034. */
  36035. getProjectionMatrix(): Matrix;
  36036. /**
  36037. * Gets the current transform matrix
  36038. * @returns a Matrix made of View * Projection
  36039. */
  36040. getTransformMatrix(): Matrix;
  36041. /**
  36042. * Sets the current transform matrix
  36043. * @param viewL defines the View matrix to use
  36044. * @param projectionL defines the Projection matrix to use
  36045. * @param viewR defines the right View matrix to use (if provided)
  36046. * @param projectionR defines the right Projection matrix to use (if provided)
  36047. */
  36048. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  36049. /**
  36050. * Gets the uniform buffer used to store scene data
  36051. * @returns a UniformBuffer
  36052. */
  36053. getSceneUniformBuffer(): UniformBuffer;
  36054. /**
  36055. * Gets an unique (relatively to the current scene) Id
  36056. * @returns an unique number for the scene
  36057. */
  36058. getUniqueId(): number;
  36059. /**
  36060. * Add a mesh to the list of scene's meshes
  36061. * @param newMesh defines the mesh to add
  36062. * @param recursive if all child meshes should also be added to the scene
  36063. */
  36064. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  36065. /**
  36066. * Remove a mesh for the list of scene's meshes
  36067. * @param toRemove defines the mesh to remove
  36068. * @param recursive if all child meshes should also be removed from the scene
  36069. * @returns the index where the mesh was in the mesh list
  36070. */
  36071. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  36072. /**
  36073. * Add a transform node to the list of scene's transform nodes
  36074. * @param newTransformNode defines the transform node to add
  36075. */
  36076. addTransformNode(newTransformNode: TransformNode): void;
  36077. /**
  36078. * Remove a transform node for the list of scene's transform nodes
  36079. * @param toRemove defines the transform node to remove
  36080. * @returns the index where the transform node was in the transform node list
  36081. */
  36082. removeTransformNode(toRemove: TransformNode): number;
  36083. /**
  36084. * Remove a skeleton for the list of scene's skeletons
  36085. * @param toRemove defines the skeleton to remove
  36086. * @returns the index where the skeleton was in the skeleton list
  36087. */
  36088. removeSkeleton(toRemove: Skeleton): number;
  36089. /**
  36090. * Remove a morph target for the list of scene's morph targets
  36091. * @param toRemove defines the morph target to remove
  36092. * @returns the index where the morph target was in the morph target list
  36093. */
  36094. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  36095. /**
  36096. * Remove a light for the list of scene's lights
  36097. * @param toRemove defines the light to remove
  36098. * @returns the index where the light was in the light list
  36099. */
  36100. removeLight(toRemove: Light): number;
  36101. /**
  36102. * Remove a camera for the list of scene's cameras
  36103. * @param toRemove defines the camera to remove
  36104. * @returns the index where the camera was in the camera list
  36105. */
  36106. removeCamera(toRemove: Camera): number;
  36107. /**
  36108. * Remove a particle system for the list of scene's particle systems
  36109. * @param toRemove defines the particle system to remove
  36110. * @returns the index where the particle system was in the particle system list
  36111. */
  36112. removeParticleSystem(toRemove: IParticleSystem): number;
  36113. /**
  36114. * Remove a animation for the list of scene's animations
  36115. * @param toRemove defines the animation to remove
  36116. * @returns the index where the animation was in the animation list
  36117. */
  36118. removeAnimation(toRemove: Animation): number;
  36119. /**
  36120. * Will stop the animation of the given target
  36121. * @param target - the target
  36122. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  36123. * @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)
  36124. */
  36125. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  36126. /**
  36127. * Removes the given animation group from this scene.
  36128. * @param toRemove The animation group to remove
  36129. * @returns The index of the removed animation group
  36130. */
  36131. removeAnimationGroup(toRemove: AnimationGroup): number;
  36132. /**
  36133. * Removes the given multi-material from this scene.
  36134. * @param toRemove The multi-material to remove
  36135. * @returns The index of the removed multi-material
  36136. */
  36137. removeMultiMaterial(toRemove: MultiMaterial): number;
  36138. /**
  36139. * Removes the given material from this scene.
  36140. * @param toRemove The material to remove
  36141. * @returns The index of the removed material
  36142. */
  36143. removeMaterial(toRemove: Material): number;
  36144. /**
  36145. * Removes the given action manager from this scene.
  36146. * @param toRemove The action manager to remove
  36147. * @returns The index of the removed action manager
  36148. */
  36149. removeActionManager(toRemove: AbstractActionManager): number;
  36150. /**
  36151. * Removes the given texture from this scene.
  36152. * @param toRemove The texture to remove
  36153. * @returns The index of the removed texture
  36154. */
  36155. removeTexture(toRemove: BaseTexture): number;
  36156. /**
  36157. * Adds the given light to this scene
  36158. * @param newLight The light to add
  36159. */
  36160. addLight(newLight: Light): void;
  36161. /**
  36162. * Sorts the list list based on light priorities
  36163. */
  36164. sortLightsByPriority(): void;
  36165. /**
  36166. * Adds the given camera to this scene
  36167. * @param newCamera The camera to add
  36168. */
  36169. addCamera(newCamera: Camera): void;
  36170. /**
  36171. * Adds the given skeleton to this scene
  36172. * @param newSkeleton The skeleton to add
  36173. */
  36174. addSkeleton(newSkeleton: Skeleton): void;
  36175. /**
  36176. * Adds the given particle system to this scene
  36177. * @param newParticleSystem The particle system to add
  36178. */
  36179. addParticleSystem(newParticleSystem: IParticleSystem): void;
  36180. /**
  36181. * Adds the given animation to this scene
  36182. * @param newAnimation The animation to add
  36183. */
  36184. addAnimation(newAnimation: Animation): void;
  36185. /**
  36186. * Adds the given animation group to this scene.
  36187. * @param newAnimationGroup The animation group to add
  36188. */
  36189. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  36190. /**
  36191. * Adds the given multi-material to this scene
  36192. * @param newMultiMaterial The multi-material to add
  36193. */
  36194. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  36195. /**
  36196. * Adds the given material to this scene
  36197. * @param newMaterial The material to add
  36198. */
  36199. addMaterial(newMaterial: Material): void;
  36200. /**
  36201. * Adds the given morph target to this scene
  36202. * @param newMorphTargetManager The morph target to add
  36203. */
  36204. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  36205. /**
  36206. * Adds the given geometry to this scene
  36207. * @param newGeometry The geometry to add
  36208. */
  36209. addGeometry(newGeometry: Geometry): void;
  36210. /**
  36211. * Adds the given action manager to this scene
  36212. * @param newActionManager The action manager to add
  36213. */
  36214. addActionManager(newActionManager: AbstractActionManager): void;
  36215. /**
  36216. * Adds the given texture to this scene.
  36217. * @param newTexture The texture to add
  36218. */
  36219. addTexture(newTexture: BaseTexture): void;
  36220. /**
  36221. * Switch active camera
  36222. * @param newCamera defines the new active camera
  36223. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  36224. */
  36225. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  36226. /**
  36227. * sets the active camera of the scene using its ID
  36228. * @param id defines the camera's ID
  36229. * @return the new active camera or null if none found.
  36230. */
  36231. setActiveCameraByID(id: string): Nullable<Camera>;
  36232. /**
  36233. * sets the active camera of the scene using its name
  36234. * @param name defines the camera's name
  36235. * @returns the new active camera or null if none found.
  36236. */
  36237. setActiveCameraByName(name: string): Nullable<Camera>;
  36238. /**
  36239. * get an animation group using its name
  36240. * @param name defines the material's name
  36241. * @return the animation group or null if none found.
  36242. */
  36243. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  36244. /**
  36245. * Get a material using its unique id
  36246. * @param uniqueId defines the material's unique id
  36247. * @return the material or null if none found.
  36248. */
  36249. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  36250. /**
  36251. * get a material using its id
  36252. * @param id defines the material's ID
  36253. * @return the material or null if none found.
  36254. */
  36255. getMaterialByID(id: string): Nullable<Material>;
  36256. /**
  36257. * Gets a the last added material using a given id
  36258. * @param id defines the material's ID
  36259. * @return the last material with the given id or null if none found.
  36260. */
  36261. getLastMaterialByID(id: string): Nullable<Material>;
  36262. /**
  36263. * Gets a material using its name
  36264. * @param name defines the material's name
  36265. * @return the material or null if none found.
  36266. */
  36267. getMaterialByName(name: string): Nullable<Material>;
  36268. /**
  36269. * Get a texture using its unique id
  36270. * @param uniqueId defines the texture's unique id
  36271. * @return the texture or null if none found.
  36272. */
  36273. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  36274. /**
  36275. * Gets a camera using its id
  36276. * @param id defines the id to look for
  36277. * @returns the camera or null if not found
  36278. */
  36279. getCameraByID(id: string): Nullable<Camera>;
  36280. /**
  36281. * Gets a camera using its unique id
  36282. * @param uniqueId defines the unique id to look for
  36283. * @returns the camera or null if not found
  36284. */
  36285. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  36286. /**
  36287. * Gets a camera using its name
  36288. * @param name defines the camera's name
  36289. * @return the camera or null if none found.
  36290. */
  36291. getCameraByName(name: string): Nullable<Camera>;
  36292. /**
  36293. * Gets a bone using its id
  36294. * @param id defines the bone's id
  36295. * @return the bone or null if not found
  36296. */
  36297. getBoneByID(id: string): Nullable<Bone>;
  36298. /**
  36299. * Gets a bone using its id
  36300. * @param name defines the bone's name
  36301. * @return the bone or null if not found
  36302. */
  36303. getBoneByName(name: string): Nullable<Bone>;
  36304. /**
  36305. * Gets a light node using its name
  36306. * @param name defines the the light's name
  36307. * @return the light or null if none found.
  36308. */
  36309. getLightByName(name: string): Nullable<Light>;
  36310. /**
  36311. * Gets a light node using its id
  36312. * @param id defines the light's id
  36313. * @return the light or null if none found.
  36314. */
  36315. getLightByID(id: string): Nullable<Light>;
  36316. /**
  36317. * Gets a light node using its scene-generated unique ID
  36318. * @param uniqueId defines the light's unique id
  36319. * @return the light or null if none found.
  36320. */
  36321. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  36322. /**
  36323. * Gets a particle system by id
  36324. * @param id defines the particle system id
  36325. * @return the corresponding system or null if none found
  36326. */
  36327. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  36328. /**
  36329. * Gets a geometry using its ID
  36330. * @param id defines the geometry's id
  36331. * @return the geometry or null if none found.
  36332. */
  36333. getGeometryByID(id: string): Nullable<Geometry>;
  36334. private _getGeometryByUniqueID;
  36335. /**
  36336. * Add a new geometry to this scene
  36337. * @param geometry defines the geometry to be added to the scene.
  36338. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  36339. * @return a boolean defining if the geometry was added or not
  36340. */
  36341. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  36342. /**
  36343. * Removes an existing geometry
  36344. * @param geometry defines the geometry to be removed from the scene
  36345. * @return a boolean defining if the geometry was removed or not
  36346. */
  36347. removeGeometry(geometry: Geometry): boolean;
  36348. /**
  36349. * Gets the list of geometries attached to the scene
  36350. * @returns an array of Geometry
  36351. */
  36352. getGeometries(): Geometry[];
  36353. /**
  36354. * Gets the first added mesh found of a given ID
  36355. * @param id defines the id to search for
  36356. * @return the mesh found or null if not found at all
  36357. */
  36358. getMeshByID(id: string): Nullable<AbstractMesh>;
  36359. /**
  36360. * Gets a list of meshes using their id
  36361. * @param id defines the id to search for
  36362. * @returns a list of meshes
  36363. */
  36364. getMeshesByID(id: string): Array<AbstractMesh>;
  36365. /**
  36366. * Gets the first added transform node found of a given ID
  36367. * @param id defines the id to search for
  36368. * @return the found transform node or null if not found at all.
  36369. */
  36370. getTransformNodeByID(id: string): Nullable<TransformNode>;
  36371. /**
  36372. * Gets a transform node with its auto-generated unique id
  36373. * @param uniqueId efines the unique id to search for
  36374. * @return the found transform node or null if not found at all.
  36375. */
  36376. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  36377. /**
  36378. * Gets a list of transform nodes using their id
  36379. * @param id defines the id to search for
  36380. * @returns a list of transform nodes
  36381. */
  36382. getTransformNodesByID(id: string): Array<TransformNode>;
  36383. /**
  36384. * Gets a mesh with its auto-generated unique id
  36385. * @param uniqueId defines the unique id to search for
  36386. * @return the found mesh or null if not found at all.
  36387. */
  36388. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  36389. /**
  36390. * Gets a the last added mesh using a given id
  36391. * @param id defines the id to search for
  36392. * @return the found mesh or null if not found at all.
  36393. */
  36394. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  36395. /**
  36396. * Gets a the last added node (Mesh, Camera, Light) using a given id
  36397. * @param id defines the id to search for
  36398. * @return the found node or null if not found at all
  36399. */
  36400. getLastEntryByID(id: string): Nullable<Node>;
  36401. /**
  36402. * Gets a node (Mesh, Camera, Light) using a given id
  36403. * @param id defines the id to search for
  36404. * @return the found node or null if not found at all
  36405. */
  36406. getNodeByID(id: string): Nullable<Node>;
  36407. /**
  36408. * Gets a node (Mesh, Camera, Light) using a given name
  36409. * @param name defines the name to search for
  36410. * @return the found node or null if not found at all.
  36411. */
  36412. getNodeByName(name: string): Nullable<Node>;
  36413. /**
  36414. * Gets a mesh using a given name
  36415. * @param name defines the name to search for
  36416. * @return the found mesh or null if not found at all.
  36417. */
  36418. getMeshByName(name: string): Nullable<AbstractMesh>;
  36419. /**
  36420. * Gets a transform node using a given name
  36421. * @param name defines the name to search for
  36422. * @return the found transform node or null if not found at all.
  36423. */
  36424. getTransformNodeByName(name: string): Nullable<TransformNode>;
  36425. /**
  36426. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  36427. * @param id defines the id to search for
  36428. * @return the found skeleton or null if not found at all.
  36429. */
  36430. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  36431. /**
  36432. * Gets a skeleton using a given auto generated unique id
  36433. * @param uniqueId defines the unique id to search for
  36434. * @return the found skeleton or null if not found at all.
  36435. */
  36436. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  36437. /**
  36438. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  36439. * @param id defines the id to search for
  36440. * @return the found skeleton or null if not found at all.
  36441. */
  36442. getSkeletonById(id: string): Nullable<Skeleton>;
  36443. /**
  36444. * Gets a skeleton using a given name
  36445. * @param name defines the name to search for
  36446. * @return the found skeleton or null if not found at all.
  36447. */
  36448. getSkeletonByName(name: string): Nullable<Skeleton>;
  36449. /**
  36450. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  36451. * @param id defines the id to search for
  36452. * @return the found morph target manager or null if not found at all.
  36453. */
  36454. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  36455. /**
  36456. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  36457. * @param id defines the id to search for
  36458. * @return the found morph target or null if not found at all.
  36459. */
  36460. getMorphTargetById(id: string): Nullable<MorphTarget>;
  36461. /**
  36462. * Gets a boolean indicating if the given mesh is active
  36463. * @param mesh defines the mesh to look for
  36464. * @returns true if the mesh is in the active list
  36465. */
  36466. isActiveMesh(mesh: AbstractMesh): boolean;
  36467. /**
  36468. * Return a unique id as a string which can serve as an identifier for the scene
  36469. */
  36470. get uid(): string;
  36471. /**
  36472. * Add an externaly attached data from its key.
  36473. * This method call will fail and return false, if such key already exists.
  36474. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  36475. * @param key the unique key that identifies the data
  36476. * @param data the data object to associate to the key for this Engine instance
  36477. * @return true if no such key were already present and the data was added successfully, false otherwise
  36478. */
  36479. addExternalData<T>(key: string, data: T): boolean;
  36480. /**
  36481. * Get an externaly attached data from its key
  36482. * @param key the unique key that identifies the data
  36483. * @return the associated data, if present (can be null), or undefined if not present
  36484. */
  36485. getExternalData<T>(key: string): Nullable<T>;
  36486. /**
  36487. * Get an externaly attached data from its key, create it using a factory if it's not already present
  36488. * @param key the unique key that identifies the data
  36489. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  36490. * @return the associated data, can be null if the factory returned null.
  36491. */
  36492. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  36493. /**
  36494. * Remove an externaly attached data from the Engine instance
  36495. * @param key the unique key that identifies the data
  36496. * @return true if the data was successfully removed, false if it doesn't exist
  36497. */
  36498. removeExternalData(key: string): boolean;
  36499. private _evaluateSubMesh;
  36500. /**
  36501. * Clear the processed materials smart array preventing retention point in material dispose.
  36502. */
  36503. freeProcessedMaterials(): void;
  36504. private _preventFreeActiveMeshesAndRenderingGroups;
  36505. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  36506. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  36507. * when disposing several meshes in a row or a hierarchy of meshes.
  36508. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  36509. */
  36510. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  36511. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  36512. /**
  36513. * Clear the active meshes smart array preventing retention point in mesh dispose.
  36514. */
  36515. freeActiveMeshes(): void;
  36516. /**
  36517. * Clear the info related to rendering groups preventing retention points during dispose.
  36518. */
  36519. freeRenderingGroups(): void;
  36520. /** @hidden */
  36521. _isInIntermediateRendering(): boolean;
  36522. /**
  36523. * Lambda returning the list of potentially active meshes.
  36524. */
  36525. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  36526. /**
  36527. * Lambda returning the list of potentially active sub meshes.
  36528. */
  36529. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  36530. /**
  36531. * Lambda returning the list of potentially intersecting sub meshes.
  36532. */
  36533. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  36534. /**
  36535. * Lambda returning the list of potentially colliding sub meshes.
  36536. */
  36537. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  36538. private _activeMeshesFrozen;
  36539. private _skipEvaluateActiveMeshesCompletely;
  36540. /**
  36541. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  36542. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  36543. * @returns the current scene
  36544. */
  36545. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  36546. /**
  36547. * Use this function to restart evaluating active meshes on every frame
  36548. * @returns the current scene
  36549. */
  36550. unfreezeActiveMeshes(): Scene;
  36551. private _evaluateActiveMeshes;
  36552. private _activeMesh;
  36553. /**
  36554. * Update the transform matrix to update from the current active camera
  36555. * @param force defines a boolean used to force the update even if cache is up to date
  36556. */
  36557. updateTransformMatrix(force?: boolean): void;
  36558. private _bindFrameBuffer;
  36559. /** @hidden */
  36560. _allowPostProcessClearColor: boolean;
  36561. /** @hidden */
  36562. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  36563. private _processSubCameras;
  36564. private _checkIntersections;
  36565. /** @hidden */
  36566. _advancePhysicsEngineStep(step: number): void;
  36567. /**
  36568. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  36569. */
  36570. getDeterministicFrameTime: () => number;
  36571. /** @hidden */
  36572. _animate(): void;
  36573. /** Execute all animations (for a frame) */
  36574. animate(): void;
  36575. /**
  36576. * Render the scene
  36577. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  36578. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  36579. */
  36580. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  36581. /**
  36582. * Freeze all materials
  36583. * A frozen material will not be updatable but should be faster to render
  36584. */
  36585. freezeMaterials(): void;
  36586. /**
  36587. * Unfreeze all materials
  36588. * A frozen material will not be updatable but should be faster to render
  36589. */
  36590. unfreezeMaterials(): void;
  36591. /**
  36592. * Releases all held ressources
  36593. */
  36594. dispose(): void;
  36595. /**
  36596. * Gets if the scene is already disposed
  36597. */
  36598. get isDisposed(): boolean;
  36599. /**
  36600. * Call this function to reduce memory footprint of the scene.
  36601. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  36602. */
  36603. clearCachedVertexData(): void;
  36604. /**
  36605. * This function will remove the local cached buffer data from texture.
  36606. * It will save memory but will prevent the texture from being rebuilt
  36607. */
  36608. cleanCachedTextureBuffer(): void;
  36609. /**
  36610. * Get the world extend vectors with an optional filter
  36611. *
  36612. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  36613. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  36614. */
  36615. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  36616. min: Vector3;
  36617. max: Vector3;
  36618. };
  36619. /**
  36620. * Creates a ray that can be used to pick in the scene
  36621. * @param x defines the x coordinate of the origin (on-screen)
  36622. * @param y defines the y coordinate of the origin (on-screen)
  36623. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36624. * @param camera defines the camera to use for the picking
  36625. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36626. * @returns a Ray
  36627. */
  36628. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  36629. /**
  36630. * Creates a ray that can be used to pick in the scene
  36631. * @param x defines the x coordinate of the origin (on-screen)
  36632. * @param y defines the y coordinate of the origin (on-screen)
  36633. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36634. * @param result defines the ray where to store the picking ray
  36635. * @param camera defines the camera to use for the picking
  36636. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36637. * @returns the current scene
  36638. */
  36639. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  36640. /**
  36641. * Creates a ray that can be used to pick in the scene
  36642. * @param x defines the x coordinate of the origin (on-screen)
  36643. * @param y defines the y coordinate of the origin (on-screen)
  36644. * @param camera defines the camera to use for the picking
  36645. * @returns a Ray
  36646. */
  36647. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  36648. /**
  36649. * Creates a ray that can be used to pick in the scene
  36650. * @param x defines the x coordinate of the origin (on-screen)
  36651. * @param y defines the y coordinate of the origin (on-screen)
  36652. * @param result defines the ray where to store the picking ray
  36653. * @param camera defines the camera to use for the picking
  36654. * @returns the current scene
  36655. */
  36656. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  36657. /** Launch a ray to try to pick a mesh in the scene
  36658. * @param x position on screen
  36659. * @param y position on screen
  36660. * @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
  36661. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  36662. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36663. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36664. * @returns a PickingInfo
  36665. */
  36666. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36667. /** Use the given ray to pick a mesh in the scene
  36668. * @param ray The ray to use to pick meshes
  36669. * @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
  36670. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  36671. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36672. * @returns a PickingInfo
  36673. */
  36674. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36675. /**
  36676. * Launch a ray to try to pick a mesh in the scene
  36677. * @param x X position on screen
  36678. * @param y Y position on screen
  36679. * @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
  36680. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36681. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36682. * @returns an array of PickingInfo
  36683. */
  36684. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36685. /**
  36686. * Launch a ray to try to pick a mesh in the scene
  36687. * @param ray Ray to use
  36688. * @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
  36689. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36690. * @returns an array of PickingInfo
  36691. */
  36692. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36693. /**
  36694. * Force the value of meshUnderPointer
  36695. * @param mesh defines the mesh to use
  36696. */
  36697. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  36698. /**
  36699. * Gets the mesh under the pointer
  36700. * @returns a Mesh or null if no mesh is under the pointer
  36701. */
  36702. getPointerOverMesh(): Nullable<AbstractMesh>;
  36703. /** @hidden */
  36704. _rebuildGeometries(): void;
  36705. /** @hidden */
  36706. _rebuildTextures(): void;
  36707. private _getByTags;
  36708. /**
  36709. * Get a list of meshes by tags
  36710. * @param tagsQuery defines the tags query to use
  36711. * @param forEach defines a predicate used to filter results
  36712. * @returns an array of Mesh
  36713. */
  36714. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  36715. /**
  36716. * Get a list of cameras by tags
  36717. * @param tagsQuery defines the tags query to use
  36718. * @param forEach defines a predicate used to filter results
  36719. * @returns an array of Camera
  36720. */
  36721. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  36722. /**
  36723. * Get a list of lights by tags
  36724. * @param tagsQuery defines the tags query to use
  36725. * @param forEach defines a predicate used to filter results
  36726. * @returns an array of Light
  36727. */
  36728. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  36729. /**
  36730. * Get a list of materials by tags
  36731. * @param tagsQuery defines the tags query to use
  36732. * @param forEach defines a predicate used to filter results
  36733. * @returns an array of Material
  36734. */
  36735. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  36736. /**
  36737. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  36738. * This allowed control for front to back rendering or reversly depending of the special needs.
  36739. *
  36740. * @param renderingGroupId The rendering group id corresponding to its index
  36741. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  36742. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  36743. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  36744. */
  36745. 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;
  36746. /**
  36747. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  36748. *
  36749. * @param renderingGroupId The rendering group id corresponding to its index
  36750. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  36751. * @param depth Automatically clears depth between groups if true and autoClear is true.
  36752. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  36753. */
  36754. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  36755. /**
  36756. * Gets the current auto clear configuration for one rendering group of the rendering
  36757. * manager.
  36758. * @param index the rendering group index to get the information for
  36759. * @returns The auto clear setup for the requested rendering group
  36760. */
  36761. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  36762. private _blockMaterialDirtyMechanism;
  36763. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  36764. get blockMaterialDirtyMechanism(): boolean;
  36765. set blockMaterialDirtyMechanism(value: boolean);
  36766. /**
  36767. * Will flag all materials as dirty to trigger new shader compilation
  36768. * @param flag defines the flag used to specify which material part must be marked as dirty
  36769. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  36770. */
  36771. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36772. /** @hidden */
  36773. _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;
  36774. /** @hidden */
  36775. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36776. /** @hidden */
  36777. _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;
  36778. /** @hidden */
  36779. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  36780. /** @hidden */
  36781. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  36782. /** @hidden */
  36783. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36784. }
  36785. }
  36786. declare module BABYLON {
  36787. /**
  36788. * Set of assets to keep when moving a scene into an asset container.
  36789. */
  36790. export class KeepAssets extends AbstractScene {
  36791. }
  36792. /**
  36793. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  36794. */
  36795. export class InstantiatedEntries {
  36796. /**
  36797. * List of new root nodes (eg. nodes with no parent)
  36798. */
  36799. rootNodes: TransformNode[];
  36800. /**
  36801. * List of new skeletons
  36802. */
  36803. skeletons: Skeleton[];
  36804. /**
  36805. * List of new animation groups
  36806. */
  36807. animationGroups: AnimationGroup[];
  36808. }
  36809. /**
  36810. * Container with a set of assets that can be added or removed from a scene.
  36811. */
  36812. export class AssetContainer extends AbstractScene {
  36813. /**
  36814. * The scene the AssetContainer belongs to.
  36815. */
  36816. scene: Scene;
  36817. /**
  36818. * Instantiates an AssetContainer.
  36819. * @param scene The scene the AssetContainer belongs to.
  36820. */
  36821. constructor(scene: Scene);
  36822. /**
  36823. * Instantiate or clone all meshes and add the new ones to the scene.
  36824. * Skeletons and animation groups will all be cloned
  36825. * @param nameFunction defines an optional function used to get new names for clones
  36826. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  36827. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  36828. */
  36829. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  36830. /**
  36831. * Adds all the assets from the container to the scene.
  36832. */
  36833. addAllToScene(): void;
  36834. /**
  36835. * Removes all the assets in the container from the scene
  36836. */
  36837. removeAllFromScene(): void;
  36838. /**
  36839. * Disposes all the assets in the container
  36840. */
  36841. dispose(): void;
  36842. private _moveAssets;
  36843. /**
  36844. * Removes all the assets contained in the scene and adds them to the container.
  36845. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  36846. */
  36847. moveAllFromScene(keepAssets?: KeepAssets): void;
  36848. /**
  36849. * 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.
  36850. * @returns the root mesh
  36851. */
  36852. createRootMesh(): Mesh;
  36853. /**
  36854. * Merge animations from this asset container into a scene
  36855. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  36856. * @param animatables set of animatables to retarget to a node from the scene
  36857. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  36858. */
  36859. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  36860. }
  36861. }
  36862. declare module BABYLON {
  36863. /**
  36864. * Defines how the parser contract is defined.
  36865. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  36866. */
  36867. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  36868. /**
  36869. * Defines how the individual parser contract is defined.
  36870. * These parser can parse an individual asset
  36871. */
  36872. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  36873. /**
  36874. * Base class of the scene acting as a container for the different elements composing a scene.
  36875. * This class is dynamically extended by the different components of the scene increasing
  36876. * flexibility and reducing coupling
  36877. */
  36878. export abstract class AbstractScene {
  36879. /**
  36880. * Stores the list of available parsers in the application.
  36881. */
  36882. private static _BabylonFileParsers;
  36883. /**
  36884. * Stores the list of available individual parsers in the application.
  36885. */
  36886. private static _IndividualBabylonFileParsers;
  36887. /**
  36888. * Adds a parser in the list of available ones
  36889. * @param name Defines the name of the parser
  36890. * @param parser Defines the parser to add
  36891. */
  36892. static AddParser(name: string, parser: BabylonFileParser): void;
  36893. /**
  36894. * Gets a general parser from the list of avaialble ones
  36895. * @param name Defines the name of the parser
  36896. * @returns the requested parser or null
  36897. */
  36898. static GetParser(name: string): Nullable<BabylonFileParser>;
  36899. /**
  36900. * Adds n individual parser in the list of available ones
  36901. * @param name Defines the name of the parser
  36902. * @param parser Defines the parser to add
  36903. */
  36904. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  36905. /**
  36906. * Gets an individual parser from the list of avaialble ones
  36907. * @param name Defines the name of the parser
  36908. * @returns the requested parser or null
  36909. */
  36910. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  36911. /**
  36912. * Parser json data and populate both a scene and its associated container object
  36913. * @param jsonData Defines the data to parse
  36914. * @param scene Defines the scene to parse the data for
  36915. * @param container Defines the container attached to the parsing sequence
  36916. * @param rootUrl Defines the root url of the data
  36917. */
  36918. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  36919. /**
  36920. * Gets the list of root nodes (ie. nodes with no parent)
  36921. */
  36922. rootNodes: Node[];
  36923. /** All of the cameras added to this scene
  36924. * @see http://doc.babylonjs.com/babylon101/cameras
  36925. */
  36926. cameras: Camera[];
  36927. /**
  36928. * All of the lights added to this scene
  36929. * @see http://doc.babylonjs.com/babylon101/lights
  36930. */
  36931. lights: Light[];
  36932. /**
  36933. * All of the (abstract) meshes added to this scene
  36934. */
  36935. meshes: AbstractMesh[];
  36936. /**
  36937. * The list of skeletons added to the scene
  36938. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36939. */
  36940. skeletons: Skeleton[];
  36941. /**
  36942. * All of the particle systems added to this scene
  36943. * @see http://doc.babylonjs.com/babylon101/particles
  36944. */
  36945. particleSystems: IParticleSystem[];
  36946. /**
  36947. * Gets a list of Animations associated with the scene
  36948. */
  36949. animations: Animation[];
  36950. /**
  36951. * All of the animation groups added to this scene
  36952. * @see http://doc.babylonjs.com/how_to/group
  36953. */
  36954. animationGroups: AnimationGroup[];
  36955. /**
  36956. * All of the multi-materials added to this scene
  36957. * @see http://doc.babylonjs.com/how_to/multi_materials
  36958. */
  36959. multiMaterials: MultiMaterial[];
  36960. /**
  36961. * All of the materials added to this scene
  36962. * In the context of a Scene, it is not supposed to be modified manually.
  36963. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  36964. * Note also that the order of the Material within the array is not significant and might change.
  36965. * @see http://doc.babylonjs.com/babylon101/materials
  36966. */
  36967. materials: Material[];
  36968. /**
  36969. * The list of morph target managers added to the scene
  36970. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  36971. */
  36972. morphTargetManagers: MorphTargetManager[];
  36973. /**
  36974. * The list of geometries used in the scene.
  36975. */
  36976. geometries: Geometry[];
  36977. /**
  36978. * All of the tranform nodes added to this scene
  36979. * In the context of a Scene, it is not supposed to be modified manually.
  36980. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  36981. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  36982. * @see http://doc.babylonjs.com/how_to/transformnode
  36983. */
  36984. transformNodes: TransformNode[];
  36985. /**
  36986. * ActionManagers available on the scene.
  36987. */
  36988. actionManagers: AbstractActionManager[];
  36989. /**
  36990. * Textures to keep.
  36991. */
  36992. textures: BaseTexture[];
  36993. /**
  36994. * Environment texture for the scene
  36995. */
  36996. environmentTexture: Nullable<BaseTexture>;
  36997. /**
  36998. * @returns all meshes, lights, cameras, transformNodes and bones
  36999. */
  37000. getNodes(): Array<Node>;
  37001. }
  37002. }
  37003. declare module BABYLON {
  37004. /**
  37005. * Interface used to define options for Sound class
  37006. */
  37007. export interface ISoundOptions {
  37008. /**
  37009. * Does the sound autoplay once loaded.
  37010. */
  37011. autoplay?: boolean;
  37012. /**
  37013. * Does the sound loop after it finishes playing once.
  37014. */
  37015. loop?: boolean;
  37016. /**
  37017. * Sound's volume
  37018. */
  37019. volume?: number;
  37020. /**
  37021. * Is it a spatial sound?
  37022. */
  37023. spatialSound?: boolean;
  37024. /**
  37025. * Maximum distance to hear that sound
  37026. */
  37027. maxDistance?: number;
  37028. /**
  37029. * Uses user defined attenuation function
  37030. */
  37031. useCustomAttenuation?: boolean;
  37032. /**
  37033. * Define the roll off factor of spatial sounds.
  37034. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37035. */
  37036. rolloffFactor?: number;
  37037. /**
  37038. * Define the reference distance the sound should be heard perfectly.
  37039. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37040. */
  37041. refDistance?: number;
  37042. /**
  37043. * Define the distance attenuation model the sound will follow.
  37044. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37045. */
  37046. distanceModel?: string;
  37047. /**
  37048. * Defines the playback speed (1 by default)
  37049. */
  37050. playbackRate?: number;
  37051. /**
  37052. * Defines if the sound is from a streaming source
  37053. */
  37054. streaming?: boolean;
  37055. /**
  37056. * Defines an optional length (in seconds) inside the sound file
  37057. */
  37058. length?: number;
  37059. /**
  37060. * Defines an optional offset (in seconds) inside the sound file
  37061. */
  37062. offset?: number;
  37063. /**
  37064. * If true, URLs will not be required to state the audio file codec to use.
  37065. */
  37066. skipCodecCheck?: boolean;
  37067. }
  37068. /**
  37069. * Defines a sound that can be played in the application.
  37070. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  37071. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37072. */
  37073. export class Sound {
  37074. /**
  37075. * The name of the sound in the scene.
  37076. */
  37077. name: string;
  37078. /**
  37079. * Does the sound autoplay once loaded.
  37080. */
  37081. autoplay: boolean;
  37082. /**
  37083. * Does the sound loop after it finishes playing once.
  37084. */
  37085. loop: boolean;
  37086. /**
  37087. * Does the sound use a custom attenuation curve to simulate the falloff
  37088. * happening when the source gets further away from the camera.
  37089. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37090. */
  37091. useCustomAttenuation: boolean;
  37092. /**
  37093. * The sound track id this sound belongs to.
  37094. */
  37095. soundTrackId: number;
  37096. /**
  37097. * Is this sound currently played.
  37098. */
  37099. isPlaying: boolean;
  37100. /**
  37101. * Is this sound currently paused.
  37102. */
  37103. isPaused: boolean;
  37104. /**
  37105. * Does this sound enables spatial sound.
  37106. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37107. */
  37108. spatialSound: boolean;
  37109. /**
  37110. * Define the reference distance the sound should be heard perfectly.
  37111. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37112. */
  37113. refDistance: number;
  37114. /**
  37115. * Define the roll off factor of spatial sounds.
  37116. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37117. */
  37118. rolloffFactor: number;
  37119. /**
  37120. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  37121. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37122. */
  37123. maxDistance: number;
  37124. /**
  37125. * Define the distance attenuation model the sound will follow.
  37126. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37127. */
  37128. distanceModel: string;
  37129. /**
  37130. * @hidden
  37131. * Back Compat
  37132. **/
  37133. onended: () => any;
  37134. /**
  37135. * Observable event when the current playing sound finishes.
  37136. */
  37137. onEndedObservable: Observable<Sound>;
  37138. private _panningModel;
  37139. private _playbackRate;
  37140. private _streaming;
  37141. private _startTime;
  37142. private _startOffset;
  37143. private _position;
  37144. /** @hidden */
  37145. _positionInEmitterSpace: boolean;
  37146. private _localDirection;
  37147. private _volume;
  37148. private _isReadyToPlay;
  37149. private _isDirectional;
  37150. private _readyToPlayCallback;
  37151. private _audioBuffer;
  37152. private _soundSource;
  37153. private _streamingSource;
  37154. private _soundPanner;
  37155. private _soundGain;
  37156. private _inputAudioNode;
  37157. private _outputAudioNode;
  37158. private _coneInnerAngle;
  37159. private _coneOuterAngle;
  37160. private _coneOuterGain;
  37161. private _scene;
  37162. private _connectedTransformNode;
  37163. private _customAttenuationFunction;
  37164. private _registerFunc;
  37165. private _isOutputConnected;
  37166. private _htmlAudioElement;
  37167. private _urlType;
  37168. private _length?;
  37169. private _offset?;
  37170. /** @hidden */
  37171. static _SceneComponentInitialization: (scene: Scene) => void;
  37172. /**
  37173. * Create a sound and attach it to a scene
  37174. * @param name Name of your sound
  37175. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  37176. * @param scene defines the scene the sound belongs to
  37177. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  37178. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  37179. */
  37180. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  37181. /**
  37182. * Release the sound and its associated resources
  37183. */
  37184. dispose(): void;
  37185. /**
  37186. * Gets if the sounds is ready to be played or not.
  37187. * @returns true if ready, otherwise false
  37188. */
  37189. isReady(): boolean;
  37190. private _soundLoaded;
  37191. /**
  37192. * Sets the data of the sound from an audiobuffer
  37193. * @param audioBuffer The audioBuffer containing the data
  37194. */
  37195. setAudioBuffer(audioBuffer: AudioBuffer): void;
  37196. /**
  37197. * Updates the current sounds options such as maxdistance, loop...
  37198. * @param options A JSON object containing values named as the object properties
  37199. */
  37200. updateOptions(options: ISoundOptions): void;
  37201. private _createSpatialParameters;
  37202. private _updateSpatialParameters;
  37203. /**
  37204. * Switch the panning model to HRTF:
  37205. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37206. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37207. */
  37208. switchPanningModelToHRTF(): void;
  37209. /**
  37210. * Switch the panning model to Equal Power:
  37211. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37212. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37213. */
  37214. switchPanningModelToEqualPower(): void;
  37215. private _switchPanningModel;
  37216. /**
  37217. * Connect this sound to a sound track audio node like gain...
  37218. * @param soundTrackAudioNode the sound track audio node to connect to
  37219. */
  37220. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  37221. /**
  37222. * Transform this sound into a directional source
  37223. * @param coneInnerAngle Size of the inner cone in degree
  37224. * @param coneOuterAngle Size of the outer cone in degree
  37225. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  37226. */
  37227. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  37228. /**
  37229. * Gets or sets the inner angle for the directional cone.
  37230. */
  37231. get directionalConeInnerAngle(): number;
  37232. /**
  37233. * Gets or sets the inner angle for the directional cone.
  37234. */
  37235. set directionalConeInnerAngle(value: number);
  37236. /**
  37237. * Gets or sets the outer angle for the directional cone.
  37238. */
  37239. get directionalConeOuterAngle(): number;
  37240. /**
  37241. * Gets or sets the outer angle for the directional cone.
  37242. */
  37243. set directionalConeOuterAngle(value: number);
  37244. /**
  37245. * Sets the position of the emitter if spatial sound is enabled
  37246. * @param newPosition Defines the new posisiton
  37247. */
  37248. setPosition(newPosition: Vector3): void;
  37249. /**
  37250. * Sets the local direction of the emitter if spatial sound is enabled
  37251. * @param newLocalDirection Defines the new local direction
  37252. */
  37253. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  37254. private _updateDirection;
  37255. /** @hidden */
  37256. updateDistanceFromListener(): void;
  37257. /**
  37258. * Sets a new custom attenuation function for the sound.
  37259. * @param callback Defines the function used for the attenuation
  37260. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37261. */
  37262. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  37263. /**
  37264. * Play the sound
  37265. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  37266. * @param offset (optional) Start the sound at a specific time in seconds
  37267. * @param length (optional) Sound duration (in seconds)
  37268. */
  37269. play(time?: number, offset?: number, length?: number): void;
  37270. private _onended;
  37271. /**
  37272. * Stop the sound
  37273. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  37274. */
  37275. stop(time?: number): void;
  37276. /**
  37277. * Put the sound in pause
  37278. */
  37279. pause(): void;
  37280. /**
  37281. * Sets a dedicated volume for this sounds
  37282. * @param newVolume Define the new volume of the sound
  37283. * @param time Define time for gradual change to new volume
  37284. */
  37285. setVolume(newVolume: number, time?: number): void;
  37286. /**
  37287. * Set the sound play back rate
  37288. * @param newPlaybackRate Define the playback rate the sound should be played at
  37289. */
  37290. setPlaybackRate(newPlaybackRate: number): void;
  37291. /**
  37292. * Gets the volume of the sound.
  37293. * @returns the volume of the sound
  37294. */
  37295. getVolume(): number;
  37296. /**
  37297. * Attach the sound to a dedicated mesh
  37298. * @param transformNode The transform node to connect the sound with
  37299. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37300. */
  37301. attachToMesh(transformNode: TransformNode): void;
  37302. /**
  37303. * Detach the sound from the previously attached mesh
  37304. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37305. */
  37306. detachFromMesh(): void;
  37307. private _onRegisterAfterWorldMatrixUpdate;
  37308. /**
  37309. * Clone the current sound in the scene.
  37310. * @returns the new sound clone
  37311. */
  37312. clone(): Nullable<Sound>;
  37313. /**
  37314. * Gets the current underlying audio buffer containing the data
  37315. * @returns the audio buffer
  37316. */
  37317. getAudioBuffer(): Nullable<AudioBuffer>;
  37318. /**
  37319. * Serializes the Sound in a JSON representation
  37320. * @returns the JSON representation of the sound
  37321. */
  37322. serialize(): any;
  37323. /**
  37324. * Parse a JSON representation of a sound to innstantiate in a given scene
  37325. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  37326. * @param scene Define the scene the new parsed sound should be created in
  37327. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  37328. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  37329. * @returns the newly parsed sound
  37330. */
  37331. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  37332. }
  37333. }
  37334. declare module BABYLON {
  37335. /**
  37336. * This defines an action helpful to play a defined sound on a triggered action.
  37337. */
  37338. export class PlaySoundAction extends Action {
  37339. private _sound;
  37340. /**
  37341. * Instantiate the action
  37342. * @param triggerOptions defines the trigger options
  37343. * @param sound defines the sound to play
  37344. * @param condition defines the trigger related conditions
  37345. */
  37346. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37347. /** @hidden */
  37348. _prepare(): void;
  37349. /**
  37350. * Execute the action and play the sound.
  37351. */
  37352. execute(): void;
  37353. /**
  37354. * Serializes the actions and its related information.
  37355. * @param parent defines the object to serialize in
  37356. * @returns the serialized object
  37357. */
  37358. serialize(parent: any): any;
  37359. }
  37360. /**
  37361. * This defines an action helpful to stop a defined sound on a triggered action.
  37362. */
  37363. export class StopSoundAction extends Action {
  37364. private _sound;
  37365. /**
  37366. * Instantiate the action
  37367. * @param triggerOptions defines the trigger options
  37368. * @param sound defines the sound to stop
  37369. * @param condition defines the trigger related conditions
  37370. */
  37371. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37372. /** @hidden */
  37373. _prepare(): void;
  37374. /**
  37375. * Execute the action and stop the sound.
  37376. */
  37377. execute(): void;
  37378. /**
  37379. * Serializes the actions and its related information.
  37380. * @param parent defines the object to serialize in
  37381. * @returns the serialized object
  37382. */
  37383. serialize(parent: any): any;
  37384. }
  37385. }
  37386. declare module BABYLON {
  37387. /**
  37388. * This defines an action responsible to change the value of a property
  37389. * by interpolating between its current value and the newly set one once triggered.
  37390. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  37391. */
  37392. export class InterpolateValueAction extends Action {
  37393. /**
  37394. * Defines the path of the property where the value should be interpolated
  37395. */
  37396. propertyPath: string;
  37397. /**
  37398. * Defines the target value at the end of the interpolation.
  37399. */
  37400. value: any;
  37401. /**
  37402. * Defines the time it will take for the property to interpolate to the value.
  37403. */
  37404. duration: number;
  37405. /**
  37406. * Defines if the other scene animations should be stopped when the action has been triggered
  37407. */
  37408. stopOtherAnimations?: boolean;
  37409. /**
  37410. * Defines a callback raised once the interpolation animation has been done.
  37411. */
  37412. onInterpolationDone?: () => void;
  37413. /**
  37414. * Observable triggered once the interpolation animation has been done.
  37415. */
  37416. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  37417. private _target;
  37418. private _effectiveTarget;
  37419. private _property;
  37420. /**
  37421. * Instantiate the action
  37422. * @param triggerOptions defines the trigger options
  37423. * @param target defines the object containing the value to interpolate
  37424. * @param propertyPath defines the path to the property in the target object
  37425. * @param value defines the target value at the end of the interpolation
  37426. * @param duration deines the time it will take for the property to interpolate to the value.
  37427. * @param condition defines the trigger related conditions
  37428. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  37429. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  37430. */
  37431. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  37432. /** @hidden */
  37433. _prepare(): void;
  37434. /**
  37435. * Execute the action starts the value interpolation.
  37436. */
  37437. execute(): void;
  37438. /**
  37439. * Serializes the actions and its related information.
  37440. * @param parent defines the object to serialize in
  37441. * @returns the serialized object
  37442. */
  37443. serialize(parent: any): any;
  37444. }
  37445. }
  37446. declare module BABYLON {
  37447. /**
  37448. * Options allowed during the creation of a sound track.
  37449. */
  37450. export interface ISoundTrackOptions {
  37451. /**
  37452. * The volume the sound track should take during creation
  37453. */
  37454. volume?: number;
  37455. /**
  37456. * Define if the sound track is the main sound track of the scene
  37457. */
  37458. mainTrack?: boolean;
  37459. }
  37460. /**
  37461. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  37462. * It will be also used in a future release to apply effects on a specific track.
  37463. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37464. */
  37465. export class SoundTrack {
  37466. /**
  37467. * The unique identifier of the sound track in the scene.
  37468. */
  37469. id: number;
  37470. /**
  37471. * The list of sounds included in the sound track.
  37472. */
  37473. soundCollection: Array<Sound>;
  37474. private _outputAudioNode;
  37475. private _scene;
  37476. private _connectedAnalyser;
  37477. private _options;
  37478. private _isInitialized;
  37479. /**
  37480. * Creates a new sound track.
  37481. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37482. * @param scene Define the scene the sound track belongs to
  37483. * @param options
  37484. */
  37485. constructor(scene: Scene, options?: ISoundTrackOptions);
  37486. private _initializeSoundTrackAudioGraph;
  37487. /**
  37488. * Release the sound track and its associated resources
  37489. */
  37490. dispose(): void;
  37491. /**
  37492. * Adds a sound to this sound track
  37493. * @param sound define the cound to add
  37494. * @ignoreNaming
  37495. */
  37496. AddSound(sound: Sound): void;
  37497. /**
  37498. * Removes a sound to this sound track
  37499. * @param sound define the cound to remove
  37500. * @ignoreNaming
  37501. */
  37502. RemoveSound(sound: Sound): void;
  37503. /**
  37504. * Set a global volume for the full sound track.
  37505. * @param newVolume Define the new volume of the sound track
  37506. */
  37507. setVolume(newVolume: number): void;
  37508. /**
  37509. * Switch the panning model to HRTF:
  37510. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37511. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37512. */
  37513. switchPanningModelToHRTF(): void;
  37514. /**
  37515. * Switch the panning model to Equal Power:
  37516. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37517. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37518. */
  37519. switchPanningModelToEqualPower(): void;
  37520. /**
  37521. * Connect the sound track to an audio analyser allowing some amazing
  37522. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37523. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37524. * @param analyser The analyser to connect to the engine
  37525. */
  37526. connectToAnalyser(analyser: Analyser): void;
  37527. }
  37528. }
  37529. declare module BABYLON {
  37530. interface AbstractScene {
  37531. /**
  37532. * The list of sounds used in the scene.
  37533. */
  37534. sounds: Nullable<Array<Sound>>;
  37535. }
  37536. interface Scene {
  37537. /**
  37538. * @hidden
  37539. * Backing field
  37540. */
  37541. _mainSoundTrack: SoundTrack;
  37542. /**
  37543. * The main sound track played by the scene.
  37544. * It cotains your primary collection of sounds.
  37545. */
  37546. mainSoundTrack: SoundTrack;
  37547. /**
  37548. * The list of sound tracks added to the scene
  37549. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37550. */
  37551. soundTracks: Nullable<Array<SoundTrack>>;
  37552. /**
  37553. * Gets a sound using a given name
  37554. * @param name defines the name to search for
  37555. * @return the found sound or null if not found at all.
  37556. */
  37557. getSoundByName(name: string): Nullable<Sound>;
  37558. /**
  37559. * Gets or sets if audio support is enabled
  37560. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37561. */
  37562. audioEnabled: boolean;
  37563. /**
  37564. * Gets or sets if audio will be output to headphones
  37565. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37566. */
  37567. headphone: boolean;
  37568. /**
  37569. * Gets or sets custom audio listener position provider
  37570. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37571. */
  37572. audioListenerPositionProvider: Nullable<() => Vector3>;
  37573. /**
  37574. * Gets or sets a refresh rate when using 3D audio positioning
  37575. */
  37576. audioPositioningRefreshRate: number;
  37577. }
  37578. /**
  37579. * Defines the sound scene component responsible to manage any sounds
  37580. * in a given scene.
  37581. */
  37582. export class AudioSceneComponent implements ISceneSerializableComponent {
  37583. /**
  37584. * The component name helpfull to identify the component in the list of scene components.
  37585. */
  37586. readonly name: string;
  37587. /**
  37588. * The scene the component belongs to.
  37589. */
  37590. scene: Scene;
  37591. private _audioEnabled;
  37592. /**
  37593. * Gets whether audio is enabled or not.
  37594. * Please use related enable/disable method to switch state.
  37595. */
  37596. get audioEnabled(): boolean;
  37597. private _headphone;
  37598. /**
  37599. * Gets whether audio is outputing to headphone or not.
  37600. * Please use the according Switch methods to change output.
  37601. */
  37602. get headphone(): boolean;
  37603. /**
  37604. * Gets or sets a refresh rate when using 3D audio positioning
  37605. */
  37606. audioPositioningRefreshRate: number;
  37607. private _audioListenerPositionProvider;
  37608. /**
  37609. * Gets the current audio listener position provider
  37610. */
  37611. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  37612. /**
  37613. * Sets a custom listener position for all sounds in the scene
  37614. * By default, this is the position of the first active camera
  37615. */
  37616. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  37617. /**
  37618. * Creates a new instance of the component for the given scene
  37619. * @param scene Defines the scene to register the component in
  37620. */
  37621. constructor(scene: Scene);
  37622. /**
  37623. * Registers the component in a given scene
  37624. */
  37625. register(): void;
  37626. /**
  37627. * Rebuilds the elements related to this component in case of
  37628. * context lost for instance.
  37629. */
  37630. rebuild(): void;
  37631. /**
  37632. * Serializes the component data to the specified json object
  37633. * @param serializationObject The object to serialize to
  37634. */
  37635. serialize(serializationObject: any): void;
  37636. /**
  37637. * Adds all the elements from the container to the scene
  37638. * @param container the container holding the elements
  37639. */
  37640. addFromContainer(container: AbstractScene): void;
  37641. /**
  37642. * Removes all the elements in the container from the scene
  37643. * @param container contains the elements to remove
  37644. * @param dispose if the removed element should be disposed (default: false)
  37645. */
  37646. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  37647. /**
  37648. * Disposes the component and the associated ressources.
  37649. */
  37650. dispose(): void;
  37651. /**
  37652. * Disables audio in the associated scene.
  37653. */
  37654. disableAudio(): void;
  37655. /**
  37656. * Enables audio in the associated scene.
  37657. */
  37658. enableAudio(): void;
  37659. /**
  37660. * Switch audio to headphone output.
  37661. */
  37662. switchAudioModeForHeadphones(): void;
  37663. /**
  37664. * Switch audio to normal speakers.
  37665. */
  37666. switchAudioModeForNormalSpeakers(): void;
  37667. private _cachedCameraDirection;
  37668. private _cachedCameraPosition;
  37669. private _lastCheck;
  37670. private _afterRender;
  37671. }
  37672. }
  37673. declare module BABYLON {
  37674. /**
  37675. * Wraps one or more Sound objects and selects one with random weight for playback.
  37676. */
  37677. export class WeightedSound {
  37678. /** When true a Sound will be selected and played when the current playing Sound completes. */
  37679. loop: boolean;
  37680. private _coneInnerAngle;
  37681. private _coneOuterAngle;
  37682. private _volume;
  37683. /** A Sound is currently playing. */
  37684. isPlaying: boolean;
  37685. /** A Sound is currently paused. */
  37686. isPaused: boolean;
  37687. private _sounds;
  37688. private _weights;
  37689. private _currentIndex?;
  37690. /**
  37691. * Creates a new WeightedSound from the list of sounds given.
  37692. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  37693. * @param sounds Array of Sounds that will be selected from.
  37694. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  37695. */
  37696. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  37697. /**
  37698. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  37699. */
  37700. get directionalConeInnerAngle(): number;
  37701. /**
  37702. * The size of cone in degress for a directional sound in which there will be no attenuation.
  37703. */
  37704. set directionalConeInnerAngle(value: number);
  37705. /**
  37706. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37707. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37708. */
  37709. get directionalConeOuterAngle(): number;
  37710. /**
  37711. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37712. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37713. */
  37714. set directionalConeOuterAngle(value: number);
  37715. /**
  37716. * Playback volume.
  37717. */
  37718. get volume(): number;
  37719. /**
  37720. * Playback volume.
  37721. */
  37722. set volume(value: number);
  37723. private _onended;
  37724. /**
  37725. * Suspend playback
  37726. */
  37727. pause(): void;
  37728. /**
  37729. * Stop playback
  37730. */
  37731. stop(): void;
  37732. /**
  37733. * Start playback.
  37734. * @param startOffset Position the clip head at a specific time in seconds.
  37735. */
  37736. play(startOffset?: number): void;
  37737. }
  37738. }
  37739. declare module BABYLON {
  37740. /**
  37741. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  37742. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37743. */
  37744. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  37745. /**
  37746. * Gets the name of the behavior.
  37747. */
  37748. get name(): string;
  37749. /**
  37750. * The easing function used by animations
  37751. */
  37752. static EasingFunction: BackEase;
  37753. /**
  37754. * The easing mode used by animations
  37755. */
  37756. static EasingMode: number;
  37757. /**
  37758. * The duration of the animation, in milliseconds
  37759. */
  37760. transitionDuration: number;
  37761. /**
  37762. * Length of the distance animated by the transition when lower radius is reached
  37763. */
  37764. lowerRadiusTransitionRange: number;
  37765. /**
  37766. * Length of the distance animated by the transition when upper radius is reached
  37767. */
  37768. upperRadiusTransitionRange: number;
  37769. private _autoTransitionRange;
  37770. /**
  37771. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37772. */
  37773. get autoTransitionRange(): boolean;
  37774. /**
  37775. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37776. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  37777. */
  37778. set autoTransitionRange(value: boolean);
  37779. private _attachedCamera;
  37780. private _onAfterCheckInputsObserver;
  37781. private _onMeshTargetChangedObserver;
  37782. /**
  37783. * Initializes the behavior.
  37784. */
  37785. init(): void;
  37786. /**
  37787. * Attaches the behavior to its arc rotate camera.
  37788. * @param camera Defines the camera to attach the behavior to
  37789. */
  37790. attach(camera: ArcRotateCamera): void;
  37791. /**
  37792. * Detaches the behavior from its current arc rotate camera.
  37793. */
  37794. detach(): void;
  37795. private _radiusIsAnimating;
  37796. private _radiusBounceTransition;
  37797. private _animatables;
  37798. private _cachedWheelPrecision;
  37799. /**
  37800. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  37801. * @param radiusLimit The limit to check against.
  37802. * @return Bool to indicate if at limit.
  37803. */
  37804. private _isRadiusAtLimit;
  37805. /**
  37806. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  37807. * @param radiusDelta The delta by which to animate to. Can be negative.
  37808. */
  37809. private _applyBoundRadiusAnimation;
  37810. /**
  37811. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  37812. */
  37813. protected _clearAnimationLocks(): void;
  37814. /**
  37815. * Stops and removes all animations that have been applied to the camera
  37816. */
  37817. stopAllAnimations(): void;
  37818. }
  37819. }
  37820. declare module BABYLON {
  37821. /**
  37822. * 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.
  37823. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37824. */
  37825. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  37826. /**
  37827. * Gets the name of the behavior.
  37828. */
  37829. get name(): string;
  37830. private _mode;
  37831. private _radiusScale;
  37832. private _positionScale;
  37833. private _defaultElevation;
  37834. private _elevationReturnTime;
  37835. private _elevationReturnWaitTime;
  37836. private _zoomStopsAnimation;
  37837. private _framingTime;
  37838. /**
  37839. * The easing function used by animations
  37840. */
  37841. static EasingFunction: ExponentialEase;
  37842. /**
  37843. * The easing mode used by animations
  37844. */
  37845. static EasingMode: number;
  37846. /**
  37847. * Sets the current mode used by the behavior
  37848. */
  37849. set mode(mode: number);
  37850. /**
  37851. * Gets current mode used by the behavior.
  37852. */
  37853. get mode(): number;
  37854. /**
  37855. * Sets the scale applied to the radius (1 by default)
  37856. */
  37857. set radiusScale(radius: number);
  37858. /**
  37859. * Gets the scale applied to the radius
  37860. */
  37861. get radiusScale(): number;
  37862. /**
  37863. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37864. */
  37865. set positionScale(scale: number);
  37866. /**
  37867. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  37868. */
  37869. get positionScale(): number;
  37870. /**
  37871. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37872. * behaviour is triggered, in radians.
  37873. */
  37874. set defaultElevation(elevation: number);
  37875. /**
  37876. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  37877. * behaviour is triggered, in radians.
  37878. */
  37879. get defaultElevation(): number;
  37880. /**
  37881. * Sets the time (in milliseconds) taken to return to the default beta position.
  37882. * Negative value indicates camera should not return to default.
  37883. */
  37884. set elevationReturnTime(speed: number);
  37885. /**
  37886. * Gets the time (in milliseconds) taken to return to the default beta position.
  37887. * Negative value indicates camera should not return to default.
  37888. */
  37889. get elevationReturnTime(): number;
  37890. /**
  37891. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37892. */
  37893. set elevationReturnWaitTime(time: number);
  37894. /**
  37895. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  37896. */
  37897. get elevationReturnWaitTime(): number;
  37898. /**
  37899. * Sets the flag that indicates if user zooming should stop animation.
  37900. */
  37901. set zoomStopsAnimation(flag: boolean);
  37902. /**
  37903. * Gets the flag that indicates if user zooming should stop animation.
  37904. */
  37905. get zoomStopsAnimation(): boolean;
  37906. /**
  37907. * Sets the transition time when framing the mesh, in milliseconds
  37908. */
  37909. set framingTime(time: number);
  37910. /**
  37911. * Gets the transition time when framing the mesh, in milliseconds
  37912. */
  37913. get framingTime(): number;
  37914. /**
  37915. * Define if the behavior should automatically change the configured
  37916. * camera limits and sensibilities.
  37917. */
  37918. autoCorrectCameraLimitsAndSensibility: boolean;
  37919. private _onPrePointerObservableObserver;
  37920. private _onAfterCheckInputsObserver;
  37921. private _onMeshTargetChangedObserver;
  37922. private _attachedCamera;
  37923. private _isPointerDown;
  37924. private _lastInteractionTime;
  37925. /**
  37926. * Initializes the behavior.
  37927. */
  37928. init(): void;
  37929. /**
  37930. * Attaches the behavior to its arc rotate camera.
  37931. * @param camera Defines the camera to attach the behavior to
  37932. */
  37933. attach(camera: ArcRotateCamera): void;
  37934. /**
  37935. * Detaches the behavior from its current arc rotate camera.
  37936. */
  37937. detach(): void;
  37938. private _animatables;
  37939. private _betaIsAnimating;
  37940. private _betaTransition;
  37941. private _radiusTransition;
  37942. private _vectorTransition;
  37943. /**
  37944. * Targets the given mesh and updates zoom level accordingly.
  37945. * @param mesh The mesh to target.
  37946. * @param radius Optional. If a cached radius position already exists, overrides default.
  37947. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37948. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37949. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37950. */
  37951. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37952. /**
  37953. * Targets the given mesh with its children and updates zoom level accordingly.
  37954. * @param mesh The mesh to target.
  37955. * @param radius Optional. If a cached radius position already exists, overrides default.
  37956. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37957. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37958. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37959. */
  37960. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37961. /**
  37962. * Targets the given meshes with their children and updates zoom level accordingly.
  37963. * @param meshes The mesh to target.
  37964. * @param radius Optional. If a cached radius position already exists, overrides default.
  37965. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37966. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37967. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37968. */
  37969. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37970. /**
  37971. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  37972. * @param minimumWorld Determines the smaller position of the bounding box extend
  37973. * @param maximumWorld Determines the bigger position of the bounding box extend
  37974. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37975. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37976. */
  37977. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37978. /**
  37979. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  37980. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  37981. * frustum width.
  37982. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  37983. * to fully enclose the mesh in the viewing frustum.
  37984. */
  37985. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  37986. /**
  37987. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  37988. * is automatically returned to its default position (expected to be above ground plane).
  37989. */
  37990. private _maintainCameraAboveGround;
  37991. /**
  37992. * Returns the frustum slope based on the canvas ratio and camera FOV
  37993. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  37994. */
  37995. private _getFrustumSlope;
  37996. /**
  37997. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  37998. */
  37999. private _clearAnimationLocks;
  38000. /**
  38001. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38002. */
  38003. private _applyUserInteraction;
  38004. /**
  38005. * Stops and removes all animations that have been applied to the camera
  38006. */
  38007. stopAllAnimations(): void;
  38008. /**
  38009. * Gets a value indicating if the user is moving the camera
  38010. */
  38011. get isUserIsMoving(): boolean;
  38012. /**
  38013. * The camera can move all the way towards the mesh.
  38014. */
  38015. static IgnoreBoundsSizeMode: number;
  38016. /**
  38017. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  38018. */
  38019. static FitFrustumSidesMode: number;
  38020. }
  38021. }
  38022. declare module BABYLON {
  38023. /**
  38024. * Base class for Camera Pointer Inputs.
  38025. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  38026. * for example usage.
  38027. */
  38028. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  38029. /**
  38030. * Defines the camera the input is attached to.
  38031. */
  38032. abstract camera: Camera;
  38033. /**
  38034. * Whether keyboard modifier keys are pressed at time of last mouse event.
  38035. */
  38036. protected _altKey: boolean;
  38037. protected _ctrlKey: boolean;
  38038. protected _metaKey: boolean;
  38039. protected _shiftKey: boolean;
  38040. /**
  38041. * Which mouse buttons were pressed at time of last mouse event.
  38042. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  38043. */
  38044. protected _buttonsPressed: number;
  38045. /**
  38046. * Defines the buttons associated with the input to handle camera move.
  38047. */
  38048. buttons: number[];
  38049. /**
  38050. * Attach the input controls to a specific dom element to get the input from.
  38051. * @param element Defines the element the controls should be listened from
  38052. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38053. */
  38054. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38055. /**
  38056. * Detach the current controls from the specified dom element.
  38057. * @param element Defines the element to stop listening the inputs from
  38058. */
  38059. detachControl(element: Nullable<HTMLElement>): void;
  38060. /**
  38061. * Gets the class name of the current input.
  38062. * @returns the class name
  38063. */
  38064. getClassName(): string;
  38065. /**
  38066. * Get the friendly name associated with the input class.
  38067. * @returns the input friendly name
  38068. */
  38069. getSimpleName(): string;
  38070. /**
  38071. * Called on pointer POINTERDOUBLETAP event.
  38072. * Override this method to provide functionality on POINTERDOUBLETAP event.
  38073. */
  38074. protected onDoubleTap(type: string): void;
  38075. /**
  38076. * Called on pointer POINTERMOVE event if only a single touch is active.
  38077. * Override this method to provide functionality.
  38078. */
  38079. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38080. /**
  38081. * Called on pointer POINTERMOVE event if multiple touches are active.
  38082. * Override this method to provide functionality.
  38083. */
  38084. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38085. /**
  38086. * Called on JS contextmenu event.
  38087. * Override this method to provide functionality.
  38088. */
  38089. protected onContextMenu(evt: PointerEvent): void;
  38090. /**
  38091. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38092. * press.
  38093. * Override this method to provide functionality.
  38094. */
  38095. protected onButtonDown(evt: PointerEvent): void;
  38096. /**
  38097. * Called each time a new POINTERUP event occurs. Ie, for each button
  38098. * release.
  38099. * Override this method to provide functionality.
  38100. */
  38101. protected onButtonUp(evt: PointerEvent): void;
  38102. /**
  38103. * Called when window becomes inactive.
  38104. * Override this method to provide functionality.
  38105. */
  38106. protected onLostFocus(): void;
  38107. private _pointerInput;
  38108. private _observer;
  38109. private _onLostFocus;
  38110. private pointA;
  38111. private pointB;
  38112. }
  38113. }
  38114. declare module BABYLON {
  38115. /**
  38116. * Manage the pointers inputs to control an arc rotate camera.
  38117. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38118. */
  38119. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  38120. /**
  38121. * Defines the camera the input is attached to.
  38122. */
  38123. camera: ArcRotateCamera;
  38124. /**
  38125. * Gets the class name of the current input.
  38126. * @returns the class name
  38127. */
  38128. getClassName(): string;
  38129. /**
  38130. * Defines the buttons associated with the input to handle camera move.
  38131. */
  38132. buttons: number[];
  38133. /**
  38134. * Defines the pointer angular sensibility along the X axis or how fast is
  38135. * the camera rotating.
  38136. */
  38137. angularSensibilityX: number;
  38138. /**
  38139. * Defines the pointer angular sensibility along the Y axis or how fast is
  38140. * the camera rotating.
  38141. */
  38142. angularSensibilityY: number;
  38143. /**
  38144. * Defines the pointer pinch precision or how fast is the camera zooming.
  38145. */
  38146. pinchPrecision: number;
  38147. /**
  38148. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38149. * from 0.
  38150. * It defines the percentage of current camera.radius to use as delta when
  38151. * pinch zoom is used.
  38152. */
  38153. pinchDeltaPercentage: number;
  38154. /**
  38155. * Defines the pointer panning sensibility or how fast is the camera moving.
  38156. */
  38157. panningSensibility: number;
  38158. /**
  38159. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  38160. */
  38161. multiTouchPanning: boolean;
  38162. /**
  38163. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  38164. * zoom (pinch) through multitouch.
  38165. */
  38166. multiTouchPanAndZoom: boolean;
  38167. /**
  38168. * Revers pinch action direction.
  38169. */
  38170. pinchInwards: boolean;
  38171. private _isPanClick;
  38172. private _twoFingerActivityCount;
  38173. private _isPinching;
  38174. /**
  38175. * Called on pointer POINTERMOVE event if only a single touch is active.
  38176. */
  38177. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38178. /**
  38179. * Called on pointer POINTERDOUBLETAP event.
  38180. */
  38181. protected onDoubleTap(type: string): void;
  38182. /**
  38183. * Called on pointer POINTERMOVE event if multiple touches are active.
  38184. */
  38185. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38186. /**
  38187. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38188. * press.
  38189. */
  38190. protected onButtonDown(evt: PointerEvent): void;
  38191. /**
  38192. * Called each time a new POINTERUP event occurs. Ie, for each button
  38193. * release.
  38194. */
  38195. protected onButtonUp(evt: PointerEvent): void;
  38196. /**
  38197. * Called when window becomes inactive.
  38198. */
  38199. protected onLostFocus(): void;
  38200. }
  38201. }
  38202. declare module BABYLON {
  38203. /**
  38204. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  38205. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38206. */
  38207. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  38208. /**
  38209. * Defines the camera the input is attached to.
  38210. */
  38211. camera: ArcRotateCamera;
  38212. /**
  38213. * Defines the list of key codes associated with the up action (increase alpha)
  38214. */
  38215. keysUp: number[];
  38216. /**
  38217. * Defines the list of key codes associated with the down action (decrease alpha)
  38218. */
  38219. keysDown: number[];
  38220. /**
  38221. * Defines the list of key codes associated with the left action (increase beta)
  38222. */
  38223. keysLeft: number[];
  38224. /**
  38225. * Defines the list of key codes associated with the right action (decrease beta)
  38226. */
  38227. keysRight: number[];
  38228. /**
  38229. * Defines the list of key codes associated with the reset action.
  38230. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  38231. */
  38232. keysReset: number[];
  38233. /**
  38234. * Defines the panning sensibility of the inputs.
  38235. * (How fast is the camera paning)
  38236. */
  38237. panningSensibility: number;
  38238. /**
  38239. * Defines the zooming sensibility of the inputs.
  38240. * (How fast is the camera zooming)
  38241. */
  38242. zoomingSensibility: number;
  38243. /**
  38244. * Defines wether maintaining the alt key down switch the movement mode from
  38245. * orientation to zoom.
  38246. */
  38247. useAltToZoom: boolean;
  38248. /**
  38249. * Rotation speed of the camera
  38250. */
  38251. angularSpeed: number;
  38252. private _keys;
  38253. private _ctrlPressed;
  38254. private _altPressed;
  38255. private _onCanvasBlurObserver;
  38256. private _onKeyboardObserver;
  38257. private _engine;
  38258. private _scene;
  38259. /**
  38260. * Attach the input controls to a specific dom element to get the input from.
  38261. * @param element Defines the element the controls should be listened from
  38262. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38263. */
  38264. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38265. /**
  38266. * Detach the current controls from the specified dom element.
  38267. * @param element Defines the element to stop listening the inputs from
  38268. */
  38269. detachControl(element: Nullable<HTMLElement>): void;
  38270. /**
  38271. * Update the current camera state depending on the inputs that have been used this frame.
  38272. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38273. */
  38274. checkInputs(): void;
  38275. /**
  38276. * Gets the class name of the current intput.
  38277. * @returns the class name
  38278. */
  38279. getClassName(): string;
  38280. /**
  38281. * Get the friendly name associated with the input class.
  38282. * @returns the input friendly name
  38283. */
  38284. getSimpleName(): string;
  38285. }
  38286. }
  38287. declare module BABYLON {
  38288. /**
  38289. * Manage the mouse wheel inputs to control an arc rotate camera.
  38290. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38291. */
  38292. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  38293. /**
  38294. * Defines the camera the input is attached to.
  38295. */
  38296. camera: ArcRotateCamera;
  38297. /**
  38298. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38299. */
  38300. wheelPrecision: number;
  38301. /**
  38302. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38303. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38304. */
  38305. wheelDeltaPercentage: number;
  38306. private _wheel;
  38307. private _observer;
  38308. private computeDeltaFromMouseWheelLegacyEvent;
  38309. /**
  38310. * Attach the input controls to a specific dom element to get the input from.
  38311. * @param element Defines the element the controls should be listened from
  38312. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38313. */
  38314. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38315. /**
  38316. * Detach the current controls from the specified dom element.
  38317. * @param element Defines the element to stop listening the inputs from
  38318. */
  38319. detachControl(element: Nullable<HTMLElement>): void;
  38320. /**
  38321. * Gets the class name of the current intput.
  38322. * @returns the class name
  38323. */
  38324. getClassName(): string;
  38325. /**
  38326. * Get the friendly name associated with the input class.
  38327. * @returns the input friendly name
  38328. */
  38329. getSimpleName(): string;
  38330. }
  38331. }
  38332. declare module BABYLON {
  38333. /**
  38334. * Default Inputs manager for the ArcRotateCamera.
  38335. * It groups all the default supported inputs for ease of use.
  38336. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38337. */
  38338. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  38339. /**
  38340. * Instantiates a new ArcRotateCameraInputsManager.
  38341. * @param camera Defines the camera the inputs belong to
  38342. */
  38343. constructor(camera: ArcRotateCamera);
  38344. /**
  38345. * Add mouse wheel input support to the input manager.
  38346. * @returns the current input manager
  38347. */
  38348. addMouseWheel(): ArcRotateCameraInputsManager;
  38349. /**
  38350. * Add pointers input support to the input manager.
  38351. * @returns the current input manager
  38352. */
  38353. addPointers(): ArcRotateCameraInputsManager;
  38354. /**
  38355. * Add keyboard input support to the input manager.
  38356. * @returns the current input manager
  38357. */
  38358. addKeyboard(): ArcRotateCameraInputsManager;
  38359. }
  38360. }
  38361. declare module BABYLON {
  38362. /**
  38363. * This represents an orbital type of camera.
  38364. *
  38365. * 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.
  38366. * 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.
  38367. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  38368. */
  38369. export class ArcRotateCamera extends TargetCamera {
  38370. /**
  38371. * Defines the rotation angle of the camera along the longitudinal axis.
  38372. */
  38373. alpha: number;
  38374. /**
  38375. * Defines the rotation angle of the camera along the latitudinal axis.
  38376. */
  38377. beta: number;
  38378. /**
  38379. * Defines the radius of the camera from it s target point.
  38380. */
  38381. radius: number;
  38382. protected _target: Vector3;
  38383. protected _targetHost: Nullable<AbstractMesh>;
  38384. /**
  38385. * Defines the target point of the camera.
  38386. * The camera looks towards it form the radius distance.
  38387. */
  38388. get target(): Vector3;
  38389. set target(value: Vector3);
  38390. /**
  38391. * Define the current local position of the camera in the scene
  38392. */
  38393. get position(): Vector3;
  38394. set position(newPosition: Vector3);
  38395. protected _upVector: Vector3;
  38396. protected _upToYMatrix: Matrix;
  38397. protected _YToUpMatrix: Matrix;
  38398. /**
  38399. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  38400. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  38401. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  38402. */
  38403. set upVector(vec: Vector3);
  38404. get upVector(): Vector3;
  38405. /**
  38406. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  38407. */
  38408. setMatUp(): void;
  38409. /**
  38410. * Current inertia value on the longitudinal axis.
  38411. * The bigger this number the longer it will take for the camera to stop.
  38412. */
  38413. inertialAlphaOffset: number;
  38414. /**
  38415. * Current inertia value on the latitudinal axis.
  38416. * The bigger this number the longer it will take for the camera to stop.
  38417. */
  38418. inertialBetaOffset: number;
  38419. /**
  38420. * Current inertia value on the radius axis.
  38421. * The bigger this number the longer it will take for the camera to stop.
  38422. */
  38423. inertialRadiusOffset: number;
  38424. /**
  38425. * Minimum allowed angle on the longitudinal axis.
  38426. * This can help limiting how the Camera is able to move in the scene.
  38427. */
  38428. lowerAlphaLimit: Nullable<number>;
  38429. /**
  38430. * Maximum allowed angle on the longitudinal axis.
  38431. * This can help limiting how the Camera is able to move in the scene.
  38432. */
  38433. upperAlphaLimit: Nullable<number>;
  38434. /**
  38435. * Minimum allowed angle on the latitudinal axis.
  38436. * This can help limiting how the Camera is able to move in the scene.
  38437. */
  38438. lowerBetaLimit: number;
  38439. /**
  38440. * Maximum allowed angle on the latitudinal axis.
  38441. * This can help limiting how the Camera is able to move in the scene.
  38442. */
  38443. upperBetaLimit: number;
  38444. /**
  38445. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  38446. * This can help limiting how the Camera is able to move in the scene.
  38447. */
  38448. lowerRadiusLimit: Nullable<number>;
  38449. /**
  38450. * Maximum allowed distance of the camera to the target (The camera can not get further).
  38451. * This can help limiting how the Camera is able to move in the scene.
  38452. */
  38453. upperRadiusLimit: Nullable<number>;
  38454. /**
  38455. * Defines the current inertia value used during panning of the camera along the X axis.
  38456. */
  38457. inertialPanningX: number;
  38458. /**
  38459. * Defines the current inertia value used during panning of the camera along the Y axis.
  38460. */
  38461. inertialPanningY: number;
  38462. /**
  38463. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  38464. * Basically if your fingers moves away from more than this distance you will be considered
  38465. * in pinch mode.
  38466. */
  38467. pinchToPanMaxDistance: number;
  38468. /**
  38469. * Defines the maximum distance the camera can pan.
  38470. * This could help keeping the cammera always in your scene.
  38471. */
  38472. panningDistanceLimit: Nullable<number>;
  38473. /**
  38474. * Defines the target of the camera before paning.
  38475. */
  38476. panningOriginTarget: Vector3;
  38477. /**
  38478. * Defines the value of the inertia used during panning.
  38479. * 0 would mean stop inertia and one would mean no decelleration at all.
  38480. */
  38481. panningInertia: number;
  38482. /**
  38483. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  38484. */
  38485. get angularSensibilityX(): number;
  38486. set angularSensibilityX(value: number);
  38487. /**
  38488. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  38489. */
  38490. get angularSensibilityY(): number;
  38491. set angularSensibilityY(value: number);
  38492. /**
  38493. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  38494. */
  38495. get pinchPrecision(): number;
  38496. set pinchPrecision(value: number);
  38497. /**
  38498. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  38499. * It will be used instead of pinchDeltaPrecision if different from 0.
  38500. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38501. */
  38502. get pinchDeltaPercentage(): number;
  38503. set pinchDeltaPercentage(value: number);
  38504. /**
  38505. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  38506. */
  38507. get panningSensibility(): number;
  38508. set panningSensibility(value: number);
  38509. /**
  38510. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  38511. */
  38512. get keysUp(): number[];
  38513. set keysUp(value: number[]);
  38514. /**
  38515. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  38516. */
  38517. get keysDown(): number[];
  38518. set keysDown(value: number[]);
  38519. /**
  38520. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  38521. */
  38522. get keysLeft(): number[];
  38523. set keysLeft(value: number[]);
  38524. /**
  38525. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  38526. */
  38527. get keysRight(): number[];
  38528. set keysRight(value: number[]);
  38529. /**
  38530. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38531. */
  38532. get wheelPrecision(): number;
  38533. set wheelPrecision(value: number);
  38534. /**
  38535. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  38536. * It will be used instead of pinchDeltaPrecision if different from 0.
  38537. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38538. */
  38539. get wheelDeltaPercentage(): number;
  38540. set wheelDeltaPercentage(value: number);
  38541. /**
  38542. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  38543. */
  38544. zoomOnFactor: number;
  38545. /**
  38546. * Defines a screen offset for the camera position.
  38547. */
  38548. targetScreenOffset: Vector2;
  38549. /**
  38550. * Allows the camera to be completely reversed.
  38551. * If false the camera can not arrive upside down.
  38552. */
  38553. allowUpsideDown: boolean;
  38554. /**
  38555. * Define if double tap/click is used to restore the previously saved state of the camera.
  38556. */
  38557. useInputToRestoreState: boolean;
  38558. /** @hidden */
  38559. _viewMatrix: Matrix;
  38560. /** @hidden */
  38561. _useCtrlForPanning: boolean;
  38562. /** @hidden */
  38563. _panningMouseButton: number;
  38564. /**
  38565. * Defines the input associated to the camera.
  38566. */
  38567. inputs: ArcRotateCameraInputsManager;
  38568. /** @hidden */
  38569. _reset: () => void;
  38570. /**
  38571. * Defines the allowed panning axis.
  38572. */
  38573. panningAxis: Vector3;
  38574. protected _localDirection: Vector3;
  38575. protected _transformedDirection: Vector3;
  38576. private _bouncingBehavior;
  38577. /**
  38578. * Gets the bouncing behavior of the camera if it has been enabled.
  38579. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38580. */
  38581. get bouncingBehavior(): Nullable<BouncingBehavior>;
  38582. /**
  38583. * Defines if the bouncing behavior of the camera is enabled on the camera.
  38584. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38585. */
  38586. get useBouncingBehavior(): boolean;
  38587. set useBouncingBehavior(value: boolean);
  38588. private _framingBehavior;
  38589. /**
  38590. * Gets the framing behavior of the camera if it has been enabled.
  38591. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38592. */
  38593. get framingBehavior(): Nullable<FramingBehavior>;
  38594. /**
  38595. * Defines if the framing behavior of the camera is enabled on the camera.
  38596. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38597. */
  38598. get useFramingBehavior(): boolean;
  38599. set useFramingBehavior(value: boolean);
  38600. private _autoRotationBehavior;
  38601. /**
  38602. * Gets the auto rotation behavior of the camera if it has been enabled.
  38603. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38604. */
  38605. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  38606. /**
  38607. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  38608. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38609. */
  38610. get useAutoRotationBehavior(): boolean;
  38611. set useAutoRotationBehavior(value: boolean);
  38612. /**
  38613. * Observable triggered when the mesh target has been changed on the camera.
  38614. */
  38615. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  38616. /**
  38617. * Event raised when the camera is colliding with a mesh.
  38618. */
  38619. onCollide: (collidedMesh: AbstractMesh) => void;
  38620. /**
  38621. * Defines whether the camera should check collision with the objects oh the scene.
  38622. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  38623. */
  38624. checkCollisions: boolean;
  38625. /**
  38626. * Defines the collision radius of the camera.
  38627. * This simulates a sphere around the camera.
  38628. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38629. */
  38630. collisionRadius: Vector3;
  38631. protected _collider: Collider;
  38632. protected _previousPosition: Vector3;
  38633. protected _collisionVelocity: Vector3;
  38634. protected _newPosition: Vector3;
  38635. protected _previousAlpha: number;
  38636. protected _previousBeta: number;
  38637. protected _previousRadius: number;
  38638. protected _collisionTriggered: boolean;
  38639. protected _targetBoundingCenter: Nullable<Vector3>;
  38640. private _computationVector;
  38641. /**
  38642. * Instantiates a new ArcRotateCamera in a given scene
  38643. * @param name Defines the name of the camera
  38644. * @param alpha Defines the camera rotation along the logitudinal axis
  38645. * @param beta Defines the camera rotation along the latitudinal axis
  38646. * @param radius Defines the camera distance from its target
  38647. * @param target Defines the camera target
  38648. * @param scene Defines the scene the camera belongs to
  38649. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  38650. */
  38651. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38652. /** @hidden */
  38653. _initCache(): void;
  38654. /** @hidden */
  38655. _updateCache(ignoreParentClass?: boolean): void;
  38656. protected _getTargetPosition(): Vector3;
  38657. private _storedAlpha;
  38658. private _storedBeta;
  38659. private _storedRadius;
  38660. private _storedTarget;
  38661. private _storedTargetScreenOffset;
  38662. /**
  38663. * Stores the current state of the camera (alpha, beta, radius and target)
  38664. * @returns the camera itself
  38665. */
  38666. storeState(): Camera;
  38667. /**
  38668. * @hidden
  38669. * Restored camera state. You must call storeState() first
  38670. */
  38671. _restoreStateValues(): boolean;
  38672. /** @hidden */
  38673. _isSynchronizedViewMatrix(): boolean;
  38674. /**
  38675. * Attached controls to the current camera.
  38676. * @param element Defines the element the controls should be listened from
  38677. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38678. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  38679. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  38680. */
  38681. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  38682. /**
  38683. * Detach the current controls from the camera.
  38684. * The camera will stop reacting to inputs.
  38685. * @param element Defines the element to stop listening the inputs from
  38686. */
  38687. detachControl(element: HTMLElement): void;
  38688. /** @hidden */
  38689. _checkInputs(): void;
  38690. protected _checkLimits(): void;
  38691. /**
  38692. * Rebuilds angles (alpha, beta) and radius from the give position and target
  38693. */
  38694. rebuildAnglesAndRadius(): void;
  38695. /**
  38696. * Use a position to define the current camera related information like alpha, beta and radius
  38697. * @param position Defines the position to set the camera at
  38698. */
  38699. setPosition(position: Vector3): void;
  38700. /**
  38701. * Defines the target the camera should look at.
  38702. * This will automatically adapt alpha beta and radius to fit within the new target.
  38703. * @param target Defines the new target as a Vector or a mesh
  38704. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  38705. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  38706. */
  38707. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  38708. /** @hidden */
  38709. _getViewMatrix(): Matrix;
  38710. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  38711. /**
  38712. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  38713. * @param meshes Defines the mesh to zoom on
  38714. * @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)
  38715. */
  38716. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  38717. /**
  38718. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  38719. * The target will be changed but the radius
  38720. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  38721. * @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)
  38722. */
  38723. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  38724. min: Vector3;
  38725. max: Vector3;
  38726. distance: number;
  38727. }, doNotUpdateMaxZ?: boolean): void;
  38728. /**
  38729. * @override
  38730. * Override Camera.createRigCamera
  38731. */
  38732. createRigCamera(name: string, cameraIndex: number): Camera;
  38733. /**
  38734. * @hidden
  38735. * @override
  38736. * Override Camera._updateRigCameras
  38737. */
  38738. _updateRigCameras(): void;
  38739. /**
  38740. * Destroy the camera and release the current resources hold by it.
  38741. */
  38742. dispose(): void;
  38743. /**
  38744. * Gets the current object class name.
  38745. * @return the class name
  38746. */
  38747. getClassName(): string;
  38748. }
  38749. }
  38750. declare module BABYLON {
  38751. /**
  38752. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  38753. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38754. */
  38755. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  38756. /**
  38757. * Gets the name of the behavior.
  38758. */
  38759. get name(): string;
  38760. private _zoomStopsAnimation;
  38761. private _idleRotationSpeed;
  38762. private _idleRotationWaitTime;
  38763. private _idleRotationSpinupTime;
  38764. /**
  38765. * Sets the flag that indicates if user zooming should stop animation.
  38766. */
  38767. set zoomStopsAnimation(flag: boolean);
  38768. /**
  38769. * Gets the flag that indicates if user zooming should stop animation.
  38770. */
  38771. get zoomStopsAnimation(): boolean;
  38772. /**
  38773. * Sets the default speed at which the camera rotates around the model.
  38774. */
  38775. set idleRotationSpeed(speed: number);
  38776. /**
  38777. * Gets the default speed at which the camera rotates around the model.
  38778. */
  38779. get idleRotationSpeed(): number;
  38780. /**
  38781. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  38782. */
  38783. set idleRotationWaitTime(time: number);
  38784. /**
  38785. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  38786. */
  38787. get idleRotationWaitTime(): number;
  38788. /**
  38789. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38790. */
  38791. set idleRotationSpinupTime(time: number);
  38792. /**
  38793. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38794. */
  38795. get idleRotationSpinupTime(): number;
  38796. /**
  38797. * Gets a value indicating if the camera is currently rotating because of this behavior
  38798. */
  38799. get rotationInProgress(): boolean;
  38800. private _onPrePointerObservableObserver;
  38801. private _onAfterCheckInputsObserver;
  38802. private _attachedCamera;
  38803. private _isPointerDown;
  38804. private _lastFrameTime;
  38805. private _lastInteractionTime;
  38806. private _cameraRotationSpeed;
  38807. /**
  38808. * Initializes the behavior.
  38809. */
  38810. init(): void;
  38811. /**
  38812. * Attaches the behavior to its arc rotate camera.
  38813. * @param camera Defines the camera to attach the behavior to
  38814. */
  38815. attach(camera: ArcRotateCamera): void;
  38816. /**
  38817. * Detaches the behavior from its current arc rotate camera.
  38818. */
  38819. detach(): void;
  38820. /**
  38821. * Returns true if user is scrolling.
  38822. * @return true if user is scrolling.
  38823. */
  38824. private _userIsZooming;
  38825. private _lastFrameRadius;
  38826. private _shouldAnimationStopForInteraction;
  38827. /**
  38828. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38829. */
  38830. private _applyUserInteraction;
  38831. private _userIsMoving;
  38832. }
  38833. }
  38834. declare module BABYLON {
  38835. /**
  38836. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  38837. */
  38838. export class AttachToBoxBehavior implements Behavior<Mesh> {
  38839. private ui;
  38840. /**
  38841. * The name of the behavior
  38842. */
  38843. name: string;
  38844. /**
  38845. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  38846. */
  38847. distanceAwayFromFace: number;
  38848. /**
  38849. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  38850. */
  38851. distanceAwayFromBottomOfFace: number;
  38852. private _faceVectors;
  38853. private _target;
  38854. private _scene;
  38855. private _onRenderObserver;
  38856. private _tmpMatrix;
  38857. private _tmpVector;
  38858. /**
  38859. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  38860. * @param ui The transform node that should be attched to the mesh
  38861. */
  38862. constructor(ui: TransformNode);
  38863. /**
  38864. * Initializes the behavior
  38865. */
  38866. init(): void;
  38867. private _closestFace;
  38868. private _zeroVector;
  38869. private _lookAtTmpMatrix;
  38870. private _lookAtToRef;
  38871. /**
  38872. * Attaches the AttachToBoxBehavior to the passed in mesh
  38873. * @param target The mesh that the specified node will be attached to
  38874. */
  38875. attach(target: Mesh): void;
  38876. /**
  38877. * Detaches the behavior from the mesh
  38878. */
  38879. detach(): void;
  38880. }
  38881. }
  38882. declare module BABYLON {
  38883. /**
  38884. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  38885. */
  38886. export class FadeInOutBehavior implements Behavior<Mesh> {
  38887. /**
  38888. * Time in milliseconds to delay before fading in (Default: 0)
  38889. */
  38890. delay: number;
  38891. /**
  38892. * Time in milliseconds for the mesh to fade in (Default: 300)
  38893. */
  38894. fadeInTime: number;
  38895. private _millisecondsPerFrame;
  38896. private _hovered;
  38897. private _hoverValue;
  38898. private _ownerNode;
  38899. /**
  38900. * Instatiates the FadeInOutBehavior
  38901. */
  38902. constructor();
  38903. /**
  38904. * The name of the behavior
  38905. */
  38906. get name(): string;
  38907. /**
  38908. * Initializes the behavior
  38909. */
  38910. init(): void;
  38911. /**
  38912. * Attaches the fade behavior on the passed in mesh
  38913. * @param ownerNode The mesh that will be faded in/out once attached
  38914. */
  38915. attach(ownerNode: Mesh): void;
  38916. /**
  38917. * Detaches the behavior from the mesh
  38918. */
  38919. detach(): void;
  38920. /**
  38921. * Triggers the mesh to begin fading in or out
  38922. * @param value if the object should fade in or out (true to fade in)
  38923. */
  38924. fadeIn(value: boolean): void;
  38925. private _update;
  38926. private _setAllVisibility;
  38927. }
  38928. }
  38929. declare module BABYLON {
  38930. /**
  38931. * Class containing a set of static utilities functions for managing Pivots
  38932. * @hidden
  38933. */
  38934. export class PivotTools {
  38935. private static _PivotCached;
  38936. private static _OldPivotPoint;
  38937. private static _PivotTranslation;
  38938. private static _PivotTmpVector;
  38939. /** @hidden */
  38940. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  38941. /** @hidden */
  38942. static _RestorePivotPoint(mesh: AbstractMesh): void;
  38943. }
  38944. }
  38945. declare module BABYLON {
  38946. /**
  38947. * Class containing static functions to help procedurally build meshes
  38948. */
  38949. export class PlaneBuilder {
  38950. /**
  38951. * Creates a plane mesh
  38952. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  38953. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  38954. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  38955. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38956. * * 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
  38957. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38958. * @param name defines the name of the mesh
  38959. * @param options defines the options used to create the mesh
  38960. * @param scene defines the hosting scene
  38961. * @returns the plane mesh
  38962. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  38963. */
  38964. static CreatePlane(name: string, options: {
  38965. size?: number;
  38966. width?: number;
  38967. height?: number;
  38968. sideOrientation?: number;
  38969. frontUVs?: Vector4;
  38970. backUVs?: Vector4;
  38971. updatable?: boolean;
  38972. sourcePlane?: Plane;
  38973. }, scene?: Nullable<Scene>): Mesh;
  38974. }
  38975. }
  38976. declare module BABYLON {
  38977. /**
  38978. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  38979. */
  38980. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  38981. private static _AnyMouseID;
  38982. /**
  38983. * Abstract mesh the behavior is set on
  38984. */
  38985. attachedNode: AbstractMesh;
  38986. private _dragPlane;
  38987. private _scene;
  38988. private _pointerObserver;
  38989. private _beforeRenderObserver;
  38990. private static _planeScene;
  38991. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  38992. /**
  38993. * 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)
  38994. */
  38995. maxDragAngle: number;
  38996. /**
  38997. * @hidden
  38998. */
  38999. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  39000. /**
  39001. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39002. */
  39003. currentDraggingPointerID: number;
  39004. /**
  39005. * The last position where the pointer hit the drag plane in world space
  39006. */
  39007. lastDragPosition: Vector3;
  39008. /**
  39009. * If the behavior is currently in a dragging state
  39010. */
  39011. dragging: boolean;
  39012. /**
  39013. * 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)
  39014. */
  39015. dragDeltaRatio: number;
  39016. /**
  39017. * If the drag plane orientation should be updated during the dragging (Default: true)
  39018. */
  39019. updateDragPlane: boolean;
  39020. private _debugMode;
  39021. private _moving;
  39022. /**
  39023. * Fires each time the attached mesh is dragged with the pointer
  39024. * * delta between last drag position and current drag position in world space
  39025. * * dragDistance along the drag axis
  39026. * * dragPlaneNormal normal of the current drag plane used during the drag
  39027. * * dragPlanePoint in world space where the drag intersects the drag plane
  39028. */
  39029. onDragObservable: Observable<{
  39030. delta: Vector3;
  39031. dragPlanePoint: Vector3;
  39032. dragPlaneNormal: Vector3;
  39033. dragDistance: number;
  39034. pointerId: number;
  39035. }>;
  39036. /**
  39037. * Fires each time a drag begins (eg. mouse down on mesh)
  39038. */
  39039. onDragStartObservable: Observable<{
  39040. dragPlanePoint: Vector3;
  39041. pointerId: number;
  39042. }>;
  39043. /**
  39044. * Fires each time a drag ends (eg. mouse release after drag)
  39045. */
  39046. onDragEndObservable: Observable<{
  39047. dragPlanePoint: Vector3;
  39048. pointerId: number;
  39049. }>;
  39050. /**
  39051. * If the attached mesh should be moved when dragged
  39052. */
  39053. moveAttached: boolean;
  39054. /**
  39055. * If the drag behavior will react to drag events (Default: true)
  39056. */
  39057. enabled: boolean;
  39058. /**
  39059. * If pointer events should start and release the drag (Default: true)
  39060. */
  39061. startAndReleaseDragOnPointerEvents: boolean;
  39062. /**
  39063. * If camera controls should be detached during the drag
  39064. */
  39065. detachCameraControls: boolean;
  39066. /**
  39067. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  39068. */
  39069. useObjectOrientationForDragging: boolean;
  39070. private _options;
  39071. /**
  39072. * Gets the options used by the behavior
  39073. */
  39074. get options(): {
  39075. dragAxis?: Vector3;
  39076. dragPlaneNormal?: Vector3;
  39077. };
  39078. /**
  39079. * Sets the options used by the behavior
  39080. */
  39081. set options(options: {
  39082. dragAxis?: Vector3;
  39083. dragPlaneNormal?: Vector3;
  39084. });
  39085. /**
  39086. * Creates a pointer drag behavior that can be attached to a mesh
  39087. * @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)
  39088. */
  39089. constructor(options?: {
  39090. dragAxis?: Vector3;
  39091. dragPlaneNormal?: Vector3;
  39092. });
  39093. /**
  39094. * Predicate to determine if it is valid to move the object to a new position when it is moved
  39095. */
  39096. validateDrag: (targetPosition: Vector3) => boolean;
  39097. /**
  39098. * The name of the behavior
  39099. */
  39100. get name(): string;
  39101. /**
  39102. * Initializes the behavior
  39103. */
  39104. init(): void;
  39105. private _tmpVector;
  39106. private _alternatePickedPoint;
  39107. private _worldDragAxis;
  39108. private _targetPosition;
  39109. private _attachedElement;
  39110. /**
  39111. * Attaches the drag behavior the passed in mesh
  39112. * @param ownerNode The mesh that will be dragged around once attached
  39113. * @param predicate Predicate to use for pick filtering
  39114. */
  39115. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  39116. /**
  39117. * Force relase the drag action by code.
  39118. */
  39119. releaseDrag(): void;
  39120. private _startDragRay;
  39121. private _lastPointerRay;
  39122. /**
  39123. * Simulates the start of a pointer drag event on the behavior
  39124. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  39125. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  39126. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  39127. */
  39128. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  39129. private _startDrag;
  39130. private _dragDelta;
  39131. private _moveDrag;
  39132. private _pickWithRayOnDragPlane;
  39133. private _pointA;
  39134. private _pointB;
  39135. private _pointC;
  39136. private _lineA;
  39137. private _lineB;
  39138. private _localAxis;
  39139. private _lookAt;
  39140. private _updateDragPlanePosition;
  39141. /**
  39142. * Detaches the behavior from the mesh
  39143. */
  39144. detach(): void;
  39145. }
  39146. }
  39147. declare module BABYLON {
  39148. /**
  39149. * A behavior that when attached to a mesh will allow the mesh to be scaled
  39150. */
  39151. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  39152. private _dragBehaviorA;
  39153. private _dragBehaviorB;
  39154. private _startDistance;
  39155. private _initialScale;
  39156. private _targetScale;
  39157. private _ownerNode;
  39158. private _sceneRenderObserver;
  39159. /**
  39160. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  39161. */
  39162. constructor();
  39163. /**
  39164. * The name of the behavior
  39165. */
  39166. get name(): string;
  39167. /**
  39168. * Initializes the behavior
  39169. */
  39170. init(): void;
  39171. private _getCurrentDistance;
  39172. /**
  39173. * Attaches the scale behavior the passed in mesh
  39174. * @param ownerNode The mesh that will be scaled around once attached
  39175. */
  39176. attach(ownerNode: Mesh): void;
  39177. /**
  39178. * Detaches the behavior from the mesh
  39179. */
  39180. detach(): void;
  39181. }
  39182. }
  39183. declare module BABYLON {
  39184. /**
  39185. * 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
  39186. */
  39187. export class SixDofDragBehavior implements Behavior<Mesh> {
  39188. private static _virtualScene;
  39189. private _ownerNode;
  39190. private _sceneRenderObserver;
  39191. private _scene;
  39192. private _targetPosition;
  39193. private _virtualOriginMesh;
  39194. private _virtualDragMesh;
  39195. private _pointerObserver;
  39196. private _moving;
  39197. private _startingOrientation;
  39198. /**
  39199. * 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)
  39200. */
  39201. private zDragFactor;
  39202. /**
  39203. * If the object should rotate to face the drag origin
  39204. */
  39205. rotateDraggedObject: boolean;
  39206. /**
  39207. * If the behavior is currently in a dragging state
  39208. */
  39209. dragging: boolean;
  39210. /**
  39211. * 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)
  39212. */
  39213. dragDeltaRatio: number;
  39214. /**
  39215. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39216. */
  39217. currentDraggingPointerID: number;
  39218. /**
  39219. * If camera controls should be detached during the drag
  39220. */
  39221. detachCameraControls: boolean;
  39222. /**
  39223. * Fires each time a drag starts
  39224. */
  39225. onDragStartObservable: Observable<{}>;
  39226. /**
  39227. * Fires each time a drag ends (eg. mouse release after drag)
  39228. */
  39229. onDragEndObservable: Observable<{}>;
  39230. /**
  39231. * 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
  39232. */
  39233. constructor();
  39234. /**
  39235. * The name of the behavior
  39236. */
  39237. get name(): string;
  39238. /**
  39239. * Initializes the behavior
  39240. */
  39241. init(): void;
  39242. /**
  39243. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  39244. */
  39245. private get _pointerCamera();
  39246. /**
  39247. * Attaches the scale behavior the passed in mesh
  39248. * @param ownerNode The mesh that will be scaled around once attached
  39249. */
  39250. attach(ownerNode: Mesh): void;
  39251. /**
  39252. * Detaches the behavior from the mesh
  39253. */
  39254. detach(): void;
  39255. }
  39256. }
  39257. declare module BABYLON {
  39258. /**
  39259. * Class used to apply inverse kinematics to bones
  39260. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  39261. */
  39262. export class BoneIKController {
  39263. private static _tmpVecs;
  39264. private static _tmpQuat;
  39265. private static _tmpMats;
  39266. /**
  39267. * Gets or sets the target mesh
  39268. */
  39269. targetMesh: AbstractMesh;
  39270. /** Gets or sets the mesh used as pole */
  39271. poleTargetMesh: AbstractMesh;
  39272. /**
  39273. * Gets or sets the bone used as pole
  39274. */
  39275. poleTargetBone: Nullable<Bone>;
  39276. /**
  39277. * Gets or sets the target position
  39278. */
  39279. targetPosition: Vector3;
  39280. /**
  39281. * Gets or sets the pole target position
  39282. */
  39283. poleTargetPosition: Vector3;
  39284. /**
  39285. * Gets or sets the pole target local offset
  39286. */
  39287. poleTargetLocalOffset: Vector3;
  39288. /**
  39289. * Gets or sets the pole angle
  39290. */
  39291. poleAngle: number;
  39292. /**
  39293. * Gets or sets the mesh associated with the controller
  39294. */
  39295. mesh: AbstractMesh;
  39296. /**
  39297. * 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)
  39298. */
  39299. slerpAmount: number;
  39300. private _bone1Quat;
  39301. private _bone1Mat;
  39302. private _bone2Ang;
  39303. private _bone1;
  39304. private _bone2;
  39305. private _bone1Length;
  39306. private _bone2Length;
  39307. private _maxAngle;
  39308. private _maxReach;
  39309. private _rightHandedSystem;
  39310. private _bendAxis;
  39311. private _slerping;
  39312. private _adjustRoll;
  39313. /**
  39314. * Gets or sets maximum allowed angle
  39315. */
  39316. get maxAngle(): number;
  39317. set maxAngle(value: number);
  39318. /**
  39319. * Creates a new BoneIKController
  39320. * @param mesh defines the mesh to control
  39321. * @param bone defines the bone to control
  39322. * @param options defines options to set up the controller
  39323. */
  39324. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  39325. targetMesh?: AbstractMesh;
  39326. poleTargetMesh?: AbstractMesh;
  39327. poleTargetBone?: Bone;
  39328. poleTargetLocalOffset?: Vector3;
  39329. poleAngle?: number;
  39330. bendAxis?: Vector3;
  39331. maxAngle?: number;
  39332. slerpAmount?: number;
  39333. });
  39334. private _setMaxAngle;
  39335. /**
  39336. * Force the controller to update the bones
  39337. */
  39338. update(): void;
  39339. }
  39340. }
  39341. declare module BABYLON {
  39342. /**
  39343. * Class used to make a bone look toward a point in space
  39344. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  39345. */
  39346. export class BoneLookController {
  39347. private static _tmpVecs;
  39348. private static _tmpQuat;
  39349. private static _tmpMats;
  39350. /**
  39351. * The target Vector3 that the bone will look at
  39352. */
  39353. target: Vector3;
  39354. /**
  39355. * The mesh that the bone is attached to
  39356. */
  39357. mesh: AbstractMesh;
  39358. /**
  39359. * The bone that will be looking to the target
  39360. */
  39361. bone: Bone;
  39362. /**
  39363. * The up axis of the coordinate system that is used when the bone is rotated
  39364. */
  39365. upAxis: Vector3;
  39366. /**
  39367. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  39368. */
  39369. upAxisSpace: Space;
  39370. /**
  39371. * Used to make an adjustment to the yaw of the bone
  39372. */
  39373. adjustYaw: number;
  39374. /**
  39375. * Used to make an adjustment to the pitch of the bone
  39376. */
  39377. adjustPitch: number;
  39378. /**
  39379. * Used to make an adjustment to the roll of the bone
  39380. */
  39381. adjustRoll: number;
  39382. /**
  39383. * 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)
  39384. */
  39385. slerpAmount: number;
  39386. private _minYaw;
  39387. private _maxYaw;
  39388. private _minPitch;
  39389. private _maxPitch;
  39390. private _minYawSin;
  39391. private _minYawCos;
  39392. private _maxYawSin;
  39393. private _maxYawCos;
  39394. private _midYawConstraint;
  39395. private _minPitchTan;
  39396. private _maxPitchTan;
  39397. private _boneQuat;
  39398. private _slerping;
  39399. private _transformYawPitch;
  39400. private _transformYawPitchInv;
  39401. private _firstFrameSkipped;
  39402. private _yawRange;
  39403. private _fowardAxis;
  39404. /**
  39405. * Gets or sets the minimum yaw angle that the bone can look to
  39406. */
  39407. get minYaw(): number;
  39408. set minYaw(value: number);
  39409. /**
  39410. * Gets or sets the maximum yaw angle that the bone can look to
  39411. */
  39412. get maxYaw(): number;
  39413. set maxYaw(value: number);
  39414. /**
  39415. * Gets or sets the minimum pitch angle that the bone can look to
  39416. */
  39417. get minPitch(): number;
  39418. set minPitch(value: number);
  39419. /**
  39420. * Gets or sets the maximum pitch angle that the bone can look to
  39421. */
  39422. get maxPitch(): number;
  39423. set maxPitch(value: number);
  39424. /**
  39425. * Create a BoneLookController
  39426. * @param mesh the mesh that the bone belongs to
  39427. * @param bone the bone that will be looking to the target
  39428. * @param target the target Vector3 to look at
  39429. * @param options optional settings:
  39430. * * maxYaw: the maximum angle the bone will yaw to
  39431. * * minYaw: the minimum angle the bone will yaw to
  39432. * * maxPitch: the maximum angle the bone will pitch to
  39433. * * minPitch: the minimum angle the bone will yaw to
  39434. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  39435. * * upAxis: the up axis of the coordinate system
  39436. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  39437. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  39438. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  39439. * * adjustYaw: used to make an adjustment to the yaw of the bone
  39440. * * adjustPitch: used to make an adjustment to the pitch of the bone
  39441. * * adjustRoll: used to make an adjustment to the roll of the bone
  39442. **/
  39443. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  39444. maxYaw?: number;
  39445. minYaw?: number;
  39446. maxPitch?: number;
  39447. minPitch?: number;
  39448. slerpAmount?: number;
  39449. upAxis?: Vector3;
  39450. upAxisSpace?: Space;
  39451. yawAxis?: Vector3;
  39452. pitchAxis?: Vector3;
  39453. adjustYaw?: number;
  39454. adjustPitch?: number;
  39455. adjustRoll?: number;
  39456. });
  39457. /**
  39458. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  39459. */
  39460. update(): void;
  39461. private _getAngleDiff;
  39462. private _getAngleBetween;
  39463. private _isAngleBetween;
  39464. }
  39465. }
  39466. declare module BABYLON {
  39467. /**
  39468. * Manage the gamepad inputs to control an arc rotate camera.
  39469. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39470. */
  39471. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  39472. /**
  39473. * Defines the camera the input is attached to.
  39474. */
  39475. camera: ArcRotateCamera;
  39476. /**
  39477. * Defines the gamepad the input is gathering event from.
  39478. */
  39479. gamepad: Nullable<Gamepad>;
  39480. /**
  39481. * Defines the gamepad rotation sensiblity.
  39482. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39483. */
  39484. gamepadRotationSensibility: number;
  39485. /**
  39486. * Defines the gamepad move sensiblity.
  39487. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39488. */
  39489. gamepadMoveSensibility: number;
  39490. private _yAxisScale;
  39491. /**
  39492. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  39493. */
  39494. get invertYAxis(): boolean;
  39495. set invertYAxis(value: boolean);
  39496. private _onGamepadConnectedObserver;
  39497. private _onGamepadDisconnectedObserver;
  39498. /**
  39499. * Attach the input controls to a specific dom element to get the input from.
  39500. * @param element Defines the element the controls should be listened from
  39501. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39502. */
  39503. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39504. /**
  39505. * Detach the current controls from the specified dom element.
  39506. * @param element Defines the element to stop listening the inputs from
  39507. */
  39508. detachControl(element: Nullable<HTMLElement>): void;
  39509. /**
  39510. * Update the current camera state depending on the inputs that have been used this frame.
  39511. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39512. */
  39513. checkInputs(): void;
  39514. /**
  39515. * Gets the class name of the current intput.
  39516. * @returns the class name
  39517. */
  39518. getClassName(): string;
  39519. /**
  39520. * Get the friendly name associated with the input class.
  39521. * @returns the input friendly name
  39522. */
  39523. getSimpleName(): string;
  39524. }
  39525. }
  39526. declare module BABYLON {
  39527. interface ArcRotateCameraInputsManager {
  39528. /**
  39529. * Add orientation input support to the input manager.
  39530. * @returns the current input manager
  39531. */
  39532. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  39533. }
  39534. /**
  39535. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  39536. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39537. */
  39538. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  39539. /**
  39540. * Defines the camera the input is attached to.
  39541. */
  39542. camera: ArcRotateCamera;
  39543. /**
  39544. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  39545. */
  39546. alphaCorrection: number;
  39547. /**
  39548. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  39549. */
  39550. gammaCorrection: number;
  39551. private _alpha;
  39552. private _gamma;
  39553. private _dirty;
  39554. private _deviceOrientationHandler;
  39555. /**
  39556. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  39557. */
  39558. constructor();
  39559. /**
  39560. * Attach the input controls to a specific dom element to get the input from.
  39561. * @param element Defines the element the controls should be listened from
  39562. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39563. */
  39564. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39565. /** @hidden */
  39566. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  39567. /**
  39568. * Update the current camera state depending on the inputs that have been used this frame.
  39569. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39570. */
  39571. checkInputs(): void;
  39572. /**
  39573. * Detach the current controls from the specified dom element.
  39574. * @param element Defines the element to stop listening the inputs from
  39575. */
  39576. detachControl(element: Nullable<HTMLElement>): void;
  39577. /**
  39578. * Gets the class name of the current intput.
  39579. * @returns the class name
  39580. */
  39581. getClassName(): string;
  39582. /**
  39583. * Get the friendly name associated with the input class.
  39584. * @returns the input friendly name
  39585. */
  39586. getSimpleName(): string;
  39587. }
  39588. }
  39589. declare module BABYLON {
  39590. /**
  39591. * Listen to mouse events to control the camera.
  39592. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39593. */
  39594. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  39595. /**
  39596. * Defines the camera the input is attached to.
  39597. */
  39598. camera: FlyCamera;
  39599. /**
  39600. * Defines if touch is enabled. (Default is true.)
  39601. */
  39602. touchEnabled: boolean;
  39603. /**
  39604. * Defines the buttons associated with the input to handle camera rotation.
  39605. */
  39606. buttons: number[];
  39607. /**
  39608. * Assign buttons for Yaw control.
  39609. */
  39610. buttonsYaw: number[];
  39611. /**
  39612. * Assign buttons for Pitch control.
  39613. */
  39614. buttonsPitch: number[];
  39615. /**
  39616. * Assign buttons for Roll control.
  39617. */
  39618. buttonsRoll: number[];
  39619. /**
  39620. * Detect if any button is being pressed while mouse is moved.
  39621. * -1 = Mouse locked.
  39622. * 0 = Left button.
  39623. * 1 = Middle Button.
  39624. * 2 = Right Button.
  39625. */
  39626. activeButton: number;
  39627. /**
  39628. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  39629. * Higher values reduce its sensitivity.
  39630. */
  39631. angularSensibility: number;
  39632. private _mousemoveCallback;
  39633. private _observer;
  39634. private _rollObserver;
  39635. private previousPosition;
  39636. private noPreventDefault;
  39637. private element;
  39638. /**
  39639. * Listen to mouse events to control the camera.
  39640. * @param touchEnabled Define if touch is enabled. (Default is true.)
  39641. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39642. */
  39643. constructor(touchEnabled?: boolean);
  39644. /**
  39645. * Attach the mouse control to the HTML DOM element.
  39646. * @param element Defines the element that listens to the input events.
  39647. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  39648. */
  39649. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39650. /**
  39651. * Detach the current controls from the specified dom element.
  39652. * @param element Defines the element to stop listening the inputs from
  39653. */
  39654. detachControl(element: Nullable<HTMLElement>): void;
  39655. /**
  39656. * Gets the class name of the current input.
  39657. * @returns the class name.
  39658. */
  39659. getClassName(): string;
  39660. /**
  39661. * Get the friendly name associated with the input class.
  39662. * @returns the input's friendly name.
  39663. */
  39664. getSimpleName(): string;
  39665. private _pointerInput;
  39666. private _onMouseMove;
  39667. /**
  39668. * Rotate camera by mouse offset.
  39669. */
  39670. private rotateCamera;
  39671. }
  39672. }
  39673. declare module BABYLON {
  39674. /**
  39675. * Default Inputs manager for the FlyCamera.
  39676. * It groups all the default supported inputs for ease of use.
  39677. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39678. */
  39679. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  39680. /**
  39681. * Instantiates a new FlyCameraInputsManager.
  39682. * @param camera Defines the camera the inputs belong to.
  39683. */
  39684. constructor(camera: FlyCamera);
  39685. /**
  39686. * Add keyboard input support to the input manager.
  39687. * @returns the new FlyCameraKeyboardMoveInput().
  39688. */
  39689. addKeyboard(): FlyCameraInputsManager;
  39690. /**
  39691. * Add mouse input support to the input manager.
  39692. * @param touchEnabled Enable touch screen support.
  39693. * @returns the new FlyCameraMouseInput().
  39694. */
  39695. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  39696. }
  39697. }
  39698. declare module BABYLON {
  39699. /**
  39700. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39701. * such as in a 3D Space Shooter or a Flight Simulator.
  39702. */
  39703. export class FlyCamera extends TargetCamera {
  39704. /**
  39705. * Define the collision ellipsoid of the camera.
  39706. * This is helpful for simulating a camera body, like a player's body.
  39707. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39708. */
  39709. ellipsoid: Vector3;
  39710. /**
  39711. * Define an offset for the position of the ellipsoid around the camera.
  39712. * This can be helpful if the camera is attached away from the player's body center,
  39713. * such as at its head.
  39714. */
  39715. ellipsoidOffset: Vector3;
  39716. /**
  39717. * Enable or disable collisions of the camera with the rest of the scene objects.
  39718. */
  39719. checkCollisions: boolean;
  39720. /**
  39721. * Enable or disable gravity on the camera.
  39722. */
  39723. applyGravity: boolean;
  39724. /**
  39725. * Define the current direction the camera is moving to.
  39726. */
  39727. cameraDirection: Vector3;
  39728. /**
  39729. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  39730. * This overrides and empties cameraRotation.
  39731. */
  39732. rotationQuaternion: Quaternion;
  39733. /**
  39734. * Track Roll to maintain the wanted Rolling when looking around.
  39735. */
  39736. _trackRoll: number;
  39737. /**
  39738. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  39739. */
  39740. rollCorrect: number;
  39741. /**
  39742. * Mimic a banked turn, Rolling the camera when Yawing.
  39743. * It's recommended to use rollCorrect = 10 for faster banking correction.
  39744. */
  39745. bankedTurn: boolean;
  39746. /**
  39747. * Limit in radians for how much Roll banking will add. (Default: 90°)
  39748. */
  39749. bankedTurnLimit: number;
  39750. /**
  39751. * Value of 0 disables the banked Roll.
  39752. * Value of 1 is equal to the Yaw angle in radians.
  39753. */
  39754. bankedTurnMultiplier: number;
  39755. /**
  39756. * The inputs manager loads all the input sources, such as keyboard and mouse.
  39757. */
  39758. inputs: FlyCameraInputsManager;
  39759. /**
  39760. * Gets the input sensibility for mouse input.
  39761. * Higher values reduce sensitivity.
  39762. */
  39763. get angularSensibility(): number;
  39764. /**
  39765. * Sets the input sensibility for a mouse input.
  39766. * Higher values reduce sensitivity.
  39767. */
  39768. set angularSensibility(value: number);
  39769. /**
  39770. * Get the keys for camera movement forward.
  39771. */
  39772. get keysForward(): number[];
  39773. /**
  39774. * Set the keys for camera movement forward.
  39775. */
  39776. set keysForward(value: number[]);
  39777. /**
  39778. * Get the keys for camera movement backward.
  39779. */
  39780. get keysBackward(): number[];
  39781. set keysBackward(value: number[]);
  39782. /**
  39783. * Get the keys for camera movement up.
  39784. */
  39785. get keysUp(): number[];
  39786. /**
  39787. * Set the keys for camera movement up.
  39788. */
  39789. set keysUp(value: number[]);
  39790. /**
  39791. * Get the keys for camera movement down.
  39792. */
  39793. get keysDown(): number[];
  39794. /**
  39795. * Set the keys for camera movement down.
  39796. */
  39797. set keysDown(value: number[]);
  39798. /**
  39799. * Get the keys for camera movement left.
  39800. */
  39801. get keysLeft(): number[];
  39802. /**
  39803. * Set the keys for camera movement left.
  39804. */
  39805. set keysLeft(value: number[]);
  39806. /**
  39807. * Set the keys for camera movement right.
  39808. */
  39809. get keysRight(): number[];
  39810. /**
  39811. * Set the keys for camera movement right.
  39812. */
  39813. set keysRight(value: number[]);
  39814. /**
  39815. * Event raised when the camera collides with a mesh in the scene.
  39816. */
  39817. onCollide: (collidedMesh: AbstractMesh) => void;
  39818. private _collider;
  39819. private _needMoveForGravity;
  39820. private _oldPosition;
  39821. private _diffPosition;
  39822. private _newPosition;
  39823. /** @hidden */
  39824. _localDirection: Vector3;
  39825. /** @hidden */
  39826. _transformedDirection: Vector3;
  39827. /**
  39828. * Instantiates a FlyCamera.
  39829. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39830. * such as in a 3D Space Shooter or a Flight Simulator.
  39831. * @param name Define the name of the camera in the scene.
  39832. * @param position Define the starting position of the camera in the scene.
  39833. * @param scene Define the scene the camera belongs to.
  39834. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  39835. */
  39836. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39837. /**
  39838. * Attach a control to the HTML DOM element.
  39839. * @param element Defines the element that listens to the input events.
  39840. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  39841. */
  39842. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39843. /**
  39844. * Detach a control from the HTML DOM element.
  39845. * The camera will stop reacting to that input.
  39846. * @param element Defines the element that listens to the input events.
  39847. */
  39848. detachControl(element: HTMLElement): void;
  39849. private _collisionMask;
  39850. /**
  39851. * Get the mask that the camera ignores in collision events.
  39852. */
  39853. get collisionMask(): number;
  39854. /**
  39855. * Set the mask that the camera ignores in collision events.
  39856. */
  39857. set collisionMask(mask: number);
  39858. /** @hidden */
  39859. _collideWithWorld(displacement: Vector3): void;
  39860. /** @hidden */
  39861. private _onCollisionPositionChange;
  39862. /** @hidden */
  39863. _checkInputs(): void;
  39864. /** @hidden */
  39865. _decideIfNeedsToMove(): boolean;
  39866. /** @hidden */
  39867. _updatePosition(): void;
  39868. /**
  39869. * Restore the Roll to its target value at the rate specified.
  39870. * @param rate - Higher means slower restoring.
  39871. * @hidden
  39872. */
  39873. restoreRoll(rate: number): void;
  39874. /**
  39875. * Destroy the camera and release the current resources held by it.
  39876. */
  39877. dispose(): void;
  39878. /**
  39879. * Get the current object class name.
  39880. * @returns the class name.
  39881. */
  39882. getClassName(): string;
  39883. }
  39884. }
  39885. declare module BABYLON {
  39886. /**
  39887. * Listen to keyboard events to control the camera.
  39888. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39889. */
  39890. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  39891. /**
  39892. * Defines the camera the input is attached to.
  39893. */
  39894. camera: FlyCamera;
  39895. /**
  39896. * The list of keyboard keys used to control the forward move of the camera.
  39897. */
  39898. keysForward: number[];
  39899. /**
  39900. * The list of keyboard keys used to control the backward move of the camera.
  39901. */
  39902. keysBackward: number[];
  39903. /**
  39904. * The list of keyboard keys used to control the forward move of the camera.
  39905. */
  39906. keysUp: number[];
  39907. /**
  39908. * The list of keyboard keys used to control the backward move of the camera.
  39909. */
  39910. keysDown: number[];
  39911. /**
  39912. * The list of keyboard keys used to control the right strafe move of the camera.
  39913. */
  39914. keysRight: number[];
  39915. /**
  39916. * The list of keyboard keys used to control the left strafe move of the camera.
  39917. */
  39918. keysLeft: number[];
  39919. private _keys;
  39920. private _onCanvasBlurObserver;
  39921. private _onKeyboardObserver;
  39922. private _engine;
  39923. private _scene;
  39924. /**
  39925. * Attach the input controls to a specific dom element to get the input from.
  39926. * @param element Defines the element the controls should be listened from
  39927. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39928. */
  39929. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39930. /**
  39931. * Detach the current controls from the specified dom element.
  39932. * @param element Defines the element to stop listening the inputs from
  39933. */
  39934. detachControl(element: Nullable<HTMLElement>): void;
  39935. /**
  39936. * Gets the class name of the current intput.
  39937. * @returns the class name
  39938. */
  39939. getClassName(): string;
  39940. /** @hidden */
  39941. _onLostFocus(e: FocusEvent): void;
  39942. /**
  39943. * Get the friendly name associated with the input class.
  39944. * @returns the input friendly name
  39945. */
  39946. getSimpleName(): string;
  39947. /**
  39948. * Update the current camera state depending on the inputs that have been used this frame.
  39949. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39950. */
  39951. checkInputs(): void;
  39952. }
  39953. }
  39954. declare module BABYLON {
  39955. /**
  39956. * Manage the mouse wheel inputs to control a follow camera.
  39957. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39958. */
  39959. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  39960. /**
  39961. * Defines the camera the input is attached to.
  39962. */
  39963. camera: FollowCamera;
  39964. /**
  39965. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  39966. */
  39967. axisControlRadius: boolean;
  39968. /**
  39969. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  39970. */
  39971. axisControlHeight: boolean;
  39972. /**
  39973. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  39974. */
  39975. axisControlRotation: boolean;
  39976. /**
  39977. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  39978. * relation to mouseWheel events.
  39979. */
  39980. wheelPrecision: number;
  39981. /**
  39982. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39983. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39984. */
  39985. wheelDeltaPercentage: number;
  39986. private _wheel;
  39987. private _observer;
  39988. /**
  39989. * Attach the input controls to a specific dom element to get the input from.
  39990. * @param element Defines the element the controls should be listened from
  39991. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39992. */
  39993. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39994. /**
  39995. * Detach the current controls from the specified dom element.
  39996. * @param element Defines the element to stop listening the inputs from
  39997. */
  39998. detachControl(element: Nullable<HTMLElement>): void;
  39999. /**
  40000. * Gets the class name of the current intput.
  40001. * @returns the class name
  40002. */
  40003. getClassName(): string;
  40004. /**
  40005. * Get the friendly name associated with the input class.
  40006. * @returns the input friendly name
  40007. */
  40008. getSimpleName(): string;
  40009. }
  40010. }
  40011. declare module BABYLON {
  40012. /**
  40013. * Manage the pointers inputs to control an follow camera.
  40014. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40015. */
  40016. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  40017. /**
  40018. * Defines the camera the input is attached to.
  40019. */
  40020. camera: FollowCamera;
  40021. /**
  40022. * Gets the class name of the current input.
  40023. * @returns the class name
  40024. */
  40025. getClassName(): string;
  40026. /**
  40027. * Defines the pointer angular sensibility along the X axis or how fast is
  40028. * the camera rotating.
  40029. * A negative number will reverse the axis direction.
  40030. */
  40031. angularSensibilityX: number;
  40032. /**
  40033. * Defines the pointer angular sensibility along the Y axis or how fast is
  40034. * the camera rotating.
  40035. * A negative number will reverse the axis direction.
  40036. */
  40037. angularSensibilityY: number;
  40038. /**
  40039. * Defines the pointer pinch precision or how fast is the camera zooming.
  40040. * A negative number will reverse the axis direction.
  40041. */
  40042. pinchPrecision: number;
  40043. /**
  40044. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  40045. * from 0.
  40046. * It defines the percentage of current camera.radius to use as delta when
  40047. * pinch zoom is used.
  40048. */
  40049. pinchDeltaPercentage: number;
  40050. /**
  40051. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  40052. */
  40053. axisXControlRadius: boolean;
  40054. /**
  40055. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  40056. */
  40057. axisXControlHeight: boolean;
  40058. /**
  40059. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  40060. */
  40061. axisXControlRotation: boolean;
  40062. /**
  40063. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  40064. */
  40065. axisYControlRadius: boolean;
  40066. /**
  40067. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  40068. */
  40069. axisYControlHeight: boolean;
  40070. /**
  40071. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  40072. */
  40073. axisYControlRotation: boolean;
  40074. /**
  40075. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  40076. */
  40077. axisPinchControlRadius: boolean;
  40078. /**
  40079. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  40080. */
  40081. axisPinchControlHeight: boolean;
  40082. /**
  40083. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  40084. */
  40085. axisPinchControlRotation: boolean;
  40086. /**
  40087. * Log error messages if basic misconfiguration has occurred.
  40088. */
  40089. warningEnable: boolean;
  40090. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40091. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40092. private _warningCounter;
  40093. private _warning;
  40094. }
  40095. }
  40096. declare module BABYLON {
  40097. /**
  40098. * Default Inputs manager for the FollowCamera.
  40099. * It groups all the default supported inputs for ease of use.
  40100. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40101. */
  40102. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  40103. /**
  40104. * Instantiates a new FollowCameraInputsManager.
  40105. * @param camera Defines the camera the inputs belong to
  40106. */
  40107. constructor(camera: FollowCamera);
  40108. /**
  40109. * Add keyboard input support to the input manager.
  40110. * @returns the current input manager
  40111. */
  40112. addKeyboard(): FollowCameraInputsManager;
  40113. /**
  40114. * Add mouse wheel input support to the input manager.
  40115. * @returns the current input manager
  40116. */
  40117. addMouseWheel(): FollowCameraInputsManager;
  40118. /**
  40119. * Add pointers input support to the input manager.
  40120. * @returns the current input manager
  40121. */
  40122. addPointers(): FollowCameraInputsManager;
  40123. /**
  40124. * Add orientation input support to the input manager.
  40125. * @returns the current input manager
  40126. */
  40127. addVRDeviceOrientation(): FollowCameraInputsManager;
  40128. }
  40129. }
  40130. declare module BABYLON {
  40131. /**
  40132. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  40133. * an arc rotate version arcFollowCamera are available.
  40134. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40135. */
  40136. export class FollowCamera extends TargetCamera {
  40137. /**
  40138. * Distance the follow camera should follow an object at
  40139. */
  40140. radius: number;
  40141. /**
  40142. * Minimum allowed distance of the camera to the axis of rotation
  40143. * (The camera can not get closer).
  40144. * This can help limiting how the Camera is able to move in the scene.
  40145. */
  40146. lowerRadiusLimit: Nullable<number>;
  40147. /**
  40148. * Maximum allowed distance of the camera to the axis of rotation
  40149. * (The camera can not get further).
  40150. * This can help limiting how the Camera is able to move in the scene.
  40151. */
  40152. upperRadiusLimit: Nullable<number>;
  40153. /**
  40154. * Define a rotation offset between the camera and the object it follows
  40155. */
  40156. rotationOffset: number;
  40157. /**
  40158. * Minimum allowed angle to camera position relative to target object.
  40159. * This can help limiting how the Camera is able to move in the scene.
  40160. */
  40161. lowerRotationOffsetLimit: Nullable<number>;
  40162. /**
  40163. * Maximum allowed angle to camera position relative to target object.
  40164. * This can help limiting how the Camera is able to move in the scene.
  40165. */
  40166. upperRotationOffsetLimit: Nullable<number>;
  40167. /**
  40168. * Define a height offset between the camera and the object it follows.
  40169. * It can help following an object from the top (like a car chaing a plane)
  40170. */
  40171. heightOffset: number;
  40172. /**
  40173. * Minimum allowed height of camera position relative to target object.
  40174. * This can help limiting how the Camera is able to move in the scene.
  40175. */
  40176. lowerHeightOffsetLimit: Nullable<number>;
  40177. /**
  40178. * Maximum allowed height of camera position relative to target object.
  40179. * This can help limiting how the Camera is able to move in the scene.
  40180. */
  40181. upperHeightOffsetLimit: Nullable<number>;
  40182. /**
  40183. * Define how fast the camera can accelerate to follow it s target.
  40184. */
  40185. cameraAcceleration: number;
  40186. /**
  40187. * Define the speed limit of the camera following an object.
  40188. */
  40189. maxCameraSpeed: number;
  40190. /**
  40191. * Define the target of the camera.
  40192. */
  40193. lockedTarget: Nullable<AbstractMesh>;
  40194. /**
  40195. * Defines the input associated with the camera.
  40196. */
  40197. inputs: FollowCameraInputsManager;
  40198. /**
  40199. * Instantiates the follow camera.
  40200. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40201. * @param name Define the name of the camera in the scene
  40202. * @param position Define the position of the camera
  40203. * @param scene Define the scene the camera belong to
  40204. * @param lockedTarget Define the target of the camera
  40205. */
  40206. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  40207. private _follow;
  40208. /**
  40209. * Attached controls to the current camera.
  40210. * @param element Defines the element the controls should be listened from
  40211. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40212. */
  40213. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40214. /**
  40215. * Detach the current controls from the camera.
  40216. * The camera will stop reacting to inputs.
  40217. * @param element Defines the element to stop listening the inputs from
  40218. */
  40219. detachControl(element: HTMLElement): void;
  40220. /** @hidden */
  40221. _checkInputs(): void;
  40222. private _checkLimits;
  40223. /**
  40224. * Gets the camera class name.
  40225. * @returns the class name
  40226. */
  40227. getClassName(): string;
  40228. }
  40229. /**
  40230. * Arc Rotate version of the follow camera.
  40231. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  40232. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40233. */
  40234. export class ArcFollowCamera extends TargetCamera {
  40235. /** The longitudinal angle of the camera */
  40236. alpha: number;
  40237. /** The latitudinal angle of the camera */
  40238. beta: number;
  40239. /** The radius of the camera from its target */
  40240. radius: number;
  40241. /** Define the camera target (the messh it should follow) */
  40242. target: Nullable<AbstractMesh>;
  40243. private _cartesianCoordinates;
  40244. /**
  40245. * Instantiates a new ArcFollowCamera
  40246. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40247. * @param name Define the name of the camera
  40248. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  40249. * @param beta Define the rotation angle of the camera around the elevation axis
  40250. * @param radius Define the radius of the camera from its target point
  40251. * @param target Define the target of the camera
  40252. * @param scene Define the scene the camera belongs to
  40253. */
  40254. constructor(name: string,
  40255. /** The longitudinal angle of the camera */
  40256. alpha: number,
  40257. /** The latitudinal angle of the camera */
  40258. beta: number,
  40259. /** The radius of the camera from its target */
  40260. radius: number,
  40261. /** Define the camera target (the messh it should follow) */
  40262. target: Nullable<AbstractMesh>, scene: Scene);
  40263. private _follow;
  40264. /** @hidden */
  40265. _checkInputs(): void;
  40266. /**
  40267. * Returns the class name of the object.
  40268. * It is mostly used internally for serialization purposes.
  40269. */
  40270. getClassName(): string;
  40271. }
  40272. }
  40273. declare module BABYLON {
  40274. /**
  40275. * Manage the keyboard inputs to control the movement of a follow camera.
  40276. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40277. */
  40278. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  40279. /**
  40280. * Defines the camera the input is attached to.
  40281. */
  40282. camera: FollowCamera;
  40283. /**
  40284. * Defines the list of key codes associated with the up action (increase heightOffset)
  40285. */
  40286. keysHeightOffsetIncr: number[];
  40287. /**
  40288. * Defines the list of key codes associated with the down action (decrease heightOffset)
  40289. */
  40290. keysHeightOffsetDecr: number[];
  40291. /**
  40292. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  40293. */
  40294. keysHeightOffsetModifierAlt: boolean;
  40295. /**
  40296. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  40297. */
  40298. keysHeightOffsetModifierCtrl: boolean;
  40299. /**
  40300. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  40301. */
  40302. keysHeightOffsetModifierShift: boolean;
  40303. /**
  40304. * Defines the list of key codes associated with the left action (increase rotationOffset)
  40305. */
  40306. keysRotationOffsetIncr: number[];
  40307. /**
  40308. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  40309. */
  40310. keysRotationOffsetDecr: number[];
  40311. /**
  40312. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  40313. */
  40314. keysRotationOffsetModifierAlt: boolean;
  40315. /**
  40316. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  40317. */
  40318. keysRotationOffsetModifierCtrl: boolean;
  40319. /**
  40320. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  40321. */
  40322. keysRotationOffsetModifierShift: boolean;
  40323. /**
  40324. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  40325. */
  40326. keysRadiusIncr: number[];
  40327. /**
  40328. * Defines the list of key codes associated with the zoom-out action (increase radius)
  40329. */
  40330. keysRadiusDecr: number[];
  40331. /**
  40332. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  40333. */
  40334. keysRadiusModifierAlt: boolean;
  40335. /**
  40336. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  40337. */
  40338. keysRadiusModifierCtrl: boolean;
  40339. /**
  40340. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  40341. */
  40342. keysRadiusModifierShift: boolean;
  40343. /**
  40344. * Defines the rate of change of heightOffset.
  40345. */
  40346. heightSensibility: number;
  40347. /**
  40348. * Defines the rate of change of rotationOffset.
  40349. */
  40350. rotationSensibility: number;
  40351. /**
  40352. * Defines the rate of change of radius.
  40353. */
  40354. radiusSensibility: number;
  40355. private _keys;
  40356. private _ctrlPressed;
  40357. private _altPressed;
  40358. private _shiftPressed;
  40359. private _onCanvasBlurObserver;
  40360. private _onKeyboardObserver;
  40361. private _engine;
  40362. private _scene;
  40363. /**
  40364. * Attach the input controls to a specific dom element to get the input from.
  40365. * @param element Defines the element the controls should be listened from
  40366. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40367. */
  40368. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40369. /**
  40370. * Detach the current controls from the specified dom element.
  40371. * @param element Defines the element to stop listening the inputs from
  40372. */
  40373. detachControl(element: Nullable<HTMLElement>): void;
  40374. /**
  40375. * Update the current camera state depending on the inputs that have been used this frame.
  40376. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40377. */
  40378. checkInputs(): void;
  40379. /**
  40380. * Gets the class name of the current input.
  40381. * @returns the class name
  40382. */
  40383. getClassName(): string;
  40384. /**
  40385. * Get the friendly name associated with the input class.
  40386. * @returns the input friendly name
  40387. */
  40388. getSimpleName(): string;
  40389. /**
  40390. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40391. * allow modification of the heightOffset value.
  40392. */
  40393. private _modifierHeightOffset;
  40394. /**
  40395. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40396. * allow modification of the rotationOffset value.
  40397. */
  40398. private _modifierRotationOffset;
  40399. /**
  40400. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40401. * allow modification of the radius value.
  40402. */
  40403. private _modifierRadius;
  40404. }
  40405. }
  40406. declare module BABYLON {
  40407. interface FreeCameraInputsManager {
  40408. /**
  40409. * @hidden
  40410. */
  40411. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  40412. /**
  40413. * Add orientation input support to the input manager.
  40414. * @returns the current input manager
  40415. */
  40416. addDeviceOrientation(): FreeCameraInputsManager;
  40417. }
  40418. /**
  40419. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  40420. * Screen rotation is taken into account.
  40421. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40422. */
  40423. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  40424. private _camera;
  40425. private _screenOrientationAngle;
  40426. private _constantTranform;
  40427. private _screenQuaternion;
  40428. private _alpha;
  40429. private _beta;
  40430. private _gamma;
  40431. /**
  40432. * Can be used to detect if a device orientation sensor is available on a device
  40433. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  40434. * @returns a promise that will resolve on orientation change
  40435. */
  40436. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  40437. /**
  40438. * @hidden
  40439. */
  40440. _onDeviceOrientationChangedObservable: Observable<void>;
  40441. /**
  40442. * Instantiates a new input
  40443. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40444. */
  40445. constructor();
  40446. /**
  40447. * Define the camera controlled by the input.
  40448. */
  40449. get camera(): FreeCamera;
  40450. set camera(camera: FreeCamera);
  40451. /**
  40452. * Attach the input controls to a specific dom element to get the input from.
  40453. * @param element Defines the element the controls should be listened from
  40454. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40455. */
  40456. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40457. private _orientationChanged;
  40458. private _deviceOrientation;
  40459. /**
  40460. * Detach the current controls from the specified dom element.
  40461. * @param element Defines the element to stop listening the inputs from
  40462. */
  40463. detachControl(element: Nullable<HTMLElement>): void;
  40464. /**
  40465. * Update the current camera state depending on the inputs that have been used this frame.
  40466. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40467. */
  40468. checkInputs(): void;
  40469. /**
  40470. * Gets the class name of the current intput.
  40471. * @returns the class name
  40472. */
  40473. getClassName(): string;
  40474. /**
  40475. * Get the friendly name associated with the input class.
  40476. * @returns the input friendly name
  40477. */
  40478. getSimpleName(): string;
  40479. }
  40480. }
  40481. declare module BABYLON {
  40482. /**
  40483. * Manage the gamepad inputs to control a free camera.
  40484. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40485. */
  40486. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  40487. /**
  40488. * Define the camera the input is attached to.
  40489. */
  40490. camera: FreeCamera;
  40491. /**
  40492. * Define the Gamepad controlling the input
  40493. */
  40494. gamepad: Nullable<Gamepad>;
  40495. /**
  40496. * Defines the gamepad rotation sensiblity.
  40497. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40498. */
  40499. gamepadAngularSensibility: number;
  40500. /**
  40501. * Defines the gamepad move sensiblity.
  40502. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40503. */
  40504. gamepadMoveSensibility: number;
  40505. private _yAxisScale;
  40506. /**
  40507. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40508. */
  40509. get invertYAxis(): boolean;
  40510. set invertYAxis(value: boolean);
  40511. private _onGamepadConnectedObserver;
  40512. private _onGamepadDisconnectedObserver;
  40513. private _cameraTransform;
  40514. private _deltaTransform;
  40515. private _vector3;
  40516. private _vector2;
  40517. /**
  40518. * Attach the input controls to a specific dom element to get the input from.
  40519. * @param element Defines the element the controls should be listened from
  40520. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40521. */
  40522. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40523. /**
  40524. * Detach the current controls from the specified dom element.
  40525. * @param element Defines the element to stop listening the inputs from
  40526. */
  40527. detachControl(element: Nullable<HTMLElement>): void;
  40528. /**
  40529. * Update the current camera state depending on the inputs that have been used this frame.
  40530. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40531. */
  40532. checkInputs(): void;
  40533. /**
  40534. * Gets the class name of the current intput.
  40535. * @returns the class name
  40536. */
  40537. getClassName(): string;
  40538. /**
  40539. * Get the friendly name associated with the input class.
  40540. * @returns the input friendly name
  40541. */
  40542. getSimpleName(): string;
  40543. }
  40544. }
  40545. declare module BABYLON {
  40546. /**
  40547. * Defines the potential axis of a Joystick
  40548. */
  40549. export enum JoystickAxis {
  40550. /** X axis */
  40551. X = 0,
  40552. /** Y axis */
  40553. Y = 1,
  40554. /** Z axis */
  40555. Z = 2
  40556. }
  40557. /**
  40558. * Class used to define virtual joystick (used in touch mode)
  40559. */
  40560. export class VirtualJoystick {
  40561. /**
  40562. * Gets or sets a boolean indicating that left and right values must be inverted
  40563. */
  40564. reverseLeftRight: boolean;
  40565. /**
  40566. * Gets or sets a boolean indicating that up and down values must be inverted
  40567. */
  40568. reverseUpDown: boolean;
  40569. /**
  40570. * Gets the offset value for the position (ie. the change of the position value)
  40571. */
  40572. deltaPosition: Vector3;
  40573. /**
  40574. * Gets a boolean indicating if the virtual joystick was pressed
  40575. */
  40576. pressed: boolean;
  40577. /**
  40578. * Canvas the virtual joystick will render onto, default z-index of this is 5
  40579. */
  40580. static Canvas: Nullable<HTMLCanvasElement>;
  40581. private static _globalJoystickIndex;
  40582. private static vjCanvasContext;
  40583. private static vjCanvasWidth;
  40584. private static vjCanvasHeight;
  40585. private static halfWidth;
  40586. private _action;
  40587. private _axisTargetedByLeftAndRight;
  40588. private _axisTargetedByUpAndDown;
  40589. private _joystickSensibility;
  40590. private _inversedSensibility;
  40591. private _joystickPointerID;
  40592. private _joystickColor;
  40593. private _joystickPointerPos;
  40594. private _joystickPreviousPointerPos;
  40595. private _joystickPointerStartPos;
  40596. private _deltaJoystickVector;
  40597. private _leftJoystick;
  40598. private _touches;
  40599. private _onPointerDownHandlerRef;
  40600. private _onPointerMoveHandlerRef;
  40601. private _onPointerUpHandlerRef;
  40602. private _onResize;
  40603. /**
  40604. * Creates a new virtual joystick
  40605. * @param leftJoystick defines that the joystick is for left hand (false by default)
  40606. */
  40607. constructor(leftJoystick?: boolean);
  40608. /**
  40609. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  40610. * @param newJoystickSensibility defines the new sensibility
  40611. */
  40612. setJoystickSensibility(newJoystickSensibility: number): void;
  40613. private _onPointerDown;
  40614. private _onPointerMove;
  40615. private _onPointerUp;
  40616. /**
  40617. * Change the color of the virtual joystick
  40618. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  40619. */
  40620. setJoystickColor(newColor: string): void;
  40621. /**
  40622. * Defines a callback to call when the joystick is touched
  40623. * @param action defines the callback
  40624. */
  40625. setActionOnTouch(action: () => any): void;
  40626. /**
  40627. * Defines which axis you'd like to control for left & right
  40628. * @param axis defines the axis to use
  40629. */
  40630. setAxisForLeftRight(axis: JoystickAxis): void;
  40631. /**
  40632. * Defines which axis you'd like to control for up & down
  40633. * @param axis defines the axis to use
  40634. */
  40635. setAxisForUpDown(axis: JoystickAxis): void;
  40636. private _drawVirtualJoystick;
  40637. /**
  40638. * Release internal HTML canvas
  40639. */
  40640. releaseCanvas(): void;
  40641. }
  40642. }
  40643. declare module BABYLON {
  40644. interface FreeCameraInputsManager {
  40645. /**
  40646. * Add virtual joystick input support to the input manager.
  40647. * @returns the current input manager
  40648. */
  40649. addVirtualJoystick(): FreeCameraInputsManager;
  40650. }
  40651. /**
  40652. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  40653. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40654. */
  40655. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  40656. /**
  40657. * Defines the camera the input is attached to.
  40658. */
  40659. camera: FreeCamera;
  40660. private _leftjoystick;
  40661. private _rightjoystick;
  40662. /**
  40663. * Gets the left stick of the virtual joystick.
  40664. * @returns The virtual Joystick
  40665. */
  40666. getLeftJoystick(): VirtualJoystick;
  40667. /**
  40668. * Gets the right stick of the virtual joystick.
  40669. * @returns The virtual Joystick
  40670. */
  40671. getRightJoystick(): VirtualJoystick;
  40672. /**
  40673. * Update the current camera state depending on the inputs that have been used this frame.
  40674. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40675. */
  40676. checkInputs(): void;
  40677. /**
  40678. * Attach the input controls to a specific dom element to get the input from.
  40679. * @param element Defines the element the controls should be listened from
  40680. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40681. */
  40682. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40683. /**
  40684. * Detach the current controls from the specified dom element.
  40685. * @param element Defines the element to stop listening the inputs from
  40686. */
  40687. detachControl(element: Nullable<HTMLElement>): void;
  40688. /**
  40689. * Gets the class name of the current intput.
  40690. * @returns the class name
  40691. */
  40692. getClassName(): string;
  40693. /**
  40694. * Get the friendly name associated with the input class.
  40695. * @returns the input friendly name
  40696. */
  40697. getSimpleName(): string;
  40698. }
  40699. }
  40700. declare module BABYLON {
  40701. /**
  40702. * This represents a FPS type of camera controlled by touch.
  40703. * This is like a universal camera minus the Gamepad controls.
  40704. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40705. */
  40706. export class TouchCamera extends FreeCamera {
  40707. /**
  40708. * Defines the touch sensibility for rotation.
  40709. * The higher the faster.
  40710. */
  40711. get touchAngularSensibility(): number;
  40712. set touchAngularSensibility(value: number);
  40713. /**
  40714. * Defines the touch sensibility for move.
  40715. * The higher the faster.
  40716. */
  40717. get touchMoveSensibility(): number;
  40718. set touchMoveSensibility(value: number);
  40719. /**
  40720. * Instantiates a new touch camera.
  40721. * This represents a FPS type of camera controlled by touch.
  40722. * This is like a universal camera minus the Gamepad controls.
  40723. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40724. * @param name Define the name of the camera in the scene
  40725. * @param position Define the start position of the camera in the scene
  40726. * @param scene Define the scene the camera belongs to
  40727. */
  40728. constructor(name: string, position: Vector3, scene: Scene);
  40729. /**
  40730. * Gets the current object class name.
  40731. * @return the class name
  40732. */
  40733. getClassName(): string;
  40734. /** @hidden */
  40735. _setupInputs(): void;
  40736. }
  40737. }
  40738. declare module BABYLON {
  40739. /**
  40740. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  40741. * being tilted forward or back and left or right.
  40742. */
  40743. export class DeviceOrientationCamera extends FreeCamera {
  40744. private _initialQuaternion;
  40745. private _quaternionCache;
  40746. private _tmpDragQuaternion;
  40747. private _disablePointerInputWhenUsingDeviceOrientation;
  40748. /**
  40749. * Creates a new device orientation camera
  40750. * @param name The name of the camera
  40751. * @param position The start position camera
  40752. * @param scene The scene the camera belongs to
  40753. */
  40754. constructor(name: string, position: Vector3, scene: Scene);
  40755. /**
  40756. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  40757. */
  40758. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  40759. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  40760. private _dragFactor;
  40761. /**
  40762. * Enabled turning on the y axis when the orientation sensor is active
  40763. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  40764. */
  40765. enableHorizontalDragging(dragFactor?: number): void;
  40766. /**
  40767. * Gets the current instance class name ("DeviceOrientationCamera").
  40768. * This helps avoiding instanceof at run time.
  40769. * @returns the class name
  40770. */
  40771. getClassName(): string;
  40772. /**
  40773. * @hidden
  40774. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  40775. */
  40776. _checkInputs(): void;
  40777. /**
  40778. * Reset the camera to its default orientation on the specified axis only.
  40779. * @param axis The axis to reset
  40780. */
  40781. resetToCurrentRotation(axis?: Axis): void;
  40782. }
  40783. }
  40784. declare module BABYLON {
  40785. /**
  40786. * Defines supported buttons for XBox360 compatible gamepads
  40787. */
  40788. export enum Xbox360Button {
  40789. /** A */
  40790. A = 0,
  40791. /** B */
  40792. B = 1,
  40793. /** X */
  40794. X = 2,
  40795. /** Y */
  40796. Y = 3,
  40797. /** Start */
  40798. Start = 4,
  40799. /** Back */
  40800. Back = 5,
  40801. /** Left button */
  40802. LB = 6,
  40803. /** Right button */
  40804. RB = 7,
  40805. /** Left stick */
  40806. LeftStick = 8,
  40807. /** Right stick */
  40808. RightStick = 9
  40809. }
  40810. /** Defines values for XBox360 DPad */
  40811. export enum Xbox360Dpad {
  40812. /** Up */
  40813. Up = 0,
  40814. /** Down */
  40815. Down = 1,
  40816. /** Left */
  40817. Left = 2,
  40818. /** Right */
  40819. Right = 3
  40820. }
  40821. /**
  40822. * Defines a XBox360 gamepad
  40823. */
  40824. export class Xbox360Pad extends Gamepad {
  40825. private _leftTrigger;
  40826. private _rightTrigger;
  40827. private _onlefttriggerchanged;
  40828. private _onrighttriggerchanged;
  40829. private _onbuttondown;
  40830. private _onbuttonup;
  40831. private _ondpaddown;
  40832. private _ondpadup;
  40833. /** Observable raised when a button is pressed */
  40834. onButtonDownObservable: Observable<Xbox360Button>;
  40835. /** Observable raised when a button is released */
  40836. onButtonUpObservable: Observable<Xbox360Button>;
  40837. /** Observable raised when a pad is pressed */
  40838. onPadDownObservable: Observable<Xbox360Dpad>;
  40839. /** Observable raised when a pad is released */
  40840. onPadUpObservable: Observable<Xbox360Dpad>;
  40841. private _buttonA;
  40842. private _buttonB;
  40843. private _buttonX;
  40844. private _buttonY;
  40845. private _buttonBack;
  40846. private _buttonStart;
  40847. private _buttonLB;
  40848. private _buttonRB;
  40849. private _buttonLeftStick;
  40850. private _buttonRightStick;
  40851. private _dPadUp;
  40852. private _dPadDown;
  40853. private _dPadLeft;
  40854. private _dPadRight;
  40855. private _isXboxOnePad;
  40856. /**
  40857. * Creates a new XBox360 gamepad object
  40858. * @param id defines the id of this gamepad
  40859. * @param index defines its index
  40860. * @param gamepad defines the internal HTML gamepad object
  40861. * @param xboxOne defines if it is a XBox One gamepad
  40862. */
  40863. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  40864. /**
  40865. * Defines the callback to call when left trigger is pressed
  40866. * @param callback defines the callback to use
  40867. */
  40868. onlefttriggerchanged(callback: (value: number) => void): void;
  40869. /**
  40870. * Defines the callback to call when right trigger is pressed
  40871. * @param callback defines the callback to use
  40872. */
  40873. onrighttriggerchanged(callback: (value: number) => void): void;
  40874. /**
  40875. * Gets the left trigger value
  40876. */
  40877. get leftTrigger(): number;
  40878. /**
  40879. * Sets the left trigger value
  40880. */
  40881. set leftTrigger(newValue: number);
  40882. /**
  40883. * Gets the right trigger value
  40884. */
  40885. get rightTrigger(): number;
  40886. /**
  40887. * Sets the right trigger value
  40888. */
  40889. set rightTrigger(newValue: number);
  40890. /**
  40891. * Defines the callback to call when a button is pressed
  40892. * @param callback defines the callback to use
  40893. */
  40894. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  40895. /**
  40896. * Defines the callback to call when a button is released
  40897. * @param callback defines the callback to use
  40898. */
  40899. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  40900. /**
  40901. * Defines the callback to call when a pad is pressed
  40902. * @param callback defines the callback to use
  40903. */
  40904. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  40905. /**
  40906. * Defines the callback to call when a pad is released
  40907. * @param callback defines the callback to use
  40908. */
  40909. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  40910. private _setButtonValue;
  40911. private _setDPadValue;
  40912. /**
  40913. * Gets the value of the `A` button
  40914. */
  40915. get buttonA(): number;
  40916. /**
  40917. * Sets the value of the `A` button
  40918. */
  40919. set buttonA(value: number);
  40920. /**
  40921. * Gets the value of the `B` button
  40922. */
  40923. get buttonB(): number;
  40924. /**
  40925. * Sets the value of the `B` button
  40926. */
  40927. set buttonB(value: number);
  40928. /**
  40929. * Gets the value of the `X` button
  40930. */
  40931. get buttonX(): number;
  40932. /**
  40933. * Sets the value of the `X` button
  40934. */
  40935. set buttonX(value: number);
  40936. /**
  40937. * Gets the value of the `Y` button
  40938. */
  40939. get buttonY(): number;
  40940. /**
  40941. * Sets the value of the `Y` button
  40942. */
  40943. set buttonY(value: number);
  40944. /**
  40945. * Gets the value of the `Start` button
  40946. */
  40947. get buttonStart(): number;
  40948. /**
  40949. * Sets the value of the `Start` button
  40950. */
  40951. set buttonStart(value: number);
  40952. /**
  40953. * Gets the value of the `Back` button
  40954. */
  40955. get buttonBack(): number;
  40956. /**
  40957. * Sets the value of the `Back` button
  40958. */
  40959. set buttonBack(value: number);
  40960. /**
  40961. * Gets the value of the `Left` button
  40962. */
  40963. get buttonLB(): number;
  40964. /**
  40965. * Sets the value of the `Left` button
  40966. */
  40967. set buttonLB(value: number);
  40968. /**
  40969. * Gets the value of the `Right` button
  40970. */
  40971. get buttonRB(): number;
  40972. /**
  40973. * Sets the value of the `Right` button
  40974. */
  40975. set buttonRB(value: number);
  40976. /**
  40977. * Gets the value of the Left joystick
  40978. */
  40979. get buttonLeftStick(): number;
  40980. /**
  40981. * Sets the value of the Left joystick
  40982. */
  40983. set buttonLeftStick(value: number);
  40984. /**
  40985. * Gets the value of the Right joystick
  40986. */
  40987. get buttonRightStick(): number;
  40988. /**
  40989. * Sets the value of the Right joystick
  40990. */
  40991. set buttonRightStick(value: number);
  40992. /**
  40993. * Gets the value of D-pad up
  40994. */
  40995. get dPadUp(): number;
  40996. /**
  40997. * Sets the value of D-pad up
  40998. */
  40999. set dPadUp(value: number);
  41000. /**
  41001. * Gets the value of D-pad down
  41002. */
  41003. get dPadDown(): number;
  41004. /**
  41005. * Sets the value of D-pad down
  41006. */
  41007. set dPadDown(value: number);
  41008. /**
  41009. * Gets the value of D-pad left
  41010. */
  41011. get dPadLeft(): number;
  41012. /**
  41013. * Sets the value of D-pad left
  41014. */
  41015. set dPadLeft(value: number);
  41016. /**
  41017. * Gets the value of D-pad right
  41018. */
  41019. get dPadRight(): number;
  41020. /**
  41021. * Sets the value of D-pad right
  41022. */
  41023. set dPadRight(value: number);
  41024. /**
  41025. * Force the gamepad to synchronize with device values
  41026. */
  41027. update(): void;
  41028. /**
  41029. * Disposes the gamepad
  41030. */
  41031. dispose(): void;
  41032. }
  41033. }
  41034. declare module BABYLON {
  41035. /**
  41036. * Defines supported buttons for DualShock compatible gamepads
  41037. */
  41038. export enum DualShockButton {
  41039. /** Cross */
  41040. Cross = 0,
  41041. /** Circle */
  41042. Circle = 1,
  41043. /** Square */
  41044. Square = 2,
  41045. /** Triangle */
  41046. Triangle = 3,
  41047. /** Options */
  41048. Options = 4,
  41049. /** Share */
  41050. Share = 5,
  41051. /** L1 */
  41052. L1 = 6,
  41053. /** R1 */
  41054. R1 = 7,
  41055. /** Left stick */
  41056. LeftStick = 8,
  41057. /** Right stick */
  41058. RightStick = 9
  41059. }
  41060. /** Defines values for DualShock DPad */
  41061. export enum DualShockDpad {
  41062. /** Up */
  41063. Up = 0,
  41064. /** Down */
  41065. Down = 1,
  41066. /** Left */
  41067. Left = 2,
  41068. /** Right */
  41069. Right = 3
  41070. }
  41071. /**
  41072. * Defines a DualShock gamepad
  41073. */
  41074. export class DualShockPad extends Gamepad {
  41075. private _leftTrigger;
  41076. private _rightTrigger;
  41077. private _onlefttriggerchanged;
  41078. private _onrighttriggerchanged;
  41079. private _onbuttondown;
  41080. private _onbuttonup;
  41081. private _ondpaddown;
  41082. private _ondpadup;
  41083. /** Observable raised when a button is pressed */
  41084. onButtonDownObservable: Observable<DualShockButton>;
  41085. /** Observable raised when a button is released */
  41086. onButtonUpObservable: Observable<DualShockButton>;
  41087. /** Observable raised when a pad is pressed */
  41088. onPadDownObservable: Observable<DualShockDpad>;
  41089. /** Observable raised when a pad is released */
  41090. onPadUpObservable: Observable<DualShockDpad>;
  41091. private _buttonCross;
  41092. private _buttonCircle;
  41093. private _buttonSquare;
  41094. private _buttonTriangle;
  41095. private _buttonShare;
  41096. private _buttonOptions;
  41097. private _buttonL1;
  41098. private _buttonR1;
  41099. private _buttonLeftStick;
  41100. private _buttonRightStick;
  41101. private _dPadUp;
  41102. private _dPadDown;
  41103. private _dPadLeft;
  41104. private _dPadRight;
  41105. /**
  41106. * Creates a new DualShock gamepad object
  41107. * @param id defines the id of this gamepad
  41108. * @param index defines its index
  41109. * @param gamepad defines the internal HTML gamepad object
  41110. */
  41111. constructor(id: string, index: number, gamepad: any);
  41112. /**
  41113. * Defines the callback to call when left trigger is pressed
  41114. * @param callback defines the callback to use
  41115. */
  41116. onlefttriggerchanged(callback: (value: number) => void): void;
  41117. /**
  41118. * Defines the callback to call when right trigger is pressed
  41119. * @param callback defines the callback to use
  41120. */
  41121. onrighttriggerchanged(callback: (value: number) => void): void;
  41122. /**
  41123. * Gets the left trigger value
  41124. */
  41125. get leftTrigger(): number;
  41126. /**
  41127. * Sets the left trigger value
  41128. */
  41129. set leftTrigger(newValue: number);
  41130. /**
  41131. * Gets the right trigger value
  41132. */
  41133. get rightTrigger(): number;
  41134. /**
  41135. * Sets the right trigger value
  41136. */
  41137. set rightTrigger(newValue: number);
  41138. /**
  41139. * Defines the callback to call when a button is pressed
  41140. * @param callback defines the callback to use
  41141. */
  41142. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  41143. /**
  41144. * Defines the callback to call when a button is released
  41145. * @param callback defines the callback to use
  41146. */
  41147. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  41148. /**
  41149. * Defines the callback to call when a pad is pressed
  41150. * @param callback defines the callback to use
  41151. */
  41152. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  41153. /**
  41154. * Defines the callback to call when a pad is released
  41155. * @param callback defines the callback to use
  41156. */
  41157. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  41158. private _setButtonValue;
  41159. private _setDPadValue;
  41160. /**
  41161. * Gets the value of the `Cross` button
  41162. */
  41163. get buttonCross(): number;
  41164. /**
  41165. * Sets the value of the `Cross` button
  41166. */
  41167. set buttonCross(value: number);
  41168. /**
  41169. * Gets the value of the `Circle` button
  41170. */
  41171. get buttonCircle(): number;
  41172. /**
  41173. * Sets the value of the `Circle` button
  41174. */
  41175. set buttonCircle(value: number);
  41176. /**
  41177. * Gets the value of the `Square` button
  41178. */
  41179. get buttonSquare(): number;
  41180. /**
  41181. * Sets the value of the `Square` button
  41182. */
  41183. set buttonSquare(value: number);
  41184. /**
  41185. * Gets the value of the `Triangle` button
  41186. */
  41187. get buttonTriangle(): number;
  41188. /**
  41189. * Sets the value of the `Triangle` button
  41190. */
  41191. set buttonTriangle(value: number);
  41192. /**
  41193. * Gets the value of the `Options` button
  41194. */
  41195. get buttonOptions(): number;
  41196. /**
  41197. * Sets the value of the `Options` button
  41198. */
  41199. set buttonOptions(value: number);
  41200. /**
  41201. * Gets the value of the `Share` button
  41202. */
  41203. get buttonShare(): number;
  41204. /**
  41205. * Sets the value of the `Share` button
  41206. */
  41207. set buttonShare(value: number);
  41208. /**
  41209. * Gets the value of the `L1` button
  41210. */
  41211. get buttonL1(): number;
  41212. /**
  41213. * Sets the value of the `L1` button
  41214. */
  41215. set buttonL1(value: number);
  41216. /**
  41217. * Gets the value of the `R1` button
  41218. */
  41219. get buttonR1(): number;
  41220. /**
  41221. * Sets the value of the `R1` button
  41222. */
  41223. set buttonR1(value: number);
  41224. /**
  41225. * Gets the value of the Left joystick
  41226. */
  41227. get buttonLeftStick(): number;
  41228. /**
  41229. * Sets the value of the Left joystick
  41230. */
  41231. set buttonLeftStick(value: number);
  41232. /**
  41233. * Gets the value of the Right joystick
  41234. */
  41235. get buttonRightStick(): number;
  41236. /**
  41237. * Sets the value of the Right joystick
  41238. */
  41239. set buttonRightStick(value: number);
  41240. /**
  41241. * Gets the value of D-pad up
  41242. */
  41243. get dPadUp(): number;
  41244. /**
  41245. * Sets the value of D-pad up
  41246. */
  41247. set dPadUp(value: number);
  41248. /**
  41249. * Gets the value of D-pad down
  41250. */
  41251. get dPadDown(): number;
  41252. /**
  41253. * Sets the value of D-pad down
  41254. */
  41255. set dPadDown(value: number);
  41256. /**
  41257. * Gets the value of D-pad left
  41258. */
  41259. get dPadLeft(): number;
  41260. /**
  41261. * Sets the value of D-pad left
  41262. */
  41263. set dPadLeft(value: number);
  41264. /**
  41265. * Gets the value of D-pad right
  41266. */
  41267. get dPadRight(): number;
  41268. /**
  41269. * Sets the value of D-pad right
  41270. */
  41271. set dPadRight(value: number);
  41272. /**
  41273. * Force the gamepad to synchronize with device values
  41274. */
  41275. update(): void;
  41276. /**
  41277. * Disposes the gamepad
  41278. */
  41279. dispose(): void;
  41280. }
  41281. }
  41282. declare module BABYLON {
  41283. /**
  41284. * Manager for handling gamepads
  41285. */
  41286. export class GamepadManager {
  41287. private _scene?;
  41288. private _babylonGamepads;
  41289. private _oneGamepadConnected;
  41290. /** @hidden */
  41291. _isMonitoring: boolean;
  41292. private _gamepadEventSupported;
  41293. private _gamepadSupport?;
  41294. /**
  41295. * observable to be triggered when the gamepad controller has been connected
  41296. */
  41297. onGamepadConnectedObservable: Observable<Gamepad>;
  41298. /**
  41299. * observable to be triggered when the gamepad controller has been disconnected
  41300. */
  41301. onGamepadDisconnectedObservable: Observable<Gamepad>;
  41302. private _onGamepadConnectedEvent;
  41303. private _onGamepadDisconnectedEvent;
  41304. /**
  41305. * Initializes the gamepad manager
  41306. * @param _scene BabylonJS scene
  41307. */
  41308. constructor(_scene?: Scene | undefined);
  41309. /**
  41310. * The gamepads in the game pad manager
  41311. */
  41312. get gamepads(): Gamepad[];
  41313. /**
  41314. * Get the gamepad controllers based on type
  41315. * @param type The type of gamepad controller
  41316. * @returns Nullable gamepad
  41317. */
  41318. getGamepadByType(type?: number): Nullable<Gamepad>;
  41319. /**
  41320. * Disposes the gamepad manager
  41321. */
  41322. dispose(): void;
  41323. private _addNewGamepad;
  41324. private _startMonitoringGamepads;
  41325. private _stopMonitoringGamepads;
  41326. /** @hidden */
  41327. _checkGamepadsStatus(): void;
  41328. private _updateGamepadObjects;
  41329. }
  41330. }
  41331. declare module BABYLON {
  41332. interface Scene {
  41333. /** @hidden */
  41334. _gamepadManager: Nullable<GamepadManager>;
  41335. /**
  41336. * Gets the gamepad manager associated with the scene
  41337. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  41338. */
  41339. gamepadManager: GamepadManager;
  41340. }
  41341. /**
  41342. * Interface representing a free camera inputs manager
  41343. */
  41344. interface FreeCameraInputsManager {
  41345. /**
  41346. * Adds gamepad input support to the FreeCameraInputsManager.
  41347. * @returns the FreeCameraInputsManager
  41348. */
  41349. addGamepad(): FreeCameraInputsManager;
  41350. }
  41351. /**
  41352. * Interface representing an arc rotate camera inputs manager
  41353. */
  41354. interface ArcRotateCameraInputsManager {
  41355. /**
  41356. * Adds gamepad input support to the ArcRotateCamera InputManager.
  41357. * @returns the camera inputs manager
  41358. */
  41359. addGamepad(): ArcRotateCameraInputsManager;
  41360. }
  41361. /**
  41362. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  41363. */
  41364. export class GamepadSystemSceneComponent implements ISceneComponent {
  41365. /**
  41366. * The component name helpfull to identify the component in the list of scene components.
  41367. */
  41368. readonly name: string;
  41369. /**
  41370. * The scene the component belongs to.
  41371. */
  41372. scene: Scene;
  41373. /**
  41374. * Creates a new instance of the component for the given scene
  41375. * @param scene Defines the scene to register the component in
  41376. */
  41377. constructor(scene: Scene);
  41378. /**
  41379. * Registers the component in a given scene
  41380. */
  41381. register(): void;
  41382. /**
  41383. * Rebuilds the elements related to this component in case of
  41384. * context lost for instance.
  41385. */
  41386. rebuild(): void;
  41387. /**
  41388. * Disposes the component and the associated ressources
  41389. */
  41390. dispose(): void;
  41391. private _beforeCameraUpdate;
  41392. }
  41393. }
  41394. declare module BABYLON {
  41395. /**
  41396. * 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,
  41397. * which still works and will still be found in many Playgrounds.
  41398. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41399. */
  41400. export class UniversalCamera extends TouchCamera {
  41401. /**
  41402. * Defines the gamepad rotation sensiblity.
  41403. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41404. */
  41405. get gamepadAngularSensibility(): number;
  41406. set gamepadAngularSensibility(value: number);
  41407. /**
  41408. * Defines the gamepad move sensiblity.
  41409. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41410. */
  41411. get gamepadMoveSensibility(): number;
  41412. set gamepadMoveSensibility(value: number);
  41413. /**
  41414. * 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,
  41415. * which still works and will still be found in many Playgrounds.
  41416. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41417. * @param name Define the name of the camera in the scene
  41418. * @param position Define the start position of the camera in the scene
  41419. * @param scene Define the scene the camera belongs to
  41420. */
  41421. constructor(name: string, position: Vector3, scene: Scene);
  41422. /**
  41423. * Gets the current object class name.
  41424. * @return the class name
  41425. */
  41426. getClassName(): string;
  41427. }
  41428. }
  41429. declare module BABYLON {
  41430. /**
  41431. * This represents a FPS type of camera. This is only here for back compat purpose.
  41432. * Please use the UniversalCamera instead as both are identical.
  41433. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41434. */
  41435. export class GamepadCamera extends UniversalCamera {
  41436. /**
  41437. * Instantiates a new Gamepad Camera
  41438. * This represents a FPS type of camera. This is only here for back compat purpose.
  41439. * Please use the UniversalCamera instead as both are identical.
  41440. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41441. * @param name Define the name of the camera in the scene
  41442. * @param position Define the start position of the camera in the scene
  41443. * @param scene Define the scene the camera belongs to
  41444. */
  41445. constructor(name: string, position: Vector3, scene: Scene);
  41446. /**
  41447. * Gets the current object class name.
  41448. * @return the class name
  41449. */
  41450. getClassName(): string;
  41451. }
  41452. }
  41453. declare module BABYLON {
  41454. /** @hidden */
  41455. export var passPixelShader: {
  41456. name: string;
  41457. shader: string;
  41458. };
  41459. }
  41460. declare module BABYLON {
  41461. /** @hidden */
  41462. export var passCubePixelShader: {
  41463. name: string;
  41464. shader: string;
  41465. };
  41466. }
  41467. declare module BABYLON {
  41468. /**
  41469. * PassPostProcess which produces an output the same as it's input
  41470. */
  41471. export class PassPostProcess extends PostProcess {
  41472. /**
  41473. * Creates the PassPostProcess
  41474. * @param name The name of the effect.
  41475. * @param options The required width/height ratio to downsize to before computing the render pass.
  41476. * @param camera The camera to apply the render pass to.
  41477. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41478. * @param engine The engine which the post process will be applied. (default: current engine)
  41479. * @param reusable If the post process can be reused on the same frame. (default: false)
  41480. * @param textureType The type of texture to be used when performing the post processing.
  41481. * @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)
  41482. */
  41483. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41484. }
  41485. /**
  41486. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  41487. */
  41488. export class PassCubePostProcess extends PostProcess {
  41489. private _face;
  41490. /**
  41491. * Gets or sets the cube face to display.
  41492. * * 0 is +X
  41493. * * 1 is -X
  41494. * * 2 is +Y
  41495. * * 3 is -Y
  41496. * * 4 is +Z
  41497. * * 5 is -Z
  41498. */
  41499. get face(): number;
  41500. set face(value: number);
  41501. /**
  41502. * Creates the PassCubePostProcess
  41503. * @param name The name of the effect.
  41504. * @param options The required width/height ratio to downsize to before computing the render pass.
  41505. * @param camera The camera to apply the render pass to.
  41506. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41507. * @param engine The engine which the post process will be applied. (default: current engine)
  41508. * @param reusable If the post process can be reused on the same frame. (default: false)
  41509. * @param textureType The type of texture to be used when performing the post processing.
  41510. * @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)
  41511. */
  41512. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41513. }
  41514. }
  41515. declare module BABYLON {
  41516. /** @hidden */
  41517. export var anaglyphPixelShader: {
  41518. name: string;
  41519. shader: string;
  41520. };
  41521. }
  41522. declare module BABYLON {
  41523. /**
  41524. * Postprocess used to generate anaglyphic rendering
  41525. */
  41526. export class AnaglyphPostProcess extends PostProcess {
  41527. private _passedProcess;
  41528. /**
  41529. * Creates a new AnaglyphPostProcess
  41530. * @param name defines postprocess name
  41531. * @param options defines creation options or target ratio scale
  41532. * @param rigCameras defines cameras using this postprocess
  41533. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  41534. * @param engine defines hosting engine
  41535. * @param reusable defines if the postprocess will be reused multiple times per frame
  41536. */
  41537. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  41538. }
  41539. }
  41540. declare module BABYLON {
  41541. /**
  41542. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  41543. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41544. */
  41545. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  41546. /**
  41547. * Creates a new AnaglyphArcRotateCamera
  41548. * @param name defines camera name
  41549. * @param alpha defines alpha angle (in radians)
  41550. * @param beta defines beta angle (in radians)
  41551. * @param radius defines radius
  41552. * @param target defines camera target
  41553. * @param interaxialDistance defines distance between each color axis
  41554. * @param scene defines the hosting scene
  41555. */
  41556. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  41557. /**
  41558. * Gets camera class name
  41559. * @returns AnaglyphArcRotateCamera
  41560. */
  41561. getClassName(): string;
  41562. }
  41563. }
  41564. declare module BABYLON {
  41565. /**
  41566. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  41567. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41568. */
  41569. export class AnaglyphFreeCamera extends FreeCamera {
  41570. /**
  41571. * Creates a new AnaglyphFreeCamera
  41572. * @param name defines camera name
  41573. * @param position defines initial position
  41574. * @param interaxialDistance defines distance between each color axis
  41575. * @param scene defines the hosting scene
  41576. */
  41577. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41578. /**
  41579. * Gets camera class name
  41580. * @returns AnaglyphFreeCamera
  41581. */
  41582. getClassName(): string;
  41583. }
  41584. }
  41585. declare module BABYLON {
  41586. /**
  41587. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  41588. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41589. */
  41590. export class AnaglyphGamepadCamera extends GamepadCamera {
  41591. /**
  41592. * Creates a new AnaglyphGamepadCamera
  41593. * @param name defines camera name
  41594. * @param position defines initial position
  41595. * @param interaxialDistance defines distance between each color axis
  41596. * @param scene defines the hosting scene
  41597. */
  41598. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41599. /**
  41600. * Gets camera class name
  41601. * @returns AnaglyphGamepadCamera
  41602. */
  41603. getClassName(): string;
  41604. }
  41605. }
  41606. declare module BABYLON {
  41607. /**
  41608. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  41609. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41610. */
  41611. export class AnaglyphUniversalCamera extends UniversalCamera {
  41612. /**
  41613. * Creates a new AnaglyphUniversalCamera
  41614. * @param name defines camera name
  41615. * @param position defines initial position
  41616. * @param interaxialDistance defines distance between each color axis
  41617. * @param scene defines the hosting scene
  41618. */
  41619. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41620. /**
  41621. * Gets camera class name
  41622. * @returns AnaglyphUniversalCamera
  41623. */
  41624. getClassName(): string;
  41625. }
  41626. }
  41627. declare module BABYLON {
  41628. /** @hidden */
  41629. export var stereoscopicInterlacePixelShader: {
  41630. name: string;
  41631. shader: string;
  41632. };
  41633. }
  41634. declare module BABYLON {
  41635. /**
  41636. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  41637. */
  41638. export class StereoscopicInterlacePostProcess extends PostProcess {
  41639. private _stepSize;
  41640. private _passedProcess;
  41641. /**
  41642. * Initializes a StereoscopicInterlacePostProcess
  41643. * @param name The name of the effect.
  41644. * @param rigCameras The rig cameras to be appled to the post process
  41645. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  41646. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41647. * @param engine The engine which the post process will be applied. (default: current engine)
  41648. * @param reusable If the post process can be reused on the same frame. (default: false)
  41649. */
  41650. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  41651. }
  41652. }
  41653. declare module BABYLON {
  41654. /**
  41655. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  41656. * @see http://doc.babylonjs.com/features/cameras
  41657. */
  41658. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  41659. /**
  41660. * Creates a new StereoscopicArcRotateCamera
  41661. * @param name defines camera name
  41662. * @param alpha defines alpha angle (in radians)
  41663. * @param beta defines beta angle (in radians)
  41664. * @param radius defines radius
  41665. * @param target defines camera target
  41666. * @param interaxialDistance defines distance between each color axis
  41667. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41668. * @param scene defines the hosting scene
  41669. */
  41670. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41671. /**
  41672. * Gets camera class name
  41673. * @returns StereoscopicArcRotateCamera
  41674. */
  41675. getClassName(): string;
  41676. }
  41677. }
  41678. declare module BABYLON {
  41679. /**
  41680. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  41681. * @see http://doc.babylonjs.com/features/cameras
  41682. */
  41683. export class StereoscopicFreeCamera extends FreeCamera {
  41684. /**
  41685. * Creates a new StereoscopicFreeCamera
  41686. * @param name defines camera name
  41687. * @param position defines initial position
  41688. * @param interaxialDistance defines distance between each color axis
  41689. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41690. * @param scene defines the hosting scene
  41691. */
  41692. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41693. /**
  41694. * Gets camera class name
  41695. * @returns StereoscopicFreeCamera
  41696. */
  41697. getClassName(): string;
  41698. }
  41699. }
  41700. declare module BABYLON {
  41701. /**
  41702. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  41703. * @see http://doc.babylonjs.com/features/cameras
  41704. */
  41705. export class StereoscopicGamepadCamera extends GamepadCamera {
  41706. /**
  41707. * Creates a new StereoscopicGamepadCamera
  41708. * @param name defines camera name
  41709. * @param position defines initial position
  41710. * @param interaxialDistance defines distance between each color axis
  41711. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41712. * @param scene defines the hosting scene
  41713. */
  41714. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41715. /**
  41716. * Gets camera class name
  41717. * @returns StereoscopicGamepadCamera
  41718. */
  41719. getClassName(): string;
  41720. }
  41721. }
  41722. declare module BABYLON {
  41723. /**
  41724. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  41725. * @see http://doc.babylonjs.com/features/cameras
  41726. */
  41727. export class StereoscopicUniversalCamera extends UniversalCamera {
  41728. /**
  41729. * Creates a new StereoscopicUniversalCamera
  41730. * @param name defines camera name
  41731. * @param position defines initial position
  41732. * @param interaxialDistance defines distance between each color axis
  41733. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41734. * @param scene defines the hosting scene
  41735. */
  41736. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41737. /**
  41738. * Gets camera class name
  41739. * @returns StereoscopicUniversalCamera
  41740. */
  41741. getClassName(): string;
  41742. }
  41743. }
  41744. declare module BABYLON {
  41745. /**
  41746. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  41747. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41748. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41749. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41750. */
  41751. export class VirtualJoysticksCamera extends FreeCamera {
  41752. /**
  41753. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  41754. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41755. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41756. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41757. * @param name Define the name of the camera in the scene
  41758. * @param position Define the start position of the camera in the scene
  41759. * @param scene Define the scene the camera belongs to
  41760. */
  41761. constructor(name: string, position: Vector3, scene: Scene);
  41762. /**
  41763. * Gets the current object class name.
  41764. * @return the class name
  41765. */
  41766. getClassName(): string;
  41767. }
  41768. }
  41769. declare module BABYLON {
  41770. /**
  41771. * This represents all the required metrics to create a VR camera.
  41772. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  41773. */
  41774. export class VRCameraMetrics {
  41775. /**
  41776. * Define the horizontal resolution off the screen.
  41777. */
  41778. hResolution: number;
  41779. /**
  41780. * Define the vertical resolution off the screen.
  41781. */
  41782. vResolution: number;
  41783. /**
  41784. * Define the horizontal screen size.
  41785. */
  41786. hScreenSize: number;
  41787. /**
  41788. * Define the vertical screen size.
  41789. */
  41790. vScreenSize: number;
  41791. /**
  41792. * Define the vertical screen center position.
  41793. */
  41794. vScreenCenter: number;
  41795. /**
  41796. * Define the distance of the eyes to the screen.
  41797. */
  41798. eyeToScreenDistance: number;
  41799. /**
  41800. * Define the distance between both lenses
  41801. */
  41802. lensSeparationDistance: number;
  41803. /**
  41804. * Define the distance between both viewer's eyes.
  41805. */
  41806. interpupillaryDistance: number;
  41807. /**
  41808. * Define the distortion factor of the VR postprocess.
  41809. * Please, touch with care.
  41810. */
  41811. distortionK: number[];
  41812. /**
  41813. * Define the chromatic aberration correction factors for the VR post process.
  41814. */
  41815. chromaAbCorrection: number[];
  41816. /**
  41817. * Define the scale factor of the post process.
  41818. * The smaller the better but the slower.
  41819. */
  41820. postProcessScaleFactor: number;
  41821. /**
  41822. * Define an offset for the lens center.
  41823. */
  41824. lensCenterOffset: number;
  41825. /**
  41826. * Define if the current vr camera should compensate the distortion of the lense or not.
  41827. */
  41828. compensateDistortion: boolean;
  41829. /**
  41830. * Defines if multiview should be enabled when rendering (Default: false)
  41831. */
  41832. multiviewEnabled: boolean;
  41833. /**
  41834. * Gets the rendering aspect ratio based on the provided resolutions.
  41835. */
  41836. get aspectRatio(): number;
  41837. /**
  41838. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  41839. */
  41840. get aspectRatioFov(): number;
  41841. /**
  41842. * @hidden
  41843. */
  41844. get leftHMatrix(): Matrix;
  41845. /**
  41846. * @hidden
  41847. */
  41848. get rightHMatrix(): Matrix;
  41849. /**
  41850. * @hidden
  41851. */
  41852. get leftPreViewMatrix(): Matrix;
  41853. /**
  41854. * @hidden
  41855. */
  41856. get rightPreViewMatrix(): Matrix;
  41857. /**
  41858. * Get the default VRMetrics based on the most generic setup.
  41859. * @returns the default vr metrics
  41860. */
  41861. static GetDefault(): VRCameraMetrics;
  41862. }
  41863. }
  41864. declare module BABYLON {
  41865. /** @hidden */
  41866. export var vrDistortionCorrectionPixelShader: {
  41867. name: string;
  41868. shader: string;
  41869. };
  41870. }
  41871. declare module BABYLON {
  41872. /**
  41873. * VRDistortionCorrectionPostProcess used for mobile VR
  41874. */
  41875. export class VRDistortionCorrectionPostProcess extends PostProcess {
  41876. private _isRightEye;
  41877. private _distortionFactors;
  41878. private _postProcessScaleFactor;
  41879. private _lensCenterOffset;
  41880. private _scaleIn;
  41881. private _scaleFactor;
  41882. private _lensCenter;
  41883. /**
  41884. * Initializes the VRDistortionCorrectionPostProcess
  41885. * @param name The name of the effect.
  41886. * @param camera The camera to apply the render pass to.
  41887. * @param isRightEye If this is for the right eye distortion
  41888. * @param vrMetrics All the required metrics for the VR camera
  41889. */
  41890. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  41891. }
  41892. }
  41893. declare module BABYLON {
  41894. /**
  41895. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  41896. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41897. */
  41898. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  41899. /**
  41900. * Creates a new VRDeviceOrientationArcRotateCamera
  41901. * @param name defines camera name
  41902. * @param alpha defines the camera rotation along the logitudinal axis
  41903. * @param beta defines the camera rotation along the latitudinal axis
  41904. * @param radius defines the camera distance from its target
  41905. * @param target defines the camera target
  41906. * @param scene defines the scene the camera belongs to
  41907. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41908. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41909. */
  41910. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41911. /**
  41912. * Gets camera class name
  41913. * @returns VRDeviceOrientationArcRotateCamera
  41914. */
  41915. getClassName(): string;
  41916. }
  41917. }
  41918. declare module BABYLON {
  41919. /**
  41920. * Camera used to simulate VR rendering (based on FreeCamera)
  41921. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41922. */
  41923. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  41924. /**
  41925. * Creates a new VRDeviceOrientationFreeCamera
  41926. * @param name defines camera name
  41927. * @param position defines the start position of the camera
  41928. * @param scene defines the scene the camera belongs to
  41929. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41930. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41931. */
  41932. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41933. /**
  41934. * Gets camera class name
  41935. * @returns VRDeviceOrientationFreeCamera
  41936. */
  41937. getClassName(): string;
  41938. }
  41939. }
  41940. declare module BABYLON {
  41941. /**
  41942. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  41943. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41944. */
  41945. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  41946. /**
  41947. * Creates a new VRDeviceOrientationGamepadCamera
  41948. * @param name defines camera name
  41949. * @param position defines the start position of the camera
  41950. * @param scene defines the scene the camera belongs to
  41951. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41952. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41953. */
  41954. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41955. /**
  41956. * Gets camera class name
  41957. * @returns VRDeviceOrientationGamepadCamera
  41958. */
  41959. getClassName(): string;
  41960. }
  41961. }
  41962. declare module BABYLON {
  41963. /** @hidden */
  41964. export var imageProcessingPixelShader: {
  41965. name: string;
  41966. shader: string;
  41967. };
  41968. }
  41969. declare module BABYLON {
  41970. /**
  41971. * ImageProcessingPostProcess
  41972. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  41973. */
  41974. export class ImageProcessingPostProcess extends PostProcess {
  41975. /**
  41976. * Default configuration related to image processing available in the PBR Material.
  41977. */
  41978. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41979. /**
  41980. * Gets the image processing configuration used either in this material.
  41981. */
  41982. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  41983. /**
  41984. * Sets the Default image processing configuration used either in the this material.
  41985. *
  41986. * If sets to null, the scene one is in use.
  41987. */
  41988. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  41989. /**
  41990. * Keep track of the image processing observer to allow dispose and replace.
  41991. */
  41992. private _imageProcessingObserver;
  41993. /**
  41994. * Attaches a new image processing configuration to the PBR Material.
  41995. * @param configuration
  41996. */
  41997. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  41998. /**
  41999. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42000. */
  42001. get colorCurves(): Nullable<ColorCurves>;
  42002. /**
  42003. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42004. */
  42005. set colorCurves(value: Nullable<ColorCurves>);
  42006. /**
  42007. * Gets wether the color curves effect is enabled.
  42008. */
  42009. get colorCurvesEnabled(): boolean;
  42010. /**
  42011. * Sets wether the color curves effect is enabled.
  42012. */
  42013. set colorCurvesEnabled(value: boolean);
  42014. /**
  42015. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42016. */
  42017. get colorGradingTexture(): Nullable<BaseTexture>;
  42018. /**
  42019. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42020. */
  42021. set colorGradingTexture(value: Nullable<BaseTexture>);
  42022. /**
  42023. * Gets wether the color grading effect is enabled.
  42024. */
  42025. get colorGradingEnabled(): boolean;
  42026. /**
  42027. * Gets wether the color grading effect is enabled.
  42028. */
  42029. set colorGradingEnabled(value: boolean);
  42030. /**
  42031. * Gets exposure used in the effect.
  42032. */
  42033. get exposure(): number;
  42034. /**
  42035. * Sets exposure used in the effect.
  42036. */
  42037. set exposure(value: number);
  42038. /**
  42039. * Gets wether tonemapping is enabled or not.
  42040. */
  42041. get toneMappingEnabled(): boolean;
  42042. /**
  42043. * Sets wether tonemapping is enabled or not
  42044. */
  42045. set toneMappingEnabled(value: boolean);
  42046. /**
  42047. * Gets the type of tone mapping effect.
  42048. */
  42049. get toneMappingType(): number;
  42050. /**
  42051. * Sets the type of tone mapping effect.
  42052. */
  42053. set toneMappingType(value: number);
  42054. /**
  42055. * Gets contrast used in the effect.
  42056. */
  42057. get contrast(): number;
  42058. /**
  42059. * Sets contrast used in the effect.
  42060. */
  42061. set contrast(value: number);
  42062. /**
  42063. * Gets Vignette stretch size.
  42064. */
  42065. get vignetteStretch(): number;
  42066. /**
  42067. * Sets Vignette stretch size.
  42068. */
  42069. set vignetteStretch(value: number);
  42070. /**
  42071. * Gets Vignette centre X Offset.
  42072. */
  42073. get vignetteCentreX(): number;
  42074. /**
  42075. * Sets Vignette centre X Offset.
  42076. */
  42077. set vignetteCentreX(value: number);
  42078. /**
  42079. * Gets Vignette centre Y Offset.
  42080. */
  42081. get vignetteCentreY(): number;
  42082. /**
  42083. * Sets Vignette centre Y Offset.
  42084. */
  42085. set vignetteCentreY(value: number);
  42086. /**
  42087. * Gets Vignette weight or intensity of the vignette effect.
  42088. */
  42089. get vignetteWeight(): number;
  42090. /**
  42091. * Sets Vignette weight or intensity of the vignette effect.
  42092. */
  42093. set vignetteWeight(value: number);
  42094. /**
  42095. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42096. * if vignetteEnabled is set to true.
  42097. */
  42098. get vignetteColor(): Color4;
  42099. /**
  42100. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42101. * if vignetteEnabled is set to true.
  42102. */
  42103. set vignetteColor(value: Color4);
  42104. /**
  42105. * Gets Camera field of view used by the Vignette effect.
  42106. */
  42107. get vignetteCameraFov(): number;
  42108. /**
  42109. * Sets Camera field of view used by the Vignette effect.
  42110. */
  42111. set vignetteCameraFov(value: number);
  42112. /**
  42113. * Gets the vignette blend mode allowing different kind of effect.
  42114. */
  42115. get vignetteBlendMode(): number;
  42116. /**
  42117. * Sets the vignette blend mode allowing different kind of effect.
  42118. */
  42119. set vignetteBlendMode(value: number);
  42120. /**
  42121. * Gets wether the vignette effect is enabled.
  42122. */
  42123. get vignetteEnabled(): boolean;
  42124. /**
  42125. * Sets wether the vignette effect is enabled.
  42126. */
  42127. set vignetteEnabled(value: boolean);
  42128. private _fromLinearSpace;
  42129. /**
  42130. * Gets wether the input of the processing is in Gamma or Linear Space.
  42131. */
  42132. get fromLinearSpace(): boolean;
  42133. /**
  42134. * Sets wether the input of the processing is in Gamma or Linear Space.
  42135. */
  42136. set fromLinearSpace(value: boolean);
  42137. /**
  42138. * Defines cache preventing GC.
  42139. */
  42140. private _defines;
  42141. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42142. /**
  42143. * "ImageProcessingPostProcess"
  42144. * @returns "ImageProcessingPostProcess"
  42145. */
  42146. getClassName(): string;
  42147. protected _updateParameters(): void;
  42148. dispose(camera?: Camera): void;
  42149. }
  42150. }
  42151. declare module BABYLON {
  42152. /**
  42153. * Class containing static functions to help procedurally build meshes
  42154. */
  42155. export class GroundBuilder {
  42156. /**
  42157. * Creates a ground mesh
  42158. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42159. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42160. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42161. * @param name defines the name of the mesh
  42162. * @param options defines the options used to create the mesh
  42163. * @param scene defines the hosting scene
  42164. * @returns the ground mesh
  42165. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42166. */
  42167. static CreateGround(name: string, options: {
  42168. width?: number;
  42169. height?: number;
  42170. subdivisions?: number;
  42171. subdivisionsX?: number;
  42172. subdivisionsY?: number;
  42173. updatable?: boolean;
  42174. }, scene: any): Mesh;
  42175. /**
  42176. * Creates a tiled ground mesh
  42177. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42178. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42179. * * 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
  42180. * * 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
  42181. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42182. * @param name defines the name of the mesh
  42183. * @param options defines the options used to create the mesh
  42184. * @param scene defines the hosting scene
  42185. * @returns the tiled ground mesh
  42186. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42187. */
  42188. static CreateTiledGround(name: string, options: {
  42189. xmin: number;
  42190. zmin: number;
  42191. xmax: number;
  42192. zmax: number;
  42193. subdivisions?: {
  42194. w: number;
  42195. h: number;
  42196. };
  42197. precision?: {
  42198. w: number;
  42199. h: number;
  42200. };
  42201. updatable?: boolean;
  42202. }, scene?: Nullable<Scene>): Mesh;
  42203. /**
  42204. * Creates a ground mesh from a height map
  42205. * * The parameter `url` sets the URL of the height map image resource.
  42206. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42207. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42208. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42209. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42210. * * 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.
  42211. * * 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).
  42212. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42213. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42214. * @param name defines the name of the mesh
  42215. * @param url defines the url to the height map
  42216. * @param options defines the options used to create the mesh
  42217. * @param scene defines the hosting scene
  42218. * @returns the ground mesh
  42219. * @see https://doc.babylonjs.com/babylon101/height_map
  42220. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42221. */
  42222. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42223. width?: number;
  42224. height?: number;
  42225. subdivisions?: number;
  42226. minHeight?: number;
  42227. maxHeight?: number;
  42228. colorFilter?: Color3;
  42229. alphaFilter?: number;
  42230. updatable?: boolean;
  42231. onReady?: (mesh: GroundMesh) => void;
  42232. }, scene?: Nullable<Scene>): GroundMesh;
  42233. }
  42234. }
  42235. declare module BABYLON {
  42236. /**
  42237. * Class containing static functions to help procedurally build meshes
  42238. */
  42239. export class TorusBuilder {
  42240. /**
  42241. * Creates a torus mesh
  42242. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42243. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42244. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42245. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42246. * * 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
  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 options defines the options used to create the mesh
  42250. * @param scene defines the hosting scene
  42251. * @returns the torus mesh
  42252. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42253. */
  42254. static CreateTorus(name: string, options: {
  42255. diameter?: number;
  42256. thickness?: number;
  42257. tessellation?: number;
  42258. updatable?: boolean;
  42259. sideOrientation?: number;
  42260. frontUVs?: Vector4;
  42261. backUVs?: Vector4;
  42262. }, scene: any): Mesh;
  42263. }
  42264. }
  42265. declare module BABYLON {
  42266. /**
  42267. * Class containing static functions to help procedurally build meshes
  42268. */
  42269. export class CylinderBuilder {
  42270. /**
  42271. * Creates a cylinder or a cone mesh
  42272. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42273. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42274. * * 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.
  42275. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42276. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42277. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42278. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42279. * * 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).
  42280. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42281. * * 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).
  42282. * * 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
  42283. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42284. * * 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
  42285. * * 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.
  42286. * * If `enclose` is false, a ring surface is one element.
  42287. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42288. * * 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
  42289. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42290. * * 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
  42291. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42292. * @param name defines the name of the mesh
  42293. * @param options defines the options used to create the mesh
  42294. * @param scene defines the hosting scene
  42295. * @returns the cylinder mesh
  42296. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42297. */
  42298. static CreateCylinder(name: string, options: {
  42299. height?: number;
  42300. diameterTop?: number;
  42301. diameterBottom?: number;
  42302. diameter?: number;
  42303. tessellation?: number;
  42304. subdivisions?: number;
  42305. arc?: number;
  42306. faceColors?: Color4[];
  42307. faceUV?: Vector4[];
  42308. updatable?: boolean;
  42309. hasRings?: boolean;
  42310. enclose?: boolean;
  42311. cap?: number;
  42312. sideOrientation?: number;
  42313. frontUVs?: Vector4;
  42314. backUVs?: Vector4;
  42315. }, scene: any): Mesh;
  42316. }
  42317. }
  42318. declare module BABYLON {
  42319. /**
  42320. * States of the webXR experience
  42321. */
  42322. export enum WebXRState {
  42323. /**
  42324. * Transitioning to being in XR mode
  42325. */
  42326. ENTERING_XR = 0,
  42327. /**
  42328. * Transitioning to non XR mode
  42329. */
  42330. EXITING_XR = 1,
  42331. /**
  42332. * In XR mode and presenting
  42333. */
  42334. IN_XR = 2,
  42335. /**
  42336. * Not entered XR mode
  42337. */
  42338. NOT_IN_XR = 3
  42339. }
  42340. /**
  42341. * Abstraction of the XR render target
  42342. */
  42343. export interface WebXRRenderTarget extends IDisposable {
  42344. /**
  42345. * xrpresent context of the canvas which can be used to display/mirror xr content
  42346. */
  42347. canvasContext: WebGLRenderingContext;
  42348. /**
  42349. * xr layer for the canvas
  42350. */
  42351. xrLayer: Nullable<XRWebGLLayer>;
  42352. /**
  42353. * Initializes the xr layer for the session
  42354. * @param xrSession xr session
  42355. * @returns a promise that will resolve once the XR Layer has been created
  42356. */
  42357. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  42358. }
  42359. }
  42360. declare module BABYLON {
  42361. /**
  42362. * COnfiguration object for WebXR output canvas
  42363. */
  42364. export class WebXRManagedOutputCanvasOptions {
  42365. /**
  42366. * Options for this XR Layer output
  42367. */
  42368. canvasOptions?: XRWebGLLayerOptions;
  42369. /**
  42370. * CSS styling for a newly created canvas (if not provided)
  42371. */
  42372. newCanvasCssStyle?: string;
  42373. /**
  42374. * An optional canvas in case you wish to create it yourself and provide it here.
  42375. * If not provided, a new canvas will be created
  42376. */
  42377. canvasElement?: HTMLCanvasElement;
  42378. /**
  42379. * Get the default values of the configuration object
  42380. * @returns default values of this configuration object
  42381. */
  42382. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  42383. }
  42384. /**
  42385. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42386. */
  42387. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  42388. private _options;
  42389. private _engine;
  42390. private _canvas;
  42391. /**
  42392. * Rendering context of the canvas which can be used to display/mirror xr content
  42393. */
  42394. canvasContext: WebGLRenderingContext;
  42395. /**
  42396. * xr layer for the canvas
  42397. */
  42398. xrLayer: Nullable<XRWebGLLayer>;
  42399. /**
  42400. * Initializes the xr layer for the session
  42401. * @param xrSession xr session
  42402. * @returns a promise that will resolve once the XR Layer has been created
  42403. */
  42404. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  42405. /**
  42406. * Initializes the canvas to be added/removed upon entering/exiting xr
  42407. * @param _xrSessionManager The XR Session manager
  42408. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  42409. */
  42410. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  42411. /**
  42412. * Disposes of the object
  42413. */
  42414. dispose(): void;
  42415. private _setManagedOutputCanvas;
  42416. private _addCanvas;
  42417. private _removeCanvas;
  42418. }
  42419. }
  42420. declare module BABYLON {
  42421. /**
  42422. * Manages an XRSession to work with Babylon's engine
  42423. * @see https://doc.babylonjs.com/how_to/webxr
  42424. */
  42425. export class WebXRSessionManager implements IDisposable {
  42426. /** The scene which the session should be created for */
  42427. scene: Scene;
  42428. /**
  42429. * Fires every time a new xrFrame arrives which can be used to update the camera
  42430. */
  42431. onXRFrameObservable: Observable<XRFrame>;
  42432. /**
  42433. * Fires when the xr session is ended either by the device or manually done
  42434. */
  42435. onXRSessionEnded: Observable<any>;
  42436. /**
  42437. * Fires when the xr session is ended either by the device or manually done
  42438. */
  42439. onXRSessionInit: Observable<XRSession>;
  42440. /**
  42441. * Fires when the reference space changed
  42442. */
  42443. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  42444. /**
  42445. * Underlying xr session
  42446. */
  42447. session: XRSession;
  42448. /**
  42449. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  42450. * or get the offset the player is currently at.
  42451. */
  42452. viewerReferenceSpace: XRReferenceSpace;
  42453. private _referenceSpace;
  42454. /**
  42455. * The current reference space used in this session. This reference space can constantly change!
  42456. * It is mainly used to offset the camera's position.
  42457. */
  42458. get referenceSpace(): XRReferenceSpace;
  42459. /**
  42460. * Set a new reference space and triggers the observable
  42461. */
  42462. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  42463. /**
  42464. * The base reference space from which the session started. good if you want to reset your
  42465. * reference space
  42466. */
  42467. baseReferenceSpace: XRReferenceSpace;
  42468. /**
  42469. * Used just in case of a failure to initialize an immersive session.
  42470. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  42471. */
  42472. defaultHeightCompensation: number;
  42473. /**
  42474. * Current XR frame
  42475. */
  42476. currentFrame: Nullable<XRFrame>;
  42477. /** WebXR timestamp updated every frame */
  42478. currentTimestamp: number;
  42479. private _xrNavigator;
  42480. private baseLayer;
  42481. private _rttProvider;
  42482. private _sessionEnded;
  42483. /**
  42484. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42485. * @param scene The scene which the session should be created for
  42486. */
  42487. constructor(
  42488. /** The scene which the session should be created for */
  42489. scene: Scene);
  42490. /**
  42491. * Initializes the manager
  42492. * After initialization enterXR can be called to start an XR session
  42493. * @returns Promise which resolves after it is initialized
  42494. */
  42495. initializeAsync(): Promise<void>;
  42496. /**
  42497. * Initializes an xr session
  42498. * @param xrSessionMode mode to initialize
  42499. * @param optionalFeatures defines optional values to pass to the session builder
  42500. * @returns a promise which will resolve once the session has been initialized
  42501. */
  42502. initializeSessionAsync(xrSessionMode: XRSessionMode, optionalFeatures?: any): Promise<XRSession>;
  42503. /**
  42504. * Sets the reference space on the xr session
  42505. * @param referenceSpace space to set
  42506. * @returns a promise that will resolve once the reference space has been set
  42507. */
  42508. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  42509. /**
  42510. * Resets the reference space to the one started the session
  42511. */
  42512. resetReferenceSpace(): void;
  42513. /**
  42514. * Updates the render state of the session
  42515. * @param state state to set
  42516. * @returns a promise that resolves once the render state has been updated
  42517. */
  42518. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42519. /**
  42520. * Starts rendering to the xr layer
  42521. * @returns a promise that will resolve once rendering has started
  42522. */
  42523. startRenderingToXRAsync(): Promise<void>;
  42524. /**
  42525. * Gets the correct render target texture to be rendered this frame for this eye
  42526. * @param eye the eye for which to get the render target
  42527. * @returns the render target for the specified eye
  42528. */
  42529. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  42530. /**
  42531. * Stops the xrSession and restores the renderloop
  42532. * @returns Promise which resolves after it exits XR
  42533. */
  42534. exitXRAsync(): Promise<void>;
  42535. /**
  42536. * Checks if a session would be supported for the creation options specified
  42537. * @param sessionMode session mode to check if supported eg. immersive-vr
  42538. * @returns true if supported
  42539. */
  42540. supportsSessionAsync(sessionMode: XRSessionMode): Promise<boolean>;
  42541. /**
  42542. * Creates a WebXRRenderTarget object for the XR session
  42543. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  42544. * @param options optional options to provide when creating a new render target
  42545. * @returns a WebXR render target to which the session can render
  42546. */
  42547. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  42548. /**
  42549. * @hidden
  42550. * Converts the render layer of xrSession to a render target
  42551. * @param session session to create render target for
  42552. * @param scene scene the new render target should be created for
  42553. * @param baseLayer the webgl layer to create the render target for
  42554. */
  42555. static _CreateRenderTargetTextureFromSession(_session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42556. /**
  42557. * Disposes of the session manager
  42558. */
  42559. dispose(): void;
  42560. /**
  42561. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  42562. * @param sessionMode defines the session to test
  42563. * @returns a promise with boolean as final value
  42564. */
  42565. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  42566. }
  42567. }
  42568. declare module BABYLON {
  42569. /**
  42570. * WebXR Camera which holds the views for the xrSession
  42571. * @see https://doc.babylonjs.com/how_to/webxr
  42572. */
  42573. export class WebXRCamera extends FreeCamera {
  42574. private _xrSessionManager;
  42575. /**
  42576. * Is the camera in debug mode. Used when using an emulator
  42577. */
  42578. debugMode: boolean;
  42579. private _firstFrame;
  42580. private _referencedPosition;
  42581. private _referenceQuaternion;
  42582. private _xrInvPositionCache;
  42583. private _xrInvQuaternionCache;
  42584. /**
  42585. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42586. * @param name the name of the camera
  42587. * @param scene the scene to add the camera to
  42588. */
  42589. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  42590. private _updateNumberOfRigCameras;
  42591. /**
  42592. * Sets this camera's transformation based on a non-vr camera
  42593. * @param otherCamera the non-vr camera to copy the transformation from
  42594. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  42595. */
  42596. setTransformationFromNonVRCamera(otherCamera: Camera, resetToBaseReferenceSpace?: boolean): void;
  42597. /** @hidden */
  42598. _updateForDualEyeDebugging(): void;
  42599. private _updateReferenceSpace;
  42600. private _updateReferenceSpaceOffset;
  42601. private _updateFromXRSession;
  42602. }
  42603. }
  42604. declare module BABYLON {
  42605. /**
  42606. * Defining the interface required for a (webxr) feature
  42607. */
  42608. export interface IWebXRFeature extends IDisposable {
  42609. /**
  42610. * Is this feature attached
  42611. */
  42612. attached: boolean;
  42613. /**
  42614. * Attach the feature to the session
  42615. * Will usually be called by the features manager
  42616. *
  42617. * @returns true if successful.
  42618. */
  42619. attach(): boolean;
  42620. /**
  42621. * Detach the feature from the session
  42622. * Will usually be called by the features manager
  42623. *
  42624. * @returns true if successful.
  42625. */
  42626. detach(): boolean;
  42627. }
  42628. /**
  42629. * Defining the constructor of a feature. Used to register the modules.
  42630. */
  42631. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  42632. /**
  42633. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  42634. * It is mainly used in AR sessions.
  42635. *
  42636. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  42637. */
  42638. export class WebXRFeaturesManager implements IDisposable {
  42639. private _xrSessionManager;
  42640. private static readonly _AvailableFeatures;
  42641. /**
  42642. * Used to register a module. After calling this function a developer can use this feature in the scene.
  42643. * Mainly used internally.
  42644. *
  42645. * @param featureName the name of the feature to register
  42646. * @param constructorFunction the function used to construct the module
  42647. * @param version the (babylon) version of the module
  42648. * @param stable is that a stable version of this module
  42649. */
  42650. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  42651. /**
  42652. * Returns a constructor of a specific feature.
  42653. *
  42654. * @param featureName the name of the feature to construct
  42655. * @param version the version of the feature to load
  42656. * @param xrSessionManager the xrSessionManager. Used to construct the module
  42657. * @param options optional options provided to the module.
  42658. * @returns a function that, when called, will return a new instance of this feature
  42659. */
  42660. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  42661. /**
  42662. * Return the latest unstable version of this feature
  42663. * @param featureName the name of the feature to search
  42664. * @returns the version number. if not found will return -1
  42665. */
  42666. static GetLatestVersionOfFeature(featureName: string): number;
  42667. /**
  42668. * Return the latest stable version of this feature
  42669. * @param featureName the name of the feature to search
  42670. * @returns the version number. if not found will return -1
  42671. */
  42672. static GetStableVersionOfFeature(featureName: string): number;
  42673. /**
  42674. * Can be used to return the list of features currently registered
  42675. *
  42676. * @returns an Array of available features
  42677. */
  42678. static GetAvailableFeatures(): string[];
  42679. /**
  42680. * Gets the versions available for a specific feature
  42681. * @param featureName the name of the feature
  42682. * @returns an array with the available versions
  42683. */
  42684. static GetAvailableVersions(featureName: string): string[];
  42685. private _features;
  42686. /**
  42687. * constructs a new features manages.
  42688. *
  42689. * @param _xrSessionManager an instance of WebXRSessionManager
  42690. */
  42691. constructor(_xrSessionManager: WebXRSessionManager);
  42692. /**
  42693. * 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.
  42694. *
  42695. * @param featureName the name of the feature to load or the class of the feature
  42696. * @param version optional version to load. if not provided the latest version will be enabled
  42697. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  42698. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  42699. * @returns a new constructed feature or throws an error if feature not found.
  42700. */
  42701. enableFeature(featureName: string | {
  42702. Name: string;
  42703. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  42704. /**
  42705. * Used to disable an already-enabled feature
  42706. * @param featureName the feature to disable
  42707. * @returns true if disable was successful
  42708. */
  42709. disableFeature(featureName: string | {
  42710. Name: string;
  42711. }): boolean;
  42712. /**
  42713. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  42714. * Can be used during a session to start a feature
  42715. * @param featureName the name of feature to attach
  42716. */
  42717. attachFeature(featureName: string): void;
  42718. /**
  42719. * Can be used inside a session or when the session ends to detach a specific feature
  42720. * @param featureName the name of the feature to detach
  42721. */
  42722. detachFeature(featureName: string): void;
  42723. /**
  42724. * Get the list of enabled features
  42725. * @returns an array of enabled features
  42726. */
  42727. getEnabledFeatures(): string[];
  42728. /**
  42729. * get the implementation of an enabled feature.
  42730. * @param featureName the name of the feature to load
  42731. * @returns the feature class, if found
  42732. */
  42733. getEnabledFeature(featureName: string): IWebXRFeature;
  42734. /**
  42735. * dispose this features manager
  42736. */
  42737. dispose(): void;
  42738. }
  42739. }
  42740. declare module BABYLON {
  42741. /**
  42742. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  42743. * @see https://doc.babylonjs.com/how_to/webxr
  42744. */
  42745. export class WebXRExperienceHelper implements IDisposable {
  42746. private scene;
  42747. /**
  42748. * Camera used to render xr content
  42749. */
  42750. camera: WebXRCamera;
  42751. /**
  42752. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42753. */
  42754. state: WebXRState;
  42755. private _setState;
  42756. /**
  42757. * Fires when the state of the experience helper has changed
  42758. */
  42759. onStateChangedObservable: Observable<WebXRState>;
  42760. /**
  42761. * Observers registered here will be triggered after the camera's initial transformation is set
  42762. * This can be used to set a different ground level or an extra rotation.
  42763. *
  42764. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  42765. * to the position set after this observable is done executing.
  42766. */
  42767. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  42768. /** Session manager used to keep track of xr session */
  42769. sessionManager: WebXRSessionManager;
  42770. /** A features manager for this xr session */
  42771. featuresManager: WebXRFeaturesManager;
  42772. private _nonVRCamera;
  42773. private _originalSceneAutoClear;
  42774. private _supported;
  42775. /**
  42776. * Creates the experience helper
  42777. * @param scene the scene to attach the experience helper to
  42778. * @returns a promise for the experience helper
  42779. */
  42780. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  42781. /**
  42782. * Creates a WebXRExperienceHelper
  42783. * @param scene The scene the helper should be created in
  42784. */
  42785. private constructor();
  42786. /**
  42787. * Exits XR mode and returns the scene to its original state
  42788. * @returns promise that resolves after xr mode has exited
  42789. */
  42790. exitXRAsync(): Promise<void>;
  42791. /**
  42792. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  42793. * @param sessionMode options for the XR session
  42794. * @param referenceSpaceType frame of reference of the XR session
  42795. * @param renderTarget the output canvas that will be used to enter XR mode
  42796. * @returns promise that resolves after xr mode has entered
  42797. */
  42798. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget: WebXRRenderTarget): Promise<WebXRSessionManager>;
  42799. /**
  42800. * Disposes of the experience helper
  42801. */
  42802. dispose(): void;
  42803. private _nonXRToXRCamera;
  42804. }
  42805. }
  42806. declare module BABYLON {
  42807. /**
  42808. * X-Y values for axes in WebXR
  42809. */
  42810. export interface IWebXRMotionControllerAxesValue {
  42811. /**
  42812. * The value of the x axis
  42813. */
  42814. x: number;
  42815. /**
  42816. * The value of the y-axis
  42817. */
  42818. y: number;
  42819. }
  42820. /**
  42821. * changed / previous values for the values of this component
  42822. */
  42823. export interface IWebXRMotionControllerComponentChangesValues<T> {
  42824. /**
  42825. * current (this frame) value
  42826. */
  42827. current: T;
  42828. /**
  42829. * previous (last change) value
  42830. */
  42831. previous: T;
  42832. }
  42833. /**
  42834. * Represents changes in the component between current frame and last values recorded
  42835. */
  42836. export interface IWebXRMotionControllerComponentChanges {
  42837. /**
  42838. * will be populated with previous and current values if touched changed
  42839. */
  42840. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  42841. /**
  42842. * will be populated with previous and current values if pressed changed
  42843. */
  42844. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  42845. /**
  42846. * will be populated with previous and current values if value changed
  42847. */
  42848. value?: IWebXRMotionControllerComponentChangesValues<number>;
  42849. /**
  42850. * will be populated with previous and current values if axes changed
  42851. */
  42852. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  42853. }
  42854. /**
  42855. * This class represents a single component (for example button or thumbstick) of a motion controller
  42856. */
  42857. export class WebXRControllerComponent implements IDisposable {
  42858. /**
  42859. * the id of this component
  42860. */
  42861. id: string;
  42862. /**
  42863. * the type of the component
  42864. */
  42865. type: MotionControllerComponentType;
  42866. private _buttonIndex;
  42867. private _axesIndices;
  42868. /**
  42869. * Thumbstick component type
  42870. */
  42871. static THUMBSTICK: string;
  42872. /**
  42873. * Touchpad component type
  42874. */
  42875. static TOUCHPAD: string;
  42876. /**
  42877. * trigger component type
  42878. */
  42879. static TRIGGER: string;
  42880. /**
  42881. * squeeze component type
  42882. */
  42883. static SQUEEZE: string;
  42884. /**
  42885. * Observers registered here will be triggered when the state of a button changes
  42886. * State change is either pressed / touched / value
  42887. */
  42888. onButtonStateChanged: Observable<WebXRControllerComponent>;
  42889. /**
  42890. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  42891. * the axes data changes
  42892. */
  42893. onAxisValueChanged: Observable<{
  42894. x: number;
  42895. y: number;
  42896. }>;
  42897. private _currentValue;
  42898. private _touched;
  42899. private _pressed;
  42900. private _axes;
  42901. private _changes;
  42902. /**
  42903. * Creates a new component for a motion controller.
  42904. * It is created by the motion controller itself
  42905. *
  42906. * @param id the id of this component
  42907. * @param type the type of the component
  42908. * @param _buttonIndex index in the buttons array of the gamepad
  42909. * @param _axesIndices indices of the values in the axes array of the gamepad
  42910. */
  42911. constructor(
  42912. /**
  42913. * the id of this component
  42914. */
  42915. id: string,
  42916. /**
  42917. * the type of the component
  42918. */
  42919. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  42920. /**
  42921. * Get the current value of this component
  42922. */
  42923. get value(): number;
  42924. /**
  42925. * is the button currently pressed
  42926. */
  42927. get pressed(): boolean;
  42928. /**
  42929. * is the button currently touched
  42930. */
  42931. get touched(): boolean;
  42932. /**
  42933. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  42934. */
  42935. get axes(): IWebXRMotionControllerAxesValue;
  42936. /**
  42937. * Get the changes. Elements will be populated only if they changed with their previous and current value
  42938. */
  42939. get changes(): IWebXRMotionControllerComponentChanges;
  42940. /**
  42941. * Is this component a button (hence - pressable)
  42942. * @returns true if can be pressed
  42943. */
  42944. isButton(): boolean;
  42945. /**
  42946. * Are there axes correlating to this component
  42947. * @return true is axes data is available
  42948. */
  42949. isAxes(): boolean;
  42950. /**
  42951. * update this component using the gamepad object it is in. Called on every frame
  42952. * @param nativeController the native gamepad controller object
  42953. */
  42954. update(nativeController: IMinimalMotionControllerObject): void;
  42955. /**
  42956. * Dispose this component
  42957. */
  42958. dispose(): void;
  42959. }
  42960. }
  42961. declare module BABYLON {
  42962. /**
  42963. * Class used to represent data loading progression
  42964. */
  42965. export class SceneLoaderProgressEvent {
  42966. /** defines if data length to load can be evaluated */
  42967. readonly lengthComputable: boolean;
  42968. /** defines the loaded data length */
  42969. readonly loaded: number;
  42970. /** defines the data length to load */
  42971. readonly total: number;
  42972. /**
  42973. * Create a new progress event
  42974. * @param lengthComputable defines if data length to load can be evaluated
  42975. * @param loaded defines the loaded data length
  42976. * @param total defines the data length to load
  42977. */
  42978. constructor(
  42979. /** defines if data length to load can be evaluated */
  42980. lengthComputable: boolean,
  42981. /** defines the loaded data length */
  42982. loaded: number,
  42983. /** defines the data length to load */
  42984. total: number);
  42985. /**
  42986. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  42987. * @param event defines the source event
  42988. * @returns a new SceneLoaderProgressEvent
  42989. */
  42990. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  42991. }
  42992. /**
  42993. * Interface used by SceneLoader plugins to define supported file extensions
  42994. */
  42995. export interface ISceneLoaderPluginExtensions {
  42996. /**
  42997. * Defines the list of supported extensions
  42998. */
  42999. [extension: string]: {
  43000. isBinary: boolean;
  43001. };
  43002. }
  43003. /**
  43004. * Interface used by SceneLoader plugin factory
  43005. */
  43006. export interface ISceneLoaderPluginFactory {
  43007. /**
  43008. * Defines the name of the factory
  43009. */
  43010. name: string;
  43011. /**
  43012. * Function called to create a new plugin
  43013. * @return the new plugin
  43014. */
  43015. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43016. /**
  43017. * The callback that returns true if the data can be directly loaded.
  43018. * @param data string containing the file data
  43019. * @returns if the data can be loaded directly
  43020. */
  43021. canDirectLoad?(data: string): boolean;
  43022. }
  43023. /**
  43024. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43025. */
  43026. export interface ISceneLoaderPluginBase {
  43027. /**
  43028. * The friendly name of this plugin.
  43029. */
  43030. name: string;
  43031. /**
  43032. * The file extensions supported by this plugin.
  43033. */
  43034. extensions: string | ISceneLoaderPluginExtensions;
  43035. /**
  43036. * The callback called when loading from a url.
  43037. * @param scene scene loading this url
  43038. * @param url url to load
  43039. * @param onSuccess callback called when the file successfully loads
  43040. * @param onProgress callback called while file is loading (if the server supports this mode)
  43041. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43042. * @param onError callback called when the file fails to load
  43043. * @returns a file request object
  43044. */
  43045. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43046. /**
  43047. * The callback called when loading from a file object.
  43048. * @param scene scene loading this file
  43049. * @param file defines the file to load
  43050. * @param onSuccess defines the callback to call when data is loaded
  43051. * @param onProgress defines the callback to call during loading process
  43052. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43053. * @param onError defines the callback to call when an error occurs
  43054. * @returns a file request object
  43055. */
  43056. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43057. /**
  43058. * The callback that returns true if the data can be directly loaded.
  43059. * @param data string containing the file data
  43060. * @returns if the data can be loaded directly
  43061. */
  43062. canDirectLoad?(data: string): boolean;
  43063. /**
  43064. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43065. * @param scene scene loading this data
  43066. * @param data string containing the data
  43067. * @returns data to pass to the plugin
  43068. */
  43069. directLoad?(scene: Scene, data: string): any;
  43070. /**
  43071. * The callback that allows custom handling of the root url based on the response url.
  43072. * @param rootUrl the original root url
  43073. * @param responseURL the response url if available
  43074. * @returns the new root url
  43075. */
  43076. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43077. }
  43078. /**
  43079. * Interface used to define a SceneLoader plugin
  43080. */
  43081. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  43082. /**
  43083. * Import meshes into a scene.
  43084. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43085. * @param scene The scene to import into
  43086. * @param data The data to import
  43087. * @param rootUrl The root url for scene and resources
  43088. * @param meshes The meshes array to import into
  43089. * @param particleSystems The particle systems array to import into
  43090. * @param skeletons The skeletons array to import into
  43091. * @param onError The callback when import fails
  43092. * @returns True if successful or false otherwise
  43093. */
  43094. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43095. /**
  43096. * Load into a scene.
  43097. * @param scene The scene to load into
  43098. * @param data The data to import
  43099. * @param rootUrl The root url for scene and resources
  43100. * @param onError The callback when import fails
  43101. * @returns True if successful or false otherwise
  43102. */
  43103. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43104. /**
  43105. * Load into an asset container.
  43106. * @param scene The scene to load into
  43107. * @param data The data to import
  43108. * @param rootUrl The root url for scene and resources
  43109. * @param onError The callback when import fails
  43110. * @returns The loaded asset container
  43111. */
  43112. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43113. }
  43114. /**
  43115. * Interface used to define an async SceneLoader plugin
  43116. */
  43117. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  43118. /**
  43119. * Import meshes into a scene.
  43120. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43121. * @param scene The scene to import into
  43122. * @param data The data to import
  43123. * @param rootUrl The root url for scene and resources
  43124. * @param onProgress The callback when the load progresses
  43125. * @param fileName Defines the name of the file to load
  43126. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43127. */
  43128. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43129. meshes: AbstractMesh[];
  43130. particleSystems: IParticleSystem[];
  43131. skeletons: Skeleton[];
  43132. animationGroups: AnimationGroup[];
  43133. }>;
  43134. /**
  43135. * Load into a scene.
  43136. * @param scene The scene to load into
  43137. * @param data The data to import
  43138. * @param rootUrl The root url for scene and resources
  43139. * @param onProgress The callback when the load progresses
  43140. * @param fileName Defines the name of the file to load
  43141. * @returns Nothing
  43142. */
  43143. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43144. /**
  43145. * Load into an asset container.
  43146. * @param scene The scene to load into
  43147. * @param data The data to import
  43148. * @param rootUrl The root url for scene and resources
  43149. * @param onProgress The callback when the load progresses
  43150. * @param fileName Defines the name of the file to load
  43151. * @returns The loaded asset container
  43152. */
  43153. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43154. }
  43155. /**
  43156. * Mode that determines how to handle old animation groups before loading new ones.
  43157. */
  43158. export enum SceneLoaderAnimationGroupLoadingMode {
  43159. /**
  43160. * Reset all old animations to initial state then dispose them.
  43161. */
  43162. Clean = 0,
  43163. /**
  43164. * Stop all old animations.
  43165. */
  43166. Stop = 1,
  43167. /**
  43168. * Restart old animations from first frame.
  43169. */
  43170. Sync = 2,
  43171. /**
  43172. * Old animations remains untouched.
  43173. */
  43174. NoSync = 3
  43175. }
  43176. /**
  43177. * Class used to load scene from various file formats using registered plugins
  43178. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43179. */
  43180. export class SceneLoader {
  43181. /**
  43182. * No logging while loading
  43183. */
  43184. static readonly NO_LOGGING: number;
  43185. /**
  43186. * Minimal logging while loading
  43187. */
  43188. static readonly MINIMAL_LOGGING: number;
  43189. /**
  43190. * Summary logging while loading
  43191. */
  43192. static readonly SUMMARY_LOGGING: number;
  43193. /**
  43194. * Detailled logging while loading
  43195. */
  43196. static readonly DETAILED_LOGGING: number;
  43197. /**
  43198. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43199. */
  43200. static get ForceFullSceneLoadingForIncremental(): boolean;
  43201. static set ForceFullSceneLoadingForIncremental(value: boolean);
  43202. /**
  43203. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43204. */
  43205. static get ShowLoadingScreen(): boolean;
  43206. static set ShowLoadingScreen(value: boolean);
  43207. /**
  43208. * Defines the current logging level (while loading the scene)
  43209. * @ignorenaming
  43210. */
  43211. static get loggingLevel(): number;
  43212. static set loggingLevel(value: number);
  43213. /**
  43214. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43215. */
  43216. static get CleanBoneMatrixWeights(): boolean;
  43217. static set CleanBoneMatrixWeights(value: boolean);
  43218. /**
  43219. * Event raised when a plugin is used to load a scene
  43220. */
  43221. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43222. private static _registeredPlugins;
  43223. private static _getDefaultPlugin;
  43224. private static _getPluginForExtension;
  43225. private static _getPluginForDirectLoad;
  43226. private static _getPluginForFilename;
  43227. private static _getDirectLoad;
  43228. private static _loadData;
  43229. private static _getFileInfo;
  43230. /**
  43231. * Gets a plugin that can load the given extension
  43232. * @param extension defines the extension to load
  43233. * @returns a plugin or null if none works
  43234. */
  43235. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43236. /**
  43237. * Gets a boolean indicating that the given extension can be loaded
  43238. * @param extension defines the extension to load
  43239. * @returns true if the extension is supported
  43240. */
  43241. static IsPluginForExtensionAvailable(extension: string): boolean;
  43242. /**
  43243. * Adds a new plugin to the list of registered plugins
  43244. * @param plugin defines the plugin to add
  43245. */
  43246. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43247. /**
  43248. * Import meshes into a scene
  43249. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43250. * @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)
  43251. * @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)
  43252. * @param scene the instance of BABYLON.Scene to append to
  43253. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43254. * @param onProgress a callback with a progress event for each file being loaded
  43255. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43256. * @param pluginExtension the extension used to determine the plugin
  43257. * @returns The loaded plugin
  43258. */
  43259. 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>;
  43260. /**
  43261. * Import meshes into a scene
  43262. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43263. * @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)
  43264. * @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)
  43265. * @param scene the instance of BABYLON.Scene to append to
  43266. * @param onProgress a callback with a progress event for each file being loaded
  43267. * @param pluginExtension the extension used to determine the plugin
  43268. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43269. */
  43270. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43271. meshes: AbstractMesh[];
  43272. particleSystems: IParticleSystem[];
  43273. skeletons: Skeleton[];
  43274. animationGroups: AnimationGroup[];
  43275. }>;
  43276. /**
  43277. * Load a scene
  43278. * @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)
  43279. * @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)
  43280. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43281. * @param onSuccess a callback with the scene when import succeeds
  43282. * @param onProgress a callback with a progress event for each file being loaded
  43283. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43284. * @param pluginExtension the extension used to determine the plugin
  43285. * @returns The loaded plugin
  43286. */
  43287. 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>;
  43288. /**
  43289. * Load a scene
  43290. * @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)
  43291. * @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)
  43292. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43293. * @param onProgress a callback with a progress event for each file being loaded
  43294. * @param pluginExtension the extension used to determine the plugin
  43295. * @returns The loaded scene
  43296. */
  43297. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43298. /**
  43299. * Append a scene
  43300. * @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)
  43301. * @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)
  43302. * @param scene is the instance of BABYLON.Scene to append to
  43303. * @param onSuccess a callback with the scene when import succeeds
  43304. * @param onProgress a callback with a progress event for each file being loaded
  43305. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43306. * @param pluginExtension the extension used to determine the plugin
  43307. * @returns The loaded plugin
  43308. */
  43309. 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>;
  43310. /**
  43311. * Append a scene
  43312. * @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)
  43313. * @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)
  43314. * @param scene is the instance of BABYLON.Scene to append to
  43315. * @param onProgress a callback with a progress event for each file being loaded
  43316. * @param pluginExtension the extension used to determine the plugin
  43317. * @returns The given scene
  43318. */
  43319. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43320. /**
  43321. * Load a scene into an asset container
  43322. * @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)
  43323. * @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)
  43324. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43325. * @param onSuccess a callback with the scene when import succeeds
  43326. * @param onProgress a callback with a progress event for each file being loaded
  43327. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43328. * @param pluginExtension the extension used to determine the plugin
  43329. * @returns The loaded plugin
  43330. */
  43331. 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>;
  43332. /**
  43333. * Load a scene into an asset container
  43334. * @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)
  43335. * @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)
  43336. * @param scene is the instance of Scene to append to
  43337. * @param onProgress a callback with a progress event for each file being loaded
  43338. * @param pluginExtension the extension used to determine the plugin
  43339. * @returns The loaded asset container
  43340. */
  43341. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43342. /**
  43343. * Import animations from a file into a scene
  43344. * @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)
  43345. * @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)
  43346. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43347. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43348. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43349. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43350. * @param onSuccess a callback with the scene when import succeeds
  43351. * @param onProgress a callback with a progress event for each file being loaded
  43352. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43353. */
  43354. 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;
  43355. /**
  43356. * Import animations from a file into a scene
  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 overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43361. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43362. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43363. * @param onSuccess a callback with the scene when import succeeds
  43364. * @param onProgress a callback with a progress event for each file being loaded
  43365. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43366. * @returns the updated scene with imported animations
  43367. */
  43368. 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>;
  43369. }
  43370. }
  43371. declare module BABYLON {
  43372. /**
  43373. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  43374. */
  43375. export type MotionControllerHandness = "none" | "left" | "right" | "left-right" | "left-right-none";
  43376. /**
  43377. * The type of components available in motion controllers.
  43378. * This is not the name of the component.
  43379. */
  43380. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  43381. /**
  43382. * The schema of motion controller layout.
  43383. * No object will be initialized using this interface
  43384. * This is used just to define the profile.
  43385. */
  43386. export interface IMotionControllerLayout {
  43387. /**
  43388. * Defines the main button component id
  43389. */
  43390. selectComponentId: string;
  43391. /**
  43392. * Available components (unsorted)
  43393. */
  43394. components: {
  43395. /**
  43396. * A map of component Ids
  43397. */
  43398. [componentId: string]: {
  43399. /**
  43400. * The type of input the component outputs
  43401. */
  43402. type: MotionControllerComponentType;
  43403. };
  43404. };
  43405. /**
  43406. * An optional gamepad object. If no gamepad object is not defined, no models will be loaded
  43407. */
  43408. gamepad?: {
  43409. /**
  43410. * Is the mapping based on the xr-standard defined here:
  43411. * https://www.w3.org/TR/webxr-gamepads-module-1/#xr-standard-gamepad-mapping
  43412. */
  43413. mapping: "" | "xr-standard";
  43414. /**
  43415. * The buttons available in this input in the right order
  43416. * index of this button will be the index in the gamepadObject.buttons array
  43417. * correlates to the componentId in components
  43418. */
  43419. buttons: Array<string | null>;
  43420. /**
  43421. * Definition of the axes of the gamepad input, sorted
  43422. * Correlates to componentIds in the components map
  43423. */
  43424. axes: Array<{
  43425. /**
  43426. * The component id that the axis correlates to
  43427. */
  43428. componentId: string;
  43429. /**
  43430. * X or Y Axis
  43431. */
  43432. axis: "x-axis" | "y-axis";
  43433. } | null>;
  43434. };
  43435. }
  43436. /**
  43437. * A definition for the layout map in the input profile
  43438. */
  43439. export interface IMotionControllerLayoutMap {
  43440. /**
  43441. * Layouts with handness type as a key
  43442. */
  43443. [handness: string]: IMotionControllerLayout;
  43444. }
  43445. /**
  43446. * The XR Input profile schema
  43447. * Profiles can be found here:
  43448. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  43449. */
  43450. export interface IMotionControllerProfile {
  43451. /**
  43452. * The id of this profile
  43453. * correlates to the profile(s) in the xrInput.profiles array
  43454. */
  43455. profileId: string;
  43456. /**
  43457. * fallback profiles for this profileId
  43458. */
  43459. fallbackProfileIds: string[];
  43460. /**
  43461. * The layout map, with handness as key
  43462. */
  43463. layouts: IMotionControllerLayoutMap;
  43464. }
  43465. /**
  43466. * A helper-interface for the 3 meshes needed for controller button animation
  43467. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  43468. */
  43469. export interface IMotionControllerButtonMeshMap {
  43470. /**
  43471. * The mesh that will be changed when value changes
  43472. */
  43473. valueMesh: AbstractMesh;
  43474. /**
  43475. * the mesh that defines the pressed value mesh position.
  43476. * This is used to find the max-position of this button
  43477. */
  43478. pressedMesh: AbstractMesh;
  43479. /**
  43480. * the mesh that defines the unpressed value mesh position.
  43481. * This is used to find the min (or initial) position of this button
  43482. */
  43483. unpressedMesh: AbstractMesh;
  43484. }
  43485. /**
  43486. * A helper-interface for the 3 meshes needed for controller axis animation.
  43487. * This will be expanded when touchpad animations are fully supported
  43488. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  43489. */
  43490. export interface IMotionControllerAxisMeshMap {
  43491. /**
  43492. * The mesh that will be changed when axis value changes
  43493. */
  43494. valueMesh: AbstractMesh;
  43495. /**
  43496. * the mesh that defines the minimum value mesh position.
  43497. */
  43498. minMesh: AbstractMesh;
  43499. /**
  43500. * the mesh that defines the maximum value mesh position.
  43501. */
  43502. maxMesh: AbstractMesh;
  43503. }
  43504. /**
  43505. * The elements needed for change-detection of the gamepad objects in motion controllers
  43506. */
  43507. export interface IMinimalMotionControllerObject {
  43508. /**
  43509. * An array of available buttons
  43510. */
  43511. buttons: Array<{
  43512. /**
  43513. * Value of the button/trigger
  43514. */
  43515. value: number;
  43516. /**
  43517. * If the button/trigger is currently touched
  43518. */
  43519. touched: boolean;
  43520. /**
  43521. * If the button/trigger is currently pressed
  43522. */
  43523. pressed: boolean;
  43524. }>;
  43525. /**
  43526. * Available axes of this controller
  43527. */
  43528. axes: number[];
  43529. }
  43530. /**
  43531. * An Abstract Motion controller
  43532. * This class receives an xrInput and a profile layout and uses those to initialize the components
  43533. * Each component has an observable to check for changes in value and state
  43534. */
  43535. export abstract class WebXRAbstractMotionController implements IDisposable {
  43536. protected scene: Scene;
  43537. protected layout: IMotionControllerLayout;
  43538. /**
  43539. * The gamepad object correlating to this controller
  43540. */
  43541. gamepadObject: IMinimalMotionControllerObject;
  43542. /**
  43543. * handness (left/right/none) of this controller
  43544. */
  43545. handness: MotionControllerHandness;
  43546. /**
  43547. * Component type map
  43548. */
  43549. static ComponentType: {
  43550. TRIGGER: string;
  43551. SQUEEZE: string;
  43552. TOUCHPAD: string;
  43553. THUMBSTICK: string;
  43554. BUTTON: string;
  43555. };
  43556. /**
  43557. * The profile id of this motion controller
  43558. */
  43559. abstract profileId: string;
  43560. /**
  43561. * A map of components (WebXRControllerComponent) in this motion controller
  43562. * Components have a ComponentType and can also have both button and axis definitions
  43563. */
  43564. readonly components: {
  43565. [id: string]: WebXRControllerComponent;
  43566. };
  43567. /**
  43568. * Observers registered here will be triggered when the model of this controller is done loading
  43569. */
  43570. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  43571. /**
  43572. * The root mesh of the model. It is null if the model was not yet initialized
  43573. */
  43574. rootMesh: Nullable<AbstractMesh>;
  43575. private _modelReady;
  43576. /**
  43577. * constructs a new abstract motion controller
  43578. * @param scene the scene to which the model of the controller will be added
  43579. * @param layout The profile layout to load
  43580. * @param gamepadObject The gamepad object correlating to this controller
  43581. * @param handness handness (left/right/none) of this controller
  43582. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  43583. */
  43584. constructor(scene: Scene, layout: IMotionControllerLayout,
  43585. /**
  43586. * The gamepad object correlating to this controller
  43587. */
  43588. gamepadObject: IMinimalMotionControllerObject,
  43589. /**
  43590. * handness (left/right/none) of this controller
  43591. */
  43592. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  43593. private _initComponent;
  43594. /**
  43595. * Update this model using the current XRFrame
  43596. * @param xrFrame the current xr frame to use and update the model
  43597. */
  43598. updateFromXRFrame(xrFrame: XRFrame): void;
  43599. /**
  43600. * Get the list of components available in this motion controller
  43601. * @returns an array of strings correlating to available components
  43602. */
  43603. getComponentTypes(): string[];
  43604. /**
  43605. * Get the main (Select) component of this controller as defined in the layout
  43606. * @returns the main component of this controller
  43607. */
  43608. getMainComponent(): WebXRControllerComponent;
  43609. /**
  43610. * get a component based an its component id as defined in layout.components
  43611. * @param id the id of the component
  43612. * @returns the component correlates to the id or undefined if not found
  43613. */
  43614. getComponent(id: string): WebXRControllerComponent;
  43615. /**
  43616. * Loads the model correlating to this controller
  43617. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  43618. * @returns A promise fulfilled with the result of the model loading
  43619. */
  43620. loadModel(): Promise<boolean>;
  43621. /**
  43622. * Update the model itself with the current frame data
  43623. * @param xrFrame the frame to use for updating the model mesh
  43624. */
  43625. protected updateModel(xrFrame: XRFrame): void;
  43626. /**
  43627. * Moves the axis on the controller mesh based on its current state
  43628. * @param axis the index of the axis
  43629. * @param axisValue the value of the axis which determines the meshes new position
  43630. * @hidden
  43631. */
  43632. protected _lerpAxisTransform(axisMap: IMotionControllerAxisMeshMap, axisValue: number): void;
  43633. /**
  43634. * Moves the buttons on the controller mesh based on their current state
  43635. * @param buttonName the name of the button to move
  43636. * @param buttonValue the value of the button which determines the buttons new position
  43637. */
  43638. protected _lerpButtonTransform(buttonMap: IMotionControllerButtonMeshMap, buttonValue: number): void;
  43639. private _getGenericFilenameAndPath;
  43640. private _getGenericParentMesh;
  43641. /**
  43642. * Get the filename and path for this controller's model
  43643. * @returns a map of filename and path
  43644. */
  43645. protected abstract _getFilenameAndPath(): {
  43646. filename: string;
  43647. path: string;
  43648. };
  43649. /**
  43650. * This function will be called after the model was successfully loaded and can be used
  43651. * for mesh transformations before it is available for the user
  43652. * @param meshes the loaded meshes
  43653. */
  43654. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  43655. /**
  43656. * Set the root mesh for this controller. Important for the WebXR controller class
  43657. * @param meshes the loaded meshes
  43658. */
  43659. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  43660. /**
  43661. * A function executed each frame that updates the mesh (if needed)
  43662. * @param xrFrame the current xrFrame
  43663. */
  43664. protected abstract _updateModel(xrFrame: XRFrame): void;
  43665. /**
  43666. * This function is called before the mesh is loaded. It checks for loading constraints.
  43667. * For example, this function can check if the GLB loader is available
  43668. * If this function returns false, the generic controller will be loaded instead
  43669. * @returns Is the client ready to load the mesh
  43670. */
  43671. protected abstract _getModelLoadingConstraints(): boolean;
  43672. /**
  43673. * Dispose this controller, the model mesh and all its components
  43674. */
  43675. dispose(): void;
  43676. }
  43677. }
  43678. declare module BABYLON {
  43679. /**
  43680. * A generic trigger-only motion controller for WebXR
  43681. */
  43682. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  43683. /**
  43684. * Static version of the profile id of this controller
  43685. */
  43686. static ProfileId: string;
  43687. profileId: string;
  43688. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  43689. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  43690. protected _updateModel(): void;
  43691. protected _getFilenameAndPath(): {
  43692. filename: string;
  43693. path: string;
  43694. };
  43695. protected _setRootMesh(meshes: AbstractMesh[]): void;
  43696. protected _getModelLoadingConstraints(): boolean;
  43697. }
  43698. }
  43699. declare module BABYLON {
  43700. /**
  43701. * A construction function type to create a new controller based on an xrInput object
  43702. */
  43703. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  43704. /**
  43705. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  43706. *
  43707. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  43708. * it should be replaced with auto-loaded controllers.
  43709. *
  43710. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  43711. */
  43712. export class WebXRMotionControllerManager {
  43713. private static _AvailableControllers;
  43714. private static _Fallbacks;
  43715. /**
  43716. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  43717. *
  43718. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  43719. *
  43720. * @param type the profile type to register
  43721. * @param constructFunction the function to be called when loading this profile
  43722. */
  43723. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  43724. /**
  43725. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  43726. * The order of search:
  43727. *
  43728. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  43729. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  43730. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  43731. * 4) return the generic trigger controller if none were found
  43732. *
  43733. * @param xrInput the xrInput to which a new controller is initialized
  43734. * @param scene the scene to which the model will be added
  43735. * @param forceProfile force a certain profile for this controller
  43736. * @return the motion controller class for this profile id or the generic standard class if none was found
  43737. */
  43738. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): WebXRAbstractMotionController;
  43739. /**
  43740. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  43741. * @param profileId the profile to which a fallback needs to be found
  43742. * @return an array with corresponding fallback profiles
  43743. */
  43744. static FindFallbackWithProfileId(profileId: string): string[];
  43745. /**
  43746. * Register a fallback to a specific profile.
  43747. * @param profileId the profileId that will receive the fallbacks
  43748. * @param fallbacks A list of fallback profiles
  43749. */
  43750. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  43751. /**
  43752. * Register the default fallbacks.
  43753. * This function is called automatically when this file is imported.
  43754. */
  43755. static DefaultFallbacks(): void;
  43756. }
  43757. }
  43758. declare module BABYLON {
  43759. /**
  43760. * Configuration options for the WebXR controller creation
  43761. */
  43762. export interface IWebXRControllerOptions {
  43763. /**
  43764. * Force a specific controller type for this controller.
  43765. * This can be used when creating your own profile or when testing different controllers
  43766. */
  43767. forceControllerProfile?: string;
  43768. }
  43769. /**
  43770. * Represents an XR controller
  43771. */
  43772. export class WebXRController {
  43773. private _scene;
  43774. /** The underlying input source for the controller */
  43775. inputSource: XRInputSource;
  43776. private _options;
  43777. /**
  43778. * 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
  43779. */
  43780. grip?: AbstractMesh;
  43781. /**
  43782. * Pointer which can be used to select objects or attach a visible laser to
  43783. */
  43784. pointer: AbstractMesh;
  43785. /**
  43786. * If available, this is the gamepad object related to this controller.
  43787. * Using this object it is possible to get click events and trackpad changes of the
  43788. * webxr controller that is currently being used.
  43789. */
  43790. gamepadController?: WebXRAbstractMotionController;
  43791. /**
  43792. * Event that fires when the controller is removed/disposed
  43793. */
  43794. onDisposeObservable: Observable<{}>;
  43795. private _tmpQuaternion;
  43796. private _tmpVector;
  43797. private _uniqueId;
  43798. /**
  43799. * Creates the controller
  43800. * @see https://doc.babylonjs.com/how_to/webxr
  43801. * @param _scene the scene which the controller should be associated to
  43802. * @param inputSource the underlying input source for the controller
  43803. * @param _options options for this controller creation
  43804. */
  43805. constructor(_scene: Scene,
  43806. /** The underlying input source for the controller */
  43807. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  43808. /**
  43809. * Get this controllers unique id
  43810. */
  43811. get uniqueId(): string;
  43812. /**
  43813. * Updates the controller pose based on the given XRFrame
  43814. * @param xrFrame xr frame to update the pose with
  43815. * @param referenceSpace reference space to use
  43816. */
  43817. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  43818. /**
  43819. * Gets a world space ray coming from the controller
  43820. * @param result the resulting ray
  43821. */
  43822. getWorldPointerRayToRef(result: Ray): void;
  43823. /**
  43824. * Disposes of the object
  43825. */
  43826. dispose(): void;
  43827. }
  43828. }
  43829. declare module BABYLON {
  43830. /**
  43831. * The schema for initialization options of the XR Input class
  43832. */
  43833. export interface IWebXRInputOptions {
  43834. /**
  43835. * If set to true no model will be automatically loaded
  43836. */
  43837. doNotLoadControllerMeshes?: boolean;
  43838. /**
  43839. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  43840. * If not found, the xr input profile data will be used.
  43841. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  43842. */
  43843. forceInputProfile?: string;
  43844. }
  43845. /**
  43846. * XR input used to track XR inputs such as controllers/rays
  43847. */
  43848. export class WebXRInput implements IDisposable {
  43849. /**
  43850. * the xr session manager for this session
  43851. */
  43852. xrSessionManager: WebXRSessionManager;
  43853. /**
  43854. * the WebXR camera for this session. Mainly used for teleportation
  43855. */
  43856. xrCamera: WebXRCamera;
  43857. private readonly options;
  43858. /**
  43859. * XR controllers being tracked
  43860. */
  43861. controllers: Array<WebXRController>;
  43862. private _frameObserver;
  43863. private _sessionEndedObserver;
  43864. private _sessionInitObserver;
  43865. /**
  43866. * Event when a controller has been connected/added
  43867. */
  43868. onControllerAddedObservable: Observable<WebXRController>;
  43869. /**
  43870. * Event when a controller has been removed/disconnected
  43871. */
  43872. onControllerRemovedObservable: Observable<WebXRController>;
  43873. /**
  43874. * Initializes the WebXRInput
  43875. * @param xrSessionManager the xr session manager for this session
  43876. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  43877. * @param options = initialization options for this xr input
  43878. */
  43879. constructor(
  43880. /**
  43881. * the xr session manager for this session
  43882. */
  43883. xrSessionManager: WebXRSessionManager,
  43884. /**
  43885. * the WebXR camera for this session. Mainly used for teleportation
  43886. */
  43887. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  43888. private _onInputSourcesChange;
  43889. private _addAndRemoveControllers;
  43890. /**
  43891. * Disposes of the object
  43892. */
  43893. dispose(): void;
  43894. }
  43895. }
  43896. declare module BABYLON {
  43897. /**
  43898. * Options interface for the pointer selection module
  43899. */
  43900. export interface IWebXRControllerPointerSelectionOptions {
  43901. /**
  43902. * the xr input to use with this pointer selection
  43903. */
  43904. xrInput: WebXRInput;
  43905. /**
  43906. * Different button type to use instead of the main component
  43907. */
  43908. overrideButtonId?: string;
  43909. /**
  43910. * The amount of time in miliseconds it takes between pick found something to a pointer down event.
  43911. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  43912. * 3000 means 3 seconds between pointing at something and selecting it
  43913. */
  43914. timeToSelect?: number;
  43915. /**
  43916. * 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)
  43917. * If not disabled, the last picked point will be used to execute a pointer up event
  43918. * If disabled, pointer up event will be triggered right after the pointer down event.
  43919. * Used in screen and gaze target ray mode only
  43920. */
  43921. disablePointerUpOnTouchOut: boolean;
  43922. /**
  43923. * For gaze mode (time to select instead of press)
  43924. */
  43925. forceGazeMode: boolean;
  43926. /**
  43927. * 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
  43928. * to start a new countdown to the pointer down event.
  43929. * Defaults to 1.
  43930. */
  43931. gazeModePointerMovedFactor?: number;
  43932. }
  43933. /**
  43934. * A module that will enable pointer selection for motion controllers of XR Input Sources
  43935. */
  43936. export class WebXRControllerPointerSelection implements IWebXRFeature {
  43937. private _xrSessionManager;
  43938. private readonly _options;
  43939. /**
  43940. * The module's name
  43941. */
  43942. static readonly Name: string;
  43943. /**
  43944. * The (Babylon) version of this module.
  43945. * This is an integer representing the implementation version.
  43946. * This number does not correspond to the webxr specs version
  43947. */
  43948. static readonly Version: number;
  43949. /**
  43950. * This color will be set to the laser pointer when selection is triggered
  43951. */
  43952. laserPointerPickedColor: Color3;
  43953. /**
  43954. * This color will be applied to the selection ring when selection is triggered
  43955. */
  43956. selectionMeshPickedColor: Color3;
  43957. /**
  43958. * default color of the selection ring
  43959. */
  43960. selectionMeshDefaultColor: Color3;
  43961. /**
  43962. * Default color of the laser pointer
  43963. */
  43964. lasterPointerDefaultColor: Color3;
  43965. private static _idCounter;
  43966. private _observerTracked;
  43967. private _attached;
  43968. private _tmpRay;
  43969. private _controllers;
  43970. /**
  43971. * Is this feature attached
  43972. */
  43973. get attached(): boolean;
  43974. private _scene;
  43975. /**
  43976. * constructs a new background remover module
  43977. * @param _xrSessionManager the session manager for this module
  43978. * @param _options read-only options to be used in this module
  43979. */
  43980. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  43981. /**
  43982. * attach this feature
  43983. * Will usually be called by the features manager
  43984. *
  43985. * @returns true if successful.
  43986. */
  43987. attach(): boolean;
  43988. /**
  43989. * detach this feature.
  43990. * Will usually be called by the features manager
  43991. *
  43992. * @returns true if successful.
  43993. */
  43994. detach(): boolean;
  43995. /**
  43996. * Get the xr controller that correlates to the pointer id in the pointer event
  43997. *
  43998. * @param id the pointer id to search for
  43999. * @returns the controller that correlates to this id or null if not found
  44000. */
  44001. getXRControllerByPointerId(id: number): Nullable<WebXRController>;
  44002. private _attachController;
  44003. private _attachScreenRayMode;
  44004. private _attachGazeMode;
  44005. private _tmpVectorForPickCompare;
  44006. private _pickingMoved;
  44007. private _attachTrackedPointerRayMode;
  44008. private _detachController;
  44009. private _generateNewMeshPair;
  44010. private _convertNormalToDirectionOfRay;
  44011. private _updatePointerDistance;
  44012. /**
  44013. * Dispose this feature and all of the resources attached
  44014. */
  44015. dispose(): void;
  44016. }
  44017. }
  44018. declare module BABYLON {
  44019. /**
  44020. * Button which can be used to enter a different mode of XR
  44021. */
  44022. export class WebXREnterExitUIButton {
  44023. /** button element */
  44024. element: HTMLElement;
  44025. /** XR initialization options for the button */
  44026. sessionMode: XRSessionMode;
  44027. /** Reference space type */
  44028. referenceSpaceType: XRReferenceSpaceType;
  44029. /**
  44030. * Creates a WebXREnterExitUIButton
  44031. * @param element button element
  44032. * @param sessionMode XR initialization session mode
  44033. * @param referenceSpaceType the type of reference space to be used
  44034. */
  44035. constructor(
  44036. /** button element */
  44037. element: HTMLElement,
  44038. /** XR initialization options for the button */
  44039. sessionMode: XRSessionMode,
  44040. /** Reference space type */
  44041. referenceSpaceType: XRReferenceSpaceType);
  44042. /**
  44043. * Overwritable function which can be used to update the button's visuals when the state changes
  44044. * @param activeButton the current active button in the UI
  44045. */
  44046. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  44047. }
  44048. /**
  44049. * Options to create the webXR UI
  44050. */
  44051. export class WebXREnterExitUIOptions {
  44052. /**
  44053. * Context to enter xr with
  44054. */
  44055. renderTarget?: Nullable<WebXRRenderTarget>;
  44056. /**
  44057. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  44058. */
  44059. customButtons?: Array<WebXREnterExitUIButton>;
  44060. /**
  44061. * A session mode to use when creating the default button.
  44062. * Default is immersive-vr
  44063. */
  44064. sessionMode?: XRSessionMode;
  44065. /**
  44066. * A reference space type to use when creating the default button.
  44067. * Default is local-floor
  44068. */
  44069. referenceSpaceType?: XRReferenceSpaceType;
  44070. }
  44071. /**
  44072. * UI to allow the user to enter/exit XR mode
  44073. */
  44074. export class WebXREnterExitUI implements IDisposable {
  44075. private scene;
  44076. /** version of the options passed to this UI */
  44077. options: WebXREnterExitUIOptions;
  44078. private _overlay;
  44079. private _buttons;
  44080. private _activeButton;
  44081. /**
  44082. * Fired every time the active button is changed.
  44083. *
  44084. * When xr is entered via a button that launches xr that button will be the callback parameter
  44085. *
  44086. * When exiting xr the callback parameter will be null)
  44087. */
  44088. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  44089. /**
  44090. * Creates UI to allow the user to enter/exit XR mode
  44091. * @param scene the scene to add the ui to
  44092. * @param helper the xr experience helper to enter/exit xr with
  44093. * @param options options to configure the UI
  44094. * @returns the created ui
  44095. */
  44096. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  44097. /**
  44098. *
  44099. * @param scene babylon scene object to use
  44100. * @param options (read-only) version of the options passed to this UI
  44101. */
  44102. private constructor();
  44103. private _updateButtons;
  44104. /**
  44105. * Disposes of the object
  44106. */
  44107. dispose(): void;
  44108. }
  44109. }
  44110. declare module BABYLON {
  44111. /**
  44112. * Class containing static functions to help procedurally build meshes
  44113. */
  44114. export class LinesBuilder {
  44115. /**
  44116. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  44117. * * 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
  44118. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  44119. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  44120. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  44121. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  44122. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44123. * * 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
  44124. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  44125. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44126. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  44127. * @param name defines the name of the new line system
  44128. * @param options defines the options used to create the line system
  44129. * @param scene defines the hosting scene
  44130. * @returns a new line system mesh
  44131. */
  44132. static CreateLineSystem(name: string, options: {
  44133. lines: Vector3[][];
  44134. updatable?: boolean;
  44135. instance?: Nullable<LinesMesh>;
  44136. colors?: Nullable<Color4[][]>;
  44137. useVertexAlpha?: boolean;
  44138. }, scene: Nullable<Scene>): LinesMesh;
  44139. /**
  44140. * Creates a line mesh
  44141. * 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
  44142. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44143. * * The parameter `points` is an array successive Vector3
  44144. * * 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
  44145. * * The optional parameter `colors` is an array of successive Color4, one per line point
  44146. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  44147. * * When updating an instance, remember that only point positions can change, not the number of points
  44148. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44149. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  44150. * @param name defines the name of the new line system
  44151. * @param options defines the options used to create the line system
  44152. * @param scene defines the hosting scene
  44153. * @returns a new line mesh
  44154. */
  44155. static CreateLines(name: string, options: {
  44156. points: Vector3[];
  44157. updatable?: boolean;
  44158. instance?: Nullable<LinesMesh>;
  44159. colors?: Color4[];
  44160. useVertexAlpha?: boolean;
  44161. }, scene?: Nullable<Scene>): LinesMesh;
  44162. /**
  44163. * Creates a dashed line mesh
  44164. * * 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
  44165. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44166. * * The parameter `points` is an array successive Vector3
  44167. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  44168. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  44169. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  44170. * * 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
  44171. * * When updating an instance, remember that only point positions can change, not the number of points
  44172. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44173. * @param name defines the name of the mesh
  44174. * @param options defines the options used to create the mesh
  44175. * @param scene defines the hosting scene
  44176. * @returns the dashed line mesh
  44177. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  44178. */
  44179. static CreateDashedLines(name: string, options: {
  44180. points: Vector3[];
  44181. dashSize?: number;
  44182. gapSize?: number;
  44183. dashNb?: number;
  44184. updatable?: boolean;
  44185. instance?: LinesMesh;
  44186. }, scene?: Nullable<Scene>): LinesMesh;
  44187. }
  44188. }
  44189. declare module BABYLON {
  44190. /**
  44191. * The options container for the teleportation module
  44192. */
  44193. export interface IWebXRTeleportationOptions {
  44194. /**
  44195. * Babylon XR Input class for controller
  44196. */
  44197. xrInput: WebXRInput;
  44198. /**
  44199. * A list of meshes to use as floor meshes.
  44200. * Meshes can be added and removed after initializing the feature using the
  44201. * addFloorMesh and removeFloorMesh functions
  44202. */
  44203. floorMeshes: AbstractMesh[];
  44204. /**
  44205. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  44206. * If you want to support rotation, make sure your mesh has a direction indicator.
  44207. *
  44208. * When left untouched, the default mesh will be initialized.
  44209. */
  44210. teleportationTargetMesh?: AbstractMesh;
  44211. /**
  44212. * Values to configure the default target mesh
  44213. */
  44214. defaultTargetMeshOptions?: {
  44215. /**
  44216. * Fill color of the teleportation area
  44217. */
  44218. teleportationFillColor?: string;
  44219. /**
  44220. * Border color for the teleportation area
  44221. */
  44222. teleportationBorderColor?: string;
  44223. /**
  44224. * Override the default material of the torus and arrow
  44225. */
  44226. torusArrowMaterial?: Material;
  44227. /**
  44228. * Disable the mesh's animation sequence
  44229. */
  44230. disableAnimation?: boolean;
  44231. };
  44232. /**
  44233. * Disable using the thumbstick and use the main component (usuallly trigger) on long press.
  44234. * This will be automatically true if the controller doesnt have a thumbstick or touchpad.
  44235. */
  44236. useMainComponentOnly?: boolean;
  44237. /**
  44238. * If main component is used (no thumbstick), how long should the "long press" take before teleporting
  44239. */
  44240. timeToTeleport?: number;
  44241. }
  44242. /**
  44243. * This is a teleportation feature to be used with webxr-enabled motion controllers.
  44244. * When enabled and attached, the feature will allow a user to move aroundand rotate in the scene using
  44245. * the input of the attached controllers.
  44246. */
  44247. export class WebXRMotionControllerTeleportation implements IWebXRFeature {
  44248. private _xrSessionManager;
  44249. private _options;
  44250. /**
  44251. * The module's name
  44252. */
  44253. static readonly Name: string;
  44254. /**
  44255. * The (Babylon) version of this module.
  44256. * This is an integer representing the implementation version.
  44257. * This number does not correspond to the webxr specs version
  44258. */
  44259. static readonly Version: number;
  44260. /**
  44261. * Is rotation enabled when moving forward?
  44262. * Disabling this feature will prevent the user from deciding the direction when teleporting
  44263. */
  44264. rotationEnabled: boolean;
  44265. /**
  44266. * Should the module support parabolic ray on top of direct ray
  44267. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  44268. * Very helpful when moving between floors / different heights
  44269. */
  44270. parabolicRayEnabled: boolean;
  44271. /**
  44272. * The distance from the user to the inspection point in the direction of the controller
  44273. * A higher number will allow the user to move further
  44274. * defaults to 5 (meters, in xr units)
  44275. */
  44276. parabolicCheckRadius: number;
  44277. /**
  44278. * How much rotation should be applied when rotating right and left
  44279. */
  44280. rotationAngle: number;
  44281. /**
  44282. * Distance to travel when moving backwards
  44283. */
  44284. backwardsTeleportationDistance: number;
  44285. private _observerTracked;
  44286. private _attached;
  44287. /**
  44288. * Is this feature attached
  44289. */
  44290. get attached(): boolean;
  44291. /**
  44292. * Add a new mesh to the floor meshes array
  44293. * @param mesh the mesh to use as floor mesh
  44294. */
  44295. addFloorMesh(mesh: AbstractMesh): void;
  44296. /**
  44297. * Remove a mesh from the floor meshes array
  44298. * @param mesh the mesh to remove
  44299. */
  44300. removeFloorMesh(mesh: AbstractMesh): void;
  44301. /**
  44302. * Remove a mesh from the floor meshes array using its name
  44303. * @param name the mesh name to remove
  44304. */
  44305. removeFloorMeshByName(name: string): void;
  44306. private _tmpRay;
  44307. private _tmpVector;
  44308. private _controllers;
  44309. /**
  44310. * constructs a new anchor system
  44311. * @param _xrSessionManager an instance of WebXRSessionManager
  44312. * @param _options configuration object for this feature
  44313. */
  44314. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  44315. private _selectionFeature;
  44316. /**
  44317. * This function sets a selection feature that will be disabled when
  44318. * the forward ray is shown and will be reattached when hidden.
  44319. * This is used to remove the selection rays when moving.
  44320. * @param selectionFeature the feature to disable when forward movement is enabled
  44321. */
  44322. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  44323. /**
  44324. * attach this feature
  44325. * Will usually be called by the features manager
  44326. *
  44327. * @returns true if successful.
  44328. */
  44329. attach(): boolean;
  44330. /**
  44331. * detach this feature.
  44332. * Will usually be called by the features manager
  44333. *
  44334. * @returns true if successful.
  44335. */
  44336. detach(): boolean;
  44337. /**
  44338. * Dispose this feature and all of the resources attached
  44339. */
  44340. dispose(): void;
  44341. private _currentTeleportationControllerId;
  44342. private _attachController;
  44343. private _teleportForward;
  44344. private _detachController;
  44345. private createDefaultTargetMesh;
  44346. private setTargetMeshVisibility;
  44347. private setTargetMeshPosition;
  44348. private _quadraticBezierCurve;
  44349. private showParabolicPath;
  44350. }
  44351. }
  44352. declare module BABYLON {
  44353. /**
  44354. * Options for the default xr helper
  44355. */
  44356. export class WebXRDefaultExperienceOptions {
  44357. /**
  44358. * Floor meshes that should be used for teleporting
  44359. */
  44360. floorMeshes?: Array<AbstractMesh>;
  44361. /**
  44362. * Enable or disable default UI to enter XR
  44363. */
  44364. disableDefaultUI?: boolean;
  44365. /**
  44366. * optional configuration for the output canvas
  44367. */
  44368. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  44369. /**
  44370. * optional UI options. This can be used among other to change session mode and reference space type
  44371. */
  44372. uiOptions?: WebXREnterExitUIOptions;
  44373. /**
  44374. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  44375. */
  44376. inputOptions?: IWebXRInputOptions;
  44377. }
  44378. /**
  44379. * Default experience which provides a similar setup to the previous webVRExperience
  44380. */
  44381. export class WebXRDefaultExperience {
  44382. /**
  44383. * Base experience
  44384. */
  44385. baseExperience: WebXRExperienceHelper;
  44386. /**
  44387. * Input experience extension
  44388. */
  44389. input: WebXRInput;
  44390. /**
  44391. * Enables laser pointer and selection
  44392. */
  44393. pointerSelection: WebXRControllerPointerSelection;
  44394. /**
  44395. * Enables teleportation
  44396. */
  44397. teleportation: WebXRMotionControllerTeleportation;
  44398. /**
  44399. * Enables ui for entering/exiting xr
  44400. */
  44401. enterExitUI: WebXREnterExitUI;
  44402. /**
  44403. * Default target xr should render to
  44404. */
  44405. renderTarget: WebXRRenderTarget;
  44406. /**
  44407. * Creates the default xr experience
  44408. * @param scene scene
  44409. * @param options options for basic configuration
  44410. * @returns resulting WebXRDefaultExperience
  44411. */
  44412. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  44413. private constructor();
  44414. /**
  44415. * DIsposes of the experience helper
  44416. */
  44417. dispose(): void;
  44418. }
  44419. }
  44420. declare module BABYLON {
  44421. /**
  44422. * Options to modify the vr teleportation behavior.
  44423. */
  44424. export interface VRTeleportationOptions {
  44425. /**
  44426. * The name of the mesh which should be used as the teleportation floor. (default: null)
  44427. */
  44428. floorMeshName?: string;
  44429. /**
  44430. * A list of meshes to be used as the teleportation floor. (default: empty)
  44431. */
  44432. floorMeshes?: Mesh[];
  44433. /**
  44434. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  44435. */
  44436. teleportationMode?: number;
  44437. /**
  44438. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  44439. */
  44440. teleportationTime?: number;
  44441. /**
  44442. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  44443. */
  44444. teleportationSpeed?: number;
  44445. /**
  44446. * The easing function used in the animation or null for Linear. (default CircleEase)
  44447. */
  44448. easingFunction?: EasingFunction;
  44449. }
  44450. /**
  44451. * Options to modify the vr experience helper's behavior.
  44452. */
  44453. export interface VRExperienceHelperOptions extends WebVROptions {
  44454. /**
  44455. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  44456. */
  44457. createDeviceOrientationCamera?: boolean;
  44458. /**
  44459. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  44460. */
  44461. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  44462. /**
  44463. * Uses the main button on the controller to toggle the laser casted. (default: true)
  44464. */
  44465. laserToggle?: boolean;
  44466. /**
  44467. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  44468. */
  44469. floorMeshes?: Mesh[];
  44470. /**
  44471. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  44472. */
  44473. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  44474. /**
  44475. * Defines if WebXR should be used instead of WebVR (if available)
  44476. */
  44477. useXR?: boolean;
  44478. }
  44479. /**
  44480. * Event containing information after VR has been entered
  44481. */
  44482. export class OnAfterEnteringVRObservableEvent {
  44483. /**
  44484. * If entering vr was successful
  44485. */
  44486. success: boolean;
  44487. }
  44488. /**
  44489. * Helps to quickly add VR support to an existing scene.
  44490. * See http://doc.babylonjs.com/how_to/webvr_helper
  44491. */
  44492. export class VRExperienceHelper {
  44493. /** Options to modify the vr experience helper's behavior. */
  44494. webVROptions: VRExperienceHelperOptions;
  44495. private _scene;
  44496. private _position;
  44497. private _btnVR;
  44498. private _btnVRDisplayed;
  44499. private _webVRsupported;
  44500. private _webVRready;
  44501. private _webVRrequesting;
  44502. private _webVRpresenting;
  44503. private _hasEnteredVR;
  44504. private _fullscreenVRpresenting;
  44505. private _inputElement;
  44506. private _webVRCamera;
  44507. private _vrDeviceOrientationCamera;
  44508. private _deviceOrientationCamera;
  44509. private _existingCamera;
  44510. private _onKeyDown;
  44511. private _onVrDisplayPresentChange;
  44512. private _onVRDisplayChanged;
  44513. private _onVRRequestPresentStart;
  44514. private _onVRRequestPresentComplete;
  44515. /**
  44516. * 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)
  44517. */
  44518. enableGazeEvenWhenNoPointerLock: boolean;
  44519. /**
  44520. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  44521. */
  44522. exitVROnDoubleTap: boolean;
  44523. /**
  44524. * Observable raised right before entering VR.
  44525. */
  44526. onEnteringVRObservable: Observable<VRExperienceHelper>;
  44527. /**
  44528. * Observable raised when entering VR has completed.
  44529. */
  44530. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  44531. /**
  44532. * Observable raised when exiting VR.
  44533. */
  44534. onExitingVRObservable: Observable<VRExperienceHelper>;
  44535. /**
  44536. * Observable raised when controller mesh is loaded.
  44537. */
  44538. onControllerMeshLoadedObservable: Observable<WebVRController>;
  44539. /** Return this.onEnteringVRObservable
  44540. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  44541. */
  44542. get onEnteringVR(): Observable<VRExperienceHelper>;
  44543. /** Return this.onExitingVRObservable
  44544. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  44545. */
  44546. get onExitingVR(): Observable<VRExperienceHelper>;
  44547. /** Return this.onControllerMeshLoadedObservable
  44548. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  44549. */
  44550. get onControllerMeshLoaded(): Observable<WebVRController>;
  44551. private _rayLength;
  44552. private _useCustomVRButton;
  44553. private _teleportationRequested;
  44554. private _teleportActive;
  44555. private _floorMeshName;
  44556. private _floorMeshesCollection;
  44557. private _teleportationMode;
  44558. private _teleportationTime;
  44559. private _teleportationSpeed;
  44560. private _teleportationEasing;
  44561. private _rotationAllowed;
  44562. private _teleportBackwardsVector;
  44563. private _teleportationTarget;
  44564. private _isDefaultTeleportationTarget;
  44565. private _postProcessMove;
  44566. private _teleportationFillColor;
  44567. private _teleportationBorderColor;
  44568. private _rotationAngle;
  44569. private _haloCenter;
  44570. private _cameraGazer;
  44571. private _padSensibilityUp;
  44572. private _padSensibilityDown;
  44573. private _leftController;
  44574. private _rightController;
  44575. private _gazeColor;
  44576. private _laserColor;
  44577. private _pickedLaserColor;
  44578. private _pickedGazeColor;
  44579. /**
  44580. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  44581. */
  44582. onNewMeshSelected: Observable<AbstractMesh>;
  44583. /**
  44584. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  44585. * This observable will provide the mesh and the controller used to select the mesh
  44586. */
  44587. onMeshSelectedWithController: Observable<{
  44588. mesh: AbstractMesh;
  44589. controller: WebVRController;
  44590. }>;
  44591. /**
  44592. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  44593. */
  44594. onNewMeshPicked: Observable<PickingInfo>;
  44595. private _circleEase;
  44596. /**
  44597. * Observable raised before camera teleportation
  44598. */
  44599. onBeforeCameraTeleport: Observable<Vector3>;
  44600. /**
  44601. * Observable raised after camera teleportation
  44602. */
  44603. onAfterCameraTeleport: Observable<Vector3>;
  44604. /**
  44605. * Observable raised when current selected mesh gets unselected
  44606. */
  44607. onSelectedMeshUnselected: Observable<AbstractMesh>;
  44608. private _raySelectionPredicate;
  44609. /**
  44610. * To be optionaly changed by user to define custom ray selection
  44611. */
  44612. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  44613. /**
  44614. * To be optionaly changed by user to define custom selection logic (after ray selection)
  44615. */
  44616. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  44617. /**
  44618. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  44619. */
  44620. teleportationEnabled: boolean;
  44621. private _defaultHeight;
  44622. private _teleportationInitialized;
  44623. private _interactionsEnabled;
  44624. private _interactionsRequested;
  44625. private _displayGaze;
  44626. private _displayLaserPointer;
  44627. /**
  44628. * The mesh used to display where the user is going to teleport.
  44629. */
  44630. get teleportationTarget(): Mesh;
  44631. /**
  44632. * Sets the mesh to be used to display where the user is going to teleport.
  44633. */
  44634. set teleportationTarget(value: Mesh);
  44635. /**
  44636. * 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
  44637. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  44638. * See http://doc.babylonjs.com/resources/baking_transformations
  44639. */
  44640. get gazeTrackerMesh(): Mesh;
  44641. set gazeTrackerMesh(value: Mesh);
  44642. /**
  44643. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  44644. */
  44645. updateGazeTrackerScale: boolean;
  44646. /**
  44647. * If the gaze trackers color should be updated when selecting meshes
  44648. */
  44649. updateGazeTrackerColor: boolean;
  44650. /**
  44651. * If the controller laser color should be updated when selecting meshes
  44652. */
  44653. updateControllerLaserColor: boolean;
  44654. /**
  44655. * The gaze tracking mesh corresponding to the left controller
  44656. */
  44657. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  44658. /**
  44659. * The gaze tracking mesh corresponding to the right controller
  44660. */
  44661. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  44662. /**
  44663. * If the ray of the gaze should be displayed.
  44664. */
  44665. get displayGaze(): boolean;
  44666. /**
  44667. * Sets if the ray of the gaze should be displayed.
  44668. */
  44669. set displayGaze(value: boolean);
  44670. /**
  44671. * If the ray of the LaserPointer should be displayed.
  44672. */
  44673. get displayLaserPointer(): boolean;
  44674. /**
  44675. * Sets if the ray of the LaserPointer should be displayed.
  44676. */
  44677. set displayLaserPointer(value: boolean);
  44678. /**
  44679. * The deviceOrientationCamera used as the camera when not in VR.
  44680. */
  44681. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  44682. /**
  44683. * Based on the current WebVR support, returns the current VR camera used.
  44684. */
  44685. get currentVRCamera(): Nullable<Camera>;
  44686. /**
  44687. * The webVRCamera which is used when in VR.
  44688. */
  44689. get webVRCamera(): WebVRFreeCamera;
  44690. /**
  44691. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  44692. */
  44693. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  44694. /**
  44695. * The html button that is used to trigger entering into VR.
  44696. */
  44697. get vrButton(): Nullable<HTMLButtonElement>;
  44698. private get _teleportationRequestInitiated();
  44699. /**
  44700. * Defines wether or not Pointer lock should be requested when switching to
  44701. * full screen.
  44702. */
  44703. requestPointerLockOnFullScreen: boolean;
  44704. /**
  44705. * If asking to force XR, this will be populated with the default xr experience
  44706. */
  44707. xr: WebXRDefaultExperience;
  44708. /**
  44709. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  44710. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  44711. */
  44712. xrTestDone: boolean;
  44713. /**
  44714. * Instantiates a VRExperienceHelper.
  44715. * Helps to quickly add VR support to an existing scene.
  44716. * @param scene The scene the VRExperienceHelper belongs to.
  44717. * @param webVROptions Options to modify the vr experience helper's behavior.
  44718. */
  44719. constructor(scene: Scene,
  44720. /** Options to modify the vr experience helper's behavior. */
  44721. webVROptions?: VRExperienceHelperOptions);
  44722. private completeVRInit;
  44723. private _onDefaultMeshLoaded;
  44724. private _onResize;
  44725. private _onFullscreenChange;
  44726. /**
  44727. * Gets a value indicating if we are currently in VR mode.
  44728. */
  44729. get isInVRMode(): boolean;
  44730. private onVrDisplayPresentChange;
  44731. private onVRDisplayChanged;
  44732. private moveButtonToBottomRight;
  44733. private displayVRButton;
  44734. private updateButtonVisibility;
  44735. private _cachedAngularSensibility;
  44736. /**
  44737. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  44738. * Otherwise, will use the fullscreen API.
  44739. */
  44740. enterVR(): void;
  44741. /**
  44742. * Attempt to exit VR, or fullscreen.
  44743. */
  44744. exitVR(): void;
  44745. /**
  44746. * The position of the vr experience helper.
  44747. */
  44748. get position(): Vector3;
  44749. /**
  44750. * Sets the position of the vr experience helper.
  44751. */
  44752. set position(value: Vector3);
  44753. /**
  44754. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  44755. */
  44756. enableInteractions(): void;
  44757. private get _noControllerIsActive();
  44758. private beforeRender;
  44759. private _isTeleportationFloor;
  44760. /**
  44761. * Adds a floor mesh to be used for teleportation.
  44762. * @param floorMesh the mesh to be used for teleportation.
  44763. */
  44764. addFloorMesh(floorMesh: Mesh): void;
  44765. /**
  44766. * Removes a floor mesh from being used for teleportation.
  44767. * @param floorMesh the mesh to be removed.
  44768. */
  44769. removeFloorMesh(floorMesh: Mesh): void;
  44770. /**
  44771. * Enables interactions and teleportation using the VR controllers and gaze.
  44772. * @param vrTeleportationOptions options to modify teleportation behavior.
  44773. */
  44774. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  44775. private _onNewGamepadConnected;
  44776. private _tryEnableInteractionOnController;
  44777. private _onNewGamepadDisconnected;
  44778. private _enableInteractionOnController;
  44779. private _checkTeleportWithRay;
  44780. private _checkRotate;
  44781. private _checkTeleportBackwards;
  44782. private _enableTeleportationOnController;
  44783. private _createTeleportationCircles;
  44784. private _displayTeleportationTarget;
  44785. private _hideTeleportationTarget;
  44786. private _rotateCamera;
  44787. private _moveTeleportationSelectorTo;
  44788. private _workingVector;
  44789. private _workingQuaternion;
  44790. private _workingMatrix;
  44791. /**
  44792. * Time Constant Teleportation Mode
  44793. */
  44794. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  44795. /**
  44796. * Speed Constant Teleportation Mode
  44797. */
  44798. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  44799. /**
  44800. * Teleports the users feet to the desired location
  44801. * @param location The location where the user's feet should be placed
  44802. */
  44803. teleportCamera(location: Vector3): void;
  44804. private _convertNormalToDirectionOfRay;
  44805. private _castRayAndSelectObject;
  44806. private _notifySelectedMeshUnselected;
  44807. /**
  44808. * Permanently set new colors for the laser pointer
  44809. * @param color the new laser color
  44810. * @param pickedColor the new laser color when picked mesh detected
  44811. */
  44812. setLaserColor(color: Color3, pickedColor?: Color3): void;
  44813. /**
  44814. * Permanently set new colors for the gaze pointer
  44815. * @param color the new gaze color
  44816. * @param pickedColor the new gaze color when picked mesh detected
  44817. */
  44818. setGazeColor(color: Color3, pickedColor?: Color3): void;
  44819. /**
  44820. * Sets the color of the laser ray from the vr controllers.
  44821. * @param color new color for the ray.
  44822. */
  44823. changeLaserColor(color: Color3): void;
  44824. /**
  44825. * Sets the color of the ray from the vr headsets gaze.
  44826. * @param color new color for the ray.
  44827. */
  44828. changeGazeColor(color: Color3): void;
  44829. /**
  44830. * Exits VR and disposes of the vr experience helper
  44831. */
  44832. dispose(): void;
  44833. /**
  44834. * Gets the name of the VRExperienceHelper class
  44835. * @returns "VRExperienceHelper"
  44836. */
  44837. getClassName(): string;
  44838. }
  44839. }
  44840. declare module BABYLON {
  44841. /**
  44842. * Options used for hit testing
  44843. */
  44844. export interface IWebXRHitTestOptions {
  44845. /**
  44846. * Only test when user interacted with the scene. Default - hit test every frame
  44847. */
  44848. testOnPointerDownOnly?: boolean;
  44849. /**
  44850. * The node to use to transform the local results to world coordinates
  44851. */
  44852. worldParentNode?: TransformNode;
  44853. }
  44854. /**
  44855. * Interface defining the babylon result of raycasting/hit-test
  44856. */
  44857. export interface IWebXRHitResult {
  44858. /**
  44859. * The native hit test result
  44860. */
  44861. xrHitResult: XRHitResult;
  44862. /**
  44863. * Transformation matrix that can be applied to a node that will put it in the hit point location
  44864. */
  44865. transformationMatrix: Matrix;
  44866. }
  44867. /**
  44868. * The currently-working hit-test module.
  44869. * Hit test (or raycasting) is used to interact with the real world.
  44870. * For further information read here - https://github.com/immersive-web/hit-test
  44871. */
  44872. export class WebXRHitTestLegacy implements IWebXRFeature {
  44873. private _xrSessionManager;
  44874. /**
  44875. * options to use when constructing this feature
  44876. */
  44877. readonly options: IWebXRHitTestOptions;
  44878. /**
  44879. * The module's name
  44880. */
  44881. static readonly Name: string;
  44882. /**
  44883. * The (Babylon) version of this module.
  44884. * This is an integer representing the implementation version.
  44885. * This number does not correspond to the webxr specs version
  44886. */
  44887. static readonly Version: number;
  44888. private _attached;
  44889. /**
  44890. * Is this feature attached
  44891. */
  44892. get attached(): boolean;
  44893. /**
  44894. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  44895. * @param event the (select) event to use to select with
  44896. * @param referenceSpace the reference space to use for this hit test
  44897. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  44898. */
  44899. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  44900. /**
  44901. * execute a hit test with an XR Ray
  44902. *
  44903. * @param xrSession a native xrSession that will execute this hit test
  44904. * @param xrRay the ray (position and direction) to use for raycasting
  44905. * @param referenceSpace native XR reference space to use for the hit-test
  44906. * @param filter filter function that will filter the results
  44907. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  44908. */
  44909. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  44910. /**
  44911. * Triggered when new babylon (transformed) hit test results are available
  44912. */
  44913. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  44914. private _onSelectEnabled;
  44915. private _xrFrameObserver;
  44916. /**
  44917. * Creates a new instance of the (legacy version) hit test feature
  44918. * @param _xrSessionManager an instance of WebXRSessionManager
  44919. * @param options options to use when constructing this feature
  44920. */
  44921. constructor(_xrSessionManager: WebXRSessionManager,
  44922. /**
  44923. * options to use when constructing this feature
  44924. */
  44925. options?: IWebXRHitTestOptions);
  44926. /**
  44927. * Populated with the last native XR Hit Results
  44928. */
  44929. lastNativeXRHitResults: XRHitResult[];
  44930. /**
  44931. * attach this feature
  44932. * Will usually be called by the features manager
  44933. *
  44934. * @returns true if successful.
  44935. */
  44936. attach(): boolean;
  44937. /**
  44938. * detach this feature.
  44939. * Will usually be called by the features manager
  44940. *
  44941. * @returns true if successful.
  44942. */
  44943. detach(): boolean;
  44944. private _onHitTestResults;
  44945. private _onSelect;
  44946. /**
  44947. * Dispose this feature and all of the resources attached
  44948. */
  44949. dispose(): void;
  44950. }
  44951. }
  44952. declare module BABYLON {
  44953. /**
  44954. * Options used in the plane detector module
  44955. */
  44956. export interface IWebXRPlaneDetectorOptions {
  44957. /**
  44958. * The node to use to transform the local results to world coordinates
  44959. */
  44960. worldParentNode?: TransformNode;
  44961. }
  44962. /**
  44963. * A babylon interface for a webxr plane.
  44964. * A Plane is actually a polygon, built from N points in space
  44965. */
  44966. export interface IWebXRPlane {
  44967. /**
  44968. * a babylon-assigned ID for this polygon
  44969. */
  44970. id: number;
  44971. /**
  44972. * the native xr-plane object
  44973. */
  44974. xrPlane: XRPlane;
  44975. /**
  44976. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  44977. */
  44978. polygonDefinition: Array<Vector3>;
  44979. /**
  44980. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  44981. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  44982. */
  44983. transformationMatrix: Matrix;
  44984. }
  44985. /**
  44986. * The plane detector is used to detect planes in the real world when in AR
  44987. * For more information see https://github.com/immersive-web/real-world-geometry/
  44988. */
  44989. export class WebXRPlaneDetector implements IWebXRFeature {
  44990. private _xrSessionManager;
  44991. private _options;
  44992. /**
  44993. * The module's name
  44994. */
  44995. static readonly Name: string;
  44996. /**
  44997. * The (Babylon) version of this module.
  44998. * This is an integer representing the implementation version.
  44999. * This number does not correspond to the webxr specs version
  45000. */
  45001. static readonly Version: number;
  45002. /**
  45003. * Observers registered here will be executed when a new plane was added to the session
  45004. */
  45005. onPlaneAddedObservable: Observable<IWebXRPlane>;
  45006. /**
  45007. * Observers registered here will be executed when a plane is no longer detected in the session
  45008. */
  45009. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  45010. /**
  45011. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  45012. * This can execute N times every frame
  45013. */
  45014. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  45015. private _attached;
  45016. /**
  45017. * Is this feature attached
  45018. */
  45019. get attached(): boolean;
  45020. private _enabled;
  45021. private _detectedPlanes;
  45022. private _lastFrameDetected;
  45023. private _observerTracked;
  45024. /**
  45025. * construct a new Plane Detector
  45026. * @param _xrSessionManager an instance of xr Session manager
  45027. * @param _options configuration to use when constructing this feature
  45028. */
  45029. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  45030. /**
  45031. * attach this feature
  45032. * Will usually be called by the features manager
  45033. *
  45034. * @returns true if successful.
  45035. */
  45036. attach(): boolean;
  45037. /**
  45038. * detach this feature.
  45039. * Will usually be called by the features manager
  45040. *
  45041. * @returns true if successful.
  45042. */
  45043. detach(): boolean;
  45044. /**
  45045. * Dispose this feature and all of the resources attached
  45046. */
  45047. dispose(): void;
  45048. private _updatePlaneWithXRPlane;
  45049. /**
  45050. * avoiding using Array.find for global support.
  45051. * @param xrPlane the plane to find in the array
  45052. */
  45053. private findIndexInPlaneArray;
  45054. }
  45055. }
  45056. declare module BABYLON {
  45057. /**
  45058. * Configuration options of the anchor system
  45059. */
  45060. export interface IWebXRAnchorSystemOptions {
  45061. /**
  45062. * a node that will be used to convert local to world coordinates
  45063. */
  45064. worldParentNode?: TransformNode;
  45065. /**
  45066. * should the anchor system use plane detection.
  45067. * If set to true, the plane-detection feature should be set using setPlaneDetector
  45068. */
  45069. usePlaneDetection?: boolean;
  45070. /**
  45071. * Should a new anchor be added every time a select event is triggered
  45072. */
  45073. addAnchorOnSelect?: boolean;
  45074. }
  45075. /**
  45076. * A babylon container for an XR Anchor
  45077. */
  45078. export interface IWebXRAnchor {
  45079. /**
  45080. * A babylon-assigned ID for this anchor
  45081. */
  45082. id: number;
  45083. /**
  45084. * The native anchor object
  45085. */
  45086. xrAnchor: XRAnchor;
  45087. /**
  45088. * Transformation matrix to apply to an object attached to this anchor
  45089. */
  45090. transformationMatrix: Matrix;
  45091. }
  45092. /**
  45093. * An implementation of the anchor system of WebXR.
  45094. * Note that the current documented implementation is not available in any browser. Future implementations
  45095. * will use the frame to create an anchor and not the session or a detected plane
  45096. * For further information see https://github.com/immersive-web/anchors/
  45097. */
  45098. export class WebXRAnchorSystem implements IWebXRFeature {
  45099. private _xrSessionManager;
  45100. private _options;
  45101. /**
  45102. * The module's name
  45103. */
  45104. static readonly Name: string;
  45105. /**
  45106. * The (Babylon) version of this module.
  45107. * This is an integer representing the implementation version.
  45108. * This number does not correspond to the webxr specs version
  45109. */
  45110. static readonly Version: number;
  45111. /**
  45112. * Observers registered here will be executed when a new anchor was added to the session
  45113. */
  45114. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  45115. /**
  45116. * Observers registered here will be executed when an existing anchor updates
  45117. * This can execute N times every frame
  45118. */
  45119. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  45120. /**
  45121. * Observers registered here will be executed when an anchor was removed from the session
  45122. */
  45123. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  45124. private _attached;
  45125. /**
  45126. * Is this feature attached
  45127. */
  45128. get attached(): boolean;
  45129. private _planeDetector;
  45130. private _hitTestModule;
  45131. private _enabled;
  45132. private _trackedAnchors;
  45133. private _lastFrameDetected;
  45134. private _observerTracked;
  45135. /**
  45136. * constructs a new anchor system
  45137. * @param _xrSessionManager an instance of WebXRSessionManager
  45138. * @param _options configuration object for this feature
  45139. */
  45140. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  45141. /**
  45142. * set the plane detector to use in order to create anchors from frames
  45143. * @param planeDetector the plane-detector module to use
  45144. * @param enable enable plane-anchors. default is true
  45145. */
  45146. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  45147. /**
  45148. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  45149. * @param hitTestModule the hit-test module to use.
  45150. */
  45151. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  45152. /**
  45153. * attach this feature
  45154. * Will usually be called by the features manager
  45155. *
  45156. * @returns true if successful.
  45157. */
  45158. attach(): boolean;
  45159. /**
  45160. * detach this feature.
  45161. * Will usually be called by the features manager
  45162. *
  45163. * @returns true if successful.
  45164. */
  45165. detach(): boolean;
  45166. /**
  45167. * Dispose this feature and all of the resources attached
  45168. */
  45169. dispose(): void;
  45170. private _onSelect;
  45171. /**
  45172. * Add anchor at a specific XR point.
  45173. *
  45174. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  45175. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  45176. * @returns a promise the fulfills when the anchor was created
  45177. */
  45178. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  45179. private _updateAnchorWithXRFrame;
  45180. /**
  45181. * avoiding using Array.find for global support.
  45182. * @param xrAnchor the plane to find in the array
  45183. */
  45184. private _findIndexInAnchorArray;
  45185. }
  45186. }
  45187. declare module BABYLON {
  45188. /**
  45189. * Options interface for the background remover plugin
  45190. */
  45191. export interface IWebXRBackgroundRemoverOptions {
  45192. /**
  45193. * don't disable the environment helper
  45194. */
  45195. ignoreEnvironmentHelper?: boolean;
  45196. /**
  45197. * flags to configure the removal of the environment helper.
  45198. * If not set, the entire background will be removed. If set, flags should be set as well.
  45199. */
  45200. environmentHelperRemovalFlags?: {
  45201. /**
  45202. * Should the skybox be removed (default false)
  45203. */
  45204. skyBox?: boolean;
  45205. /**
  45206. * Should the ground be removed (default false)
  45207. */
  45208. ground?: boolean;
  45209. };
  45210. /**
  45211. * Further background meshes to disable when entering AR
  45212. */
  45213. backgroundMeshes?: AbstractMesh[];
  45214. }
  45215. /**
  45216. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  45217. */
  45218. export class WebXRBackgroundRemover implements IWebXRFeature {
  45219. private _xrSessionManager;
  45220. /**
  45221. * read-only options to be used in this module
  45222. */
  45223. readonly options: IWebXRBackgroundRemoverOptions;
  45224. /**
  45225. * The module's name
  45226. */
  45227. static readonly Name: string;
  45228. /**
  45229. * The (Babylon) version of this module.
  45230. * This is an integer representing the implementation version.
  45231. * This number does not correspond to the webxr specs version
  45232. */
  45233. static readonly Version: number;
  45234. /**
  45235. * registered observers will be triggered when the background state changes
  45236. */
  45237. onBackgroundStateChangedObservable: Observable<boolean>;
  45238. private _attached;
  45239. /**
  45240. * Is this feature attached
  45241. */
  45242. get attached(): boolean;
  45243. /**
  45244. * constructs a new background remover module
  45245. * @param _xrSessionManager the session manager for this module
  45246. * @param options read-only options to be used in this module
  45247. */
  45248. constructor(_xrSessionManager: WebXRSessionManager,
  45249. /**
  45250. * read-only options to be used in this module
  45251. */
  45252. options?: IWebXRBackgroundRemoverOptions);
  45253. /**
  45254. * attach this feature
  45255. * Will usually be called by the features manager
  45256. *
  45257. * @returns true if successful.
  45258. */
  45259. attach(): boolean;
  45260. /**
  45261. * detach this feature.
  45262. * Will usually be called by the features manager
  45263. *
  45264. * @returns true if successful.
  45265. */
  45266. detach(): boolean;
  45267. private _setBackgroundState;
  45268. /**
  45269. * Dispose this feature and all of the resources attached
  45270. */
  45271. dispose(): void;
  45272. }
  45273. }
  45274. declare module BABYLON {
  45275. /**
  45276. * The motion controller class for all microsoft mixed reality controllers
  45277. */
  45278. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  45279. /**
  45280. * The base url used to load the left and right controller models
  45281. */
  45282. static MODEL_BASE_URL: string;
  45283. /**
  45284. * The name of the left controller model file
  45285. */
  45286. static MODEL_LEFT_FILENAME: string;
  45287. /**
  45288. * The name of the right controller model file
  45289. */
  45290. static MODEL_RIGHT_FILENAME: string;
  45291. profileId: string;
  45292. protected readonly _mapping: {
  45293. defaultButton: {
  45294. "valueNodeName": string;
  45295. "unpressedNodeName": string;
  45296. "pressedNodeName": string;
  45297. };
  45298. defaultAxis: {
  45299. "valueNodeName": string;
  45300. "minNodeName": string;
  45301. "maxNodeName": string;
  45302. };
  45303. buttons: {
  45304. "xr-standard-trigger": {
  45305. "rootNodeName": string;
  45306. "componentProperty": string;
  45307. "states": string[];
  45308. };
  45309. "xr-standard-squeeze": {
  45310. "rootNodeName": string;
  45311. "componentProperty": string;
  45312. "states": string[];
  45313. };
  45314. "xr-standard-touchpad": {
  45315. "rootNodeName": string;
  45316. "labelAnchorNodeName": string;
  45317. "touchPointNodeName": string;
  45318. };
  45319. "xr-standard-thumbstick": {
  45320. "rootNodeName": string;
  45321. "componentProperty": string;
  45322. "states": string[];
  45323. };
  45324. };
  45325. axes: {
  45326. "xr-standard-touchpad": {
  45327. "x-axis": {
  45328. "rootNodeName": string;
  45329. };
  45330. "y-axis": {
  45331. "rootNodeName": string;
  45332. };
  45333. };
  45334. "xr-standard-thumbstick": {
  45335. "x-axis": {
  45336. "rootNodeName": string;
  45337. };
  45338. "y-axis": {
  45339. "rootNodeName": string;
  45340. };
  45341. };
  45342. };
  45343. };
  45344. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  45345. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  45346. private _getChildByName;
  45347. private _getImmediateChildByName;
  45348. protected _getFilenameAndPath(): {
  45349. filename: string;
  45350. path: string;
  45351. };
  45352. protected _updateModel(): void;
  45353. protected _getModelLoadingConstraints(): boolean;
  45354. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45355. }
  45356. }
  45357. declare module BABYLON {
  45358. /**
  45359. * The motion controller class for oculus touch (quest, rift).
  45360. * This class supports legacy mapping as well the standard xr mapping
  45361. */
  45362. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  45363. private _forceLegacyControllers;
  45364. /**
  45365. * The base url used to load the left and right controller models
  45366. */
  45367. static MODEL_BASE_URL: string;
  45368. /**
  45369. * The name of the left controller model file
  45370. */
  45371. static MODEL_LEFT_FILENAME: string;
  45372. /**
  45373. * The name of the right controller model file
  45374. */
  45375. static MODEL_RIGHT_FILENAME: string;
  45376. /**
  45377. * Base Url for the Quest controller model.
  45378. */
  45379. static QUEST_MODEL_BASE_URL: string;
  45380. profileId: string;
  45381. private _modelRootNode;
  45382. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  45383. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  45384. protected _getFilenameAndPath(): {
  45385. filename: string;
  45386. path: string;
  45387. };
  45388. /**
  45389. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  45390. * between the touch and touch 2.
  45391. */
  45392. private _isQuest;
  45393. protected _updateModel(): void;
  45394. protected _getModelLoadingConstraints(): boolean;
  45395. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45396. }
  45397. }
  45398. declare module BABYLON {
  45399. /**
  45400. * The motion controller class for the standard HTC-Vive controllers
  45401. */
  45402. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  45403. /**
  45404. * The base url used to load the left and right controller models
  45405. */
  45406. static MODEL_BASE_URL: string;
  45407. /**
  45408. * File name for the controller model.
  45409. */
  45410. static MODEL_FILENAME: string;
  45411. profileId: string;
  45412. private _modelRootNode;
  45413. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean);
  45414. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  45415. protected _getFilenameAndPath(): {
  45416. filename: string;
  45417. path: string;
  45418. };
  45419. protected _updateModel(): void;
  45420. protected _getModelLoadingConstraints(): boolean;
  45421. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45422. }
  45423. }
  45424. declare module BABYLON {
  45425. /**
  45426. * Contains an array of blocks representing the octree
  45427. */
  45428. export interface IOctreeContainer<T> {
  45429. /**
  45430. * Blocks within the octree
  45431. */
  45432. blocks: Array<OctreeBlock<T>>;
  45433. }
  45434. /**
  45435. * Class used to store a cell in an octree
  45436. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45437. */
  45438. export class OctreeBlock<T> {
  45439. /**
  45440. * Gets the content of the current block
  45441. */
  45442. entries: T[];
  45443. /**
  45444. * Gets the list of block children
  45445. */
  45446. blocks: Array<OctreeBlock<T>>;
  45447. private _depth;
  45448. private _maxDepth;
  45449. private _capacity;
  45450. private _minPoint;
  45451. private _maxPoint;
  45452. private _boundingVectors;
  45453. private _creationFunc;
  45454. /**
  45455. * Creates a new block
  45456. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  45457. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  45458. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45459. * @param depth defines the current depth of this block in the octree
  45460. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  45461. * @param creationFunc defines a callback to call when an element is added to the block
  45462. */
  45463. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  45464. /**
  45465. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45466. */
  45467. get capacity(): number;
  45468. /**
  45469. * Gets the minimum vector (in world space) of the block's bounding box
  45470. */
  45471. get minPoint(): Vector3;
  45472. /**
  45473. * Gets the maximum vector (in world space) of the block's bounding box
  45474. */
  45475. get maxPoint(): Vector3;
  45476. /**
  45477. * Add a new element to this block
  45478. * @param entry defines the element to add
  45479. */
  45480. addEntry(entry: T): void;
  45481. /**
  45482. * Remove an element from this block
  45483. * @param entry defines the element to remove
  45484. */
  45485. removeEntry(entry: T): void;
  45486. /**
  45487. * Add an array of elements to this block
  45488. * @param entries defines the array of elements to add
  45489. */
  45490. addEntries(entries: T[]): void;
  45491. /**
  45492. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  45493. * @param frustumPlanes defines the frustum planes to test
  45494. * @param selection defines the array to store current content if selection is positive
  45495. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45496. */
  45497. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45498. /**
  45499. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  45500. * @param sphereCenter defines the bounding sphere center
  45501. * @param sphereRadius defines the bounding sphere radius
  45502. * @param selection defines the array to store current content if selection is positive
  45503. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45504. */
  45505. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45506. /**
  45507. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  45508. * @param ray defines the ray to test with
  45509. * @param selection defines the array to store current content if selection is positive
  45510. */
  45511. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  45512. /**
  45513. * Subdivide the content into child blocks (this block will then be empty)
  45514. */
  45515. createInnerBlocks(): void;
  45516. /**
  45517. * @hidden
  45518. */
  45519. 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;
  45520. }
  45521. }
  45522. declare module BABYLON {
  45523. /**
  45524. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  45525. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45526. */
  45527. export class Octree<T> {
  45528. /** 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.) */
  45529. maxDepth: number;
  45530. /**
  45531. * Blocks within the octree containing objects
  45532. */
  45533. blocks: Array<OctreeBlock<T>>;
  45534. /**
  45535. * Content stored in the octree
  45536. */
  45537. dynamicContent: T[];
  45538. private _maxBlockCapacity;
  45539. private _selectionContent;
  45540. private _creationFunc;
  45541. /**
  45542. * Creates a octree
  45543. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45544. * @param creationFunc function to be used to instatiate the octree
  45545. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  45546. * @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.)
  45547. */
  45548. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  45549. /** 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.) */
  45550. maxDepth?: number);
  45551. /**
  45552. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  45553. * @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);
  45554. * @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);
  45555. * @param entries meshes to be added to the octree blocks
  45556. */
  45557. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  45558. /**
  45559. * Adds a mesh to the octree
  45560. * @param entry Mesh to add to the octree
  45561. */
  45562. addMesh(entry: T): void;
  45563. /**
  45564. * Remove an element from the octree
  45565. * @param entry defines the element to remove
  45566. */
  45567. removeMesh(entry: T): void;
  45568. /**
  45569. * Selects an array of meshes within the frustum
  45570. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  45571. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  45572. * @returns array of meshes within the frustum
  45573. */
  45574. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  45575. /**
  45576. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  45577. * @param sphereCenter defines the bounding sphere center
  45578. * @param sphereRadius defines the bounding sphere radius
  45579. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45580. * @returns an array of objects that intersect the sphere
  45581. */
  45582. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  45583. /**
  45584. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  45585. * @param ray defines the ray to test with
  45586. * @returns array of intersected objects
  45587. */
  45588. intersectsRay(ray: Ray): SmartArray<T>;
  45589. /**
  45590. * Adds a mesh into the octree block if it intersects the block
  45591. */
  45592. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  45593. /**
  45594. * Adds a submesh into the octree block if it intersects the block
  45595. */
  45596. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  45597. }
  45598. }
  45599. declare module BABYLON {
  45600. interface Scene {
  45601. /**
  45602. * @hidden
  45603. * Backing Filed
  45604. */
  45605. _selectionOctree: Octree<AbstractMesh>;
  45606. /**
  45607. * Gets the octree used to boost mesh selection (picking)
  45608. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45609. */
  45610. selectionOctree: Octree<AbstractMesh>;
  45611. /**
  45612. * Creates or updates the octree used to boost selection (picking)
  45613. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45614. * @param maxCapacity defines the maximum capacity per leaf
  45615. * @param maxDepth defines the maximum depth of the octree
  45616. * @returns an octree of AbstractMesh
  45617. */
  45618. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  45619. }
  45620. interface AbstractMesh {
  45621. /**
  45622. * @hidden
  45623. * Backing Field
  45624. */
  45625. _submeshesOctree: Octree<SubMesh>;
  45626. /**
  45627. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  45628. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  45629. * @param maxCapacity defines the maximum size of each block (64 by default)
  45630. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  45631. * @returns the new octree
  45632. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  45633. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45634. */
  45635. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  45636. }
  45637. /**
  45638. * Defines the octree scene component responsible to manage any octrees
  45639. * in a given scene.
  45640. */
  45641. export class OctreeSceneComponent {
  45642. /**
  45643. * The component name help to identify the component in the list of scene components.
  45644. */
  45645. readonly name: string;
  45646. /**
  45647. * The scene the component belongs to.
  45648. */
  45649. scene: Scene;
  45650. /**
  45651. * Indicates if the meshes have been checked to make sure they are isEnabled()
  45652. */
  45653. readonly checksIsEnabled: boolean;
  45654. /**
  45655. * Creates a new instance of the component for the given scene
  45656. * @param scene Defines the scene to register the component in
  45657. */
  45658. constructor(scene: Scene);
  45659. /**
  45660. * Registers the component in a given scene
  45661. */
  45662. register(): void;
  45663. /**
  45664. * Return the list of active meshes
  45665. * @returns the list of active meshes
  45666. */
  45667. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  45668. /**
  45669. * Return the list of active sub meshes
  45670. * @param mesh The mesh to get the candidates sub meshes from
  45671. * @returns the list of active sub meshes
  45672. */
  45673. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  45674. private _tempRay;
  45675. /**
  45676. * Return the list of sub meshes intersecting with a given local ray
  45677. * @param mesh defines the mesh to find the submesh for
  45678. * @param localRay defines the ray in local space
  45679. * @returns the list of intersecting sub meshes
  45680. */
  45681. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  45682. /**
  45683. * Return the list of sub meshes colliding with a collider
  45684. * @param mesh defines the mesh to find the submesh for
  45685. * @param collider defines the collider to evaluate the collision against
  45686. * @returns the list of colliding sub meshes
  45687. */
  45688. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  45689. /**
  45690. * Rebuilds the elements related to this component in case of
  45691. * context lost for instance.
  45692. */
  45693. rebuild(): void;
  45694. /**
  45695. * Disposes the component and the associated ressources.
  45696. */
  45697. dispose(): void;
  45698. }
  45699. }
  45700. declare module BABYLON {
  45701. /**
  45702. * Renders a layer on top of an existing scene
  45703. */
  45704. export class UtilityLayerRenderer implements IDisposable {
  45705. /** the original scene that will be rendered on top of */
  45706. originalScene: Scene;
  45707. private _pointerCaptures;
  45708. private _lastPointerEvents;
  45709. private static _DefaultUtilityLayer;
  45710. private static _DefaultKeepDepthUtilityLayer;
  45711. private _sharedGizmoLight;
  45712. private _renderCamera;
  45713. /**
  45714. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  45715. * @returns the camera that is used when rendering the utility layer
  45716. */
  45717. getRenderCamera(): Nullable<Camera>;
  45718. /**
  45719. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  45720. * @param cam the camera that should be used when rendering the utility layer
  45721. */
  45722. setRenderCamera(cam: Nullable<Camera>): void;
  45723. /**
  45724. * @hidden
  45725. * Light which used by gizmos to get light shading
  45726. */
  45727. _getSharedGizmoLight(): HemisphericLight;
  45728. /**
  45729. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  45730. */
  45731. pickUtilitySceneFirst: boolean;
  45732. /**
  45733. * 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)
  45734. */
  45735. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  45736. /**
  45737. * 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)
  45738. */
  45739. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  45740. /**
  45741. * The scene that is rendered on top of the original scene
  45742. */
  45743. utilityLayerScene: Scene;
  45744. /**
  45745. * If the utility layer should automatically be rendered on top of existing scene
  45746. */
  45747. shouldRender: boolean;
  45748. /**
  45749. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  45750. */
  45751. onlyCheckPointerDownEvents: boolean;
  45752. /**
  45753. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  45754. */
  45755. processAllEvents: boolean;
  45756. /**
  45757. * Observable raised when the pointer move from the utility layer scene to the main scene
  45758. */
  45759. onPointerOutObservable: Observable<number>;
  45760. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  45761. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  45762. private _afterRenderObserver;
  45763. private _sceneDisposeObserver;
  45764. private _originalPointerObserver;
  45765. /**
  45766. * Instantiates a UtilityLayerRenderer
  45767. * @param originalScene the original scene that will be rendered on top of
  45768. * @param handleEvents boolean indicating if the utility layer should handle events
  45769. */
  45770. constructor(
  45771. /** the original scene that will be rendered on top of */
  45772. originalScene: Scene, handleEvents?: boolean);
  45773. private _notifyObservers;
  45774. /**
  45775. * Renders the utility layers scene on top of the original scene
  45776. */
  45777. render(): void;
  45778. /**
  45779. * Disposes of the renderer
  45780. */
  45781. dispose(): void;
  45782. private _updateCamera;
  45783. }
  45784. }
  45785. declare module BABYLON {
  45786. /**
  45787. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  45788. */
  45789. export class Gizmo implements IDisposable {
  45790. /** The utility layer the gizmo will be added to */
  45791. gizmoLayer: UtilityLayerRenderer;
  45792. /**
  45793. * The root mesh of the gizmo
  45794. */
  45795. _rootMesh: Mesh;
  45796. private _attachedMesh;
  45797. /**
  45798. * Ratio for the scale of the gizmo (Default: 1)
  45799. */
  45800. scaleRatio: number;
  45801. /**
  45802. * If a custom mesh has been set (Default: false)
  45803. */
  45804. protected _customMeshSet: boolean;
  45805. /**
  45806. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  45807. * * When set, interactions will be enabled
  45808. */
  45809. get attachedMesh(): Nullable<AbstractMesh>;
  45810. set attachedMesh(value: Nullable<AbstractMesh>);
  45811. /**
  45812. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45813. * @param mesh The mesh to replace the default mesh of the gizmo
  45814. */
  45815. setCustomMesh(mesh: Mesh): void;
  45816. /**
  45817. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  45818. */
  45819. updateGizmoRotationToMatchAttachedMesh: boolean;
  45820. /**
  45821. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  45822. */
  45823. updateGizmoPositionToMatchAttachedMesh: boolean;
  45824. /**
  45825. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  45826. */
  45827. updateScale: boolean;
  45828. protected _interactionsEnabled: boolean;
  45829. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45830. private _beforeRenderObserver;
  45831. private _tempVector;
  45832. /**
  45833. * Creates a gizmo
  45834. * @param gizmoLayer The utility layer the gizmo will be added to
  45835. */
  45836. constructor(
  45837. /** The utility layer the gizmo will be added to */
  45838. gizmoLayer?: UtilityLayerRenderer);
  45839. /**
  45840. * Updates the gizmo to match the attached mesh's position/rotation
  45841. */
  45842. protected _update(): void;
  45843. /**
  45844. * Disposes of the gizmo
  45845. */
  45846. dispose(): void;
  45847. }
  45848. }
  45849. declare module BABYLON {
  45850. /**
  45851. * Single plane drag gizmo
  45852. */
  45853. export class PlaneDragGizmo extends Gizmo {
  45854. /**
  45855. * Drag behavior responsible for the gizmos dragging interactions
  45856. */
  45857. dragBehavior: PointerDragBehavior;
  45858. private _pointerObserver;
  45859. /**
  45860. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45861. */
  45862. snapDistance: number;
  45863. /**
  45864. * Event that fires each time the gizmo snaps to a new location.
  45865. * * snapDistance is the the change in distance
  45866. */
  45867. onSnapObservable: Observable<{
  45868. snapDistance: number;
  45869. }>;
  45870. private _plane;
  45871. private _coloredMaterial;
  45872. private _hoverMaterial;
  45873. private _isEnabled;
  45874. private _parent;
  45875. /** @hidden */
  45876. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  45877. /** @hidden */
  45878. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45879. /**
  45880. * Creates a PlaneDragGizmo
  45881. * @param gizmoLayer The utility layer the gizmo will be added to
  45882. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  45883. * @param color The color of the gizmo
  45884. */
  45885. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45886. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45887. /**
  45888. * If the gizmo is enabled
  45889. */
  45890. set isEnabled(value: boolean);
  45891. get isEnabled(): boolean;
  45892. /**
  45893. * Disposes of the gizmo
  45894. */
  45895. dispose(): void;
  45896. }
  45897. }
  45898. declare module BABYLON {
  45899. /**
  45900. * Gizmo that enables dragging a mesh along 3 axis
  45901. */
  45902. export class PositionGizmo extends Gizmo {
  45903. /**
  45904. * Internal gizmo used for interactions on the x axis
  45905. */
  45906. xGizmo: AxisDragGizmo;
  45907. /**
  45908. * Internal gizmo used for interactions on the y axis
  45909. */
  45910. yGizmo: AxisDragGizmo;
  45911. /**
  45912. * Internal gizmo used for interactions on the z axis
  45913. */
  45914. zGizmo: AxisDragGizmo;
  45915. /**
  45916. * Internal gizmo used for interactions on the yz plane
  45917. */
  45918. xPlaneGizmo: PlaneDragGizmo;
  45919. /**
  45920. * Internal gizmo used for interactions on the xz plane
  45921. */
  45922. yPlaneGizmo: PlaneDragGizmo;
  45923. /**
  45924. * Internal gizmo used for interactions on the xy plane
  45925. */
  45926. zPlaneGizmo: PlaneDragGizmo;
  45927. /**
  45928. * private variables
  45929. */
  45930. private _meshAttached;
  45931. private _updateGizmoRotationToMatchAttachedMesh;
  45932. private _snapDistance;
  45933. private _scaleRatio;
  45934. /** Fires an event when any of it's sub gizmos are dragged */
  45935. onDragStartObservable: Observable<unknown>;
  45936. /** Fires an event when any of it's sub gizmos are released from dragging */
  45937. onDragEndObservable: Observable<unknown>;
  45938. /**
  45939. * If set to true, planar drag is enabled
  45940. */
  45941. private _planarGizmoEnabled;
  45942. get attachedMesh(): Nullable<AbstractMesh>;
  45943. set attachedMesh(mesh: Nullable<AbstractMesh>);
  45944. /**
  45945. * Creates a PositionGizmo
  45946. * @param gizmoLayer The utility layer the gizmo will be added to
  45947. */
  45948. constructor(gizmoLayer?: UtilityLayerRenderer);
  45949. /**
  45950. * If the planar drag gizmo is enabled
  45951. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  45952. */
  45953. set planarGizmoEnabled(value: boolean);
  45954. get planarGizmoEnabled(): boolean;
  45955. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  45956. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  45957. /**
  45958. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45959. */
  45960. set snapDistance(value: number);
  45961. get snapDistance(): number;
  45962. /**
  45963. * Ratio for the scale of the gizmo (Default: 1)
  45964. */
  45965. set scaleRatio(value: number);
  45966. get scaleRatio(): number;
  45967. /**
  45968. * Disposes of the gizmo
  45969. */
  45970. dispose(): void;
  45971. /**
  45972. * CustomMeshes are not supported by this gizmo
  45973. * @param mesh The mesh to replace the default mesh of the gizmo
  45974. */
  45975. setCustomMesh(mesh: Mesh): void;
  45976. }
  45977. }
  45978. declare module BABYLON {
  45979. /**
  45980. * Single axis drag gizmo
  45981. */
  45982. export class AxisDragGizmo extends Gizmo {
  45983. /**
  45984. * Drag behavior responsible for the gizmos dragging interactions
  45985. */
  45986. dragBehavior: PointerDragBehavior;
  45987. private _pointerObserver;
  45988. /**
  45989. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45990. */
  45991. snapDistance: number;
  45992. /**
  45993. * Event that fires each time the gizmo snaps to a new location.
  45994. * * snapDistance is the the change in distance
  45995. */
  45996. onSnapObservable: Observable<{
  45997. snapDistance: number;
  45998. }>;
  45999. private _isEnabled;
  46000. private _parent;
  46001. private _arrow;
  46002. private _coloredMaterial;
  46003. private _hoverMaterial;
  46004. /** @hidden */
  46005. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  46006. /** @hidden */
  46007. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  46008. /**
  46009. * Creates an AxisDragGizmo
  46010. * @param gizmoLayer The utility layer the gizmo will be added to
  46011. * @param dragAxis The axis which the gizmo will be able to drag on
  46012. * @param color The color of the gizmo
  46013. */
  46014. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  46015. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46016. /**
  46017. * If the gizmo is enabled
  46018. */
  46019. set isEnabled(value: boolean);
  46020. get isEnabled(): boolean;
  46021. /**
  46022. * Disposes of the gizmo
  46023. */
  46024. dispose(): void;
  46025. }
  46026. }
  46027. declare module BABYLON.Debug {
  46028. /**
  46029. * The Axes viewer will show 3 axes in a specific point in space
  46030. */
  46031. export class AxesViewer {
  46032. private _xAxis;
  46033. private _yAxis;
  46034. private _zAxis;
  46035. private _scaleLinesFactor;
  46036. private _instanced;
  46037. /**
  46038. * Gets the hosting scene
  46039. */
  46040. scene: Scene;
  46041. /**
  46042. * Gets or sets a number used to scale line length
  46043. */
  46044. scaleLines: number;
  46045. /** Gets the node hierarchy used to render x-axis */
  46046. get xAxis(): TransformNode;
  46047. /** Gets the node hierarchy used to render y-axis */
  46048. get yAxis(): TransformNode;
  46049. /** Gets the node hierarchy used to render z-axis */
  46050. get zAxis(): TransformNode;
  46051. /**
  46052. * Creates a new AxesViewer
  46053. * @param scene defines the hosting scene
  46054. * @param scaleLines defines a number used to scale line length (1 by default)
  46055. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  46056. * @param xAxis defines the node hierarchy used to render the x-axis
  46057. * @param yAxis defines the node hierarchy used to render the y-axis
  46058. * @param zAxis defines the node hierarchy used to render the z-axis
  46059. */
  46060. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  46061. /**
  46062. * Force the viewer to update
  46063. * @param position defines the position of the viewer
  46064. * @param xaxis defines the x axis of the viewer
  46065. * @param yaxis defines the y axis of the viewer
  46066. * @param zaxis defines the z axis of the viewer
  46067. */
  46068. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  46069. /**
  46070. * Creates an instance of this axes viewer.
  46071. * @returns a new axes viewer with instanced meshes
  46072. */
  46073. createInstance(): AxesViewer;
  46074. /** Releases resources */
  46075. dispose(): void;
  46076. private static _SetRenderingGroupId;
  46077. }
  46078. }
  46079. declare module BABYLON.Debug {
  46080. /**
  46081. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  46082. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  46083. */
  46084. export class BoneAxesViewer extends AxesViewer {
  46085. /**
  46086. * Gets or sets the target mesh where to display the axes viewer
  46087. */
  46088. mesh: Nullable<Mesh>;
  46089. /**
  46090. * Gets or sets the target bone where to display the axes viewer
  46091. */
  46092. bone: Nullable<Bone>;
  46093. /** Gets current position */
  46094. pos: Vector3;
  46095. /** Gets direction of X axis */
  46096. xaxis: Vector3;
  46097. /** Gets direction of Y axis */
  46098. yaxis: Vector3;
  46099. /** Gets direction of Z axis */
  46100. zaxis: Vector3;
  46101. /**
  46102. * Creates a new BoneAxesViewer
  46103. * @param scene defines the hosting scene
  46104. * @param bone defines the target bone
  46105. * @param mesh defines the target mesh
  46106. * @param scaleLines defines a scaling factor for line length (1 by default)
  46107. */
  46108. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  46109. /**
  46110. * Force the viewer to update
  46111. */
  46112. update(): void;
  46113. /** Releases resources */
  46114. dispose(): void;
  46115. }
  46116. }
  46117. declare module BABYLON {
  46118. /**
  46119. * Interface used to define scene explorer extensibility option
  46120. */
  46121. export interface IExplorerExtensibilityOption {
  46122. /**
  46123. * Define the option label
  46124. */
  46125. label: string;
  46126. /**
  46127. * Defines the action to execute on click
  46128. */
  46129. action: (entity: any) => void;
  46130. }
  46131. /**
  46132. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  46133. */
  46134. export interface IExplorerExtensibilityGroup {
  46135. /**
  46136. * Defines a predicate to test if a given type mut be extended
  46137. */
  46138. predicate: (entity: any) => boolean;
  46139. /**
  46140. * Gets the list of options added to a type
  46141. */
  46142. entries: IExplorerExtensibilityOption[];
  46143. }
  46144. /**
  46145. * Interface used to define the options to use to create the Inspector
  46146. */
  46147. export interface IInspectorOptions {
  46148. /**
  46149. * Display in overlay mode (default: false)
  46150. */
  46151. overlay?: boolean;
  46152. /**
  46153. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  46154. */
  46155. globalRoot?: HTMLElement;
  46156. /**
  46157. * Display the Scene explorer
  46158. */
  46159. showExplorer?: boolean;
  46160. /**
  46161. * Display the property inspector
  46162. */
  46163. showInspector?: boolean;
  46164. /**
  46165. * Display in embed mode (both panes on the right)
  46166. */
  46167. embedMode?: boolean;
  46168. /**
  46169. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  46170. */
  46171. handleResize?: boolean;
  46172. /**
  46173. * Allow the panes to popup (default: true)
  46174. */
  46175. enablePopup?: boolean;
  46176. /**
  46177. * Allow the panes to be closed by users (default: true)
  46178. */
  46179. enableClose?: boolean;
  46180. /**
  46181. * Optional list of extensibility entries
  46182. */
  46183. explorerExtensibility?: IExplorerExtensibilityGroup[];
  46184. /**
  46185. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  46186. */
  46187. inspectorURL?: string;
  46188. /**
  46189. * Optional initial tab (default to DebugLayerTab.Properties)
  46190. */
  46191. initialTab?: DebugLayerTab;
  46192. }
  46193. interface Scene {
  46194. /**
  46195. * @hidden
  46196. * Backing field
  46197. */
  46198. _debugLayer: DebugLayer;
  46199. /**
  46200. * Gets the debug layer (aka Inspector) associated with the scene
  46201. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46202. */
  46203. debugLayer: DebugLayer;
  46204. }
  46205. /**
  46206. * Enum of inspector action tab
  46207. */
  46208. export enum DebugLayerTab {
  46209. /**
  46210. * Properties tag (default)
  46211. */
  46212. Properties = 0,
  46213. /**
  46214. * Debug tab
  46215. */
  46216. Debug = 1,
  46217. /**
  46218. * Statistics tab
  46219. */
  46220. Statistics = 2,
  46221. /**
  46222. * Tools tab
  46223. */
  46224. Tools = 3,
  46225. /**
  46226. * Settings tab
  46227. */
  46228. Settings = 4
  46229. }
  46230. /**
  46231. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46232. * what is happening in your scene
  46233. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46234. */
  46235. export class DebugLayer {
  46236. /**
  46237. * Define the url to get the inspector script from.
  46238. * By default it uses the babylonjs CDN.
  46239. * @ignoreNaming
  46240. */
  46241. static InspectorURL: string;
  46242. private _scene;
  46243. private BJSINSPECTOR;
  46244. private _onPropertyChangedObservable?;
  46245. /**
  46246. * Observable triggered when a property is changed through the inspector.
  46247. */
  46248. get onPropertyChangedObservable(): any;
  46249. /**
  46250. * Instantiates a new debug layer.
  46251. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46252. * what is happening in your scene
  46253. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46254. * @param scene Defines the scene to inspect
  46255. */
  46256. constructor(scene: Scene);
  46257. /** Creates the inspector window. */
  46258. private _createInspector;
  46259. /**
  46260. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  46261. * @param entity defines the entity to select
  46262. * @param lineContainerTitle defines the specific block to highlight
  46263. */
  46264. select(entity: any, lineContainerTitle?: string): void;
  46265. /** Get the inspector from bundle or global */
  46266. private _getGlobalInspector;
  46267. /**
  46268. * Get if the inspector is visible or not.
  46269. * @returns true if visible otherwise, false
  46270. */
  46271. isVisible(): boolean;
  46272. /**
  46273. * Hide the inspector and close its window.
  46274. */
  46275. hide(): void;
  46276. /**
  46277. * Launch the debugLayer.
  46278. * @param config Define the configuration of the inspector
  46279. * @return a promise fulfilled when the debug layer is visible
  46280. */
  46281. show(config?: IInspectorOptions): Promise<DebugLayer>;
  46282. }
  46283. }
  46284. declare module BABYLON {
  46285. /**
  46286. * Class containing static functions to help procedurally build meshes
  46287. */
  46288. export class BoxBuilder {
  46289. /**
  46290. * Creates a box mesh
  46291. * * The parameter `size` sets the size (float) of each box side (default 1)
  46292. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  46293. * * 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)
  46294. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  46295. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46296. * * 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
  46297. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46298. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  46299. * @param name defines the name of the mesh
  46300. * @param options defines the options used to create the mesh
  46301. * @param scene defines the hosting scene
  46302. * @returns the box mesh
  46303. */
  46304. static CreateBox(name: string, options: {
  46305. size?: number;
  46306. width?: number;
  46307. height?: number;
  46308. depth?: number;
  46309. faceUV?: Vector4[];
  46310. faceColors?: Color4[];
  46311. sideOrientation?: number;
  46312. frontUVs?: Vector4;
  46313. backUVs?: Vector4;
  46314. wrap?: boolean;
  46315. topBaseAt?: number;
  46316. bottomBaseAt?: number;
  46317. updatable?: boolean;
  46318. }, scene?: Nullable<Scene>): Mesh;
  46319. }
  46320. }
  46321. declare module BABYLON {
  46322. /**
  46323. * Class containing static functions to help procedurally build meshes
  46324. */
  46325. export class SphereBuilder {
  46326. /**
  46327. * Creates a sphere mesh
  46328. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  46329. * * 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`)
  46330. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  46331. * * 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
  46332. * * 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)
  46333. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46334. * * 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
  46335. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46336. * @param name defines the name of the mesh
  46337. * @param options defines the options used to create the mesh
  46338. * @param scene defines the hosting scene
  46339. * @returns the sphere mesh
  46340. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  46341. */
  46342. static CreateSphere(name: string, options: {
  46343. segments?: number;
  46344. diameter?: number;
  46345. diameterX?: number;
  46346. diameterY?: number;
  46347. diameterZ?: number;
  46348. arc?: number;
  46349. slice?: number;
  46350. sideOrientation?: number;
  46351. frontUVs?: Vector4;
  46352. backUVs?: Vector4;
  46353. updatable?: boolean;
  46354. }, scene?: Nullable<Scene>): Mesh;
  46355. }
  46356. }
  46357. declare module BABYLON.Debug {
  46358. /**
  46359. * Used to show the physics impostor around the specific mesh
  46360. */
  46361. export class PhysicsViewer {
  46362. /** @hidden */
  46363. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  46364. /** @hidden */
  46365. protected _meshes: Array<Nullable<AbstractMesh>>;
  46366. /** @hidden */
  46367. protected _scene: Nullable<Scene>;
  46368. /** @hidden */
  46369. protected _numMeshes: number;
  46370. /** @hidden */
  46371. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  46372. private _renderFunction;
  46373. private _utilityLayer;
  46374. private _debugBoxMesh;
  46375. private _debugSphereMesh;
  46376. private _debugCylinderMesh;
  46377. private _debugMaterial;
  46378. private _debugMeshMeshes;
  46379. /**
  46380. * Creates a new PhysicsViewer
  46381. * @param scene defines the hosting scene
  46382. */
  46383. constructor(scene: Scene);
  46384. /** @hidden */
  46385. protected _updateDebugMeshes(): void;
  46386. /**
  46387. * Renders a specified physic impostor
  46388. * @param impostor defines the impostor to render
  46389. * @param targetMesh defines the mesh represented by the impostor
  46390. * @returns the new debug mesh used to render the impostor
  46391. */
  46392. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  46393. /**
  46394. * Hides a specified physic impostor
  46395. * @param impostor defines the impostor to hide
  46396. */
  46397. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  46398. private _getDebugMaterial;
  46399. private _getDebugBoxMesh;
  46400. private _getDebugSphereMesh;
  46401. private _getDebugCylinderMesh;
  46402. private _getDebugMeshMesh;
  46403. private _getDebugMesh;
  46404. /** Releases all resources */
  46405. dispose(): void;
  46406. }
  46407. }
  46408. declare module BABYLON {
  46409. /**
  46410. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46411. * in order to better appreciate the issue one might have.
  46412. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46413. */
  46414. export class RayHelper {
  46415. /**
  46416. * Defines the ray we are currently tryin to visualize.
  46417. */
  46418. ray: Nullable<Ray>;
  46419. private _renderPoints;
  46420. private _renderLine;
  46421. private _renderFunction;
  46422. private _scene;
  46423. private _updateToMeshFunction;
  46424. private _attachedToMesh;
  46425. private _meshSpaceDirection;
  46426. private _meshSpaceOrigin;
  46427. /**
  46428. * Helper function to create a colored helper in a scene in one line.
  46429. * @param ray Defines the ray we are currently tryin to visualize
  46430. * @param scene Defines the scene the ray is used in
  46431. * @param color Defines the color we want to see the ray in
  46432. * @returns The newly created ray helper.
  46433. */
  46434. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  46435. /**
  46436. * Instantiate a new ray helper.
  46437. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46438. * in order to better appreciate the issue one might have.
  46439. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46440. * @param ray Defines the ray we are currently tryin to visualize
  46441. */
  46442. constructor(ray: Ray);
  46443. /**
  46444. * Shows the ray we are willing to debug.
  46445. * @param scene Defines the scene the ray needs to be rendered in
  46446. * @param color Defines the color the ray needs to be rendered in
  46447. */
  46448. show(scene: Scene, color?: Color3): void;
  46449. /**
  46450. * Hides the ray we are debugging.
  46451. */
  46452. hide(): void;
  46453. private _render;
  46454. /**
  46455. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  46456. * @param mesh Defines the mesh we want the helper attached to
  46457. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  46458. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  46459. * @param length Defines the length of the ray
  46460. */
  46461. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  46462. /**
  46463. * Detach the ray helper from the mesh it has previously been attached to.
  46464. */
  46465. detachFromMesh(): void;
  46466. private _updateToMesh;
  46467. /**
  46468. * Dispose the helper and release its associated resources.
  46469. */
  46470. dispose(): void;
  46471. }
  46472. }
  46473. declare module BABYLON.Debug {
  46474. /**
  46475. * Class used to render a debug view of a given skeleton
  46476. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  46477. */
  46478. export class SkeletonViewer {
  46479. /** defines the skeleton to render */
  46480. skeleton: Skeleton;
  46481. /** defines the mesh attached to the skeleton */
  46482. mesh: AbstractMesh;
  46483. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46484. autoUpdateBonesMatrices: boolean;
  46485. /** defines the rendering group id to use with the viewer */
  46486. renderingGroupId: number;
  46487. /** Gets or sets the color used to render the skeleton */
  46488. color: Color3;
  46489. private _scene;
  46490. private _debugLines;
  46491. private _debugMesh;
  46492. private _isEnabled;
  46493. private _renderFunction;
  46494. private _utilityLayer;
  46495. /**
  46496. * Returns the mesh used to render the bones
  46497. */
  46498. get debugMesh(): Nullable<LinesMesh>;
  46499. /**
  46500. * Creates a new SkeletonViewer
  46501. * @param skeleton defines the skeleton to render
  46502. * @param mesh defines the mesh attached to the skeleton
  46503. * @param scene defines the hosting scene
  46504. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  46505. * @param renderingGroupId defines the rendering group id to use with the viewer
  46506. */
  46507. constructor(
  46508. /** defines the skeleton to render */
  46509. skeleton: Skeleton,
  46510. /** defines the mesh attached to the skeleton */
  46511. mesh: AbstractMesh, scene: Scene,
  46512. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46513. autoUpdateBonesMatrices?: boolean,
  46514. /** defines the rendering group id to use with the viewer */
  46515. renderingGroupId?: number);
  46516. /** Gets or sets a boolean indicating if the viewer is enabled */
  46517. set isEnabled(value: boolean);
  46518. get isEnabled(): boolean;
  46519. private _getBonePosition;
  46520. private _getLinesForBonesWithLength;
  46521. private _getLinesForBonesNoLength;
  46522. /** Update the viewer to sync with current skeleton state */
  46523. update(): void;
  46524. /** Release associated resources */
  46525. dispose(): void;
  46526. }
  46527. }
  46528. declare module BABYLON {
  46529. /**
  46530. * Options to create the null engine
  46531. */
  46532. export class NullEngineOptions {
  46533. /**
  46534. * Render width (Default: 512)
  46535. */
  46536. renderWidth: number;
  46537. /**
  46538. * Render height (Default: 256)
  46539. */
  46540. renderHeight: number;
  46541. /**
  46542. * Texture size (Default: 512)
  46543. */
  46544. textureSize: number;
  46545. /**
  46546. * If delta time between frames should be constant
  46547. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46548. */
  46549. deterministicLockstep: boolean;
  46550. /**
  46551. * Maximum about of steps between frames (Default: 4)
  46552. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46553. */
  46554. lockstepMaxSteps: number;
  46555. }
  46556. /**
  46557. * The null engine class provides support for headless version of babylon.js.
  46558. * This can be used in server side scenario or for testing purposes
  46559. */
  46560. export class NullEngine extends Engine {
  46561. private _options;
  46562. /**
  46563. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  46564. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46565. * @returns true if engine is in deterministic lock step mode
  46566. */
  46567. isDeterministicLockStep(): boolean;
  46568. /**
  46569. * Gets the max steps when engine is running in deterministic lock step
  46570. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46571. * @returns the max steps
  46572. */
  46573. getLockstepMaxSteps(): number;
  46574. /**
  46575. * Gets the current hardware scaling level.
  46576. * By default the hardware scaling level is computed from the window device ratio.
  46577. * 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.
  46578. * @returns a number indicating the current hardware scaling level
  46579. */
  46580. getHardwareScalingLevel(): number;
  46581. constructor(options?: NullEngineOptions);
  46582. /**
  46583. * Creates a vertex buffer
  46584. * @param vertices the data for the vertex buffer
  46585. * @returns the new WebGL static buffer
  46586. */
  46587. createVertexBuffer(vertices: FloatArray): DataBuffer;
  46588. /**
  46589. * Creates a new index buffer
  46590. * @param indices defines the content of the index buffer
  46591. * @param updatable defines if the index buffer must be updatable
  46592. * @returns a new webGL buffer
  46593. */
  46594. createIndexBuffer(indices: IndicesArray): DataBuffer;
  46595. /**
  46596. * Clear the current render buffer or the current render target (if any is set up)
  46597. * @param color defines the color to use
  46598. * @param backBuffer defines if the back buffer must be cleared
  46599. * @param depth defines if the depth buffer must be cleared
  46600. * @param stencil defines if the stencil buffer must be cleared
  46601. */
  46602. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46603. /**
  46604. * Gets the current render width
  46605. * @param useScreen defines if screen size must be used (or the current render target if any)
  46606. * @returns a number defining the current render width
  46607. */
  46608. getRenderWidth(useScreen?: boolean): number;
  46609. /**
  46610. * Gets the current render height
  46611. * @param useScreen defines if screen size must be used (or the current render target if any)
  46612. * @returns a number defining the current render height
  46613. */
  46614. getRenderHeight(useScreen?: boolean): number;
  46615. /**
  46616. * Set the WebGL's viewport
  46617. * @param viewport defines the viewport element to be used
  46618. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  46619. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  46620. */
  46621. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  46622. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  46623. /**
  46624. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  46625. * @param pipelineContext defines the pipeline context to use
  46626. * @param uniformsNames defines the list of uniform names
  46627. * @returns an array of webGL uniform locations
  46628. */
  46629. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  46630. /**
  46631. * Gets the lsit of active attributes for a given webGL program
  46632. * @param pipelineContext defines the pipeline context to use
  46633. * @param attributesNames defines the list of attribute names to get
  46634. * @returns an array of indices indicating the offset of each attribute
  46635. */
  46636. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46637. /**
  46638. * Binds an effect to the webGL context
  46639. * @param effect defines the effect to bind
  46640. */
  46641. bindSamplers(effect: Effect): void;
  46642. /**
  46643. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  46644. * @param effect defines the effect to activate
  46645. */
  46646. enableEffect(effect: Effect): void;
  46647. /**
  46648. * Set various states to the webGL context
  46649. * @param culling defines backface culling state
  46650. * @param zOffset defines the value to apply to zOffset (0 by default)
  46651. * @param force defines if states must be applied even if cache is up to date
  46652. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  46653. */
  46654. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46655. /**
  46656. * Set the value of an uniform to an array of int32
  46657. * @param uniform defines the webGL uniform location where to store the value
  46658. * @param array defines the array of int32 to store
  46659. */
  46660. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46661. /**
  46662. * Set the value of an uniform to an array of int32 (stored as vec2)
  46663. * @param uniform defines the webGL uniform location where to store the value
  46664. * @param array defines the array of int32 to store
  46665. */
  46666. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46667. /**
  46668. * Set the value of an uniform to an array of int32 (stored as vec3)
  46669. * @param uniform defines the webGL uniform location where to store the value
  46670. * @param array defines the array of int32 to store
  46671. */
  46672. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46673. /**
  46674. * Set the value of an uniform to an array of int32 (stored as vec4)
  46675. * @param uniform defines the webGL uniform location where to store the value
  46676. * @param array defines the array of int32 to store
  46677. */
  46678. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46679. /**
  46680. * Set the value of an uniform to an array of float32
  46681. * @param uniform defines the webGL uniform location where to store the value
  46682. * @param array defines the array of float32 to store
  46683. */
  46684. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46685. /**
  46686. * Set the value of an uniform to an array of float32 (stored as vec2)
  46687. * @param uniform defines the webGL uniform location where to store the value
  46688. * @param array defines the array of float32 to store
  46689. */
  46690. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46691. /**
  46692. * Set the value of an uniform to an array of float32 (stored as vec3)
  46693. * @param uniform defines the webGL uniform location where to store the value
  46694. * @param array defines the array of float32 to store
  46695. */
  46696. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46697. /**
  46698. * Set the value of an uniform to an array of float32 (stored as vec4)
  46699. * @param uniform defines the webGL uniform location where to store the value
  46700. * @param array defines the array of float32 to store
  46701. */
  46702. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46703. /**
  46704. * Set the value of an uniform to an array of number
  46705. * @param uniform defines the webGL uniform location where to store the value
  46706. * @param array defines the array of number to store
  46707. */
  46708. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46709. /**
  46710. * Set the value of an uniform to an array of number (stored as vec2)
  46711. * @param uniform defines the webGL uniform location where to store the value
  46712. * @param array defines the array of number to store
  46713. */
  46714. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46715. /**
  46716. * Set the value of an uniform to an array of number (stored as vec3)
  46717. * @param uniform defines the webGL uniform location where to store the value
  46718. * @param array defines the array of number to store
  46719. */
  46720. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46721. /**
  46722. * Set the value of an uniform to an array of number (stored as vec4)
  46723. * @param uniform defines the webGL uniform location where to store the value
  46724. * @param array defines the array of number to store
  46725. */
  46726. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46727. /**
  46728. * Set the value of an uniform to an array of float32 (stored as matrices)
  46729. * @param uniform defines the webGL uniform location where to store the value
  46730. * @param matrices defines the array of float32 to store
  46731. */
  46732. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46733. /**
  46734. * Set the value of an uniform to a matrix (3x3)
  46735. * @param uniform defines the webGL uniform location where to store the value
  46736. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  46737. */
  46738. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46739. /**
  46740. * Set the value of an uniform to a matrix (2x2)
  46741. * @param uniform defines the webGL uniform location where to store the value
  46742. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  46743. */
  46744. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46745. /**
  46746. * Set the value of an uniform to a number (float)
  46747. * @param uniform defines the webGL uniform location where to store the value
  46748. * @param value defines the float number to store
  46749. */
  46750. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46751. /**
  46752. * Set the value of an uniform to a vec2
  46753. * @param uniform defines the webGL uniform location where to store the value
  46754. * @param x defines the 1st component of the value
  46755. * @param y defines the 2nd component of the value
  46756. */
  46757. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46758. /**
  46759. * Set the value of an uniform to a vec3
  46760. * @param uniform defines the webGL uniform location where to store the value
  46761. * @param x defines the 1st component of the value
  46762. * @param y defines the 2nd component of the value
  46763. * @param z defines the 3rd component of the value
  46764. */
  46765. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46766. /**
  46767. * Set the value of an uniform to a boolean
  46768. * @param uniform defines the webGL uniform location where to store the value
  46769. * @param bool defines the boolean to store
  46770. */
  46771. setBool(uniform: WebGLUniformLocation, bool: number): void;
  46772. /**
  46773. * Set the value of an uniform to a vec4
  46774. * @param uniform defines the webGL uniform location where to store the value
  46775. * @param x defines the 1st component of the value
  46776. * @param y defines the 2nd component of the value
  46777. * @param z defines the 3rd component of the value
  46778. * @param w defines the 4th component of the value
  46779. */
  46780. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46781. /**
  46782. * Sets the current alpha mode
  46783. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  46784. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46785. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46786. */
  46787. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46788. /**
  46789. * Bind webGl buffers directly to the webGL context
  46790. * @param vertexBuffers defines the vertex buffer to bind
  46791. * @param indexBuffer defines the index buffer to bind
  46792. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  46793. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  46794. * @param effect defines the effect associated with the vertex buffer
  46795. */
  46796. bindBuffers(vertexBuffers: {
  46797. [key: string]: VertexBuffer;
  46798. }, indexBuffer: DataBuffer, effect: Effect): void;
  46799. /**
  46800. * Force the entire cache to be cleared
  46801. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  46802. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  46803. */
  46804. wipeCaches(bruteForce?: boolean): void;
  46805. /**
  46806. * Send a draw order
  46807. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  46808. * @param indexStart defines the starting index
  46809. * @param indexCount defines the number of index to draw
  46810. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46811. */
  46812. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  46813. /**
  46814. * Draw a list of indexed primitives
  46815. * @param fillMode defines the primitive to use
  46816. * @param indexStart defines the starting index
  46817. * @param indexCount defines the number of index to draw
  46818. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46819. */
  46820. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46821. /**
  46822. * Draw a list of unindexed primitives
  46823. * @param fillMode defines the primitive to use
  46824. * @param verticesStart defines the index of first vertex to draw
  46825. * @param verticesCount defines the count of vertices to draw
  46826. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46827. */
  46828. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46829. /** @hidden */
  46830. _createTexture(): WebGLTexture;
  46831. /** @hidden */
  46832. _releaseTexture(texture: InternalTexture): void;
  46833. /**
  46834. * Usually called from Texture.ts.
  46835. * Passed information to create a WebGLTexture
  46836. * @param urlArg defines a value which contains one of the following:
  46837. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46838. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46839. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46840. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46841. * @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)
  46842. * @param scene needed for loading to the correct scene
  46843. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  46844. * @param onLoad optional callback to be called upon successful completion
  46845. * @param onError optional callback to be called upon failure
  46846. * @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
  46847. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46848. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46849. * @param forcedExtension defines the extension to use to pick the right loader
  46850. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  46851. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46852. */
  46853. 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;
  46854. /**
  46855. * Creates a new render target texture
  46856. * @param size defines the size of the texture
  46857. * @param options defines the options used to create the texture
  46858. * @returns a new render target texture stored in an InternalTexture
  46859. */
  46860. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46861. /**
  46862. * Update the sampling mode of a given texture
  46863. * @param samplingMode defines the required sampling mode
  46864. * @param texture defines the texture to update
  46865. */
  46866. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46867. /**
  46868. * Binds the frame buffer to the specified texture.
  46869. * @param texture The texture to render to or null for the default canvas
  46870. * @param faceIndex The face of the texture to render to in case of cube texture
  46871. * @param requiredWidth The width of the target to render to
  46872. * @param requiredHeight The height of the target to render to
  46873. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  46874. * @param lodLevel defines le lod level to bind to the frame buffer
  46875. */
  46876. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46877. /**
  46878. * Unbind the current render target texture from the webGL context
  46879. * @param texture defines the render target texture to unbind
  46880. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46881. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46882. */
  46883. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46884. /**
  46885. * Creates a dynamic vertex buffer
  46886. * @param vertices the data for the dynamic vertex buffer
  46887. * @returns the new WebGL dynamic buffer
  46888. */
  46889. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  46890. /**
  46891. * Update the content of a dynamic texture
  46892. * @param texture defines the texture to update
  46893. * @param canvas defines the canvas containing the source
  46894. * @param invertY defines if data must be stored with Y axis inverted
  46895. * @param premulAlpha defines if alpha is stored as premultiplied
  46896. * @param format defines the format of the data
  46897. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  46898. */
  46899. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  46900. /**
  46901. * Gets a boolean indicating if all created effects are ready
  46902. * @returns true if all effects are ready
  46903. */
  46904. areAllEffectsReady(): boolean;
  46905. /**
  46906. * @hidden
  46907. * Get the current error code of the webGL context
  46908. * @returns the error code
  46909. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  46910. */
  46911. getError(): number;
  46912. /** @hidden */
  46913. _getUnpackAlignement(): number;
  46914. /** @hidden */
  46915. _unpackFlipY(value: boolean): void;
  46916. /**
  46917. * Update a dynamic index buffer
  46918. * @param indexBuffer defines the target index buffer
  46919. * @param indices defines the data to update
  46920. * @param offset defines the offset in the target index buffer where update should start
  46921. */
  46922. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  46923. /**
  46924. * Updates a dynamic vertex buffer.
  46925. * @param vertexBuffer the vertex buffer to update
  46926. * @param vertices the data used to update the vertex buffer
  46927. * @param byteOffset the byte offset of the data (optional)
  46928. * @param byteLength the byte length of the data (optional)
  46929. */
  46930. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  46931. /** @hidden */
  46932. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  46933. /** @hidden */
  46934. _bindTexture(channel: number, texture: InternalTexture): void;
  46935. protected _deleteBuffer(buffer: WebGLBuffer): void;
  46936. /**
  46937. * 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
  46938. */
  46939. releaseEffects(): void;
  46940. displayLoadingUI(): void;
  46941. hideLoadingUI(): void;
  46942. /** @hidden */
  46943. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46944. /** @hidden */
  46945. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46946. /** @hidden */
  46947. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46948. /** @hidden */
  46949. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46950. }
  46951. }
  46952. declare module BABYLON {
  46953. /** @hidden */
  46954. export class _OcclusionDataStorage {
  46955. /** @hidden */
  46956. occlusionInternalRetryCounter: number;
  46957. /** @hidden */
  46958. isOcclusionQueryInProgress: boolean;
  46959. /** @hidden */
  46960. isOccluded: boolean;
  46961. /** @hidden */
  46962. occlusionRetryCount: number;
  46963. /** @hidden */
  46964. occlusionType: number;
  46965. /** @hidden */
  46966. occlusionQueryAlgorithmType: number;
  46967. }
  46968. interface Engine {
  46969. /**
  46970. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  46971. * @return the new query
  46972. */
  46973. createQuery(): WebGLQuery;
  46974. /**
  46975. * Delete and release a webGL query
  46976. * @param query defines the query to delete
  46977. * @return the current engine
  46978. */
  46979. deleteQuery(query: WebGLQuery): Engine;
  46980. /**
  46981. * Check if a given query has resolved and got its value
  46982. * @param query defines the query to check
  46983. * @returns true if the query got its value
  46984. */
  46985. isQueryResultAvailable(query: WebGLQuery): boolean;
  46986. /**
  46987. * Gets the value of a given query
  46988. * @param query defines the query to check
  46989. * @returns the value of the query
  46990. */
  46991. getQueryResult(query: WebGLQuery): number;
  46992. /**
  46993. * Initiates an occlusion query
  46994. * @param algorithmType defines the algorithm to use
  46995. * @param query defines the query to use
  46996. * @returns the current engine
  46997. * @see http://doc.babylonjs.com/features/occlusionquery
  46998. */
  46999. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  47000. /**
  47001. * Ends an occlusion query
  47002. * @see http://doc.babylonjs.com/features/occlusionquery
  47003. * @param algorithmType defines the algorithm to use
  47004. * @returns the current engine
  47005. */
  47006. endOcclusionQuery(algorithmType: number): Engine;
  47007. /**
  47008. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  47009. * Please note that only one query can be issued at a time
  47010. * @returns a time token used to track the time span
  47011. */
  47012. startTimeQuery(): Nullable<_TimeToken>;
  47013. /**
  47014. * Ends a time query
  47015. * @param token defines the token used to measure the time span
  47016. * @returns the time spent (in ns)
  47017. */
  47018. endTimeQuery(token: _TimeToken): int;
  47019. /** @hidden */
  47020. _currentNonTimestampToken: Nullable<_TimeToken>;
  47021. /** @hidden */
  47022. _createTimeQuery(): WebGLQuery;
  47023. /** @hidden */
  47024. _deleteTimeQuery(query: WebGLQuery): void;
  47025. /** @hidden */
  47026. _getGlAlgorithmType(algorithmType: number): number;
  47027. /** @hidden */
  47028. _getTimeQueryResult(query: WebGLQuery): any;
  47029. /** @hidden */
  47030. _getTimeQueryAvailability(query: WebGLQuery): any;
  47031. }
  47032. interface AbstractMesh {
  47033. /**
  47034. * Backing filed
  47035. * @hidden
  47036. */
  47037. __occlusionDataStorage: _OcclusionDataStorage;
  47038. /**
  47039. * Access property
  47040. * @hidden
  47041. */
  47042. _occlusionDataStorage: _OcclusionDataStorage;
  47043. /**
  47044. * 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.
  47045. * The default value is -1 which means don't break the query and wait till the result
  47046. * @see http://doc.babylonjs.com/features/occlusionquery
  47047. */
  47048. occlusionRetryCount: number;
  47049. /**
  47050. * 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:
  47051. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  47052. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  47053. * * 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.
  47054. * @see http://doc.babylonjs.com/features/occlusionquery
  47055. */
  47056. occlusionType: number;
  47057. /**
  47058. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  47059. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  47060. * * 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.
  47061. * @see http://doc.babylonjs.com/features/occlusionquery
  47062. */
  47063. occlusionQueryAlgorithmType: number;
  47064. /**
  47065. * 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
  47066. * @see http://doc.babylonjs.com/features/occlusionquery
  47067. */
  47068. isOccluded: boolean;
  47069. /**
  47070. * Flag to check the progress status of the query
  47071. * @see http://doc.babylonjs.com/features/occlusionquery
  47072. */
  47073. isOcclusionQueryInProgress: boolean;
  47074. }
  47075. }
  47076. declare module BABYLON {
  47077. /** @hidden */
  47078. export var _forceTransformFeedbackToBundle: boolean;
  47079. interface Engine {
  47080. /**
  47081. * Creates a webGL transform feedback object
  47082. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  47083. * @returns the webGL transform feedback object
  47084. */
  47085. createTransformFeedback(): WebGLTransformFeedback;
  47086. /**
  47087. * Delete a webGL transform feedback object
  47088. * @param value defines the webGL transform feedback object to delete
  47089. */
  47090. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  47091. /**
  47092. * Bind a webGL transform feedback object to the webgl context
  47093. * @param value defines the webGL transform feedback object to bind
  47094. */
  47095. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  47096. /**
  47097. * Begins a transform feedback operation
  47098. * @param usePoints defines if points or triangles must be used
  47099. */
  47100. beginTransformFeedback(usePoints: boolean): void;
  47101. /**
  47102. * Ends a transform feedback operation
  47103. */
  47104. endTransformFeedback(): void;
  47105. /**
  47106. * Specify the varyings to use with transform feedback
  47107. * @param program defines the associated webGL program
  47108. * @param value defines the list of strings representing the varying names
  47109. */
  47110. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  47111. /**
  47112. * Bind a webGL buffer for a transform feedback operation
  47113. * @param value defines the webGL buffer to bind
  47114. */
  47115. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  47116. }
  47117. }
  47118. declare module BABYLON {
  47119. /**
  47120. * Creation options of the multi render target texture.
  47121. */
  47122. export interface IMultiRenderTargetOptions {
  47123. /**
  47124. * Define if the texture needs to create mip maps after render.
  47125. */
  47126. generateMipMaps?: boolean;
  47127. /**
  47128. * Define the types of all the draw buffers we want to create
  47129. */
  47130. types?: number[];
  47131. /**
  47132. * Define the sampling modes of all the draw buffers we want to create
  47133. */
  47134. samplingModes?: number[];
  47135. /**
  47136. * Define if a depth buffer is required
  47137. */
  47138. generateDepthBuffer?: boolean;
  47139. /**
  47140. * Define if a stencil buffer is required
  47141. */
  47142. generateStencilBuffer?: boolean;
  47143. /**
  47144. * Define if a depth texture is required instead of a depth buffer
  47145. */
  47146. generateDepthTexture?: boolean;
  47147. /**
  47148. * Define the number of desired draw buffers
  47149. */
  47150. textureCount?: number;
  47151. /**
  47152. * Define if aspect ratio should be adapted to the texture or stay the scene one
  47153. */
  47154. doNotChangeAspectRatio?: boolean;
  47155. /**
  47156. * Define the default type of the buffers we are creating
  47157. */
  47158. defaultType?: number;
  47159. }
  47160. /**
  47161. * A multi render target, like a render target provides the ability to render to a texture.
  47162. * Unlike the render target, it can render to several draw buffers in one draw.
  47163. * This is specially interesting in deferred rendering or for any effects requiring more than
  47164. * just one color from a single pass.
  47165. */
  47166. export class MultiRenderTarget extends RenderTargetTexture {
  47167. private _internalTextures;
  47168. private _textures;
  47169. private _multiRenderTargetOptions;
  47170. /**
  47171. * Get if draw buffers are currently supported by the used hardware and browser.
  47172. */
  47173. get isSupported(): boolean;
  47174. /**
  47175. * Get the list of textures generated by the multi render target.
  47176. */
  47177. get textures(): Texture[];
  47178. /**
  47179. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  47180. */
  47181. get depthTexture(): Texture;
  47182. /**
  47183. * Set the wrapping mode on U of all the textures we are rendering to.
  47184. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47185. */
  47186. set wrapU(wrap: number);
  47187. /**
  47188. * Set the wrapping mode on V of all the textures we are rendering to.
  47189. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47190. */
  47191. set wrapV(wrap: number);
  47192. /**
  47193. * Instantiate a new multi render target texture.
  47194. * A multi render target, like a render target provides the ability to render to a texture.
  47195. * Unlike the render target, it can render to several draw buffers in one draw.
  47196. * This is specially interesting in deferred rendering or for any effects requiring more than
  47197. * just one color from a single pass.
  47198. * @param name Define the name of the texture
  47199. * @param size Define the size of the buffers to render to
  47200. * @param count Define the number of target we are rendering into
  47201. * @param scene Define the scene the texture belongs to
  47202. * @param options Define the options used to create the multi render target
  47203. */
  47204. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47205. /** @hidden */
  47206. _rebuild(): void;
  47207. private _createInternalTextures;
  47208. private _createTextures;
  47209. /**
  47210. * Define the number of samples used if MSAA is enabled.
  47211. */
  47212. get samples(): number;
  47213. set samples(value: number);
  47214. /**
  47215. * Resize all the textures in the multi render target.
  47216. * Be carrefull as it will recreate all the data in the new texture.
  47217. * @param size Define the new size
  47218. */
  47219. resize(size: any): void;
  47220. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47221. /**
  47222. * Dispose the render targets and their associated resources
  47223. */
  47224. dispose(): void;
  47225. /**
  47226. * Release all the underlying texture used as draw buffers.
  47227. */
  47228. releaseInternalTextures(): void;
  47229. }
  47230. }
  47231. declare module BABYLON {
  47232. interface ThinEngine {
  47233. /**
  47234. * Unbind a list of render target textures from the webGL context
  47235. * This is used only when drawBuffer extension or webGL2 are active
  47236. * @param textures defines the render target textures to unbind
  47237. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47238. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47239. */
  47240. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  47241. /**
  47242. * Create a multi render target texture
  47243. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  47244. * @param size defines the size of the texture
  47245. * @param options defines the creation options
  47246. * @returns the cube texture as an InternalTexture
  47247. */
  47248. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  47249. /**
  47250. * Update the sample count for a given multiple render target texture
  47251. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  47252. * @param textures defines the textures to update
  47253. * @param samples defines the sample count to set
  47254. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  47255. */
  47256. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  47257. }
  47258. }
  47259. declare module BABYLON {
  47260. /**
  47261. * Class used to define an additional view for the engine
  47262. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47263. */
  47264. export class EngineView {
  47265. /** Defines the canvas where to render the view */
  47266. target: HTMLCanvasElement;
  47267. /** Defines an optional camera used to render the view (will use active camera else) */
  47268. camera?: Camera;
  47269. }
  47270. interface Engine {
  47271. /**
  47272. * Gets or sets the HTML element to use for attaching events
  47273. */
  47274. inputElement: Nullable<HTMLElement>;
  47275. /**
  47276. * Gets the current engine view
  47277. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47278. */
  47279. activeView: Nullable<EngineView>;
  47280. /** Gets or sets the list of views */
  47281. views: EngineView[];
  47282. /**
  47283. * Register a new child canvas
  47284. * @param canvas defines the canvas to register
  47285. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  47286. * @returns the associated view
  47287. */
  47288. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  47289. /**
  47290. * Remove a registered child canvas
  47291. * @param canvas defines the canvas to remove
  47292. * @returns the current engine
  47293. */
  47294. unRegisterView(canvas: HTMLCanvasElement): Engine;
  47295. }
  47296. }
  47297. declare module BABYLON {
  47298. /**
  47299. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  47300. */
  47301. export interface CubeMapInfo {
  47302. /**
  47303. * The pixel array for the front face.
  47304. * This is stored in format, left to right, up to down format.
  47305. */
  47306. front: Nullable<ArrayBufferView>;
  47307. /**
  47308. * The pixel array for the back face.
  47309. * This is stored in format, left to right, up to down format.
  47310. */
  47311. back: Nullable<ArrayBufferView>;
  47312. /**
  47313. * The pixel array for the left face.
  47314. * This is stored in format, left to right, up to down format.
  47315. */
  47316. left: Nullable<ArrayBufferView>;
  47317. /**
  47318. * The pixel array for the right face.
  47319. * This is stored in format, left to right, up to down format.
  47320. */
  47321. right: Nullable<ArrayBufferView>;
  47322. /**
  47323. * The pixel array for the up face.
  47324. * This is stored in format, left to right, up to down format.
  47325. */
  47326. up: Nullable<ArrayBufferView>;
  47327. /**
  47328. * The pixel array for the down face.
  47329. * This is stored in format, left to right, up to down format.
  47330. */
  47331. down: Nullable<ArrayBufferView>;
  47332. /**
  47333. * The size of the cubemap stored.
  47334. *
  47335. * Each faces will be size * size pixels.
  47336. */
  47337. size: number;
  47338. /**
  47339. * The format of the texture.
  47340. *
  47341. * RGBA, RGB.
  47342. */
  47343. format: number;
  47344. /**
  47345. * The type of the texture data.
  47346. *
  47347. * UNSIGNED_INT, FLOAT.
  47348. */
  47349. type: number;
  47350. /**
  47351. * Specifies whether the texture is in gamma space.
  47352. */
  47353. gammaSpace: boolean;
  47354. }
  47355. /**
  47356. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  47357. */
  47358. export class PanoramaToCubeMapTools {
  47359. private static FACE_FRONT;
  47360. private static FACE_BACK;
  47361. private static FACE_RIGHT;
  47362. private static FACE_LEFT;
  47363. private static FACE_DOWN;
  47364. private static FACE_UP;
  47365. /**
  47366. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  47367. *
  47368. * @param float32Array The source data.
  47369. * @param inputWidth The width of the input panorama.
  47370. * @param inputHeight The height of the input panorama.
  47371. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  47372. * @return The cubemap data
  47373. */
  47374. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  47375. private static CreateCubemapTexture;
  47376. private static CalcProjectionSpherical;
  47377. }
  47378. }
  47379. declare module BABYLON {
  47380. /**
  47381. * Helper class dealing with the extraction of spherical polynomial dataArray
  47382. * from a cube map.
  47383. */
  47384. export class CubeMapToSphericalPolynomialTools {
  47385. private static FileFaces;
  47386. /**
  47387. * Converts a texture to the according Spherical Polynomial data.
  47388. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47389. *
  47390. * @param texture The texture to extract the information from.
  47391. * @return The Spherical Polynomial data.
  47392. */
  47393. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  47394. /**
  47395. * Converts a cubemap to the according Spherical Polynomial data.
  47396. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47397. *
  47398. * @param cubeInfo The Cube map to extract the information from.
  47399. * @return The Spherical Polynomial data.
  47400. */
  47401. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  47402. }
  47403. }
  47404. declare module BABYLON {
  47405. interface BaseTexture {
  47406. /**
  47407. * Get the polynomial representation of the texture data.
  47408. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  47409. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  47410. */
  47411. sphericalPolynomial: Nullable<SphericalPolynomial>;
  47412. }
  47413. }
  47414. declare module BABYLON {
  47415. /** @hidden */
  47416. export var rgbdEncodePixelShader: {
  47417. name: string;
  47418. shader: string;
  47419. };
  47420. }
  47421. declare module BABYLON {
  47422. /** @hidden */
  47423. export var rgbdDecodePixelShader: {
  47424. name: string;
  47425. shader: string;
  47426. };
  47427. }
  47428. declare module BABYLON {
  47429. /**
  47430. * Raw texture data and descriptor sufficient for WebGL texture upload
  47431. */
  47432. export interface EnvironmentTextureInfo {
  47433. /**
  47434. * Version of the environment map
  47435. */
  47436. version: number;
  47437. /**
  47438. * Width of image
  47439. */
  47440. width: number;
  47441. /**
  47442. * Irradiance information stored in the file.
  47443. */
  47444. irradiance: any;
  47445. /**
  47446. * Specular information stored in the file.
  47447. */
  47448. specular: any;
  47449. }
  47450. /**
  47451. * Defines One Image in the file. It requires only the position in the file
  47452. * as well as the length.
  47453. */
  47454. interface BufferImageData {
  47455. /**
  47456. * Length of the image data.
  47457. */
  47458. length: number;
  47459. /**
  47460. * Position of the data from the null terminator delimiting the end of the JSON.
  47461. */
  47462. position: number;
  47463. }
  47464. /**
  47465. * Defines the specular data enclosed in the file.
  47466. * This corresponds to the version 1 of the data.
  47467. */
  47468. export interface EnvironmentTextureSpecularInfoV1 {
  47469. /**
  47470. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  47471. */
  47472. specularDataPosition?: number;
  47473. /**
  47474. * This contains all the images data needed to reconstruct the cubemap.
  47475. */
  47476. mipmaps: Array<BufferImageData>;
  47477. /**
  47478. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  47479. */
  47480. lodGenerationScale: number;
  47481. }
  47482. /**
  47483. * Sets of helpers addressing the serialization and deserialization of environment texture
  47484. * stored in a BabylonJS env file.
  47485. * Those files are usually stored as .env files.
  47486. */
  47487. export class EnvironmentTextureTools {
  47488. /**
  47489. * Magic number identifying the env file.
  47490. */
  47491. private static _MagicBytes;
  47492. /**
  47493. * Gets the environment info from an env file.
  47494. * @param data The array buffer containing the .env bytes.
  47495. * @returns the environment file info (the json header) if successfully parsed.
  47496. */
  47497. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  47498. /**
  47499. * Creates an environment texture from a loaded cube texture.
  47500. * @param texture defines the cube texture to convert in env file
  47501. * @return a promise containing the environment data if succesfull.
  47502. */
  47503. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47504. /**
  47505. * Creates a JSON representation of the spherical data.
  47506. * @param texture defines the texture containing the polynomials
  47507. * @return the JSON representation of the spherical info
  47508. */
  47509. private static _CreateEnvTextureIrradiance;
  47510. /**
  47511. * Creates the ArrayBufferViews used for initializing environment texture image data.
  47512. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  47513. * @param info parameters that determine what views will be created for accessing the underlying buffer
  47514. * @return the views described by info providing access to the underlying buffer
  47515. */
  47516. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  47517. /**
  47518. * Uploads the texture info contained in the env file to the GPU.
  47519. * @param texture defines the internal texture to upload to
  47520. * @param arrayBuffer defines the buffer cotaining the data to load
  47521. * @param info defines the texture info retrieved through the GetEnvInfo method
  47522. * @returns a promise
  47523. */
  47524. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  47525. private static _OnImageReadyAsync;
  47526. /**
  47527. * Uploads the levels of image data to the GPU.
  47528. * @param texture defines the internal texture to upload to
  47529. * @param imageData defines the array buffer views of image data [mipmap][face]
  47530. * @returns a promise
  47531. */
  47532. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47533. /**
  47534. * Uploads spherical polynomials information to the texture.
  47535. * @param texture defines the texture we are trying to upload the information to
  47536. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47537. */
  47538. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47539. /** @hidden */
  47540. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47541. }
  47542. }
  47543. declare module BABYLON {
  47544. /**
  47545. * Contains position and normal vectors for a vertex
  47546. */
  47547. export class PositionNormalVertex {
  47548. /** the position of the vertex (defaut: 0,0,0) */
  47549. position: Vector3;
  47550. /** the normal of the vertex (defaut: 0,1,0) */
  47551. normal: Vector3;
  47552. /**
  47553. * Creates a PositionNormalVertex
  47554. * @param position the position of the vertex (defaut: 0,0,0)
  47555. * @param normal the normal of the vertex (defaut: 0,1,0)
  47556. */
  47557. constructor(
  47558. /** the position of the vertex (defaut: 0,0,0) */
  47559. position?: Vector3,
  47560. /** the normal of the vertex (defaut: 0,1,0) */
  47561. normal?: Vector3);
  47562. /**
  47563. * Clones the PositionNormalVertex
  47564. * @returns the cloned PositionNormalVertex
  47565. */
  47566. clone(): PositionNormalVertex;
  47567. }
  47568. /**
  47569. * Contains position, normal and uv vectors for a vertex
  47570. */
  47571. export class PositionNormalTextureVertex {
  47572. /** the position of the vertex (defaut: 0,0,0) */
  47573. position: Vector3;
  47574. /** the normal of the vertex (defaut: 0,1,0) */
  47575. normal: Vector3;
  47576. /** the uv of the vertex (default: 0,0) */
  47577. uv: Vector2;
  47578. /**
  47579. * Creates a PositionNormalTextureVertex
  47580. * @param position the position of the vertex (defaut: 0,0,0)
  47581. * @param normal the normal of the vertex (defaut: 0,1,0)
  47582. * @param uv the uv of the vertex (default: 0,0)
  47583. */
  47584. constructor(
  47585. /** the position of the vertex (defaut: 0,0,0) */
  47586. position?: Vector3,
  47587. /** the normal of the vertex (defaut: 0,1,0) */
  47588. normal?: Vector3,
  47589. /** the uv of the vertex (default: 0,0) */
  47590. uv?: Vector2);
  47591. /**
  47592. * Clones the PositionNormalTextureVertex
  47593. * @returns the cloned PositionNormalTextureVertex
  47594. */
  47595. clone(): PositionNormalTextureVertex;
  47596. }
  47597. }
  47598. declare module BABYLON {
  47599. /** @hidden */
  47600. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  47601. private _genericAttributeLocation;
  47602. private _varyingLocationCount;
  47603. private _varyingLocationMap;
  47604. private _replacements;
  47605. private _textureCount;
  47606. private _uniforms;
  47607. lineProcessor(line: string): string;
  47608. attributeProcessor(attribute: string): string;
  47609. varyingProcessor(varying: string, isFragment: boolean): string;
  47610. uniformProcessor(uniform: string): string;
  47611. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  47612. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  47613. }
  47614. }
  47615. declare module BABYLON {
  47616. /**
  47617. * Container for accessors for natively-stored mesh data buffers.
  47618. */
  47619. class NativeDataBuffer extends DataBuffer {
  47620. /**
  47621. * Accessor value used to identify/retrieve a natively-stored index buffer.
  47622. */
  47623. nativeIndexBuffer?: any;
  47624. /**
  47625. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  47626. */
  47627. nativeVertexBuffer?: any;
  47628. }
  47629. /** @hidden */
  47630. class NativeTexture extends InternalTexture {
  47631. getInternalTexture(): InternalTexture;
  47632. getViewCount(): number;
  47633. }
  47634. /** @hidden */
  47635. export class NativeEngine extends Engine {
  47636. private readonly _native;
  47637. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  47638. private readonly INVALID_HANDLE;
  47639. getHardwareScalingLevel(): number;
  47640. constructor();
  47641. /**
  47642. * Can be used to override the current requestAnimationFrame requester.
  47643. * @hidden
  47644. */
  47645. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  47646. /**
  47647. * Override default engine behavior.
  47648. * @param color
  47649. * @param backBuffer
  47650. * @param depth
  47651. * @param stencil
  47652. */
  47653. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  47654. /**
  47655. * Gets host document
  47656. * @returns the host document object
  47657. */
  47658. getHostDocument(): Nullable<Document>;
  47659. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  47660. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  47661. createVertexBuffer(data: DataArray): NativeDataBuffer;
  47662. recordVertexArrayObject(vertexBuffers: {
  47663. [key: string]: VertexBuffer;
  47664. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  47665. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47666. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47667. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  47668. /**
  47669. * Draw a list of indexed primitives
  47670. * @param fillMode defines the primitive to use
  47671. * @param indexStart defines the starting index
  47672. * @param indexCount defines the number of index to draw
  47673. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47674. */
  47675. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47676. /**
  47677. * Draw a list of unindexed primitives
  47678. * @param fillMode defines the primitive to use
  47679. * @param verticesStart defines the index of first vertex to draw
  47680. * @param verticesCount defines the count of vertices to draw
  47681. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47682. */
  47683. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47684. createPipelineContext(): IPipelineContext;
  47685. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  47686. /** @hidden */
  47687. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  47688. /** @hidden */
  47689. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  47690. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47691. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47692. protected _setProgram(program: WebGLProgram): void;
  47693. _releaseEffect(effect: Effect): void;
  47694. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  47695. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  47696. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  47697. bindSamplers(effect: Effect): void;
  47698. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  47699. getRenderWidth(useScreen?: boolean): number;
  47700. getRenderHeight(useScreen?: boolean): number;
  47701. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  47702. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47703. /**
  47704. * Set the z offset to apply to current rendering
  47705. * @param value defines the offset to apply
  47706. */
  47707. setZOffset(value: number): void;
  47708. /**
  47709. * Gets the current value of the zOffset
  47710. * @returns the current zOffset state
  47711. */
  47712. getZOffset(): number;
  47713. /**
  47714. * Enable or disable depth buffering
  47715. * @param enable defines the state to set
  47716. */
  47717. setDepthBuffer(enable: boolean): void;
  47718. /**
  47719. * Gets a boolean indicating if depth writing is enabled
  47720. * @returns the current depth writing state
  47721. */
  47722. getDepthWrite(): boolean;
  47723. /**
  47724. * Enable or disable depth writing
  47725. * @param enable defines the state to set
  47726. */
  47727. setDepthWrite(enable: boolean): void;
  47728. /**
  47729. * Enable or disable color writing
  47730. * @param enable defines the state to set
  47731. */
  47732. setColorWrite(enable: boolean): void;
  47733. /**
  47734. * Gets a boolean indicating if color writing is enabled
  47735. * @returns the current color writing state
  47736. */
  47737. getColorWrite(): boolean;
  47738. /**
  47739. * Sets alpha constants used by some alpha blending modes
  47740. * @param r defines the red component
  47741. * @param g defines the green component
  47742. * @param b defines the blue component
  47743. * @param a defines the alpha component
  47744. */
  47745. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  47746. /**
  47747. * Sets the current alpha mode
  47748. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  47749. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47750. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47751. */
  47752. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47753. /**
  47754. * Gets the current alpha mode
  47755. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47756. * @returns the current alpha mode
  47757. */
  47758. getAlphaMode(): number;
  47759. setInt(uniform: WebGLUniformLocation, int: number): void;
  47760. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  47761. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  47762. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  47763. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  47764. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  47765. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  47766. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47767. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47768. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47769. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47770. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47771. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47772. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47773. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47774. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47775. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47776. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47777. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47778. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47779. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  47780. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  47781. wipeCaches(bruteForce?: boolean): void;
  47782. _createTexture(): WebGLTexture;
  47783. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  47784. /**
  47785. * Usually called from BABYLON.Texture.ts.
  47786. * Passed information to create a WebGLTexture
  47787. * @param urlArg defines a value which contains one of the following:
  47788. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47789. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47790. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47791. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47792. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  47793. * @param scene needed for loading to the correct scene
  47794. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  47795. * @param onLoad optional callback to be called upon successful completion
  47796. * @param onError optional callback to be called upon failure
  47797. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  47798. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47799. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47800. * @param forcedExtension defines the extension to use to pick the right loader
  47801. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47802. */
  47803. 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;
  47804. /**
  47805. * Creates a cube texture
  47806. * @param rootUrl defines the url where the files to load is located
  47807. * @param scene defines the current scene
  47808. * @param files defines the list of files to load (1 per face)
  47809. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  47810. * @param onLoad defines an optional callback raised when the texture is loaded
  47811. * @param onError defines an optional callback raised if there is an issue to load the texture
  47812. * @param format defines the format of the data
  47813. * @param forcedExtension defines the extension to use to pick the right loader
  47814. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  47815. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  47816. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  47817. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  47818. * @returns the cube texture as an InternalTexture
  47819. */
  47820. 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;
  47821. private _getSamplingFilter;
  47822. private static _GetNativeTextureFormat;
  47823. createRenderTargetTexture(size: number | {
  47824. width: number;
  47825. height: number;
  47826. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  47827. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47828. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47829. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47830. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  47831. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  47832. /**
  47833. * Updates a dynamic vertex buffer.
  47834. * @param vertexBuffer the vertex buffer to update
  47835. * @param data the data used to update the vertex buffer
  47836. * @param byteOffset the byte offset of the data (optional)
  47837. * @param byteLength the byte length of the data (optional)
  47838. */
  47839. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  47840. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  47841. private _updateAnisotropicLevel;
  47842. private _getAddressMode;
  47843. /** @hidden */
  47844. _bindTexture(channel: number, texture: InternalTexture): void;
  47845. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  47846. releaseEffects(): void;
  47847. /** @hidden */
  47848. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47849. /** @hidden */
  47850. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47851. /** @hidden */
  47852. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47853. /** @hidden */
  47854. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47855. }
  47856. }
  47857. declare module BABYLON {
  47858. /**
  47859. * Gather the list of clipboard event types as constants.
  47860. */
  47861. export class ClipboardEventTypes {
  47862. /**
  47863. * The clipboard event is fired when a copy command is active (pressed).
  47864. */
  47865. static readonly COPY: number;
  47866. /**
  47867. * The clipboard event is fired when a cut command is active (pressed).
  47868. */
  47869. static readonly CUT: number;
  47870. /**
  47871. * The clipboard event is fired when a paste command is active (pressed).
  47872. */
  47873. static readonly PASTE: number;
  47874. }
  47875. /**
  47876. * This class is used to store clipboard related info for the onClipboardObservable event.
  47877. */
  47878. export class ClipboardInfo {
  47879. /**
  47880. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47881. */
  47882. type: number;
  47883. /**
  47884. * Defines the related dom event
  47885. */
  47886. event: ClipboardEvent;
  47887. /**
  47888. *Creates an instance of ClipboardInfo.
  47889. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  47890. * @param event Defines the related dom event
  47891. */
  47892. constructor(
  47893. /**
  47894. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47895. */
  47896. type: number,
  47897. /**
  47898. * Defines the related dom event
  47899. */
  47900. event: ClipboardEvent);
  47901. /**
  47902. * Get the clipboard event's type from the keycode.
  47903. * @param keyCode Defines the keyCode for the current keyboard event.
  47904. * @return {number}
  47905. */
  47906. static GetTypeFromCharacter(keyCode: number): number;
  47907. }
  47908. }
  47909. declare module BABYLON {
  47910. /**
  47911. * Google Daydream controller
  47912. */
  47913. export class DaydreamController extends WebVRController {
  47914. /**
  47915. * Base Url for the controller model.
  47916. */
  47917. static MODEL_BASE_URL: string;
  47918. /**
  47919. * File name for the controller model.
  47920. */
  47921. static MODEL_FILENAME: string;
  47922. /**
  47923. * Gamepad Id prefix used to identify Daydream Controller.
  47924. */
  47925. static readonly GAMEPAD_ID_PREFIX: string;
  47926. /**
  47927. * Creates a new DaydreamController from a gamepad
  47928. * @param vrGamepad the gamepad that the controller should be created from
  47929. */
  47930. constructor(vrGamepad: any);
  47931. /**
  47932. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47933. * @param scene scene in which to add meshes
  47934. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47935. */
  47936. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47937. /**
  47938. * Called once for each button that changed state since the last frame
  47939. * @param buttonIdx Which button index changed
  47940. * @param state New state of the button
  47941. * @param changes Which properties on the state changed since last frame
  47942. */
  47943. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47944. }
  47945. }
  47946. declare module BABYLON {
  47947. /**
  47948. * Gear VR Controller
  47949. */
  47950. export class GearVRController extends WebVRController {
  47951. /**
  47952. * Base Url for the controller model.
  47953. */
  47954. static MODEL_BASE_URL: string;
  47955. /**
  47956. * File name for the controller model.
  47957. */
  47958. static MODEL_FILENAME: string;
  47959. /**
  47960. * Gamepad Id prefix used to identify this controller.
  47961. */
  47962. static readonly GAMEPAD_ID_PREFIX: string;
  47963. private readonly _buttonIndexToObservableNameMap;
  47964. /**
  47965. * Creates a new GearVRController from a gamepad
  47966. * @param vrGamepad the gamepad that the controller should be created from
  47967. */
  47968. constructor(vrGamepad: any);
  47969. /**
  47970. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47971. * @param scene scene in which to add meshes
  47972. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47973. */
  47974. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47975. /**
  47976. * Called once for each button that changed state since the last frame
  47977. * @param buttonIdx Which button index changed
  47978. * @param state New state of the button
  47979. * @param changes Which properties on the state changed since last frame
  47980. */
  47981. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47982. }
  47983. }
  47984. declare module BABYLON {
  47985. /**
  47986. * Generic Controller
  47987. */
  47988. export class GenericController extends WebVRController {
  47989. /**
  47990. * Base Url for the controller model.
  47991. */
  47992. static readonly MODEL_BASE_URL: string;
  47993. /**
  47994. * File name for the controller model.
  47995. */
  47996. static readonly MODEL_FILENAME: string;
  47997. /**
  47998. * Creates a new GenericController from a gamepad
  47999. * @param vrGamepad the gamepad that the controller should be created from
  48000. */
  48001. constructor(vrGamepad: any);
  48002. /**
  48003. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48004. * @param scene scene in which to add meshes
  48005. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48006. */
  48007. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48008. /**
  48009. * Called once for each button that changed state since the last frame
  48010. * @param buttonIdx Which button index changed
  48011. * @param state New state of the button
  48012. * @param changes Which properties on the state changed since last frame
  48013. */
  48014. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48015. }
  48016. }
  48017. declare module BABYLON {
  48018. /**
  48019. * Oculus Touch Controller
  48020. */
  48021. export class OculusTouchController extends WebVRController {
  48022. /**
  48023. * Base Url for the controller model.
  48024. */
  48025. static MODEL_BASE_URL: string;
  48026. /**
  48027. * File name for the left controller model.
  48028. */
  48029. static MODEL_LEFT_FILENAME: string;
  48030. /**
  48031. * File name for the right controller model.
  48032. */
  48033. static MODEL_RIGHT_FILENAME: string;
  48034. /**
  48035. * Base Url for the Quest controller model.
  48036. */
  48037. static QUEST_MODEL_BASE_URL: string;
  48038. /**
  48039. * @hidden
  48040. * If the controllers are running on a device that needs the updated Quest controller models
  48041. */
  48042. static _IsQuest: boolean;
  48043. /**
  48044. * Fired when the secondary trigger on this controller is modified
  48045. */
  48046. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  48047. /**
  48048. * Fired when the thumb rest on this controller is modified
  48049. */
  48050. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  48051. /**
  48052. * Creates a new OculusTouchController from a gamepad
  48053. * @param vrGamepad the gamepad that the controller should be created from
  48054. */
  48055. constructor(vrGamepad: any);
  48056. /**
  48057. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48058. * @param scene scene in which to add meshes
  48059. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48060. */
  48061. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48062. /**
  48063. * Fired when the A button on this controller is modified
  48064. */
  48065. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48066. /**
  48067. * Fired when the B button on this controller is modified
  48068. */
  48069. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48070. /**
  48071. * Fired when the X button on this controller is modified
  48072. */
  48073. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48074. /**
  48075. * Fired when the Y button on this controller is modified
  48076. */
  48077. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48078. /**
  48079. * Called once for each button that changed state since the last frame
  48080. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  48081. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  48082. * 2) secondary trigger (same)
  48083. * 3) A (right) X (left), touch, pressed = value
  48084. * 4) B / Y
  48085. * 5) thumb rest
  48086. * @param buttonIdx Which button index changed
  48087. * @param state New state of the button
  48088. * @param changes Which properties on the state changed since last frame
  48089. */
  48090. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48091. }
  48092. }
  48093. declare module BABYLON {
  48094. /**
  48095. * Vive Controller
  48096. */
  48097. export class ViveController extends WebVRController {
  48098. /**
  48099. * Base Url for the controller model.
  48100. */
  48101. static MODEL_BASE_URL: string;
  48102. /**
  48103. * File name for the controller model.
  48104. */
  48105. static MODEL_FILENAME: string;
  48106. /**
  48107. * Creates a new ViveController from a gamepad
  48108. * @param vrGamepad the gamepad that the controller should be created from
  48109. */
  48110. constructor(vrGamepad: any);
  48111. /**
  48112. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48113. * @param scene scene in which to add meshes
  48114. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48115. */
  48116. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  48117. /**
  48118. * Fired when the left button on this controller is modified
  48119. */
  48120. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48121. /**
  48122. * Fired when the right button on this controller is modified
  48123. */
  48124. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48125. /**
  48126. * Fired when the menu button on this controller is modified
  48127. */
  48128. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48129. /**
  48130. * Called once for each button that changed state since the last frame
  48131. * Vive mapping:
  48132. * 0: touchpad
  48133. * 1: trigger
  48134. * 2: left AND right buttons
  48135. * 3: menu button
  48136. * @param buttonIdx Which button index changed
  48137. * @param state New state of the button
  48138. * @param changes Which properties on the state changed since last frame
  48139. */
  48140. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48141. }
  48142. }
  48143. declare module BABYLON {
  48144. /**
  48145. * Defines the WindowsMotionController object that the state of the windows motion controller
  48146. */
  48147. export class WindowsMotionController extends WebVRController {
  48148. /**
  48149. * The base url used to load the left and right controller models
  48150. */
  48151. static MODEL_BASE_URL: string;
  48152. /**
  48153. * The name of the left controller model file
  48154. */
  48155. static MODEL_LEFT_FILENAME: string;
  48156. /**
  48157. * The name of the right controller model file
  48158. */
  48159. static MODEL_RIGHT_FILENAME: string;
  48160. /**
  48161. * The controller name prefix for this controller type
  48162. */
  48163. static readonly GAMEPAD_ID_PREFIX: string;
  48164. /**
  48165. * The controller id pattern for this controller type
  48166. */
  48167. private static readonly GAMEPAD_ID_PATTERN;
  48168. private _loadedMeshInfo;
  48169. protected readonly _mapping: {
  48170. buttons: string[];
  48171. buttonMeshNames: {
  48172. 'trigger': string;
  48173. 'menu': string;
  48174. 'grip': string;
  48175. 'thumbstick': string;
  48176. 'trackpad': string;
  48177. };
  48178. buttonObservableNames: {
  48179. 'trigger': string;
  48180. 'menu': string;
  48181. 'grip': string;
  48182. 'thumbstick': string;
  48183. 'trackpad': string;
  48184. };
  48185. axisMeshNames: string[];
  48186. pointingPoseMeshName: string;
  48187. };
  48188. /**
  48189. * Fired when the trackpad on this controller is clicked
  48190. */
  48191. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48192. /**
  48193. * Fired when the trackpad on this controller is modified
  48194. */
  48195. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48196. /**
  48197. * The current x and y values of this controller's trackpad
  48198. */
  48199. trackpad: StickValues;
  48200. /**
  48201. * Creates a new WindowsMotionController from a gamepad
  48202. * @param vrGamepad the gamepad that the controller should be created from
  48203. */
  48204. constructor(vrGamepad: any);
  48205. /**
  48206. * Fired when the trigger on this controller is modified
  48207. */
  48208. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48209. /**
  48210. * Fired when the menu button on this controller is modified
  48211. */
  48212. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48213. /**
  48214. * Fired when the grip button on this controller is modified
  48215. */
  48216. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48217. /**
  48218. * Fired when the thumbstick button on this controller is modified
  48219. */
  48220. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48221. /**
  48222. * Fired when the touchpad button on this controller is modified
  48223. */
  48224. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48225. /**
  48226. * Fired when the touchpad values on this controller are modified
  48227. */
  48228. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  48229. protected _updateTrackpad(): void;
  48230. /**
  48231. * Called once per frame by the engine.
  48232. */
  48233. update(): void;
  48234. /**
  48235. * Called once for each button that changed state since the last frame
  48236. * @param buttonIdx Which button index changed
  48237. * @param state New state of the button
  48238. * @param changes Which properties on the state changed since last frame
  48239. */
  48240. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48241. /**
  48242. * Moves the buttons on the controller mesh based on their current state
  48243. * @param buttonName the name of the button to move
  48244. * @param buttonValue the value of the button which determines the buttons new position
  48245. */
  48246. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  48247. /**
  48248. * Moves the axis on the controller mesh based on its current state
  48249. * @param axis the index of the axis
  48250. * @param axisValue the value of the axis which determines the meshes new position
  48251. * @hidden
  48252. */
  48253. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  48254. /**
  48255. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48256. * @param scene scene in which to add meshes
  48257. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48258. */
  48259. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  48260. /**
  48261. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  48262. * can be transformed by button presses and axes values, based on this._mapping.
  48263. *
  48264. * @param scene scene in which the meshes exist
  48265. * @param meshes list of meshes that make up the controller model to process
  48266. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  48267. */
  48268. private processModel;
  48269. private createMeshInfo;
  48270. /**
  48271. * Gets the ray of the controller in the direction the controller is pointing
  48272. * @param length the length the resulting ray should be
  48273. * @returns a ray in the direction the controller is pointing
  48274. */
  48275. getForwardRay(length?: number): Ray;
  48276. /**
  48277. * Disposes of the controller
  48278. */
  48279. dispose(): void;
  48280. }
  48281. /**
  48282. * This class represents a new windows motion controller in XR.
  48283. */
  48284. export class XRWindowsMotionController extends WindowsMotionController {
  48285. /**
  48286. * Changing the original WIndowsMotionController mapping to fir the new mapping
  48287. */
  48288. protected readonly _mapping: {
  48289. buttons: string[];
  48290. buttonMeshNames: {
  48291. 'trigger': string;
  48292. 'menu': string;
  48293. 'grip': string;
  48294. 'thumbstick': string;
  48295. 'trackpad': string;
  48296. };
  48297. buttonObservableNames: {
  48298. 'trigger': string;
  48299. 'menu': string;
  48300. 'grip': string;
  48301. 'thumbstick': string;
  48302. 'trackpad': string;
  48303. };
  48304. axisMeshNames: string[];
  48305. pointingPoseMeshName: string;
  48306. };
  48307. /**
  48308. * Construct a new XR-Based windows motion controller
  48309. *
  48310. * @param gamepadInfo the gamepad object from the browser
  48311. */
  48312. constructor(gamepadInfo: any);
  48313. /**
  48314. * holds the thumbstick values (X,Y)
  48315. */
  48316. thumbstickValues: StickValues;
  48317. /**
  48318. * Fired when the thumbstick on this controller is clicked
  48319. */
  48320. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  48321. /**
  48322. * Fired when the thumbstick on this controller is modified
  48323. */
  48324. onThumbstickValuesChangedObservable: Observable<StickValues>;
  48325. /**
  48326. * Fired when the touchpad button on this controller is modified
  48327. */
  48328. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48329. /**
  48330. * Fired when the touchpad values on this controller are modified
  48331. */
  48332. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48333. /**
  48334. * Fired when the thumbstick button on this controller is modified
  48335. * here to prevent breaking changes
  48336. */
  48337. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48338. /**
  48339. * updating the thumbstick(!) and not the trackpad.
  48340. * This is named this way due to the difference between WebVR and XR and to avoid
  48341. * changing the parent class.
  48342. */
  48343. protected _updateTrackpad(): void;
  48344. /**
  48345. * Disposes the class with joy
  48346. */
  48347. dispose(): void;
  48348. }
  48349. }
  48350. declare module BABYLON {
  48351. /**
  48352. * Class containing static functions to help procedurally build meshes
  48353. */
  48354. export class PolyhedronBuilder {
  48355. /**
  48356. * Creates a polyhedron mesh
  48357. * * 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
  48358. * * The parameter `size` (positive float, default 1) sets the polygon size
  48359. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  48360. * * 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`
  48361. * * 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
  48362. * * 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)`)
  48363. * * 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
  48364. * * 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
  48365. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48366. * * 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
  48367. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48368. * @param name defines the name of the mesh
  48369. * @param options defines the options used to create the mesh
  48370. * @param scene defines the hosting scene
  48371. * @returns the polyhedron mesh
  48372. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  48373. */
  48374. static CreatePolyhedron(name: string, options: {
  48375. type?: number;
  48376. size?: number;
  48377. sizeX?: number;
  48378. sizeY?: number;
  48379. sizeZ?: number;
  48380. custom?: any;
  48381. faceUV?: Vector4[];
  48382. faceColors?: Color4[];
  48383. flat?: boolean;
  48384. updatable?: boolean;
  48385. sideOrientation?: number;
  48386. frontUVs?: Vector4;
  48387. backUVs?: Vector4;
  48388. }, scene?: Nullable<Scene>): Mesh;
  48389. }
  48390. }
  48391. declare module BABYLON {
  48392. /**
  48393. * Gizmo that enables scaling a mesh along 3 axis
  48394. */
  48395. export class ScaleGizmo extends Gizmo {
  48396. /**
  48397. * Internal gizmo used for interactions on the x axis
  48398. */
  48399. xGizmo: AxisScaleGizmo;
  48400. /**
  48401. * Internal gizmo used for interactions on the y axis
  48402. */
  48403. yGizmo: AxisScaleGizmo;
  48404. /**
  48405. * Internal gizmo used for interactions on the z axis
  48406. */
  48407. zGizmo: AxisScaleGizmo;
  48408. /**
  48409. * Internal gizmo used to scale all axis equally
  48410. */
  48411. uniformScaleGizmo: AxisScaleGizmo;
  48412. private _meshAttached;
  48413. private _updateGizmoRotationToMatchAttachedMesh;
  48414. private _snapDistance;
  48415. private _scaleRatio;
  48416. private _uniformScalingMesh;
  48417. private _octahedron;
  48418. private _sensitivity;
  48419. /** Fires an event when any of it's sub gizmos are dragged */
  48420. onDragStartObservable: Observable<unknown>;
  48421. /** Fires an event when any of it's sub gizmos are released from dragging */
  48422. onDragEndObservable: Observable<unknown>;
  48423. get attachedMesh(): Nullable<AbstractMesh>;
  48424. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48425. /**
  48426. * Creates a ScaleGizmo
  48427. * @param gizmoLayer The utility layer the gizmo will be added to
  48428. */
  48429. constructor(gizmoLayer?: UtilityLayerRenderer);
  48430. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48431. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48432. /**
  48433. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48434. */
  48435. set snapDistance(value: number);
  48436. get snapDistance(): number;
  48437. /**
  48438. * Ratio for the scale of the gizmo (Default: 1)
  48439. */
  48440. set scaleRatio(value: number);
  48441. get scaleRatio(): number;
  48442. /**
  48443. * Sensitivity factor for dragging (Default: 1)
  48444. */
  48445. set sensitivity(value: number);
  48446. get sensitivity(): number;
  48447. /**
  48448. * Disposes of the gizmo
  48449. */
  48450. dispose(): void;
  48451. }
  48452. }
  48453. declare module BABYLON {
  48454. /**
  48455. * Single axis scale gizmo
  48456. */
  48457. export class AxisScaleGizmo extends Gizmo {
  48458. /**
  48459. * Drag behavior responsible for the gizmos dragging interactions
  48460. */
  48461. dragBehavior: PointerDragBehavior;
  48462. private _pointerObserver;
  48463. /**
  48464. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48465. */
  48466. snapDistance: number;
  48467. /**
  48468. * Event that fires each time the gizmo snaps to a new location.
  48469. * * snapDistance is the the change in distance
  48470. */
  48471. onSnapObservable: Observable<{
  48472. snapDistance: number;
  48473. }>;
  48474. /**
  48475. * If the scaling operation should be done on all axis (default: false)
  48476. */
  48477. uniformScaling: boolean;
  48478. /**
  48479. * Custom sensitivity value for the drag strength
  48480. */
  48481. sensitivity: number;
  48482. private _isEnabled;
  48483. private _parent;
  48484. private _arrow;
  48485. private _coloredMaterial;
  48486. private _hoverMaterial;
  48487. /**
  48488. * Creates an AxisScaleGizmo
  48489. * @param gizmoLayer The utility layer the gizmo will be added to
  48490. * @param dragAxis The axis which the gizmo will be able to scale on
  48491. * @param color The color of the gizmo
  48492. */
  48493. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  48494. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48495. /**
  48496. * If the gizmo is enabled
  48497. */
  48498. set isEnabled(value: boolean);
  48499. get isEnabled(): boolean;
  48500. /**
  48501. * Disposes of the gizmo
  48502. */
  48503. dispose(): void;
  48504. /**
  48505. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  48506. * @param mesh The mesh to replace the default mesh of the gizmo
  48507. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  48508. */
  48509. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  48510. }
  48511. }
  48512. declare module BABYLON {
  48513. /**
  48514. * Bounding box gizmo
  48515. */
  48516. export class BoundingBoxGizmo extends Gizmo {
  48517. private _lineBoundingBox;
  48518. private _rotateSpheresParent;
  48519. private _scaleBoxesParent;
  48520. private _boundingDimensions;
  48521. private _renderObserver;
  48522. private _pointerObserver;
  48523. private _scaleDragSpeed;
  48524. private _tmpQuaternion;
  48525. private _tmpVector;
  48526. private _tmpRotationMatrix;
  48527. /**
  48528. * 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)
  48529. */
  48530. ignoreChildren: boolean;
  48531. /**
  48532. * 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)
  48533. */
  48534. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  48535. /**
  48536. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  48537. */
  48538. rotationSphereSize: number;
  48539. /**
  48540. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  48541. */
  48542. scaleBoxSize: number;
  48543. /**
  48544. * 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)
  48545. */
  48546. fixedDragMeshScreenSize: boolean;
  48547. /**
  48548. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  48549. */
  48550. fixedDragMeshScreenSizeDistanceFactor: number;
  48551. /**
  48552. * Fired when a rotation sphere or scale box is dragged
  48553. */
  48554. onDragStartObservable: Observable<{}>;
  48555. /**
  48556. * Fired when a scale box is dragged
  48557. */
  48558. onScaleBoxDragObservable: Observable<{}>;
  48559. /**
  48560. * Fired when a scale box drag is ended
  48561. */
  48562. onScaleBoxDragEndObservable: Observable<{}>;
  48563. /**
  48564. * Fired when a rotation sphere is dragged
  48565. */
  48566. onRotationSphereDragObservable: Observable<{}>;
  48567. /**
  48568. * Fired when a rotation sphere drag is ended
  48569. */
  48570. onRotationSphereDragEndObservable: Observable<{}>;
  48571. /**
  48572. * 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)
  48573. */
  48574. scalePivot: Nullable<Vector3>;
  48575. /**
  48576. * Mesh used as a pivot to rotate the attached mesh
  48577. */
  48578. private _anchorMesh;
  48579. private _existingMeshScale;
  48580. private _dragMesh;
  48581. private pointerDragBehavior;
  48582. private coloredMaterial;
  48583. private hoverColoredMaterial;
  48584. /**
  48585. * Sets the color of the bounding box gizmo
  48586. * @param color the color to set
  48587. */
  48588. setColor(color: Color3): void;
  48589. /**
  48590. * Creates an BoundingBoxGizmo
  48591. * @param gizmoLayer The utility layer the gizmo will be added to
  48592. * @param color The color of the gizmo
  48593. */
  48594. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  48595. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48596. private _selectNode;
  48597. /**
  48598. * Updates the bounding box information for the Gizmo
  48599. */
  48600. updateBoundingBox(): void;
  48601. private _updateRotationSpheres;
  48602. private _updateScaleBoxes;
  48603. /**
  48604. * Enables rotation on the specified axis and disables rotation on the others
  48605. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  48606. */
  48607. setEnabledRotationAxis(axis: string): void;
  48608. /**
  48609. * Enables/disables scaling
  48610. * @param enable if scaling should be enabled
  48611. */
  48612. setEnabledScaling(enable: boolean): void;
  48613. private _updateDummy;
  48614. /**
  48615. * Enables a pointer drag behavior on the bounding box of the gizmo
  48616. */
  48617. enableDragBehavior(): void;
  48618. /**
  48619. * Disposes of the gizmo
  48620. */
  48621. dispose(): void;
  48622. /**
  48623. * 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)
  48624. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  48625. * @returns the bounding box mesh with the passed in mesh as a child
  48626. */
  48627. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  48628. /**
  48629. * CustomMeshes are not supported by this gizmo
  48630. * @param mesh The mesh to replace the default mesh of the gizmo
  48631. */
  48632. setCustomMesh(mesh: Mesh): void;
  48633. }
  48634. }
  48635. declare module BABYLON {
  48636. /**
  48637. * Single plane rotation gizmo
  48638. */
  48639. export class PlaneRotationGizmo extends Gizmo {
  48640. /**
  48641. * Drag behavior responsible for the gizmos dragging interactions
  48642. */
  48643. dragBehavior: PointerDragBehavior;
  48644. private _pointerObserver;
  48645. /**
  48646. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  48647. */
  48648. snapDistance: number;
  48649. /**
  48650. * Event that fires each time the gizmo snaps to a new location.
  48651. * * snapDistance is the the change in distance
  48652. */
  48653. onSnapObservable: Observable<{
  48654. snapDistance: number;
  48655. }>;
  48656. private _isEnabled;
  48657. private _parent;
  48658. /**
  48659. * Creates a PlaneRotationGizmo
  48660. * @param gizmoLayer The utility layer the gizmo will be added to
  48661. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  48662. * @param color The color of the gizmo
  48663. * @param tessellation Amount of tessellation to be used when creating rotation circles
  48664. * @param useEulerRotation Use and update Euler angle instead of quaternion
  48665. */
  48666. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  48667. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48668. /**
  48669. * If the gizmo is enabled
  48670. */
  48671. set isEnabled(value: boolean);
  48672. get isEnabled(): boolean;
  48673. /**
  48674. * Disposes of the gizmo
  48675. */
  48676. dispose(): void;
  48677. }
  48678. }
  48679. declare module BABYLON {
  48680. /**
  48681. * Gizmo that enables rotating a mesh along 3 axis
  48682. */
  48683. export class RotationGizmo extends Gizmo {
  48684. /**
  48685. * Internal gizmo used for interactions on the x axis
  48686. */
  48687. xGizmo: PlaneRotationGizmo;
  48688. /**
  48689. * Internal gizmo used for interactions on the y axis
  48690. */
  48691. yGizmo: PlaneRotationGizmo;
  48692. /**
  48693. * Internal gizmo used for interactions on the z axis
  48694. */
  48695. zGizmo: PlaneRotationGizmo;
  48696. /** Fires an event when any of it's sub gizmos are dragged */
  48697. onDragStartObservable: Observable<unknown>;
  48698. /** Fires an event when any of it's sub gizmos are released from dragging */
  48699. onDragEndObservable: Observable<unknown>;
  48700. private _meshAttached;
  48701. get attachedMesh(): Nullable<AbstractMesh>;
  48702. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48703. /**
  48704. * Creates a RotationGizmo
  48705. * @param gizmoLayer The utility layer the gizmo will be added to
  48706. * @param tessellation Amount of tessellation to be used when creating rotation circles
  48707. * @param useEulerRotation Use and update Euler angle instead of quaternion
  48708. */
  48709. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  48710. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48711. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48712. /**
  48713. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48714. */
  48715. set snapDistance(value: number);
  48716. get snapDistance(): number;
  48717. /**
  48718. * Ratio for the scale of the gizmo (Default: 1)
  48719. */
  48720. set scaleRatio(value: number);
  48721. get scaleRatio(): number;
  48722. /**
  48723. * Disposes of the gizmo
  48724. */
  48725. dispose(): void;
  48726. /**
  48727. * CustomMeshes are not supported by this gizmo
  48728. * @param mesh The mesh to replace the default mesh of the gizmo
  48729. */
  48730. setCustomMesh(mesh: Mesh): void;
  48731. }
  48732. }
  48733. declare module BABYLON {
  48734. /**
  48735. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  48736. */
  48737. export class GizmoManager implements IDisposable {
  48738. private scene;
  48739. /**
  48740. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  48741. */
  48742. gizmos: {
  48743. positionGizmo: Nullable<PositionGizmo>;
  48744. rotationGizmo: Nullable<RotationGizmo>;
  48745. scaleGizmo: Nullable<ScaleGizmo>;
  48746. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  48747. };
  48748. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  48749. clearGizmoOnEmptyPointerEvent: boolean;
  48750. /** Fires an event when the manager is attached to a mesh */
  48751. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  48752. private _gizmosEnabled;
  48753. private _pointerObserver;
  48754. private _attachedMesh;
  48755. private _boundingBoxColor;
  48756. private _defaultUtilityLayer;
  48757. private _defaultKeepDepthUtilityLayer;
  48758. /**
  48759. * When bounding box gizmo is enabled, this can be used to track drag/end events
  48760. */
  48761. boundingBoxDragBehavior: SixDofDragBehavior;
  48762. /**
  48763. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  48764. */
  48765. attachableMeshes: Nullable<Array<AbstractMesh>>;
  48766. /**
  48767. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  48768. */
  48769. usePointerToAttachGizmos: boolean;
  48770. /**
  48771. * Utility layer that the bounding box gizmo belongs to
  48772. */
  48773. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  48774. /**
  48775. * Utility layer that all gizmos besides bounding box belong to
  48776. */
  48777. get utilityLayer(): UtilityLayerRenderer;
  48778. /**
  48779. * Instatiates a gizmo manager
  48780. * @param scene the scene to overlay the gizmos on top of
  48781. */
  48782. constructor(scene: Scene);
  48783. /**
  48784. * Attaches a set of gizmos to the specified mesh
  48785. * @param mesh The mesh the gizmo's should be attached to
  48786. */
  48787. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  48788. /**
  48789. * If the position gizmo is enabled
  48790. */
  48791. set positionGizmoEnabled(value: boolean);
  48792. get positionGizmoEnabled(): boolean;
  48793. /**
  48794. * If the rotation gizmo is enabled
  48795. */
  48796. set rotationGizmoEnabled(value: boolean);
  48797. get rotationGizmoEnabled(): boolean;
  48798. /**
  48799. * If the scale gizmo is enabled
  48800. */
  48801. set scaleGizmoEnabled(value: boolean);
  48802. get scaleGizmoEnabled(): boolean;
  48803. /**
  48804. * If the boundingBox gizmo is enabled
  48805. */
  48806. set boundingBoxGizmoEnabled(value: boolean);
  48807. get boundingBoxGizmoEnabled(): boolean;
  48808. /**
  48809. * Disposes of the gizmo manager
  48810. */
  48811. dispose(): void;
  48812. }
  48813. }
  48814. declare module BABYLON {
  48815. /**
  48816. * A directional light is defined by a direction (what a surprise!).
  48817. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  48818. * 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.
  48819. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48820. */
  48821. export class DirectionalLight extends ShadowLight {
  48822. private _shadowFrustumSize;
  48823. /**
  48824. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  48825. */
  48826. get shadowFrustumSize(): number;
  48827. /**
  48828. * Specifies a fix frustum size for the shadow generation.
  48829. */
  48830. set shadowFrustumSize(value: number);
  48831. private _shadowOrthoScale;
  48832. /**
  48833. * Gets the shadow projection scale against the optimal computed one.
  48834. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48835. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48836. */
  48837. get shadowOrthoScale(): number;
  48838. /**
  48839. * Sets the shadow projection scale against the optimal computed one.
  48840. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48841. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48842. */
  48843. set shadowOrthoScale(value: number);
  48844. /**
  48845. * Automatically compute the projection matrix to best fit (including all the casters)
  48846. * on each frame.
  48847. */
  48848. autoUpdateExtends: boolean;
  48849. /**
  48850. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  48851. * on each frame. autoUpdateExtends must be set to true for this to work
  48852. */
  48853. autoCalcShadowZBounds: boolean;
  48854. private _orthoLeft;
  48855. private _orthoRight;
  48856. private _orthoTop;
  48857. private _orthoBottom;
  48858. /**
  48859. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  48860. * The directional light is emitted from everywhere in the given direction.
  48861. * It can cast shadows.
  48862. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48863. * @param name The friendly name of the light
  48864. * @param direction The direction of the light
  48865. * @param scene The scene the light belongs to
  48866. */
  48867. constructor(name: string, direction: Vector3, scene: Scene);
  48868. /**
  48869. * Returns the string "DirectionalLight".
  48870. * @return The class name
  48871. */
  48872. getClassName(): string;
  48873. /**
  48874. * Returns the integer 1.
  48875. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48876. */
  48877. getTypeID(): number;
  48878. /**
  48879. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  48880. * Returns the DirectionalLight Shadow projection matrix.
  48881. */
  48882. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48883. /**
  48884. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  48885. * Returns the DirectionalLight Shadow projection matrix.
  48886. */
  48887. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  48888. /**
  48889. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  48890. * Returns the DirectionalLight Shadow projection matrix.
  48891. */
  48892. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48893. protected _buildUniformLayout(): void;
  48894. /**
  48895. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  48896. * @param effect The effect to update
  48897. * @param lightIndex The index of the light in the effect to update
  48898. * @returns The directional light
  48899. */
  48900. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  48901. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  48902. /**
  48903. * Gets the minZ used for shadow according to both the scene and the light.
  48904. *
  48905. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48906. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48907. * @param activeCamera The camera we are returning the min for
  48908. * @returns the depth min z
  48909. */
  48910. getDepthMinZ(activeCamera: Camera): number;
  48911. /**
  48912. * Gets the maxZ used for shadow according to both the scene and the light.
  48913. *
  48914. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48915. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48916. * @param activeCamera The camera we are returning the max for
  48917. * @returns the depth max z
  48918. */
  48919. getDepthMaxZ(activeCamera: Camera): number;
  48920. /**
  48921. * Prepares the list of defines specific to the light type.
  48922. * @param defines the list of defines
  48923. * @param lightIndex defines the index of the light for the effect
  48924. */
  48925. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48926. }
  48927. }
  48928. declare module BABYLON {
  48929. /**
  48930. * Class containing static functions to help procedurally build meshes
  48931. */
  48932. export class HemisphereBuilder {
  48933. /**
  48934. * Creates a hemisphere mesh
  48935. * @param name defines the name of the mesh
  48936. * @param options defines the options used to create the mesh
  48937. * @param scene defines the hosting scene
  48938. * @returns the hemisphere mesh
  48939. */
  48940. static CreateHemisphere(name: string, options: {
  48941. segments?: number;
  48942. diameter?: number;
  48943. sideOrientation?: number;
  48944. }, scene: any): Mesh;
  48945. }
  48946. }
  48947. declare module BABYLON {
  48948. /**
  48949. * A spot light is defined by a position, a direction, an angle, and an exponent.
  48950. * These values define a cone of light starting from the position, emitting toward the direction.
  48951. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  48952. * and the exponent defines the speed of the decay of the light with distance (reach).
  48953. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48954. */
  48955. export class SpotLight extends ShadowLight {
  48956. private _angle;
  48957. private _innerAngle;
  48958. private _cosHalfAngle;
  48959. private _lightAngleScale;
  48960. private _lightAngleOffset;
  48961. /**
  48962. * Gets the cone angle of the spot light in Radians.
  48963. */
  48964. get angle(): number;
  48965. /**
  48966. * Sets the cone angle of the spot light in Radians.
  48967. */
  48968. set angle(value: number);
  48969. /**
  48970. * Only used in gltf falloff mode, this defines the angle where
  48971. * the directional falloff will start before cutting at angle which could be seen
  48972. * as outer angle.
  48973. */
  48974. get innerAngle(): number;
  48975. /**
  48976. * Only used in gltf falloff mode, this defines the angle where
  48977. * the directional falloff will start before cutting at angle which could be seen
  48978. * as outer angle.
  48979. */
  48980. set innerAngle(value: number);
  48981. private _shadowAngleScale;
  48982. /**
  48983. * Allows scaling the angle of the light for shadow generation only.
  48984. */
  48985. get shadowAngleScale(): number;
  48986. /**
  48987. * Allows scaling the angle of the light for shadow generation only.
  48988. */
  48989. set shadowAngleScale(value: number);
  48990. /**
  48991. * The light decay speed with the distance from the emission spot.
  48992. */
  48993. exponent: number;
  48994. private _projectionTextureMatrix;
  48995. /**
  48996. * Allows reading the projecton texture
  48997. */
  48998. get projectionTextureMatrix(): Matrix;
  48999. protected _projectionTextureLightNear: number;
  49000. /**
  49001. * Gets the near clip of the Spotlight for texture projection.
  49002. */
  49003. get projectionTextureLightNear(): number;
  49004. /**
  49005. * Sets the near clip of the Spotlight for texture projection.
  49006. */
  49007. set projectionTextureLightNear(value: number);
  49008. protected _projectionTextureLightFar: number;
  49009. /**
  49010. * Gets the far clip of the Spotlight for texture projection.
  49011. */
  49012. get projectionTextureLightFar(): number;
  49013. /**
  49014. * Sets the far clip of the Spotlight for texture projection.
  49015. */
  49016. set projectionTextureLightFar(value: number);
  49017. protected _projectionTextureUpDirection: Vector3;
  49018. /**
  49019. * Gets the Up vector of the Spotlight for texture projection.
  49020. */
  49021. get projectionTextureUpDirection(): Vector3;
  49022. /**
  49023. * Sets the Up vector of the Spotlight for texture projection.
  49024. */
  49025. set projectionTextureUpDirection(value: Vector3);
  49026. private _projectionTexture;
  49027. /**
  49028. * Gets the projection texture of the light.
  49029. */
  49030. get projectionTexture(): Nullable<BaseTexture>;
  49031. /**
  49032. * Sets the projection texture of the light.
  49033. */
  49034. set projectionTexture(value: Nullable<BaseTexture>);
  49035. private _projectionTextureViewLightDirty;
  49036. private _projectionTextureProjectionLightDirty;
  49037. private _projectionTextureDirty;
  49038. private _projectionTextureViewTargetVector;
  49039. private _projectionTextureViewLightMatrix;
  49040. private _projectionTextureProjectionLightMatrix;
  49041. private _projectionTextureScalingMatrix;
  49042. /**
  49043. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  49044. * It can cast shadows.
  49045. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49046. * @param name The light friendly name
  49047. * @param position The position of the spot light in the scene
  49048. * @param direction The direction of the light in the scene
  49049. * @param angle The cone angle of the light in Radians
  49050. * @param exponent The light decay speed with the distance from the emission spot
  49051. * @param scene The scene the lights belongs to
  49052. */
  49053. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  49054. /**
  49055. * Returns the string "SpotLight".
  49056. * @returns the class name
  49057. */
  49058. getClassName(): string;
  49059. /**
  49060. * Returns the integer 2.
  49061. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49062. */
  49063. getTypeID(): number;
  49064. /**
  49065. * Overrides the direction setter to recompute the projection texture view light Matrix.
  49066. */
  49067. protected _setDirection(value: Vector3): void;
  49068. /**
  49069. * Overrides the position setter to recompute the projection texture view light Matrix.
  49070. */
  49071. protected _setPosition(value: Vector3): void;
  49072. /**
  49073. * 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.
  49074. * Returns the SpotLight.
  49075. */
  49076. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49077. protected _computeProjectionTextureViewLightMatrix(): void;
  49078. protected _computeProjectionTextureProjectionLightMatrix(): void;
  49079. /**
  49080. * Main function for light texture projection matrix computing.
  49081. */
  49082. protected _computeProjectionTextureMatrix(): void;
  49083. protected _buildUniformLayout(): void;
  49084. private _computeAngleValues;
  49085. /**
  49086. * Sets the passed Effect "effect" with the Light textures.
  49087. * @param effect The effect to update
  49088. * @param lightIndex The index of the light in the effect to update
  49089. * @returns The light
  49090. */
  49091. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  49092. /**
  49093. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  49094. * @param effect The effect to update
  49095. * @param lightIndex The index of the light in the effect to update
  49096. * @returns The spot light
  49097. */
  49098. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  49099. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  49100. /**
  49101. * Disposes the light and the associated resources.
  49102. */
  49103. dispose(): void;
  49104. /**
  49105. * Prepares the list of defines specific to the light type.
  49106. * @param defines the list of defines
  49107. * @param lightIndex defines the index of the light for the effect
  49108. */
  49109. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49110. }
  49111. }
  49112. declare module BABYLON {
  49113. /**
  49114. * Gizmo that enables viewing a light
  49115. */
  49116. export class LightGizmo extends Gizmo {
  49117. private _lightMesh;
  49118. private _material;
  49119. private _cachedPosition;
  49120. private _cachedForward;
  49121. private _attachedMeshParent;
  49122. /**
  49123. * Creates a LightGizmo
  49124. * @param gizmoLayer The utility layer the gizmo will be added to
  49125. */
  49126. constructor(gizmoLayer?: UtilityLayerRenderer);
  49127. private _light;
  49128. /**
  49129. * The light that the gizmo is attached to
  49130. */
  49131. set light(light: Nullable<Light>);
  49132. get light(): Nullable<Light>;
  49133. /**
  49134. * Gets the material used to render the light gizmo
  49135. */
  49136. get material(): StandardMaterial;
  49137. /**
  49138. * @hidden
  49139. * Updates the gizmo to match the attached mesh's position/rotation
  49140. */
  49141. protected _update(): void;
  49142. private static _Scale;
  49143. /**
  49144. * Creates the lines for a light mesh
  49145. */
  49146. private static _CreateLightLines;
  49147. /**
  49148. * Disposes of the light gizmo
  49149. */
  49150. dispose(): void;
  49151. private static _CreateHemisphericLightMesh;
  49152. private static _CreatePointLightMesh;
  49153. private static _CreateSpotLightMesh;
  49154. private static _CreateDirectionalLightMesh;
  49155. }
  49156. }
  49157. declare module BABYLON {
  49158. /** @hidden */
  49159. export var backgroundFragmentDeclaration: {
  49160. name: string;
  49161. shader: string;
  49162. };
  49163. }
  49164. declare module BABYLON {
  49165. /** @hidden */
  49166. export var backgroundUboDeclaration: {
  49167. name: string;
  49168. shader: string;
  49169. };
  49170. }
  49171. declare module BABYLON {
  49172. /** @hidden */
  49173. export var backgroundPixelShader: {
  49174. name: string;
  49175. shader: string;
  49176. };
  49177. }
  49178. declare module BABYLON {
  49179. /** @hidden */
  49180. export var backgroundVertexDeclaration: {
  49181. name: string;
  49182. shader: string;
  49183. };
  49184. }
  49185. declare module BABYLON {
  49186. /** @hidden */
  49187. export var backgroundVertexShader: {
  49188. name: string;
  49189. shader: string;
  49190. };
  49191. }
  49192. declare module BABYLON {
  49193. /**
  49194. * Background material used to create an efficient environement around your scene.
  49195. */
  49196. export class BackgroundMaterial extends PushMaterial {
  49197. /**
  49198. * Standard reflectance value at parallel view angle.
  49199. */
  49200. static StandardReflectance0: number;
  49201. /**
  49202. * Standard reflectance value at grazing angle.
  49203. */
  49204. static StandardReflectance90: number;
  49205. protected _primaryColor: Color3;
  49206. /**
  49207. * Key light Color (multiply against the environement texture)
  49208. */
  49209. primaryColor: Color3;
  49210. protected __perceptualColor: Nullable<Color3>;
  49211. /**
  49212. * Experimental Internal Use Only.
  49213. *
  49214. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  49215. * This acts as a helper to set the primary color to a more "human friendly" value.
  49216. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  49217. * output color as close as possible from the chosen value.
  49218. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  49219. * part of lighting setup.)
  49220. */
  49221. get _perceptualColor(): Nullable<Color3>;
  49222. set _perceptualColor(value: Nullable<Color3>);
  49223. protected _primaryColorShadowLevel: float;
  49224. /**
  49225. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  49226. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  49227. */
  49228. get primaryColorShadowLevel(): float;
  49229. set primaryColorShadowLevel(value: float);
  49230. protected _primaryColorHighlightLevel: float;
  49231. /**
  49232. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  49233. * The primary color is used at the level chosen to define what the white area would look.
  49234. */
  49235. get primaryColorHighlightLevel(): float;
  49236. set primaryColorHighlightLevel(value: float);
  49237. protected _reflectionTexture: Nullable<BaseTexture>;
  49238. /**
  49239. * Reflection Texture used in the material.
  49240. * Should be author in a specific way for the best result (refer to the documentation).
  49241. */
  49242. reflectionTexture: Nullable<BaseTexture>;
  49243. protected _reflectionBlur: float;
  49244. /**
  49245. * Reflection Texture level of blur.
  49246. *
  49247. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  49248. * texture twice.
  49249. */
  49250. reflectionBlur: float;
  49251. protected _diffuseTexture: Nullable<BaseTexture>;
  49252. /**
  49253. * Diffuse Texture used in the material.
  49254. * Should be author in a specific way for the best result (refer to the documentation).
  49255. */
  49256. diffuseTexture: Nullable<BaseTexture>;
  49257. protected _shadowLights: Nullable<IShadowLight[]>;
  49258. /**
  49259. * Specify the list of lights casting shadow on the material.
  49260. * All scene shadow lights will be included if null.
  49261. */
  49262. shadowLights: Nullable<IShadowLight[]>;
  49263. protected _shadowLevel: float;
  49264. /**
  49265. * Helps adjusting the shadow to a softer level if required.
  49266. * 0 means black shadows and 1 means no shadows.
  49267. */
  49268. shadowLevel: float;
  49269. protected _sceneCenter: Vector3;
  49270. /**
  49271. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  49272. * It is usually zero but might be interesting to modify according to your setup.
  49273. */
  49274. sceneCenter: Vector3;
  49275. protected _opacityFresnel: boolean;
  49276. /**
  49277. * This helps specifying that the material is falling off to the sky box at grazing angle.
  49278. * This helps ensuring a nice transition when the camera goes under the ground.
  49279. */
  49280. opacityFresnel: boolean;
  49281. protected _reflectionFresnel: boolean;
  49282. /**
  49283. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  49284. * This helps adding a mirror texture on the ground.
  49285. */
  49286. reflectionFresnel: boolean;
  49287. protected _reflectionFalloffDistance: number;
  49288. /**
  49289. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  49290. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  49291. */
  49292. reflectionFalloffDistance: number;
  49293. protected _reflectionAmount: number;
  49294. /**
  49295. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  49296. */
  49297. reflectionAmount: number;
  49298. protected _reflectionReflectance0: number;
  49299. /**
  49300. * This specifies the weight of the reflection at grazing angle.
  49301. */
  49302. reflectionReflectance0: number;
  49303. protected _reflectionReflectance90: number;
  49304. /**
  49305. * This specifies the weight of the reflection at a perpendicular point of view.
  49306. */
  49307. reflectionReflectance90: number;
  49308. /**
  49309. * Sets the reflection reflectance fresnel values according to the default standard
  49310. * empirically know to work well :-)
  49311. */
  49312. set reflectionStandardFresnelWeight(value: number);
  49313. protected _useRGBColor: boolean;
  49314. /**
  49315. * Helps to directly use the maps channels instead of their level.
  49316. */
  49317. useRGBColor: boolean;
  49318. protected _enableNoise: boolean;
  49319. /**
  49320. * This helps reducing the banding effect that could occur on the background.
  49321. */
  49322. enableNoise: boolean;
  49323. /**
  49324. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49325. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  49326. * Recommended to be keep at 1.0 except for special cases.
  49327. */
  49328. get fovMultiplier(): number;
  49329. set fovMultiplier(value: number);
  49330. private _fovMultiplier;
  49331. /**
  49332. * Enable the FOV adjustment feature controlled by fovMultiplier.
  49333. */
  49334. useEquirectangularFOV: boolean;
  49335. private _maxSimultaneousLights;
  49336. /**
  49337. * Number of Simultaneous lights allowed on the material.
  49338. */
  49339. maxSimultaneousLights: int;
  49340. /**
  49341. * Default configuration related to image processing available in the Background Material.
  49342. */
  49343. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49344. /**
  49345. * Keep track of the image processing observer to allow dispose and replace.
  49346. */
  49347. private _imageProcessingObserver;
  49348. /**
  49349. * Attaches a new image processing configuration to the PBR Material.
  49350. * @param configuration (if null the scene configuration will be use)
  49351. */
  49352. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49353. /**
  49354. * Gets the image processing configuration used either in this material.
  49355. */
  49356. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  49357. /**
  49358. * Sets the Default image processing configuration used either in the this material.
  49359. *
  49360. * If sets to null, the scene one is in use.
  49361. */
  49362. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  49363. /**
  49364. * Gets wether the color curves effect is enabled.
  49365. */
  49366. get cameraColorCurvesEnabled(): boolean;
  49367. /**
  49368. * Sets wether the color curves effect is enabled.
  49369. */
  49370. set cameraColorCurvesEnabled(value: boolean);
  49371. /**
  49372. * Gets wether the color grading effect is enabled.
  49373. */
  49374. get cameraColorGradingEnabled(): boolean;
  49375. /**
  49376. * Gets wether the color grading effect is enabled.
  49377. */
  49378. set cameraColorGradingEnabled(value: boolean);
  49379. /**
  49380. * Gets wether tonemapping is enabled or not.
  49381. */
  49382. get cameraToneMappingEnabled(): boolean;
  49383. /**
  49384. * Sets wether tonemapping is enabled or not
  49385. */
  49386. set cameraToneMappingEnabled(value: boolean);
  49387. /**
  49388. * The camera exposure used on this material.
  49389. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49390. * This corresponds to a photographic exposure.
  49391. */
  49392. get cameraExposure(): float;
  49393. /**
  49394. * The camera exposure used on this material.
  49395. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49396. * This corresponds to a photographic exposure.
  49397. */
  49398. set cameraExposure(value: float);
  49399. /**
  49400. * Gets The camera contrast used on this material.
  49401. */
  49402. get cameraContrast(): float;
  49403. /**
  49404. * Sets The camera contrast used on this material.
  49405. */
  49406. set cameraContrast(value: float);
  49407. /**
  49408. * Gets the Color Grading 2D Lookup Texture.
  49409. */
  49410. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  49411. /**
  49412. * Sets the Color Grading 2D Lookup Texture.
  49413. */
  49414. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  49415. /**
  49416. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49417. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49418. * 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;
  49419. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49420. */
  49421. get cameraColorCurves(): Nullable<ColorCurves>;
  49422. /**
  49423. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49424. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49425. * 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;
  49426. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49427. */
  49428. set cameraColorCurves(value: Nullable<ColorCurves>);
  49429. /**
  49430. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  49431. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  49432. */
  49433. switchToBGR: boolean;
  49434. private _renderTargets;
  49435. private _reflectionControls;
  49436. private _white;
  49437. private _primaryShadowColor;
  49438. private _primaryHighlightColor;
  49439. /**
  49440. * Instantiates a Background Material in the given scene
  49441. * @param name The friendly name of the material
  49442. * @param scene The scene to add the material to
  49443. */
  49444. constructor(name: string, scene: Scene);
  49445. /**
  49446. * Gets a boolean indicating that current material needs to register RTT
  49447. */
  49448. get hasRenderTargetTextures(): boolean;
  49449. /**
  49450. * The entire material has been created in order to prevent overdraw.
  49451. * @returns false
  49452. */
  49453. needAlphaTesting(): boolean;
  49454. /**
  49455. * The entire material has been created in order to prevent overdraw.
  49456. * @returns true if blending is enable
  49457. */
  49458. needAlphaBlending(): boolean;
  49459. /**
  49460. * Checks wether the material is ready to be rendered for a given mesh.
  49461. * @param mesh The mesh to render
  49462. * @param subMesh The submesh to check against
  49463. * @param useInstances Specify wether or not the material is used with instances
  49464. * @returns true if all the dependencies are ready (Textures, Effects...)
  49465. */
  49466. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  49467. /**
  49468. * Compute the primary color according to the chosen perceptual color.
  49469. */
  49470. private _computePrimaryColorFromPerceptualColor;
  49471. /**
  49472. * Compute the highlights and shadow colors according to their chosen levels.
  49473. */
  49474. private _computePrimaryColors;
  49475. /**
  49476. * Build the uniform buffer used in the material.
  49477. */
  49478. buildUniformLayout(): void;
  49479. /**
  49480. * Unbind the material.
  49481. */
  49482. unbind(): void;
  49483. /**
  49484. * Bind only the world matrix to the material.
  49485. * @param world The world matrix to bind.
  49486. */
  49487. bindOnlyWorldMatrix(world: Matrix): void;
  49488. /**
  49489. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  49490. * @param world The world matrix to bind.
  49491. * @param subMesh The submesh to bind for.
  49492. */
  49493. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49494. /**
  49495. * Checks to see if a texture is used in the material.
  49496. * @param texture - Base texture to use.
  49497. * @returns - Boolean specifying if a texture is used in the material.
  49498. */
  49499. hasTexture(texture: BaseTexture): boolean;
  49500. /**
  49501. * Dispose the material.
  49502. * @param forceDisposeEffect Force disposal of the associated effect.
  49503. * @param forceDisposeTextures Force disposal of the associated textures.
  49504. */
  49505. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  49506. /**
  49507. * Clones the material.
  49508. * @param name The cloned name.
  49509. * @returns The cloned material.
  49510. */
  49511. clone(name: string): BackgroundMaterial;
  49512. /**
  49513. * Serializes the current material to its JSON representation.
  49514. * @returns The JSON representation.
  49515. */
  49516. serialize(): any;
  49517. /**
  49518. * Gets the class name of the material
  49519. * @returns "BackgroundMaterial"
  49520. */
  49521. getClassName(): string;
  49522. /**
  49523. * Parse a JSON input to create back a background material.
  49524. * @param source The JSON data to parse
  49525. * @param scene The scene to create the parsed material in
  49526. * @param rootUrl The root url of the assets the material depends upon
  49527. * @returns the instantiated BackgroundMaterial.
  49528. */
  49529. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  49530. }
  49531. }
  49532. declare module BABYLON {
  49533. /**
  49534. * Represents the different options available during the creation of
  49535. * a Environment helper.
  49536. *
  49537. * This can control the default ground, skybox and image processing setup of your scene.
  49538. */
  49539. export interface IEnvironmentHelperOptions {
  49540. /**
  49541. * Specifies wether or not to create a ground.
  49542. * True by default.
  49543. */
  49544. createGround: boolean;
  49545. /**
  49546. * Specifies the ground size.
  49547. * 15 by default.
  49548. */
  49549. groundSize: number;
  49550. /**
  49551. * The texture used on the ground for the main color.
  49552. * Comes from the BabylonJS CDN by default.
  49553. *
  49554. * Remarks: Can be either a texture or a url.
  49555. */
  49556. groundTexture: string | BaseTexture;
  49557. /**
  49558. * The color mixed in the ground texture by default.
  49559. * BabylonJS clearColor by default.
  49560. */
  49561. groundColor: Color3;
  49562. /**
  49563. * Specifies the ground opacity.
  49564. * 1 by default.
  49565. */
  49566. groundOpacity: number;
  49567. /**
  49568. * Enables the ground to receive shadows.
  49569. * True by default.
  49570. */
  49571. enableGroundShadow: boolean;
  49572. /**
  49573. * Helps preventing the shadow to be fully black on the ground.
  49574. * 0.5 by default.
  49575. */
  49576. groundShadowLevel: number;
  49577. /**
  49578. * Creates a mirror texture attach to the ground.
  49579. * false by default.
  49580. */
  49581. enableGroundMirror: boolean;
  49582. /**
  49583. * Specifies the ground mirror size ratio.
  49584. * 0.3 by default as the default kernel is 64.
  49585. */
  49586. groundMirrorSizeRatio: number;
  49587. /**
  49588. * Specifies the ground mirror blur kernel size.
  49589. * 64 by default.
  49590. */
  49591. groundMirrorBlurKernel: number;
  49592. /**
  49593. * Specifies the ground mirror visibility amount.
  49594. * 1 by default
  49595. */
  49596. groundMirrorAmount: number;
  49597. /**
  49598. * Specifies the ground mirror reflectance weight.
  49599. * This uses the standard weight of the background material to setup the fresnel effect
  49600. * of the mirror.
  49601. * 1 by default.
  49602. */
  49603. groundMirrorFresnelWeight: number;
  49604. /**
  49605. * Specifies the ground mirror Falloff distance.
  49606. * This can helps reducing the size of the reflection.
  49607. * 0 by Default.
  49608. */
  49609. groundMirrorFallOffDistance: number;
  49610. /**
  49611. * Specifies the ground mirror texture type.
  49612. * Unsigned Int by Default.
  49613. */
  49614. groundMirrorTextureType: number;
  49615. /**
  49616. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  49617. * the shown objects.
  49618. */
  49619. groundYBias: number;
  49620. /**
  49621. * Specifies wether or not to create a skybox.
  49622. * True by default.
  49623. */
  49624. createSkybox: boolean;
  49625. /**
  49626. * Specifies the skybox size.
  49627. * 20 by default.
  49628. */
  49629. skyboxSize: number;
  49630. /**
  49631. * The texture used on the skybox for the main color.
  49632. * Comes from the BabylonJS CDN by default.
  49633. *
  49634. * Remarks: Can be either a texture or a url.
  49635. */
  49636. skyboxTexture: string | BaseTexture;
  49637. /**
  49638. * The color mixed in the skybox texture by default.
  49639. * BabylonJS clearColor by default.
  49640. */
  49641. skyboxColor: Color3;
  49642. /**
  49643. * The background rotation around the Y axis of the scene.
  49644. * This helps aligning the key lights of your scene with the background.
  49645. * 0 by default.
  49646. */
  49647. backgroundYRotation: number;
  49648. /**
  49649. * Compute automatically the size of the elements to best fit with the scene.
  49650. */
  49651. sizeAuto: boolean;
  49652. /**
  49653. * Default position of the rootMesh if autoSize is not true.
  49654. */
  49655. rootPosition: Vector3;
  49656. /**
  49657. * Sets up the image processing in the scene.
  49658. * true by default.
  49659. */
  49660. setupImageProcessing: boolean;
  49661. /**
  49662. * The texture used as your environment texture in the scene.
  49663. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  49664. *
  49665. * Remarks: Can be either a texture or a url.
  49666. */
  49667. environmentTexture: string | BaseTexture;
  49668. /**
  49669. * The value of the exposure to apply to the scene.
  49670. * 0.6 by default if setupImageProcessing is true.
  49671. */
  49672. cameraExposure: number;
  49673. /**
  49674. * The value of the contrast to apply to the scene.
  49675. * 1.6 by default if setupImageProcessing is true.
  49676. */
  49677. cameraContrast: number;
  49678. /**
  49679. * Specifies wether or not tonemapping should be enabled in the scene.
  49680. * true by default if setupImageProcessing is true.
  49681. */
  49682. toneMappingEnabled: boolean;
  49683. }
  49684. /**
  49685. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  49686. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  49687. * It also helps with the default setup of your imageProcessing configuration.
  49688. */
  49689. export class EnvironmentHelper {
  49690. /**
  49691. * Default ground texture URL.
  49692. */
  49693. private static _groundTextureCDNUrl;
  49694. /**
  49695. * Default skybox texture URL.
  49696. */
  49697. private static _skyboxTextureCDNUrl;
  49698. /**
  49699. * Default environment texture URL.
  49700. */
  49701. private static _environmentTextureCDNUrl;
  49702. /**
  49703. * Creates the default options for the helper.
  49704. */
  49705. private static _getDefaultOptions;
  49706. private _rootMesh;
  49707. /**
  49708. * Gets the root mesh created by the helper.
  49709. */
  49710. get rootMesh(): Mesh;
  49711. private _skybox;
  49712. /**
  49713. * Gets the skybox created by the helper.
  49714. */
  49715. get skybox(): Nullable<Mesh>;
  49716. private _skyboxTexture;
  49717. /**
  49718. * Gets the skybox texture created by the helper.
  49719. */
  49720. get skyboxTexture(): Nullable<BaseTexture>;
  49721. private _skyboxMaterial;
  49722. /**
  49723. * Gets the skybox material created by the helper.
  49724. */
  49725. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  49726. private _ground;
  49727. /**
  49728. * Gets the ground mesh created by the helper.
  49729. */
  49730. get ground(): Nullable<Mesh>;
  49731. private _groundTexture;
  49732. /**
  49733. * Gets the ground texture created by the helper.
  49734. */
  49735. get groundTexture(): Nullable<BaseTexture>;
  49736. private _groundMirror;
  49737. /**
  49738. * Gets the ground mirror created by the helper.
  49739. */
  49740. get groundMirror(): Nullable<MirrorTexture>;
  49741. /**
  49742. * Gets the ground mirror render list to helps pushing the meshes
  49743. * you wish in the ground reflection.
  49744. */
  49745. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  49746. private _groundMaterial;
  49747. /**
  49748. * Gets the ground material created by the helper.
  49749. */
  49750. get groundMaterial(): Nullable<BackgroundMaterial>;
  49751. /**
  49752. * Stores the creation options.
  49753. */
  49754. private readonly _scene;
  49755. private _options;
  49756. /**
  49757. * This observable will be notified with any error during the creation of the environment,
  49758. * mainly texture creation errors.
  49759. */
  49760. onErrorObservable: Observable<{
  49761. message?: string;
  49762. exception?: any;
  49763. }>;
  49764. /**
  49765. * constructor
  49766. * @param options Defines the options we want to customize the helper
  49767. * @param scene The scene to add the material to
  49768. */
  49769. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  49770. /**
  49771. * Updates the background according to the new options
  49772. * @param options
  49773. */
  49774. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  49775. /**
  49776. * Sets the primary color of all the available elements.
  49777. * @param color the main color to affect to the ground and the background
  49778. */
  49779. setMainColor(color: Color3): void;
  49780. /**
  49781. * Setup the image processing according to the specified options.
  49782. */
  49783. private _setupImageProcessing;
  49784. /**
  49785. * Setup the environment texture according to the specified options.
  49786. */
  49787. private _setupEnvironmentTexture;
  49788. /**
  49789. * Setup the background according to the specified options.
  49790. */
  49791. private _setupBackground;
  49792. /**
  49793. * Get the scene sizes according to the setup.
  49794. */
  49795. private _getSceneSize;
  49796. /**
  49797. * Setup the ground according to the specified options.
  49798. */
  49799. private _setupGround;
  49800. /**
  49801. * Setup the ground material according to the specified options.
  49802. */
  49803. private _setupGroundMaterial;
  49804. /**
  49805. * Setup the ground diffuse texture according to the specified options.
  49806. */
  49807. private _setupGroundDiffuseTexture;
  49808. /**
  49809. * Setup the ground mirror texture according to the specified options.
  49810. */
  49811. private _setupGroundMirrorTexture;
  49812. /**
  49813. * Setup the ground to receive the mirror texture.
  49814. */
  49815. private _setupMirrorInGroundMaterial;
  49816. /**
  49817. * Setup the skybox according to the specified options.
  49818. */
  49819. private _setupSkybox;
  49820. /**
  49821. * Setup the skybox material according to the specified options.
  49822. */
  49823. private _setupSkyboxMaterial;
  49824. /**
  49825. * Setup the skybox reflection texture according to the specified options.
  49826. */
  49827. private _setupSkyboxReflectionTexture;
  49828. private _errorHandler;
  49829. /**
  49830. * Dispose all the elements created by the Helper.
  49831. */
  49832. dispose(): void;
  49833. }
  49834. }
  49835. declare module BABYLON {
  49836. /**
  49837. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  49838. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  49839. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  49840. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  49841. */
  49842. export class PhotoDome extends TransformNode {
  49843. /**
  49844. * Define the image as a Monoscopic panoramic 360 image.
  49845. */
  49846. static readonly MODE_MONOSCOPIC: number;
  49847. /**
  49848. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  49849. */
  49850. static readonly MODE_TOPBOTTOM: number;
  49851. /**
  49852. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  49853. */
  49854. static readonly MODE_SIDEBYSIDE: number;
  49855. private _useDirectMapping;
  49856. /**
  49857. * The texture being displayed on the sphere
  49858. */
  49859. protected _photoTexture: Texture;
  49860. /**
  49861. * Gets or sets the texture being displayed on the sphere
  49862. */
  49863. get photoTexture(): Texture;
  49864. set photoTexture(value: Texture);
  49865. /**
  49866. * Observable raised when an error occured while loading the 360 image
  49867. */
  49868. onLoadErrorObservable: Observable<string>;
  49869. /**
  49870. * The skybox material
  49871. */
  49872. protected _material: BackgroundMaterial;
  49873. /**
  49874. * The surface used for the skybox
  49875. */
  49876. protected _mesh: Mesh;
  49877. /**
  49878. * Gets the mesh used for the skybox.
  49879. */
  49880. get mesh(): Mesh;
  49881. /**
  49882. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49883. * Also see the options.resolution property.
  49884. */
  49885. get fovMultiplier(): number;
  49886. set fovMultiplier(value: number);
  49887. private _imageMode;
  49888. /**
  49889. * Gets or set the current video mode for the video. It can be:
  49890. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  49891. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  49892. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  49893. */
  49894. get imageMode(): number;
  49895. set imageMode(value: number);
  49896. /**
  49897. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  49898. * @param name Element's name, child elements will append suffixes for their own names.
  49899. * @param urlsOfPhoto defines the url of the photo to display
  49900. * @param options defines an object containing optional or exposed sub element properties
  49901. * @param onError defines a callback called when an error occured while loading the texture
  49902. */
  49903. constructor(name: string, urlOfPhoto: string, options: {
  49904. resolution?: number;
  49905. size?: number;
  49906. useDirectMapping?: boolean;
  49907. faceForward?: boolean;
  49908. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  49909. private _onBeforeCameraRenderObserver;
  49910. private _changeImageMode;
  49911. /**
  49912. * Releases resources associated with this node.
  49913. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  49914. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  49915. */
  49916. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  49917. }
  49918. }
  49919. declare module BABYLON {
  49920. /**
  49921. * Class used to host RGBD texture specific utilities
  49922. */
  49923. export class RGBDTextureTools {
  49924. /**
  49925. * Expand the RGBD Texture from RGBD to Half Float if possible.
  49926. * @param texture the texture to expand.
  49927. */
  49928. static ExpandRGBDTexture(texture: Texture): void;
  49929. }
  49930. }
  49931. declare module BABYLON {
  49932. /**
  49933. * Class used to host texture specific utilities
  49934. */
  49935. export class BRDFTextureTools {
  49936. /**
  49937. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  49938. * @param scene defines the hosting scene
  49939. * @returns the environment BRDF texture
  49940. */
  49941. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  49942. private static _environmentBRDFBase64Texture;
  49943. }
  49944. }
  49945. declare module BABYLON {
  49946. /**
  49947. * @hidden
  49948. */
  49949. export interface IMaterialClearCoatDefines {
  49950. CLEARCOAT: boolean;
  49951. CLEARCOAT_DEFAULTIOR: boolean;
  49952. CLEARCOAT_TEXTURE: boolean;
  49953. CLEARCOAT_TEXTUREDIRECTUV: number;
  49954. CLEARCOAT_BUMP: boolean;
  49955. CLEARCOAT_BUMPDIRECTUV: number;
  49956. CLEARCOAT_TINT: boolean;
  49957. CLEARCOAT_TINT_TEXTURE: boolean;
  49958. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49959. /** @hidden */
  49960. _areTexturesDirty: boolean;
  49961. }
  49962. /**
  49963. * Define the code related to the clear coat parameters of the pbr material.
  49964. */
  49965. export class PBRClearCoatConfiguration {
  49966. /**
  49967. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  49968. * The default fits with a polyurethane material.
  49969. */
  49970. private static readonly _DefaultIndexOfRefraction;
  49971. private _isEnabled;
  49972. /**
  49973. * Defines if the clear coat is enabled in the material.
  49974. */
  49975. isEnabled: boolean;
  49976. /**
  49977. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  49978. */
  49979. intensity: number;
  49980. /**
  49981. * Defines the clear coat layer roughness.
  49982. */
  49983. roughness: number;
  49984. private _indexOfRefraction;
  49985. /**
  49986. * Defines the index of refraction of the clear coat.
  49987. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  49988. * The default fits with a polyurethane material.
  49989. * Changing the default value is more performance intensive.
  49990. */
  49991. indexOfRefraction: number;
  49992. private _texture;
  49993. /**
  49994. * Stores the clear coat values in a texture.
  49995. */
  49996. texture: Nullable<BaseTexture>;
  49997. private _bumpTexture;
  49998. /**
  49999. * Define the clear coat specific bump texture.
  50000. */
  50001. bumpTexture: Nullable<BaseTexture>;
  50002. private _isTintEnabled;
  50003. /**
  50004. * Defines if the clear coat tint is enabled in the material.
  50005. */
  50006. isTintEnabled: boolean;
  50007. /**
  50008. * Defines the clear coat tint of the material.
  50009. * This is only use if tint is enabled
  50010. */
  50011. tintColor: Color3;
  50012. /**
  50013. * Defines the distance at which the tint color should be found in the
  50014. * clear coat media.
  50015. * This is only use if tint is enabled
  50016. */
  50017. tintColorAtDistance: number;
  50018. /**
  50019. * Defines the clear coat layer thickness.
  50020. * This is only use if tint is enabled
  50021. */
  50022. tintThickness: number;
  50023. private _tintTexture;
  50024. /**
  50025. * Stores the clear tint values in a texture.
  50026. * rgb is tint
  50027. * a is a thickness factor
  50028. */
  50029. tintTexture: Nullable<BaseTexture>;
  50030. /** @hidden */
  50031. private _internalMarkAllSubMeshesAsTexturesDirty;
  50032. /** @hidden */
  50033. _markAllSubMeshesAsTexturesDirty(): void;
  50034. /**
  50035. * Instantiate a new istance of clear coat configuration.
  50036. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50037. */
  50038. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50039. /**
  50040. * Gets wehter the submesh is ready to be used or not.
  50041. * @param defines the list of "defines" to update.
  50042. * @param scene defines the scene the material belongs to.
  50043. * @param engine defines the engine the material belongs to.
  50044. * @param disableBumpMap defines wether the material disables bump or not.
  50045. * @returns - boolean indicating that the submesh is ready or not.
  50046. */
  50047. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  50048. /**
  50049. * Checks to see if a texture is used in the material.
  50050. * @param defines the list of "defines" to update.
  50051. * @param scene defines the scene to the material belongs to.
  50052. */
  50053. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  50054. /**
  50055. * Binds the material data.
  50056. * @param uniformBuffer defines the Uniform buffer to fill in.
  50057. * @param scene defines the scene the material belongs to.
  50058. * @param engine defines the engine the material belongs to.
  50059. * @param disableBumpMap defines wether the material disables bump or not.
  50060. * @param isFrozen defines wether the material is frozen or not.
  50061. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50062. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50063. */
  50064. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  50065. /**
  50066. * Checks to see if a texture is used in the material.
  50067. * @param texture - Base texture to use.
  50068. * @returns - Boolean specifying if a texture is used in the material.
  50069. */
  50070. hasTexture(texture: BaseTexture): boolean;
  50071. /**
  50072. * Returns an array of the actively used textures.
  50073. * @param activeTextures Array of BaseTextures
  50074. */
  50075. getActiveTextures(activeTextures: BaseTexture[]): void;
  50076. /**
  50077. * Returns the animatable textures.
  50078. * @param animatables Array of animatable textures.
  50079. */
  50080. getAnimatables(animatables: IAnimatable[]): void;
  50081. /**
  50082. * Disposes the resources of the material.
  50083. * @param forceDisposeTextures - Forces the disposal of all textures.
  50084. */
  50085. dispose(forceDisposeTextures?: boolean): void;
  50086. /**
  50087. * Get the current class name of the texture useful for serialization or dynamic coding.
  50088. * @returns "PBRClearCoatConfiguration"
  50089. */
  50090. getClassName(): string;
  50091. /**
  50092. * Add fallbacks to the effect fallbacks list.
  50093. * @param defines defines the Base texture to use.
  50094. * @param fallbacks defines the current fallback list.
  50095. * @param currentRank defines the current fallback rank.
  50096. * @returns the new fallback rank.
  50097. */
  50098. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50099. /**
  50100. * Add the required uniforms to the current list.
  50101. * @param uniforms defines the current uniform list.
  50102. */
  50103. static AddUniforms(uniforms: string[]): void;
  50104. /**
  50105. * Add the required samplers to the current list.
  50106. * @param samplers defines the current sampler list.
  50107. */
  50108. static AddSamplers(samplers: string[]): void;
  50109. /**
  50110. * Add the required uniforms to the current buffer.
  50111. * @param uniformBuffer defines the current uniform buffer.
  50112. */
  50113. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50114. /**
  50115. * Makes a duplicate of the current configuration into another one.
  50116. * @param clearCoatConfiguration define the config where to copy the info
  50117. */
  50118. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  50119. /**
  50120. * Serializes this clear coat configuration.
  50121. * @returns - An object with the serialized config.
  50122. */
  50123. serialize(): any;
  50124. /**
  50125. * Parses a anisotropy Configuration from a serialized object.
  50126. * @param source - Serialized object.
  50127. * @param scene Defines the scene we are parsing for
  50128. * @param rootUrl Defines the rootUrl to load from
  50129. */
  50130. parse(source: any, scene: Scene, rootUrl: string): void;
  50131. }
  50132. }
  50133. declare module BABYLON {
  50134. /**
  50135. * @hidden
  50136. */
  50137. export interface IMaterialAnisotropicDefines {
  50138. ANISOTROPIC: boolean;
  50139. ANISOTROPIC_TEXTURE: boolean;
  50140. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50141. MAINUV1: boolean;
  50142. _areTexturesDirty: boolean;
  50143. _needUVs: boolean;
  50144. }
  50145. /**
  50146. * Define the code related to the anisotropic parameters of the pbr material.
  50147. */
  50148. export class PBRAnisotropicConfiguration {
  50149. private _isEnabled;
  50150. /**
  50151. * Defines if the anisotropy is enabled in the material.
  50152. */
  50153. isEnabled: boolean;
  50154. /**
  50155. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  50156. */
  50157. intensity: number;
  50158. /**
  50159. * Defines if the effect is along the tangents, bitangents or in between.
  50160. * By default, the effect is "strectching" the highlights along the tangents.
  50161. */
  50162. direction: Vector2;
  50163. private _texture;
  50164. /**
  50165. * Stores the anisotropy values in a texture.
  50166. * rg is direction (like normal from -1 to 1)
  50167. * b is a intensity
  50168. */
  50169. texture: Nullable<BaseTexture>;
  50170. /** @hidden */
  50171. private _internalMarkAllSubMeshesAsTexturesDirty;
  50172. /** @hidden */
  50173. _markAllSubMeshesAsTexturesDirty(): void;
  50174. /**
  50175. * Instantiate a new istance of anisotropy configuration.
  50176. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50177. */
  50178. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50179. /**
  50180. * Specifies that the submesh is ready to be used.
  50181. * @param defines the list of "defines" to update.
  50182. * @param scene defines the scene the material belongs to.
  50183. * @returns - boolean indicating that the submesh is ready or not.
  50184. */
  50185. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  50186. /**
  50187. * Checks to see if a texture is used in the material.
  50188. * @param defines the list of "defines" to update.
  50189. * @param mesh the mesh we are preparing the defines for.
  50190. * @param scene defines the scene the material belongs to.
  50191. */
  50192. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  50193. /**
  50194. * Binds the material data.
  50195. * @param uniformBuffer defines the Uniform buffer to fill in.
  50196. * @param scene defines the scene the material belongs to.
  50197. * @param isFrozen defines wether the material is frozen or not.
  50198. */
  50199. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50200. /**
  50201. * Checks to see if a texture is used in the material.
  50202. * @param texture - Base texture to use.
  50203. * @returns - Boolean specifying if a texture is used in the material.
  50204. */
  50205. hasTexture(texture: BaseTexture): boolean;
  50206. /**
  50207. * Returns an array of the actively used textures.
  50208. * @param activeTextures Array of BaseTextures
  50209. */
  50210. getActiveTextures(activeTextures: BaseTexture[]): void;
  50211. /**
  50212. * Returns the animatable textures.
  50213. * @param animatables Array of animatable textures.
  50214. */
  50215. getAnimatables(animatables: IAnimatable[]): void;
  50216. /**
  50217. * Disposes the resources of the material.
  50218. * @param forceDisposeTextures - Forces the disposal of all textures.
  50219. */
  50220. dispose(forceDisposeTextures?: boolean): void;
  50221. /**
  50222. * Get the current class name of the texture useful for serialization or dynamic coding.
  50223. * @returns "PBRAnisotropicConfiguration"
  50224. */
  50225. getClassName(): string;
  50226. /**
  50227. * Add fallbacks to the effect fallbacks list.
  50228. * @param defines defines the Base texture to use.
  50229. * @param fallbacks defines the current fallback list.
  50230. * @param currentRank defines the current fallback rank.
  50231. * @returns the new fallback rank.
  50232. */
  50233. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50234. /**
  50235. * Add the required uniforms to the current list.
  50236. * @param uniforms defines the current uniform list.
  50237. */
  50238. static AddUniforms(uniforms: string[]): void;
  50239. /**
  50240. * Add the required uniforms to the current buffer.
  50241. * @param uniformBuffer defines the current uniform buffer.
  50242. */
  50243. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50244. /**
  50245. * Add the required samplers to the current list.
  50246. * @param samplers defines the current sampler list.
  50247. */
  50248. static AddSamplers(samplers: string[]): void;
  50249. /**
  50250. * Makes a duplicate of the current configuration into another one.
  50251. * @param anisotropicConfiguration define the config where to copy the info
  50252. */
  50253. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  50254. /**
  50255. * Serializes this anisotropy configuration.
  50256. * @returns - An object with the serialized config.
  50257. */
  50258. serialize(): any;
  50259. /**
  50260. * Parses a anisotropy Configuration from a serialized object.
  50261. * @param source - Serialized object.
  50262. * @param scene Defines the scene we are parsing for
  50263. * @param rootUrl Defines the rootUrl to load from
  50264. */
  50265. parse(source: any, scene: Scene, rootUrl: string): void;
  50266. }
  50267. }
  50268. declare module BABYLON {
  50269. /**
  50270. * @hidden
  50271. */
  50272. export interface IMaterialBRDFDefines {
  50273. BRDF_V_HEIGHT_CORRELATED: boolean;
  50274. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50275. SPHERICAL_HARMONICS: boolean;
  50276. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50277. /** @hidden */
  50278. _areMiscDirty: boolean;
  50279. }
  50280. /**
  50281. * Define the code related to the BRDF parameters of the pbr material.
  50282. */
  50283. export class PBRBRDFConfiguration {
  50284. /**
  50285. * Default value used for the energy conservation.
  50286. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50287. */
  50288. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  50289. /**
  50290. * Default value used for the Smith Visibility Height Correlated mode.
  50291. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50292. */
  50293. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  50294. /**
  50295. * Default value used for the IBL diffuse part.
  50296. * This can help switching back to the polynomials mode globally which is a tiny bit
  50297. * less GPU intensive at the drawback of a lower quality.
  50298. */
  50299. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  50300. /**
  50301. * Default value used for activating energy conservation for the specular workflow.
  50302. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50303. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50304. */
  50305. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  50306. private _useEnergyConservation;
  50307. /**
  50308. * Defines if the material uses energy conservation.
  50309. */
  50310. useEnergyConservation: boolean;
  50311. private _useSmithVisibilityHeightCorrelated;
  50312. /**
  50313. * LEGACY Mode set to false
  50314. * Defines if the material uses height smith correlated visibility term.
  50315. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  50316. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  50317. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  50318. * Not relying on height correlated will also disable energy conservation.
  50319. */
  50320. useSmithVisibilityHeightCorrelated: boolean;
  50321. private _useSphericalHarmonics;
  50322. /**
  50323. * LEGACY Mode set to false
  50324. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  50325. * diffuse part of the IBL.
  50326. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  50327. * to the ground truth.
  50328. */
  50329. useSphericalHarmonics: boolean;
  50330. private _useSpecularGlossinessInputEnergyConservation;
  50331. /**
  50332. * Defines if the material uses energy conservation, when the specular workflow is active.
  50333. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50334. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50335. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  50336. */
  50337. useSpecularGlossinessInputEnergyConservation: boolean;
  50338. /** @hidden */
  50339. private _internalMarkAllSubMeshesAsMiscDirty;
  50340. /** @hidden */
  50341. _markAllSubMeshesAsMiscDirty(): void;
  50342. /**
  50343. * Instantiate a new istance of clear coat configuration.
  50344. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  50345. */
  50346. constructor(markAllSubMeshesAsMiscDirty: () => void);
  50347. /**
  50348. * Checks to see if a texture is used in the material.
  50349. * @param defines the list of "defines" to update.
  50350. */
  50351. prepareDefines(defines: IMaterialBRDFDefines): void;
  50352. /**
  50353. * Get the current class name of the texture useful for serialization or dynamic coding.
  50354. * @returns "PBRClearCoatConfiguration"
  50355. */
  50356. getClassName(): string;
  50357. /**
  50358. * Makes a duplicate of the current configuration into another one.
  50359. * @param brdfConfiguration define the config where to copy the info
  50360. */
  50361. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  50362. /**
  50363. * Serializes this BRDF configuration.
  50364. * @returns - An object with the serialized config.
  50365. */
  50366. serialize(): any;
  50367. /**
  50368. * Parses a anisotropy Configuration from a serialized object.
  50369. * @param source - Serialized object.
  50370. * @param scene Defines the scene we are parsing for
  50371. * @param rootUrl Defines the rootUrl to load from
  50372. */
  50373. parse(source: any, scene: Scene, rootUrl: string): void;
  50374. }
  50375. }
  50376. declare module BABYLON {
  50377. /**
  50378. * @hidden
  50379. */
  50380. export interface IMaterialSheenDefines {
  50381. SHEEN: boolean;
  50382. SHEEN_TEXTURE: boolean;
  50383. SHEEN_TEXTUREDIRECTUV: number;
  50384. SHEEN_LINKWITHALBEDO: boolean;
  50385. /** @hidden */
  50386. _areTexturesDirty: boolean;
  50387. }
  50388. /**
  50389. * Define the code related to the Sheen parameters of the pbr material.
  50390. */
  50391. export class PBRSheenConfiguration {
  50392. private _isEnabled;
  50393. /**
  50394. * Defines if the material uses sheen.
  50395. */
  50396. isEnabled: boolean;
  50397. private _linkSheenWithAlbedo;
  50398. /**
  50399. * Defines if the sheen is linked to the sheen color.
  50400. */
  50401. linkSheenWithAlbedo: boolean;
  50402. /**
  50403. * Defines the sheen intensity.
  50404. */
  50405. intensity: number;
  50406. /**
  50407. * Defines the sheen color.
  50408. */
  50409. color: Color3;
  50410. private _texture;
  50411. /**
  50412. * Stores the sheen tint values in a texture.
  50413. * rgb is tint
  50414. * a is a intensity
  50415. */
  50416. texture: Nullable<BaseTexture>;
  50417. /** @hidden */
  50418. private _internalMarkAllSubMeshesAsTexturesDirty;
  50419. /** @hidden */
  50420. _markAllSubMeshesAsTexturesDirty(): void;
  50421. /**
  50422. * Instantiate a new istance of clear coat configuration.
  50423. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50424. */
  50425. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50426. /**
  50427. * Specifies that the submesh is ready to be used.
  50428. * @param defines the list of "defines" to update.
  50429. * @param scene defines the scene the material belongs to.
  50430. * @returns - boolean indicating that the submesh is ready or not.
  50431. */
  50432. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  50433. /**
  50434. * Checks to see if a texture is used in the material.
  50435. * @param defines the list of "defines" to update.
  50436. * @param scene defines the scene the material belongs to.
  50437. */
  50438. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  50439. /**
  50440. * Binds the material data.
  50441. * @param uniformBuffer defines the Uniform buffer to fill in.
  50442. * @param scene defines the scene the material belongs to.
  50443. * @param isFrozen defines wether the material is frozen or not.
  50444. */
  50445. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50446. /**
  50447. * Checks to see if a texture is used in the material.
  50448. * @param texture - Base texture to use.
  50449. * @returns - Boolean specifying if a texture is used in the material.
  50450. */
  50451. hasTexture(texture: BaseTexture): boolean;
  50452. /**
  50453. * Returns an array of the actively used textures.
  50454. * @param activeTextures Array of BaseTextures
  50455. */
  50456. getActiveTextures(activeTextures: BaseTexture[]): void;
  50457. /**
  50458. * Returns the animatable textures.
  50459. * @param animatables Array of animatable textures.
  50460. */
  50461. getAnimatables(animatables: IAnimatable[]): void;
  50462. /**
  50463. * Disposes the resources of the material.
  50464. * @param forceDisposeTextures - Forces the disposal of all textures.
  50465. */
  50466. dispose(forceDisposeTextures?: boolean): void;
  50467. /**
  50468. * Get the current class name of the texture useful for serialization or dynamic coding.
  50469. * @returns "PBRSheenConfiguration"
  50470. */
  50471. getClassName(): string;
  50472. /**
  50473. * Add fallbacks to the effect fallbacks list.
  50474. * @param defines defines the Base texture to use.
  50475. * @param fallbacks defines the current fallback list.
  50476. * @param currentRank defines the current fallback rank.
  50477. * @returns the new fallback rank.
  50478. */
  50479. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50480. /**
  50481. * Add the required uniforms to the current list.
  50482. * @param uniforms defines the current uniform list.
  50483. */
  50484. static AddUniforms(uniforms: string[]): void;
  50485. /**
  50486. * Add the required uniforms to the current buffer.
  50487. * @param uniformBuffer defines the current uniform buffer.
  50488. */
  50489. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50490. /**
  50491. * Add the required samplers to the current list.
  50492. * @param samplers defines the current sampler list.
  50493. */
  50494. static AddSamplers(samplers: string[]): void;
  50495. /**
  50496. * Makes a duplicate of the current configuration into another one.
  50497. * @param sheenConfiguration define the config where to copy the info
  50498. */
  50499. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  50500. /**
  50501. * Serializes this BRDF configuration.
  50502. * @returns - An object with the serialized config.
  50503. */
  50504. serialize(): any;
  50505. /**
  50506. * Parses a anisotropy Configuration from a serialized object.
  50507. * @param source - Serialized object.
  50508. * @param scene Defines the scene we are parsing for
  50509. * @param rootUrl Defines the rootUrl to load from
  50510. */
  50511. parse(source: any, scene: Scene, rootUrl: string): void;
  50512. }
  50513. }
  50514. declare module BABYLON {
  50515. /**
  50516. * @hidden
  50517. */
  50518. export interface IMaterialSubSurfaceDefines {
  50519. SUBSURFACE: boolean;
  50520. SS_REFRACTION: boolean;
  50521. SS_TRANSLUCENCY: boolean;
  50522. SS_SCATERRING: boolean;
  50523. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50524. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50525. SS_REFRACTIONMAP_3D: boolean;
  50526. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50527. SS_LODINREFRACTIONALPHA: boolean;
  50528. SS_GAMMAREFRACTION: boolean;
  50529. SS_RGBDREFRACTION: boolean;
  50530. SS_LINEARSPECULARREFRACTION: boolean;
  50531. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50532. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50533. /** @hidden */
  50534. _areTexturesDirty: boolean;
  50535. }
  50536. /**
  50537. * Define the code related to the sub surface parameters of the pbr material.
  50538. */
  50539. export class PBRSubSurfaceConfiguration {
  50540. private _isRefractionEnabled;
  50541. /**
  50542. * Defines if the refraction is enabled in the material.
  50543. */
  50544. isRefractionEnabled: boolean;
  50545. private _isTranslucencyEnabled;
  50546. /**
  50547. * Defines if the translucency is enabled in the material.
  50548. */
  50549. isTranslucencyEnabled: boolean;
  50550. private _isScatteringEnabled;
  50551. /**
  50552. * Defines the refraction intensity of the material.
  50553. * The refraction when enabled replaces the Diffuse part of the material.
  50554. * The intensity helps transitionning between diffuse and refraction.
  50555. */
  50556. refractionIntensity: number;
  50557. /**
  50558. * Defines the translucency intensity of the material.
  50559. * When translucency has been enabled, this defines how much of the "translucency"
  50560. * is addded to the diffuse part of the material.
  50561. */
  50562. translucencyIntensity: number;
  50563. /**
  50564. * Defines the scattering intensity of the material.
  50565. * When scattering has been enabled, this defines how much of the "scattered light"
  50566. * is addded to the diffuse part of the material.
  50567. */
  50568. scatteringIntensity: number;
  50569. private _thicknessTexture;
  50570. /**
  50571. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  50572. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  50573. * 0 would mean minimumThickness
  50574. * 1 would mean maximumThickness
  50575. * The other channels might be use as a mask to vary the different effects intensity.
  50576. */
  50577. thicknessTexture: Nullable<BaseTexture>;
  50578. private _refractionTexture;
  50579. /**
  50580. * Defines the texture to use for refraction.
  50581. */
  50582. refractionTexture: Nullable<BaseTexture>;
  50583. private _indexOfRefraction;
  50584. /**
  50585. * Defines the index of refraction used in the material.
  50586. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  50587. */
  50588. indexOfRefraction: number;
  50589. private _invertRefractionY;
  50590. /**
  50591. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50592. */
  50593. invertRefractionY: boolean;
  50594. private _linkRefractionWithTransparency;
  50595. /**
  50596. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50597. * Materials half opaque for instance using refraction could benefit from this control.
  50598. */
  50599. linkRefractionWithTransparency: boolean;
  50600. /**
  50601. * Defines the minimum thickness stored in the thickness map.
  50602. * If no thickness map is defined, this value will be used to simulate thickness.
  50603. */
  50604. minimumThickness: number;
  50605. /**
  50606. * Defines the maximum thickness stored in the thickness map.
  50607. */
  50608. maximumThickness: number;
  50609. /**
  50610. * Defines the volume tint of the material.
  50611. * This is used for both translucency and scattering.
  50612. */
  50613. tintColor: Color3;
  50614. /**
  50615. * Defines the distance at which the tint color should be found in the media.
  50616. * This is used for refraction only.
  50617. */
  50618. tintColorAtDistance: number;
  50619. /**
  50620. * Defines how far each channel transmit through the media.
  50621. * It is defined as a color to simplify it selection.
  50622. */
  50623. diffusionDistance: Color3;
  50624. private _useMaskFromThicknessTexture;
  50625. /**
  50626. * Stores the intensity of the different subsurface effects in the thickness texture.
  50627. * * the green channel is the translucency intensity.
  50628. * * the blue channel is the scattering intensity.
  50629. * * the alpha channel is the refraction intensity.
  50630. */
  50631. useMaskFromThicknessTexture: boolean;
  50632. /** @hidden */
  50633. private _internalMarkAllSubMeshesAsTexturesDirty;
  50634. /** @hidden */
  50635. _markAllSubMeshesAsTexturesDirty(): void;
  50636. /**
  50637. * Instantiate a new istance of sub surface configuration.
  50638. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50639. */
  50640. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50641. /**
  50642. * Gets wehter the submesh is ready to be used or not.
  50643. * @param defines the list of "defines" to update.
  50644. * @param scene defines the scene the material belongs to.
  50645. * @returns - boolean indicating that the submesh is ready or not.
  50646. */
  50647. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  50648. /**
  50649. * Checks to see if a texture is used in the material.
  50650. * @param defines the list of "defines" to update.
  50651. * @param scene defines the scene to the material belongs to.
  50652. */
  50653. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  50654. /**
  50655. * Binds the material data.
  50656. * @param uniformBuffer defines the Uniform buffer to fill in.
  50657. * @param scene defines the scene the material belongs to.
  50658. * @param engine defines the engine the material belongs to.
  50659. * @param isFrozen defines wether the material is frozen or not.
  50660. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  50661. */
  50662. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  50663. /**
  50664. * Unbinds the material from the mesh.
  50665. * @param activeEffect defines the effect that should be unbound from.
  50666. * @returns true if unbound, otherwise false
  50667. */
  50668. unbind(activeEffect: Effect): boolean;
  50669. /**
  50670. * Returns the texture used for refraction or null if none is used.
  50671. * @param scene defines the scene the material belongs to.
  50672. * @returns - Refraction texture if present. If no refraction texture and refraction
  50673. * is linked with transparency, returns environment texture. Otherwise, returns null.
  50674. */
  50675. private _getRefractionTexture;
  50676. /**
  50677. * Returns true if alpha blending should be disabled.
  50678. */
  50679. get disableAlphaBlending(): boolean;
  50680. /**
  50681. * Fills the list of render target textures.
  50682. * @param renderTargets the list of render targets to update
  50683. */
  50684. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  50685. /**
  50686. * Checks to see if a texture is used in the material.
  50687. * @param texture - Base texture to use.
  50688. * @returns - Boolean specifying if a texture is used in the material.
  50689. */
  50690. hasTexture(texture: BaseTexture): boolean;
  50691. /**
  50692. * Gets a boolean indicating that current material needs to register RTT
  50693. * @returns true if this uses a render target otherwise false.
  50694. */
  50695. hasRenderTargetTextures(): boolean;
  50696. /**
  50697. * Returns an array of the actively used textures.
  50698. * @param activeTextures Array of BaseTextures
  50699. */
  50700. getActiveTextures(activeTextures: BaseTexture[]): void;
  50701. /**
  50702. * Returns the animatable textures.
  50703. * @param animatables Array of animatable textures.
  50704. */
  50705. getAnimatables(animatables: IAnimatable[]): void;
  50706. /**
  50707. * Disposes the resources of the material.
  50708. * @param forceDisposeTextures - Forces the disposal of all textures.
  50709. */
  50710. dispose(forceDisposeTextures?: boolean): void;
  50711. /**
  50712. * Get the current class name of the texture useful for serialization or dynamic coding.
  50713. * @returns "PBRSubSurfaceConfiguration"
  50714. */
  50715. getClassName(): string;
  50716. /**
  50717. * Add fallbacks to the effect fallbacks list.
  50718. * @param defines defines the Base texture to use.
  50719. * @param fallbacks defines the current fallback list.
  50720. * @param currentRank defines the current fallback rank.
  50721. * @returns the new fallback rank.
  50722. */
  50723. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50724. /**
  50725. * Add the required uniforms to the current list.
  50726. * @param uniforms defines the current uniform list.
  50727. */
  50728. static AddUniforms(uniforms: string[]): void;
  50729. /**
  50730. * Add the required samplers to the current list.
  50731. * @param samplers defines the current sampler list.
  50732. */
  50733. static AddSamplers(samplers: string[]): void;
  50734. /**
  50735. * Add the required uniforms to the current buffer.
  50736. * @param uniformBuffer defines the current uniform buffer.
  50737. */
  50738. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50739. /**
  50740. * Makes a duplicate of the current configuration into another one.
  50741. * @param configuration define the config where to copy the info
  50742. */
  50743. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  50744. /**
  50745. * Serializes this Sub Surface configuration.
  50746. * @returns - An object with the serialized config.
  50747. */
  50748. serialize(): any;
  50749. /**
  50750. * Parses a anisotropy Configuration from a serialized object.
  50751. * @param source - Serialized object.
  50752. * @param scene Defines the scene we are parsing for
  50753. * @param rootUrl Defines the rootUrl to load from
  50754. */
  50755. parse(source: any, scene: Scene, rootUrl: string): void;
  50756. }
  50757. }
  50758. declare module BABYLON {
  50759. /** @hidden */
  50760. export var pbrFragmentDeclaration: {
  50761. name: string;
  50762. shader: string;
  50763. };
  50764. }
  50765. declare module BABYLON {
  50766. /** @hidden */
  50767. export var pbrUboDeclaration: {
  50768. name: string;
  50769. shader: string;
  50770. };
  50771. }
  50772. declare module BABYLON {
  50773. /** @hidden */
  50774. export var pbrFragmentExtraDeclaration: {
  50775. name: string;
  50776. shader: string;
  50777. };
  50778. }
  50779. declare module BABYLON {
  50780. /** @hidden */
  50781. export var pbrFragmentSamplersDeclaration: {
  50782. name: string;
  50783. shader: string;
  50784. };
  50785. }
  50786. declare module BABYLON {
  50787. /** @hidden */
  50788. export var pbrHelperFunctions: {
  50789. name: string;
  50790. shader: string;
  50791. };
  50792. }
  50793. declare module BABYLON {
  50794. /** @hidden */
  50795. export var harmonicsFunctions: {
  50796. name: string;
  50797. shader: string;
  50798. };
  50799. }
  50800. declare module BABYLON {
  50801. /** @hidden */
  50802. export var pbrDirectLightingSetupFunctions: {
  50803. name: string;
  50804. shader: string;
  50805. };
  50806. }
  50807. declare module BABYLON {
  50808. /** @hidden */
  50809. export var pbrDirectLightingFalloffFunctions: {
  50810. name: string;
  50811. shader: string;
  50812. };
  50813. }
  50814. declare module BABYLON {
  50815. /** @hidden */
  50816. export var pbrBRDFFunctions: {
  50817. name: string;
  50818. shader: string;
  50819. };
  50820. }
  50821. declare module BABYLON {
  50822. /** @hidden */
  50823. export var pbrDirectLightingFunctions: {
  50824. name: string;
  50825. shader: string;
  50826. };
  50827. }
  50828. declare module BABYLON {
  50829. /** @hidden */
  50830. export var pbrIBLFunctions: {
  50831. name: string;
  50832. shader: string;
  50833. };
  50834. }
  50835. declare module BABYLON {
  50836. /** @hidden */
  50837. export var pbrDebug: {
  50838. name: string;
  50839. shader: string;
  50840. };
  50841. }
  50842. declare module BABYLON {
  50843. /** @hidden */
  50844. export var pbrPixelShader: {
  50845. name: string;
  50846. shader: string;
  50847. };
  50848. }
  50849. declare module BABYLON {
  50850. /** @hidden */
  50851. export var pbrVertexDeclaration: {
  50852. name: string;
  50853. shader: string;
  50854. };
  50855. }
  50856. declare module BABYLON {
  50857. /** @hidden */
  50858. export var pbrVertexShader: {
  50859. name: string;
  50860. shader: string;
  50861. };
  50862. }
  50863. declare module BABYLON {
  50864. /**
  50865. * Manages the defines for the PBR Material.
  50866. * @hidden
  50867. */
  50868. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  50869. PBR: boolean;
  50870. MAINUV1: boolean;
  50871. MAINUV2: boolean;
  50872. UV1: boolean;
  50873. UV2: boolean;
  50874. ALBEDO: boolean;
  50875. ALBEDODIRECTUV: number;
  50876. VERTEXCOLOR: boolean;
  50877. AMBIENT: boolean;
  50878. AMBIENTDIRECTUV: number;
  50879. AMBIENTINGRAYSCALE: boolean;
  50880. OPACITY: boolean;
  50881. VERTEXALPHA: boolean;
  50882. OPACITYDIRECTUV: number;
  50883. OPACITYRGB: boolean;
  50884. ALPHATEST: boolean;
  50885. DEPTHPREPASS: boolean;
  50886. ALPHABLEND: boolean;
  50887. ALPHAFROMALBEDO: boolean;
  50888. ALPHATESTVALUE: string;
  50889. SPECULAROVERALPHA: boolean;
  50890. RADIANCEOVERALPHA: boolean;
  50891. ALPHAFRESNEL: boolean;
  50892. LINEARALPHAFRESNEL: boolean;
  50893. PREMULTIPLYALPHA: boolean;
  50894. EMISSIVE: boolean;
  50895. EMISSIVEDIRECTUV: number;
  50896. REFLECTIVITY: boolean;
  50897. REFLECTIVITYDIRECTUV: number;
  50898. SPECULARTERM: boolean;
  50899. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  50900. MICROSURFACEAUTOMATIC: boolean;
  50901. LODBASEDMICROSFURACE: boolean;
  50902. MICROSURFACEMAP: boolean;
  50903. MICROSURFACEMAPDIRECTUV: number;
  50904. METALLICWORKFLOW: boolean;
  50905. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  50906. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  50907. METALLNESSSTOREINMETALMAPBLUE: boolean;
  50908. AOSTOREINMETALMAPRED: boolean;
  50909. METALLICF0FACTORFROMMETALLICMAP: boolean;
  50910. ENVIRONMENTBRDF: boolean;
  50911. ENVIRONMENTBRDF_RGBD: boolean;
  50912. NORMAL: boolean;
  50913. TANGENT: boolean;
  50914. BUMP: boolean;
  50915. BUMPDIRECTUV: number;
  50916. OBJECTSPACE_NORMALMAP: boolean;
  50917. PARALLAX: boolean;
  50918. PARALLAXOCCLUSION: boolean;
  50919. NORMALXYSCALE: boolean;
  50920. LIGHTMAP: boolean;
  50921. LIGHTMAPDIRECTUV: number;
  50922. USELIGHTMAPASSHADOWMAP: boolean;
  50923. GAMMALIGHTMAP: boolean;
  50924. RGBDLIGHTMAP: boolean;
  50925. REFLECTION: boolean;
  50926. REFLECTIONMAP_3D: boolean;
  50927. REFLECTIONMAP_SPHERICAL: boolean;
  50928. REFLECTIONMAP_PLANAR: boolean;
  50929. REFLECTIONMAP_CUBIC: boolean;
  50930. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  50931. REFLECTIONMAP_PROJECTION: boolean;
  50932. REFLECTIONMAP_SKYBOX: boolean;
  50933. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  50934. REFLECTIONMAP_EXPLICIT: boolean;
  50935. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  50936. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  50937. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  50938. INVERTCUBICMAP: boolean;
  50939. USESPHERICALFROMREFLECTIONMAP: boolean;
  50940. USEIRRADIANCEMAP: boolean;
  50941. SPHERICAL_HARMONICS: boolean;
  50942. USESPHERICALINVERTEX: boolean;
  50943. REFLECTIONMAP_OPPOSITEZ: boolean;
  50944. LODINREFLECTIONALPHA: boolean;
  50945. GAMMAREFLECTION: boolean;
  50946. RGBDREFLECTION: boolean;
  50947. LINEARSPECULARREFLECTION: boolean;
  50948. RADIANCEOCCLUSION: boolean;
  50949. HORIZONOCCLUSION: boolean;
  50950. INSTANCES: boolean;
  50951. NUM_BONE_INFLUENCERS: number;
  50952. BonesPerMesh: number;
  50953. BONETEXTURE: boolean;
  50954. NONUNIFORMSCALING: boolean;
  50955. MORPHTARGETS: boolean;
  50956. MORPHTARGETS_NORMAL: boolean;
  50957. MORPHTARGETS_TANGENT: boolean;
  50958. MORPHTARGETS_UV: boolean;
  50959. NUM_MORPH_INFLUENCERS: number;
  50960. IMAGEPROCESSING: boolean;
  50961. VIGNETTE: boolean;
  50962. VIGNETTEBLENDMODEMULTIPLY: boolean;
  50963. VIGNETTEBLENDMODEOPAQUE: boolean;
  50964. TONEMAPPING: boolean;
  50965. TONEMAPPING_ACES: boolean;
  50966. CONTRAST: boolean;
  50967. COLORCURVES: boolean;
  50968. COLORGRADING: boolean;
  50969. COLORGRADING3D: boolean;
  50970. SAMPLER3DGREENDEPTH: boolean;
  50971. SAMPLER3DBGRMAP: boolean;
  50972. IMAGEPROCESSINGPOSTPROCESS: boolean;
  50973. EXPOSURE: boolean;
  50974. MULTIVIEW: boolean;
  50975. USEPHYSICALLIGHTFALLOFF: boolean;
  50976. USEGLTFLIGHTFALLOFF: boolean;
  50977. TWOSIDEDLIGHTING: boolean;
  50978. SHADOWFLOAT: boolean;
  50979. CLIPPLANE: boolean;
  50980. CLIPPLANE2: boolean;
  50981. CLIPPLANE3: boolean;
  50982. CLIPPLANE4: boolean;
  50983. CLIPPLANE5: boolean;
  50984. CLIPPLANE6: boolean;
  50985. POINTSIZE: boolean;
  50986. FOG: boolean;
  50987. LOGARITHMICDEPTH: boolean;
  50988. FORCENORMALFORWARD: boolean;
  50989. SPECULARAA: boolean;
  50990. CLEARCOAT: boolean;
  50991. CLEARCOAT_DEFAULTIOR: boolean;
  50992. CLEARCOAT_TEXTURE: boolean;
  50993. CLEARCOAT_TEXTUREDIRECTUV: number;
  50994. CLEARCOAT_BUMP: boolean;
  50995. CLEARCOAT_BUMPDIRECTUV: number;
  50996. CLEARCOAT_TINT: boolean;
  50997. CLEARCOAT_TINT_TEXTURE: boolean;
  50998. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50999. ANISOTROPIC: boolean;
  51000. ANISOTROPIC_TEXTURE: boolean;
  51001. ANISOTROPIC_TEXTUREDIRECTUV: number;
  51002. BRDF_V_HEIGHT_CORRELATED: boolean;
  51003. MS_BRDF_ENERGY_CONSERVATION: boolean;
  51004. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  51005. SHEEN: boolean;
  51006. SHEEN_TEXTURE: boolean;
  51007. SHEEN_TEXTUREDIRECTUV: number;
  51008. SHEEN_LINKWITHALBEDO: boolean;
  51009. SUBSURFACE: boolean;
  51010. SS_REFRACTION: boolean;
  51011. SS_TRANSLUCENCY: boolean;
  51012. SS_SCATERRING: boolean;
  51013. SS_THICKNESSANDMASK_TEXTURE: boolean;
  51014. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  51015. SS_REFRACTIONMAP_3D: boolean;
  51016. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  51017. SS_LODINREFRACTIONALPHA: boolean;
  51018. SS_GAMMAREFRACTION: boolean;
  51019. SS_RGBDREFRACTION: boolean;
  51020. SS_LINEARSPECULARREFRACTION: boolean;
  51021. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  51022. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  51023. UNLIT: boolean;
  51024. DEBUGMODE: number;
  51025. /**
  51026. * Initializes the PBR Material defines.
  51027. */
  51028. constructor();
  51029. /**
  51030. * Resets the PBR Material defines.
  51031. */
  51032. reset(): void;
  51033. }
  51034. /**
  51035. * The Physically based material base class of BJS.
  51036. *
  51037. * This offers the main features of a standard PBR material.
  51038. * For more information, please refer to the documentation :
  51039. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51040. */
  51041. export abstract class PBRBaseMaterial extends PushMaterial {
  51042. /**
  51043. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51044. */
  51045. static readonly PBRMATERIAL_OPAQUE: number;
  51046. /**
  51047. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51048. */
  51049. static readonly PBRMATERIAL_ALPHATEST: number;
  51050. /**
  51051. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51052. */
  51053. static readonly PBRMATERIAL_ALPHABLEND: number;
  51054. /**
  51055. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51056. * They are also discarded below the alpha cutoff threshold to improve performances.
  51057. */
  51058. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51059. /**
  51060. * Defines the default value of how much AO map is occluding the analytical lights
  51061. * (point spot...).
  51062. */
  51063. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51064. /**
  51065. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  51066. */
  51067. static readonly LIGHTFALLOFF_PHYSICAL: number;
  51068. /**
  51069. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  51070. * to enhance interoperability with other engines.
  51071. */
  51072. static readonly LIGHTFALLOFF_GLTF: number;
  51073. /**
  51074. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  51075. * to enhance interoperability with other materials.
  51076. */
  51077. static readonly LIGHTFALLOFF_STANDARD: number;
  51078. /**
  51079. * Intensity of the direct lights e.g. the four lights available in your scene.
  51080. * This impacts both the direct diffuse and specular highlights.
  51081. */
  51082. protected _directIntensity: number;
  51083. /**
  51084. * Intensity of the emissive part of the material.
  51085. * This helps controlling the emissive effect without modifying the emissive color.
  51086. */
  51087. protected _emissiveIntensity: number;
  51088. /**
  51089. * Intensity of the environment e.g. how much the environment will light the object
  51090. * either through harmonics for rough material or through the refelction for shiny ones.
  51091. */
  51092. protected _environmentIntensity: number;
  51093. /**
  51094. * This is a special control allowing the reduction of the specular highlights coming from the
  51095. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51096. */
  51097. protected _specularIntensity: number;
  51098. /**
  51099. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  51100. */
  51101. private _lightingInfos;
  51102. /**
  51103. * Debug Control allowing disabling the bump map on this material.
  51104. */
  51105. protected _disableBumpMap: boolean;
  51106. /**
  51107. * AKA Diffuse Texture in standard nomenclature.
  51108. */
  51109. protected _albedoTexture: Nullable<BaseTexture>;
  51110. /**
  51111. * AKA Occlusion Texture in other nomenclature.
  51112. */
  51113. protected _ambientTexture: Nullable<BaseTexture>;
  51114. /**
  51115. * AKA Occlusion Texture Intensity in other nomenclature.
  51116. */
  51117. protected _ambientTextureStrength: number;
  51118. /**
  51119. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51120. * 1 means it completely occludes it
  51121. * 0 mean it has no impact
  51122. */
  51123. protected _ambientTextureImpactOnAnalyticalLights: number;
  51124. /**
  51125. * Stores the alpha values in a texture.
  51126. */
  51127. protected _opacityTexture: Nullable<BaseTexture>;
  51128. /**
  51129. * Stores the reflection values in a texture.
  51130. */
  51131. protected _reflectionTexture: Nullable<BaseTexture>;
  51132. /**
  51133. * Stores the emissive values in a texture.
  51134. */
  51135. protected _emissiveTexture: Nullable<BaseTexture>;
  51136. /**
  51137. * AKA Specular texture in other nomenclature.
  51138. */
  51139. protected _reflectivityTexture: Nullable<BaseTexture>;
  51140. /**
  51141. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51142. */
  51143. protected _metallicTexture: Nullable<BaseTexture>;
  51144. /**
  51145. * Specifies the metallic scalar of the metallic/roughness workflow.
  51146. * Can also be used to scale the metalness values of the metallic texture.
  51147. */
  51148. protected _metallic: Nullable<number>;
  51149. /**
  51150. * Specifies the roughness scalar of the metallic/roughness workflow.
  51151. * Can also be used to scale the roughness values of the metallic texture.
  51152. */
  51153. protected _roughness: Nullable<number>;
  51154. /**
  51155. * Specifies the an F0 factor to help configuring the material F0.
  51156. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51157. * to 0.5 the previously hard coded value stays the same.
  51158. * Can also be used to scale the F0 values of the metallic texture.
  51159. */
  51160. protected _metallicF0Factor: number;
  51161. /**
  51162. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51163. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51164. * your expectation as it multiplies with the texture data.
  51165. */
  51166. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  51167. /**
  51168. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51169. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51170. */
  51171. protected _microSurfaceTexture: Nullable<BaseTexture>;
  51172. /**
  51173. * Stores surface normal data used to displace a mesh in a texture.
  51174. */
  51175. protected _bumpTexture: Nullable<BaseTexture>;
  51176. /**
  51177. * Stores the pre-calculated light information of a mesh in a texture.
  51178. */
  51179. protected _lightmapTexture: Nullable<BaseTexture>;
  51180. /**
  51181. * The color of a material in ambient lighting.
  51182. */
  51183. protected _ambientColor: Color3;
  51184. /**
  51185. * AKA Diffuse Color in other nomenclature.
  51186. */
  51187. protected _albedoColor: Color3;
  51188. /**
  51189. * AKA Specular Color in other nomenclature.
  51190. */
  51191. protected _reflectivityColor: Color3;
  51192. /**
  51193. * The color applied when light is reflected from a material.
  51194. */
  51195. protected _reflectionColor: Color3;
  51196. /**
  51197. * The color applied when light is emitted from a material.
  51198. */
  51199. protected _emissiveColor: Color3;
  51200. /**
  51201. * AKA Glossiness in other nomenclature.
  51202. */
  51203. protected _microSurface: number;
  51204. /**
  51205. * Specifies that the material will use the light map as a show map.
  51206. */
  51207. protected _useLightmapAsShadowmap: boolean;
  51208. /**
  51209. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51210. * makes the reflect vector face the model (under horizon).
  51211. */
  51212. protected _useHorizonOcclusion: boolean;
  51213. /**
  51214. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51215. * too much the area relying on ambient texture to define their ambient occlusion.
  51216. */
  51217. protected _useRadianceOcclusion: boolean;
  51218. /**
  51219. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51220. */
  51221. protected _useAlphaFromAlbedoTexture: boolean;
  51222. /**
  51223. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  51224. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51225. */
  51226. protected _useSpecularOverAlpha: boolean;
  51227. /**
  51228. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51229. */
  51230. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51231. /**
  51232. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51233. */
  51234. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  51235. /**
  51236. * Specifies if the metallic texture contains the roughness information in its green channel.
  51237. */
  51238. protected _useRoughnessFromMetallicTextureGreen: boolean;
  51239. /**
  51240. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51241. */
  51242. protected _useMetallnessFromMetallicTextureBlue: boolean;
  51243. /**
  51244. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51245. */
  51246. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  51247. /**
  51248. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51249. */
  51250. protected _useAmbientInGrayScale: boolean;
  51251. /**
  51252. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51253. * The material will try to infer what glossiness each pixel should be.
  51254. */
  51255. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  51256. /**
  51257. * Defines the falloff type used in this material.
  51258. * It by default is Physical.
  51259. */
  51260. protected _lightFalloff: number;
  51261. /**
  51262. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51263. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51264. */
  51265. protected _useRadianceOverAlpha: boolean;
  51266. /**
  51267. * Allows using an object space normal map (instead of tangent space).
  51268. */
  51269. protected _useObjectSpaceNormalMap: boolean;
  51270. /**
  51271. * Allows using the bump map in parallax mode.
  51272. */
  51273. protected _useParallax: boolean;
  51274. /**
  51275. * Allows using the bump map in parallax occlusion mode.
  51276. */
  51277. protected _useParallaxOcclusion: boolean;
  51278. /**
  51279. * Controls the scale bias of the parallax mode.
  51280. */
  51281. protected _parallaxScaleBias: number;
  51282. /**
  51283. * If sets to true, disables all the lights affecting the material.
  51284. */
  51285. protected _disableLighting: boolean;
  51286. /**
  51287. * Number of Simultaneous lights allowed on the material.
  51288. */
  51289. protected _maxSimultaneousLights: number;
  51290. /**
  51291. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  51292. */
  51293. protected _invertNormalMapX: boolean;
  51294. /**
  51295. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  51296. */
  51297. protected _invertNormalMapY: boolean;
  51298. /**
  51299. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51300. */
  51301. protected _twoSidedLighting: boolean;
  51302. /**
  51303. * Defines the alpha limits in alpha test mode.
  51304. */
  51305. protected _alphaCutOff: number;
  51306. /**
  51307. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51308. */
  51309. protected _forceAlphaTest: boolean;
  51310. /**
  51311. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51312. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51313. */
  51314. protected _useAlphaFresnel: boolean;
  51315. /**
  51316. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51317. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51318. */
  51319. protected _useLinearAlphaFresnel: boolean;
  51320. /**
  51321. * The transparency mode of the material.
  51322. */
  51323. protected _transparencyMode: Nullable<number>;
  51324. /**
  51325. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  51326. * from cos thetav and roughness:
  51327. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  51328. */
  51329. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  51330. /**
  51331. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51332. */
  51333. protected _forceIrradianceInFragment: boolean;
  51334. /**
  51335. * Force normal to face away from face.
  51336. */
  51337. protected _forceNormalForward: boolean;
  51338. /**
  51339. * Enables specular anti aliasing in the PBR shader.
  51340. * It will both interacts on the Geometry for analytical and IBL lighting.
  51341. * It also prefilter the roughness map based on the bump values.
  51342. */
  51343. protected _enableSpecularAntiAliasing: boolean;
  51344. /**
  51345. * Default configuration related to image processing available in the PBR Material.
  51346. */
  51347. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51348. /**
  51349. * Keep track of the image processing observer to allow dispose and replace.
  51350. */
  51351. private _imageProcessingObserver;
  51352. /**
  51353. * Attaches a new image processing configuration to the PBR Material.
  51354. * @param configuration
  51355. */
  51356. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51357. /**
  51358. * Stores the available render targets.
  51359. */
  51360. private _renderTargets;
  51361. /**
  51362. * Sets the global ambient color for the material used in lighting calculations.
  51363. */
  51364. private _globalAmbientColor;
  51365. /**
  51366. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  51367. */
  51368. private _useLogarithmicDepth;
  51369. /**
  51370. * If set to true, no lighting calculations will be applied.
  51371. */
  51372. private _unlit;
  51373. private _debugMode;
  51374. /**
  51375. * @hidden
  51376. * This is reserved for the inspector.
  51377. * Defines the material debug mode.
  51378. * It helps seeing only some components of the material while troubleshooting.
  51379. */
  51380. debugMode: number;
  51381. /**
  51382. * @hidden
  51383. * This is reserved for the inspector.
  51384. * Specify from where on screen the debug mode should start.
  51385. * The value goes from -1 (full screen) to 1 (not visible)
  51386. * It helps with side by side comparison against the final render
  51387. * This defaults to -1
  51388. */
  51389. private debugLimit;
  51390. /**
  51391. * @hidden
  51392. * This is reserved for the inspector.
  51393. * As the default viewing range might not be enough (if the ambient is really small for instance)
  51394. * You can use the factor to better multiply the final value.
  51395. */
  51396. private debugFactor;
  51397. /**
  51398. * Defines the clear coat layer parameters for the material.
  51399. */
  51400. readonly clearCoat: PBRClearCoatConfiguration;
  51401. /**
  51402. * Defines the anisotropic parameters for the material.
  51403. */
  51404. readonly anisotropy: PBRAnisotropicConfiguration;
  51405. /**
  51406. * Defines the BRDF parameters for the material.
  51407. */
  51408. readonly brdf: PBRBRDFConfiguration;
  51409. /**
  51410. * Defines the Sheen parameters for the material.
  51411. */
  51412. readonly sheen: PBRSheenConfiguration;
  51413. /**
  51414. * Defines the SubSurface parameters for the material.
  51415. */
  51416. readonly subSurface: PBRSubSurfaceConfiguration;
  51417. /**
  51418. * Custom callback helping to override the default shader used in the material.
  51419. */
  51420. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  51421. protected _rebuildInParallel: boolean;
  51422. /**
  51423. * Instantiates a new PBRMaterial instance.
  51424. *
  51425. * @param name The material name
  51426. * @param scene The scene the material will be use in.
  51427. */
  51428. constructor(name: string, scene: Scene);
  51429. /**
  51430. * Gets a boolean indicating that current material needs to register RTT
  51431. */
  51432. get hasRenderTargetTextures(): boolean;
  51433. /**
  51434. * Gets the name of the material class.
  51435. */
  51436. getClassName(): string;
  51437. /**
  51438. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51439. */
  51440. get useLogarithmicDepth(): boolean;
  51441. /**
  51442. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51443. */
  51444. set useLogarithmicDepth(value: boolean);
  51445. /**
  51446. * Gets the current transparency mode.
  51447. */
  51448. get transparencyMode(): Nullable<number>;
  51449. /**
  51450. * Sets the transparency mode of the material.
  51451. *
  51452. * | Value | Type | Description |
  51453. * | ----- | ----------------------------------- | ----------- |
  51454. * | 0 | OPAQUE | |
  51455. * | 1 | ALPHATEST | |
  51456. * | 2 | ALPHABLEND | |
  51457. * | 3 | ALPHATESTANDBLEND | |
  51458. *
  51459. */
  51460. set transparencyMode(value: Nullable<number>);
  51461. /**
  51462. * Returns true if alpha blending should be disabled.
  51463. */
  51464. private get _disableAlphaBlending();
  51465. /**
  51466. * Specifies whether or not this material should be rendered in alpha blend mode.
  51467. */
  51468. needAlphaBlending(): boolean;
  51469. /**
  51470. * Specifies if the mesh will require alpha blending.
  51471. * @param mesh - BJS mesh.
  51472. */
  51473. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  51474. /**
  51475. * Specifies whether or not this material should be rendered in alpha test mode.
  51476. */
  51477. needAlphaTesting(): boolean;
  51478. /**
  51479. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  51480. */
  51481. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  51482. /**
  51483. * Gets the texture used for the alpha test.
  51484. */
  51485. getAlphaTestTexture(): Nullable<BaseTexture>;
  51486. /**
  51487. * Specifies that the submesh is ready to be used.
  51488. * @param mesh - BJS mesh.
  51489. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  51490. * @param useInstances - Specifies that instances should be used.
  51491. * @returns - boolean indicating that the submesh is ready or not.
  51492. */
  51493. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51494. /**
  51495. * Specifies if the material uses metallic roughness workflow.
  51496. * @returns boolean specifiying if the material uses metallic roughness workflow.
  51497. */
  51498. isMetallicWorkflow(): boolean;
  51499. private _prepareEffect;
  51500. private _prepareDefines;
  51501. /**
  51502. * Force shader compilation
  51503. */
  51504. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  51505. /**
  51506. * Initializes the uniform buffer layout for the shader.
  51507. */
  51508. buildUniformLayout(): void;
  51509. /**
  51510. * Unbinds the material from the mesh
  51511. */
  51512. unbind(): void;
  51513. /**
  51514. * Binds the submesh data.
  51515. * @param world - The world matrix.
  51516. * @param mesh - The BJS mesh.
  51517. * @param subMesh - A submesh of the BJS mesh.
  51518. */
  51519. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51520. /**
  51521. * Returns the animatable textures.
  51522. * @returns - Array of animatable textures.
  51523. */
  51524. getAnimatables(): IAnimatable[];
  51525. /**
  51526. * Returns the texture used for reflections.
  51527. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  51528. */
  51529. private _getReflectionTexture;
  51530. /**
  51531. * Returns an array of the actively used textures.
  51532. * @returns - Array of BaseTextures
  51533. */
  51534. getActiveTextures(): BaseTexture[];
  51535. /**
  51536. * Checks to see if a texture is used in the material.
  51537. * @param texture - Base texture to use.
  51538. * @returns - Boolean specifying if a texture is used in the material.
  51539. */
  51540. hasTexture(texture: BaseTexture): boolean;
  51541. /**
  51542. * Disposes the resources of the material.
  51543. * @param forceDisposeEffect - Forces the disposal of effects.
  51544. * @param forceDisposeTextures - Forces the disposal of all textures.
  51545. */
  51546. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51547. }
  51548. }
  51549. declare module BABYLON {
  51550. /**
  51551. * The Physically based material of BJS.
  51552. *
  51553. * This offers the main features of a standard PBR material.
  51554. * For more information, please refer to the documentation :
  51555. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51556. */
  51557. export class PBRMaterial extends PBRBaseMaterial {
  51558. /**
  51559. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51560. */
  51561. static readonly PBRMATERIAL_OPAQUE: number;
  51562. /**
  51563. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51564. */
  51565. static readonly PBRMATERIAL_ALPHATEST: number;
  51566. /**
  51567. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51568. */
  51569. static readonly PBRMATERIAL_ALPHABLEND: number;
  51570. /**
  51571. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51572. * They are also discarded below the alpha cutoff threshold to improve performances.
  51573. */
  51574. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51575. /**
  51576. * Defines the default value of how much AO map is occluding the analytical lights
  51577. * (point spot...).
  51578. */
  51579. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51580. /**
  51581. * Intensity of the direct lights e.g. the four lights available in your scene.
  51582. * This impacts both the direct diffuse and specular highlights.
  51583. */
  51584. directIntensity: number;
  51585. /**
  51586. * Intensity of the emissive part of the material.
  51587. * This helps controlling the emissive effect without modifying the emissive color.
  51588. */
  51589. emissiveIntensity: number;
  51590. /**
  51591. * Intensity of the environment e.g. how much the environment will light the object
  51592. * either through harmonics for rough material or through the refelction for shiny ones.
  51593. */
  51594. environmentIntensity: number;
  51595. /**
  51596. * This is a special control allowing the reduction of the specular highlights coming from the
  51597. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51598. */
  51599. specularIntensity: number;
  51600. /**
  51601. * Debug Control allowing disabling the bump map on this material.
  51602. */
  51603. disableBumpMap: boolean;
  51604. /**
  51605. * AKA Diffuse Texture in standard nomenclature.
  51606. */
  51607. albedoTexture: BaseTexture;
  51608. /**
  51609. * AKA Occlusion Texture in other nomenclature.
  51610. */
  51611. ambientTexture: BaseTexture;
  51612. /**
  51613. * AKA Occlusion Texture Intensity in other nomenclature.
  51614. */
  51615. ambientTextureStrength: number;
  51616. /**
  51617. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51618. * 1 means it completely occludes it
  51619. * 0 mean it has no impact
  51620. */
  51621. ambientTextureImpactOnAnalyticalLights: number;
  51622. /**
  51623. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  51624. */
  51625. opacityTexture: BaseTexture;
  51626. /**
  51627. * Stores the reflection values in a texture.
  51628. */
  51629. reflectionTexture: Nullable<BaseTexture>;
  51630. /**
  51631. * Stores the emissive values in a texture.
  51632. */
  51633. emissiveTexture: BaseTexture;
  51634. /**
  51635. * AKA Specular texture in other nomenclature.
  51636. */
  51637. reflectivityTexture: BaseTexture;
  51638. /**
  51639. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51640. */
  51641. metallicTexture: BaseTexture;
  51642. /**
  51643. * Specifies the metallic scalar of the metallic/roughness workflow.
  51644. * Can also be used to scale the metalness values of the metallic texture.
  51645. */
  51646. metallic: Nullable<number>;
  51647. /**
  51648. * Specifies the roughness scalar of the metallic/roughness workflow.
  51649. * Can also be used to scale the roughness values of the metallic texture.
  51650. */
  51651. roughness: Nullable<number>;
  51652. /**
  51653. * Specifies the an F0 factor to help configuring the material F0.
  51654. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51655. * to 0.5 the previously hard coded value stays the same.
  51656. * Can also be used to scale the F0 values of the metallic texture.
  51657. */
  51658. metallicF0Factor: number;
  51659. /**
  51660. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51661. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51662. * your expectation as it multiplies with the texture data.
  51663. */
  51664. useMetallicF0FactorFromMetallicTexture: boolean;
  51665. /**
  51666. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51667. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51668. */
  51669. microSurfaceTexture: BaseTexture;
  51670. /**
  51671. * Stores surface normal data used to displace a mesh in a texture.
  51672. */
  51673. bumpTexture: BaseTexture;
  51674. /**
  51675. * Stores the pre-calculated light information of a mesh in a texture.
  51676. */
  51677. lightmapTexture: BaseTexture;
  51678. /**
  51679. * Stores the refracted light information in a texture.
  51680. */
  51681. get refractionTexture(): Nullable<BaseTexture>;
  51682. set refractionTexture(value: Nullable<BaseTexture>);
  51683. /**
  51684. * The color of a material in ambient lighting.
  51685. */
  51686. ambientColor: Color3;
  51687. /**
  51688. * AKA Diffuse Color in other nomenclature.
  51689. */
  51690. albedoColor: Color3;
  51691. /**
  51692. * AKA Specular Color in other nomenclature.
  51693. */
  51694. reflectivityColor: Color3;
  51695. /**
  51696. * The color reflected from the material.
  51697. */
  51698. reflectionColor: Color3;
  51699. /**
  51700. * The color emitted from the material.
  51701. */
  51702. emissiveColor: Color3;
  51703. /**
  51704. * AKA Glossiness in other nomenclature.
  51705. */
  51706. microSurface: number;
  51707. /**
  51708. * source material index of refraction (IOR)' / 'destination material IOR.
  51709. */
  51710. get indexOfRefraction(): number;
  51711. set indexOfRefraction(value: number);
  51712. /**
  51713. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  51714. */
  51715. get invertRefractionY(): boolean;
  51716. set invertRefractionY(value: boolean);
  51717. /**
  51718. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51719. * Materials half opaque for instance using refraction could benefit from this control.
  51720. */
  51721. get linkRefractionWithTransparency(): boolean;
  51722. set linkRefractionWithTransparency(value: boolean);
  51723. /**
  51724. * If true, the light map contains occlusion information instead of lighting info.
  51725. */
  51726. useLightmapAsShadowmap: boolean;
  51727. /**
  51728. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51729. */
  51730. useAlphaFromAlbedoTexture: boolean;
  51731. /**
  51732. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51733. */
  51734. forceAlphaTest: boolean;
  51735. /**
  51736. * Defines the alpha limits in alpha test mode.
  51737. */
  51738. alphaCutOff: number;
  51739. /**
  51740. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  51741. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51742. */
  51743. useSpecularOverAlpha: boolean;
  51744. /**
  51745. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51746. */
  51747. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51748. /**
  51749. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51750. */
  51751. useRoughnessFromMetallicTextureAlpha: boolean;
  51752. /**
  51753. * Specifies if the metallic texture contains the roughness information in its green channel.
  51754. */
  51755. useRoughnessFromMetallicTextureGreen: boolean;
  51756. /**
  51757. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51758. */
  51759. useMetallnessFromMetallicTextureBlue: boolean;
  51760. /**
  51761. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51762. */
  51763. useAmbientOcclusionFromMetallicTextureRed: boolean;
  51764. /**
  51765. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51766. */
  51767. useAmbientInGrayScale: boolean;
  51768. /**
  51769. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51770. * The material will try to infer what glossiness each pixel should be.
  51771. */
  51772. useAutoMicroSurfaceFromReflectivityMap: boolean;
  51773. /**
  51774. * BJS is using an harcoded light falloff based on a manually sets up range.
  51775. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51776. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51777. */
  51778. get usePhysicalLightFalloff(): boolean;
  51779. /**
  51780. * BJS is using an harcoded light falloff based on a manually sets up range.
  51781. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51782. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51783. */
  51784. set usePhysicalLightFalloff(value: boolean);
  51785. /**
  51786. * In order to support the falloff compatibility with gltf, a special mode has been added
  51787. * to reproduce the gltf light falloff.
  51788. */
  51789. get useGLTFLightFalloff(): boolean;
  51790. /**
  51791. * In order to support the falloff compatibility with gltf, a special mode has been added
  51792. * to reproduce the gltf light falloff.
  51793. */
  51794. set useGLTFLightFalloff(value: boolean);
  51795. /**
  51796. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51797. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51798. */
  51799. useRadianceOverAlpha: boolean;
  51800. /**
  51801. * Allows using an object space normal map (instead of tangent space).
  51802. */
  51803. useObjectSpaceNormalMap: boolean;
  51804. /**
  51805. * Allows using the bump map in parallax mode.
  51806. */
  51807. useParallax: boolean;
  51808. /**
  51809. * Allows using the bump map in parallax occlusion mode.
  51810. */
  51811. useParallaxOcclusion: boolean;
  51812. /**
  51813. * Controls the scale bias of the parallax mode.
  51814. */
  51815. parallaxScaleBias: number;
  51816. /**
  51817. * If sets to true, disables all the lights affecting the material.
  51818. */
  51819. disableLighting: boolean;
  51820. /**
  51821. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51822. */
  51823. forceIrradianceInFragment: boolean;
  51824. /**
  51825. * Number of Simultaneous lights allowed on the material.
  51826. */
  51827. maxSimultaneousLights: number;
  51828. /**
  51829. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51830. */
  51831. invertNormalMapX: boolean;
  51832. /**
  51833. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51834. */
  51835. invertNormalMapY: boolean;
  51836. /**
  51837. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51838. */
  51839. twoSidedLighting: boolean;
  51840. /**
  51841. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51842. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51843. */
  51844. useAlphaFresnel: boolean;
  51845. /**
  51846. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51847. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51848. */
  51849. useLinearAlphaFresnel: boolean;
  51850. /**
  51851. * Let user defines the brdf lookup texture used for IBL.
  51852. * A default 8bit version is embedded but you could point at :
  51853. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  51854. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  51855. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  51856. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  51857. */
  51858. environmentBRDFTexture: Nullable<BaseTexture>;
  51859. /**
  51860. * Force normal to face away from face.
  51861. */
  51862. forceNormalForward: boolean;
  51863. /**
  51864. * Enables specular anti aliasing in the PBR shader.
  51865. * It will both interacts on the Geometry for analytical and IBL lighting.
  51866. * It also prefilter the roughness map based on the bump values.
  51867. */
  51868. enableSpecularAntiAliasing: boolean;
  51869. /**
  51870. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51871. * makes the reflect vector face the model (under horizon).
  51872. */
  51873. useHorizonOcclusion: boolean;
  51874. /**
  51875. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51876. * too much the area relying on ambient texture to define their ambient occlusion.
  51877. */
  51878. useRadianceOcclusion: boolean;
  51879. /**
  51880. * If set to true, no lighting calculations will be applied.
  51881. */
  51882. unlit: boolean;
  51883. /**
  51884. * Gets the image processing configuration used either in this material.
  51885. */
  51886. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  51887. /**
  51888. * Sets the Default image processing configuration used either in the this material.
  51889. *
  51890. * If sets to null, the scene one is in use.
  51891. */
  51892. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  51893. /**
  51894. * Gets wether the color curves effect is enabled.
  51895. */
  51896. get cameraColorCurvesEnabled(): boolean;
  51897. /**
  51898. * Sets wether the color curves effect is enabled.
  51899. */
  51900. set cameraColorCurvesEnabled(value: boolean);
  51901. /**
  51902. * Gets wether the color grading effect is enabled.
  51903. */
  51904. get cameraColorGradingEnabled(): boolean;
  51905. /**
  51906. * Gets wether the color grading effect is enabled.
  51907. */
  51908. set cameraColorGradingEnabled(value: boolean);
  51909. /**
  51910. * Gets wether tonemapping is enabled or not.
  51911. */
  51912. get cameraToneMappingEnabled(): boolean;
  51913. /**
  51914. * Sets wether tonemapping is enabled or not
  51915. */
  51916. set cameraToneMappingEnabled(value: boolean);
  51917. /**
  51918. * The camera exposure used on this material.
  51919. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51920. * This corresponds to a photographic exposure.
  51921. */
  51922. get cameraExposure(): number;
  51923. /**
  51924. * The camera exposure used on this material.
  51925. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51926. * This corresponds to a photographic exposure.
  51927. */
  51928. set cameraExposure(value: number);
  51929. /**
  51930. * Gets The camera contrast used on this material.
  51931. */
  51932. get cameraContrast(): number;
  51933. /**
  51934. * Sets The camera contrast used on this material.
  51935. */
  51936. set cameraContrast(value: number);
  51937. /**
  51938. * Gets the Color Grading 2D Lookup Texture.
  51939. */
  51940. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  51941. /**
  51942. * Sets the Color Grading 2D Lookup Texture.
  51943. */
  51944. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  51945. /**
  51946. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51947. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51948. * 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;
  51949. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51950. */
  51951. get cameraColorCurves(): Nullable<ColorCurves>;
  51952. /**
  51953. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51954. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51955. * 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;
  51956. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51957. */
  51958. set cameraColorCurves(value: Nullable<ColorCurves>);
  51959. /**
  51960. * Instantiates a new PBRMaterial instance.
  51961. *
  51962. * @param name The material name
  51963. * @param scene The scene the material will be use in.
  51964. */
  51965. constructor(name: string, scene: Scene);
  51966. /**
  51967. * Returns the name of this material class.
  51968. */
  51969. getClassName(): string;
  51970. /**
  51971. * Makes a duplicate of the current material.
  51972. * @param name - name to use for the new material.
  51973. */
  51974. clone(name: string): PBRMaterial;
  51975. /**
  51976. * Serializes this PBR Material.
  51977. * @returns - An object with the serialized material.
  51978. */
  51979. serialize(): any;
  51980. /**
  51981. * Parses a PBR Material from a serialized object.
  51982. * @param source - Serialized object.
  51983. * @param scene - BJS scene instance.
  51984. * @param rootUrl - url for the scene object
  51985. * @returns - PBRMaterial
  51986. */
  51987. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  51988. }
  51989. }
  51990. declare module BABYLON {
  51991. /**
  51992. * Direct draw surface info
  51993. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  51994. */
  51995. export interface DDSInfo {
  51996. /**
  51997. * Width of the texture
  51998. */
  51999. width: number;
  52000. /**
  52001. * Width of the texture
  52002. */
  52003. height: number;
  52004. /**
  52005. * Number of Mipmaps for the texture
  52006. * @see https://en.wikipedia.org/wiki/Mipmap
  52007. */
  52008. mipmapCount: number;
  52009. /**
  52010. * If the textures format is a known fourCC format
  52011. * @see https://www.fourcc.org/
  52012. */
  52013. isFourCC: boolean;
  52014. /**
  52015. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  52016. */
  52017. isRGB: boolean;
  52018. /**
  52019. * If the texture is a lumincance format
  52020. */
  52021. isLuminance: boolean;
  52022. /**
  52023. * If this is a cube texture
  52024. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  52025. */
  52026. isCube: boolean;
  52027. /**
  52028. * If the texture is a compressed format eg. FOURCC_DXT1
  52029. */
  52030. isCompressed: boolean;
  52031. /**
  52032. * The dxgiFormat of the texture
  52033. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  52034. */
  52035. dxgiFormat: number;
  52036. /**
  52037. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  52038. */
  52039. textureType: number;
  52040. /**
  52041. * Sphericle polynomial created for the dds texture
  52042. */
  52043. sphericalPolynomial?: SphericalPolynomial;
  52044. }
  52045. /**
  52046. * Class used to provide DDS decompression tools
  52047. */
  52048. export class DDSTools {
  52049. /**
  52050. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  52051. */
  52052. static StoreLODInAlphaChannel: boolean;
  52053. /**
  52054. * Gets DDS information from an array buffer
  52055. * @param arrayBuffer defines the array buffer to read data from
  52056. * @returns the DDS information
  52057. */
  52058. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  52059. private static _FloatView;
  52060. private static _Int32View;
  52061. private static _ToHalfFloat;
  52062. private static _FromHalfFloat;
  52063. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  52064. private static _GetHalfFloatRGBAArrayBuffer;
  52065. private static _GetFloatRGBAArrayBuffer;
  52066. private static _GetFloatAsUIntRGBAArrayBuffer;
  52067. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  52068. private static _GetRGBAArrayBuffer;
  52069. private static _ExtractLongWordOrder;
  52070. private static _GetRGBArrayBuffer;
  52071. private static _GetLuminanceArrayBuffer;
  52072. /**
  52073. * Uploads DDS Levels to a Babylon Texture
  52074. * @hidden
  52075. */
  52076. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  52077. }
  52078. interface ThinEngine {
  52079. /**
  52080. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  52081. * @param rootUrl defines the url where the file to load is located
  52082. * @param scene defines the current scene
  52083. * @param lodScale defines scale to apply to the mip map selection
  52084. * @param lodOffset defines offset to apply to the mip map selection
  52085. * @param onLoad defines an optional callback raised when the texture is loaded
  52086. * @param onError defines an optional callback raised if there is an issue to load the texture
  52087. * @param format defines the format of the data
  52088. * @param forcedExtension defines the extension to use to pick the right loader
  52089. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  52090. * @returns the cube texture as an InternalTexture
  52091. */
  52092. 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;
  52093. }
  52094. }
  52095. declare module BABYLON {
  52096. /**
  52097. * Implementation of the DDS Texture Loader.
  52098. * @hidden
  52099. */
  52100. export class _DDSTextureLoader implements IInternalTextureLoader {
  52101. /**
  52102. * Defines wether the loader supports cascade loading the different faces.
  52103. */
  52104. readonly supportCascades: boolean;
  52105. /**
  52106. * This returns if the loader support the current file information.
  52107. * @param extension defines the file extension of the file being loaded
  52108. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52109. * @param fallback defines the fallback internal texture if any
  52110. * @param isBase64 defines whether the texture is encoded as a base64
  52111. * @param isBuffer defines whether the texture data are stored as a buffer
  52112. * @returns true if the loader can load the specified file
  52113. */
  52114. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52115. /**
  52116. * Transform the url before loading if required.
  52117. * @param rootUrl the url of the texture
  52118. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52119. * @returns the transformed texture
  52120. */
  52121. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52122. /**
  52123. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52124. * @param rootUrl the url of the texture
  52125. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52126. * @returns the fallback texture
  52127. */
  52128. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52129. /**
  52130. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52131. * @param data contains the texture data
  52132. * @param texture defines the BabylonJS internal texture
  52133. * @param createPolynomials will be true if polynomials have been requested
  52134. * @param onLoad defines the callback to trigger once the texture is ready
  52135. * @param onError defines the callback to trigger in case of error
  52136. */
  52137. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52138. /**
  52139. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52140. * @param data contains the texture data
  52141. * @param texture defines the BabylonJS internal texture
  52142. * @param callback defines the method to call once ready to upload
  52143. */
  52144. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52145. }
  52146. }
  52147. declare module BABYLON {
  52148. /**
  52149. * Implementation of the ENV Texture Loader.
  52150. * @hidden
  52151. */
  52152. export class _ENVTextureLoader implements IInternalTextureLoader {
  52153. /**
  52154. * Defines wether the loader supports cascade loading the different faces.
  52155. */
  52156. readonly supportCascades: boolean;
  52157. /**
  52158. * This returns if the loader support the current file information.
  52159. * @param extension defines the file extension of the file being loaded
  52160. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52161. * @param fallback defines the fallback internal texture if any
  52162. * @param isBase64 defines whether the texture is encoded as a base64
  52163. * @param isBuffer defines whether the texture data are stored as a buffer
  52164. * @returns true if the loader can load the specified file
  52165. */
  52166. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52167. /**
  52168. * Transform the url before loading if required.
  52169. * @param rootUrl the url of the texture
  52170. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52171. * @returns the transformed texture
  52172. */
  52173. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52174. /**
  52175. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52176. * @param rootUrl the url of the texture
  52177. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52178. * @returns the fallback texture
  52179. */
  52180. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52181. /**
  52182. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52183. * @param data contains the texture data
  52184. * @param texture defines the BabylonJS internal texture
  52185. * @param createPolynomials will be true if polynomials have been requested
  52186. * @param onLoad defines the callback to trigger once the texture is ready
  52187. * @param onError defines the callback to trigger in case of error
  52188. */
  52189. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52190. /**
  52191. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52192. * @param data contains the texture data
  52193. * @param texture defines the BabylonJS internal texture
  52194. * @param callback defines the method to call once ready to upload
  52195. */
  52196. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52197. }
  52198. }
  52199. declare module BABYLON {
  52200. /**
  52201. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52202. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52203. */
  52204. export class KhronosTextureContainer {
  52205. /** contents of the KTX container file */
  52206. arrayBuffer: any;
  52207. private static HEADER_LEN;
  52208. private static COMPRESSED_2D;
  52209. private static COMPRESSED_3D;
  52210. private static TEX_2D;
  52211. private static TEX_3D;
  52212. /**
  52213. * Gets the openGL type
  52214. */
  52215. glType: number;
  52216. /**
  52217. * Gets the openGL type size
  52218. */
  52219. glTypeSize: number;
  52220. /**
  52221. * Gets the openGL format
  52222. */
  52223. glFormat: number;
  52224. /**
  52225. * Gets the openGL internal format
  52226. */
  52227. glInternalFormat: number;
  52228. /**
  52229. * Gets the base internal format
  52230. */
  52231. glBaseInternalFormat: number;
  52232. /**
  52233. * Gets image width in pixel
  52234. */
  52235. pixelWidth: number;
  52236. /**
  52237. * Gets image height in pixel
  52238. */
  52239. pixelHeight: number;
  52240. /**
  52241. * Gets image depth in pixels
  52242. */
  52243. pixelDepth: number;
  52244. /**
  52245. * Gets the number of array elements
  52246. */
  52247. numberOfArrayElements: number;
  52248. /**
  52249. * Gets the number of faces
  52250. */
  52251. numberOfFaces: number;
  52252. /**
  52253. * Gets the number of mipmap levels
  52254. */
  52255. numberOfMipmapLevels: number;
  52256. /**
  52257. * Gets the bytes of key value data
  52258. */
  52259. bytesOfKeyValueData: number;
  52260. /**
  52261. * Gets the load type
  52262. */
  52263. loadType: number;
  52264. /**
  52265. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  52266. */
  52267. isInvalid: boolean;
  52268. /**
  52269. * Creates a new KhronosTextureContainer
  52270. * @param arrayBuffer contents of the KTX container file
  52271. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  52272. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  52273. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  52274. */
  52275. constructor(
  52276. /** contents of the KTX container file */
  52277. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  52278. /**
  52279. * Uploads KTX content to a Babylon Texture.
  52280. * It is assumed that the texture has already been created & is currently bound
  52281. * @hidden
  52282. */
  52283. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  52284. private _upload2DCompressedLevels;
  52285. }
  52286. }
  52287. declare module BABYLON {
  52288. /**
  52289. * Implementation of the KTX Texture Loader.
  52290. * @hidden
  52291. */
  52292. export class _KTXTextureLoader implements IInternalTextureLoader {
  52293. /**
  52294. * Defines wether the loader supports cascade loading the different faces.
  52295. */
  52296. readonly supportCascades: boolean;
  52297. /**
  52298. * This returns if the loader support the current file information.
  52299. * @param extension defines the file extension of the file being loaded
  52300. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52301. * @param fallback defines the fallback internal texture if any
  52302. * @param isBase64 defines whether the texture is encoded as a base64
  52303. * @param isBuffer defines whether the texture data are stored as a buffer
  52304. * @returns true if the loader can load the specified file
  52305. */
  52306. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52307. /**
  52308. * Transform the url before loading if required.
  52309. * @param rootUrl the url of the texture
  52310. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52311. * @returns the transformed texture
  52312. */
  52313. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52314. /**
  52315. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52316. * @param rootUrl the url of the texture
  52317. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52318. * @returns the fallback texture
  52319. */
  52320. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52321. /**
  52322. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52323. * @param data contains the texture data
  52324. * @param texture defines the BabylonJS internal texture
  52325. * @param createPolynomials will be true if polynomials have been requested
  52326. * @param onLoad defines the callback to trigger once the texture is ready
  52327. * @param onError defines the callback to trigger in case of error
  52328. */
  52329. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52330. /**
  52331. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52332. * @param data contains the texture data
  52333. * @param texture defines the BabylonJS internal texture
  52334. * @param callback defines the method to call once ready to upload
  52335. */
  52336. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  52337. }
  52338. }
  52339. declare module BABYLON {
  52340. /** @hidden */
  52341. export var _forceSceneHelpersToBundle: boolean;
  52342. interface Scene {
  52343. /**
  52344. * Creates a default light for the scene.
  52345. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  52346. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  52347. */
  52348. createDefaultLight(replace?: boolean): void;
  52349. /**
  52350. * Creates a default camera for the scene.
  52351. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  52352. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52353. * @param replace has default false, when true replaces the active camera in the scene
  52354. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  52355. */
  52356. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52357. /**
  52358. * Creates a default camera and a default light.
  52359. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  52360. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52361. * @param replace has the default false, when true replaces the active camera/light in the scene
  52362. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  52363. */
  52364. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52365. /**
  52366. * Creates a new sky box
  52367. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  52368. * @param environmentTexture defines the texture to use as environment texture
  52369. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  52370. * @param scale defines the overall scale of the skybox
  52371. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  52372. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  52373. * @returns a new mesh holding the sky box
  52374. */
  52375. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  52376. /**
  52377. * Creates a new environment
  52378. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  52379. * @param options defines the options you can use to configure the environment
  52380. * @returns the new EnvironmentHelper
  52381. */
  52382. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  52383. /**
  52384. * Creates a new VREXperienceHelper
  52385. * @see http://doc.babylonjs.com/how_to/webvr_helper
  52386. * @param webVROptions defines the options used to create the new VREXperienceHelper
  52387. * @returns a new VREXperienceHelper
  52388. */
  52389. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  52390. /**
  52391. * Creates a new WebXRDefaultExperience
  52392. * @see http://doc.babylonjs.com/how_to/webxr
  52393. * @param options experience options
  52394. * @returns a promise for a new WebXRDefaultExperience
  52395. */
  52396. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  52397. }
  52398. }
  52399. declare module BABYLON {
  52400. /**
  52401. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  52402. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  52403. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  52404. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  52405. */
  52406. export class VideoDome extends TransformNode {
  52407. /**
  52408. * Define the video source as a Monoscopic panoramic 360 video.
  52409. */
  52410. static readonly MODE_MONOSCOPIC: number;
  52411. /**
  52412. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52413. */
  52414. static readonly MODE_TOPBOTTOM: number;
  52415. /**
  52416. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52417. */
  52418. static readonly MODE_SIDEBYSIDE: number;
  52419. private _halfDome;
  52420. private _useDirectMapping;
  52421. /**
  52422. * The video texture being displayed on the sphere
  52423. */
  52424. protected _videoTexture: VideoTexture;
  52425. /**
  52426. * Gets the video texture being displayed on the sphere
  52427. */
  52428. get videoTexture(): VideoTexture;
  52429. /**
  52430. * The skybox material
  52431. */
  52432. protected _material: BackgroundMaterial;
  52433. /**
  52434. * The surface used for the skybox
  52435. */
  52436. protected _mesh: Mesh;
  52437. /**
  52438. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  52439. */
  52440. private _halfDomeMask;
  52441. /**
  52442. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52443. * Also see the options.resolution property.
  52444. */
  52445. get fovMultiplier(): number;
  52446. set fovMultiplier(value: number);
  52447. private _videoMode;
  52448. /**
  52449. * Gets or set the current video mode for the video. It can be:
  52450. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  52451. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52452. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52453. */
  52454. get videoMode(): number;
  52455. set videoMode(value: number);
  52456. /**
  52457. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  52458. *
  52459. */
  52460. get halfDome(): boolean;
  52461. /**
  52462. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  52463. */
  52464. set halfDome(enabled: boolean);
  52465. /**
  52466. * Oberserver used in Stereoscopic VR Mode.
  52467. */
  52468. private _onBeforeCameraRenderObserver;
  52469. /**
  52470. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  52471. * @param name Element's name, child elements will append suffixes for their own names.
  52472. * @param urlsOrVideo defines the url(s) or the video element to use
  52473. * @param options An object containing optional or exposed sub element properties
  52474. */
  52475. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  52476. resolution?: number;
  52477. clickToPlay?: boolean;
  52478. autoPlay?: boolean;
  52479. loop?: boolean;
  52480. size?: number;
  52481. poster?: string;
  52482. faceForward?: boolean;
  52483. useDirectMapping?: boolean;
  52484. halfDomeMode?: boolean;
  52485. }, scene: Scene);
  52486. private _changeVideoMode;
  52487. /**
  52488. * Releases resources associated with this node.
  52489. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  52490. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  52491. */
  52492. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  52493. }
  52494. }
  52495. declare module BABYLON {
  52496. /**
  52497. * This class can be used to get instrumentation data from a Babylon engine
  52498. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52499. */
  52500. export class EngineInstrumentation implements IDisposable {
  52501. /**
  52502. * Define the instrumented engine.
  52503. */
  52504. engine: Engine;
  52505. private _captureGPUFrameTime;
  52506. private _gpuFrameTimeToken;
  52507. private _gpuFrameTime;
  52508. private _captureShaderCompilationTime;
  52509. private _shaderCompilationTime;
  52510. private _onBeginFrameObserver;
  52511. private _onEndFrameObserver;
  52512. private _onBeforeShaderCompilationObserver;
  52513. private _onAfterShaderCompilationObserver;
  52514. /**
  52515. * Gets the perf counter used for GPU frame time
  52516. */
  52517. get gpuFrameTimeCounter(): PerfCounter;
  52518. /**
  52519. * Gets the GPU frame time capture status
  52520. */
  52521. get captureGPUFrameTime(): boolean;
  52522. /**
  52523. * Enable or disable the GPU frame time capture
  52524. */
  52525. set captureGPUFrameTime(value: boolean);
  52526. /**
  52527. * Gets the perf counter used for shader compilation time
  52528. */
  52529. get shaderCompilationTimeCounter(): PerfCounter;
  52530. /**
  52531. * Gets the shader compilation time capture status
  52532. */
  52533. get captureShaderCompilationTime(): boolean;
  52534. /**
  52535. * Enable or disable the shader compilation time capture
  52536. */
  52537. set captureShaderCompilationTime(value: boolean);
  52538. /**
  52539. * Instantiates a new engine instrumentation.
  52540. * This class can be used to get instrumentation data from a Babylon engine
  52541. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52542. * @param engine Defines the engine to instrument
  52543. */
  52544. constructor(
  52545. /**
  52546. * Define the instrumented engine.
  52547. */
  52548. engine: Engine);
  52549. /**
  52550. * Dispose and release associated resources.
  52551. */
  52552. dispose(): void;
  52553. }
  52554. }
  52555. declare module BABYLON {
  52556. /**
  52557. * This class can be used to get instrumentation data from a Babylon engine
  52558. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52559. */
  52560. export class SceneInstrumentation implements IDisposable {
  52561. /**
  52562. * Defines the scene to instrument
  52563. */
  52564. scene: Scene;
  52565. private _captureActiveMeshesEvaluationTime;
  52566. private _activeMeshesEvaluationTime;
  52567. private _captureRenderTargetsRenderTime;
  52568. private _renderTargetsRenderTime;
  52569. private _captureFrameTime;
  52570. private _frameTime;
  52571. private _captureRenderTime;
  52572. private _renderTime;
  52573. private _captureInterFrameTime;
  52574. private _interFrameTime;
  52575. private _captureParticlesRenderTime;
  52576. private _particlesRenderTime;
  52577. private _captureSpritesRenderTime;
  52578. private _spritesRenderTime;
  52579. private _capturePhysicsTime;
  52580. private _physicsTime;
  52581. private _captureAnimationsTime;
  52582. private _animationsTime;
  52583. private _captureCameraRenderTime;
  52584. private _cameraRenderTime;
  52585. private _onBeforeActiveMeshesEvaluationObserver;
  52586. private _onAfterActiveMeshesEvaluationObserver;
  52587. private _onBeforeRenderTargetsRenderObserver;
  52588. private _onAfterRenderTargetsRenderObserver;
  52589. private _onAfterRenderObserver;
  52590. private _onBeforeDrawPhaseObserver;
  52591. private _onAfterDrawPhaseObserver;
  52592. private _onBeforeAnimationsObserver;
  52593. private _onBeforeParticlesRenderingObserver;
  52594. private _onAfterParticlesRenderingObserver;
  52595. private _onBeforeSpritesRenderingObserver;
  52596. private _onAfterSpritesRenderingObserver;
  52597. private _onBeforePhysicsObserver;
  52598. private _onAfterPhysicsObserver;
  52599. private _onAfterAnimationsObserver;
  52600. private _onBeforeCameraRenderObserver;
  52601. private _onAfterCameraRenderObserver;
  52602. /**
  52603. * Gets the perf counter used for active meshes evaluation time
  52604. */
  52605. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  52606. /**
  52607. * Gets the active meshes evaluation time capture status
  52608. */
  52609. get captureActiveMeshesEvaluationTime(): boolean;
  52610. /**
  52611. * Enable or disable the active meshes evaluation time capture
  52612. */
  52613. set captureActiveMeshesEvaluationTime(value: boolean);
  52614. /**
  52615. * Gets the perf counter used for render targets render time
  52616. */
  52617. get renderTargetsRenderTimeCounter(): PerfCounter;
  52618. /**
  52619. * Gets the render targets render time capture status
  52620. */
  52621. get captureRenderTargetsRenderTime(): boolean;
  52622. /**
  52623. * Enable or disable the render targets render time capture
  52624. */
  52625. set captureRenderTargetsRenderTime(value: boolean);
  52626. /**
  52627. * Gets the perf counter used for particles render time
  52628. */
  52629. get particlesRenderTimeCounter(): PerfCounter;
  52630. /**
  52631. * Gets the particles render time capture status
  52632. */
  52633. get captureParticlesRenderTime(): boolean;
  52634. /**
  52635. * Enable or disable the particles render time capture
  52636. */
  52637. set captureParticlesRenderTime(value: boolean);
  52638. /**
  52639. * Gets the perf counter used for sprites render time
  52640. */
  52641. get spritesRenderTimeCounter(): PerfCounter;
  52642. /**
  52643. * Gets the sprites render time capture status
  52644. */
  52645. get captureSpritesRenderTime(): boolean;
  52646. /**
  52647. * Enable or disable the sprites render time capture
  52648. */
  52649. set captureSpritesRenderTime(value: boolean);
  52650. /**
  52651. * Gets the perf counter used for physics time
  52652. */
  52653. get physicsTimeCounter(): PerfCounter;
  52654. /**
  52655. * Gets the physics time capture status
  52656. */
  52657. get capturePhysicsTime(): boolean;
  52658. /**
  52659. * Enable or disable the physics time capture
  52660. */
  52661. set capturePhysicsTime(value: boolean);
  52662. /**
  52663. * Gets the perf counter used for animations time
  52664. */
  52665. get animationsTimeCounter(): PerfCounter;
  52666. /**
  52667. * Gets the animations time capture status
  52668. */
  52669. get captureAnimationsTime(): boolean;
  52670. /**
  52671. * Enable or disable the animations time capture
  52672. */
  52673. set captureAnimationsTime(value: boolean);
  52674. /**
  52675. * Gets the perf counter used for frame time capture
  52676. */
  52677. get frameTimeCounter(): PerfCounter;
  52678. /**
  52679. * Gets the frame time capture status
  52680. */
  52681. get captureFrameTime(): boolean;
  52682. /**
  52683. * Enable or disable the frame time capture
  52684. */
  52685. set captureFrameTime(value: boolean);
  52686. /**
  52687. * Gets the perf counter used for inter-frames time capture
  52688. */
  52689. get interFrameTimeCounter(): PerfCounter;
  52690. /**
  52691. * Gets the inter-frames time capture status
  52692. */
  52693. get captureInterFrameTime(): boolean;
  52694. /**
  52695. * Enable or disable the inter-frames time capture
  52696. */
  52697. set captureInterFrameTime(value: boolean);
  52698. /**
  52699. * Gets the perf counter used for render time capture
  52700. */
  52701. get renderTimeCounter(): PerfCounter;
  52702. /**
  52703. * Gets the render time capture status
  52704. */
  52705. get captureRenderTime(): boolean;
  52706. /**
  52707. * Enable or disable the render time capture
  52708. */
  52709. set captureRenderTime(value: boolean);
  52710. /**
  52711. * Gets the perf counter used for camera render time capture
  52712. */
  52713. get cameraRenderTimeCounter(): PerfCounter;
  52714. /**
  52715. * Gets the camera render time capture status
  52716. */
  52717. get captureCameraRenderTime(): boolean;
  52718. /**
  52719. * Enable or disable the camera render time capture
  52720. */
  52721. set captureCameraRenderTime(value: boolean);
  52722. /**
  52723. * Gets the perf counter used for draw calls
  52724. */
  52725. get drawCallsCounter(): PerfCounter;
  52726. /**
  52727. * Instantiates a new scene instrumentation.
  52728. * This class can be used to get instrumentation data from a Babylon engine
  52729. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52730. * @param scene Defines the scene to instrument
  52731. */
  52732. constructor(
  52733. /**
  52734. * Defines the scene to instrument
  52735. */
  52736. scene: Scene);
  52737. /**
  52738. * Dispose and release associated resources.
  52739. */
  52740. dispose(): void;
  52741. }
  52742. }
  52743. declare module BABYLON {
  52744. /** @hidden */
  52745. export var glowMapGenerationPixelShader: {
  52746. name: string;
  52747. shader: string;
  52748. };
  52749. }
  52750. declare module BABYLON {
  52751. /** @hidden */
  52752. export var glowMapGenerationVertexShader: {
  52753. name: string;
  52754. shader: string;
  52755. };
  52756. }
  52757. declare module BABYLON {
  52758. /**
  52759. * Effect layer options. This helps customizing the behaviour
  52760. * of the effect layer.
  52761. */
  52762. export interface IEffectLayerOptions {
  52763. /**
  52764. * Multiplication factor apply to the canvas size to compute the render target size
  52765. * used to generated the objects (the smaller the faster).
  52766. */
  52767. mainTextureRatio: number;
  52768. /**
  52769. * Enforces a fixed size texture to ensure effect stability across devices.
  52770. */
  52771. mainTextureFixedSize?: number;
  52772. /**
  52773. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  52774. */
  52775. alphaBlendingMode: number;
  52776. /**
  52777. * The camera attached to the layer.
  52778. */
  52779. camera: Nullable<Camera>;
  52780. /**
  52781. * The rendering group to draw the layer in.
  52782. */
  52783. renderingGroupId: number;
  52784. }
  52785. /**
  52786. * The effect layer Helps adding post process effect blended with the main pass.
  52787. *
  52788. * This can be for instance use to generate glow or higlight effects on the scene.
  52789. *
  52790. * The effect layer class can not be used directly and is intented to inherited from to be
  52791. * customized per effects.
  52792. */
  52793. export abstract class EffectLayer {
  52794. private _vertexBuffers;
  52795. private _indexBuffer;
  52796. private _cachedDefines;
  52797. private _effectLayerMapGenerationEffect;
  52798. private _effectLayerOptions;
  52799. private _mergeEffect;
  52800. protected _scene: Scene;
  52801. protected _engine: Engine;
  52802. protected _maxSize: number;
  52803. protected _mainTextureDesiredSize: ISize;
  52804. protected _mainTexture: RenderTargetTexture;
  52805. protected _shouldRender: boolean;
  52806. protected _postProcesses: PostProcess[];
  52807. protected _textures: BaseTexture[];
  52808. protected _emissiveTextureAndColor: {
  52809. texture: Nullable<BaseTexture>;
  52810. color: Color4;
  52811. };
  52812. /**
  52813. * The name of the layer
  52814. */
  52815. name: string;
  52816. /**
  52817. * The clear color of the texture used to generate the glow map.
  52818. */
  52819. neutralColor: Color4;
  52820. /**
  52821. * Specifies wether the highlight layer is enabled or not.
  52822. */
  52823. isEnabled: boolean;
  52824. /**
  52825. * Gets the camera attached to the layer.
  52826. */
  52827. get camera(): Nullable<Camera>;
  52828. /**
  52829. * Gets the rendering group id the layer should render in.
  52830. */
  52831. get renderingGroupId(): number;
  52832. set renderingGroupId(renderingGroupId: number);
  52833. /**
  52834. * An event triggered when the effect layer has been disposed.
  52835. */
  52836. onDisposeObservable: Observable<EffectLayer>;
  52837. /**
  52838. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  52839. */
  52840. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  52841. /**
  52842. * An event triggered when the generated texture is being merged in the scene.
  52843. */
  52844. onBeforeComposeObservable: Observable<EffectLayer>;
  52845. /**
  52846. * An event triggered when the mesh is rendered into the effect render target.
  52847. */
  52848. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  52849. /**
  52850. * An event triggered after the mesh has been rendered into the effect render target.
  52851. */
  52852. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  52853. /**
  52854. * An event triggered when the generated texture has been merged in the scene.
  52855. */
  52856. onAfterComposeObservable: Observable<EffectLayer>;
  52857. /**
  52858. * An event triggered when the efffect layer changes its size.
  52859. */
  52860. onSizeChangedObservable: Observable<EffectLayer>;
  52861. /** @hidden */
  52862. static _SceneComponentInitialization: (scene: Scene) => void;
  52863. /**
  52864. * Instantiates a new effect Layer and references it in the scene.
  52865. * @param name The name of the layer
  52866. * @param scene The scene to use the layer in
  52867. */
  52868. constructor(
  52869. /** The Friendly of the effect in the scene */
  52870. name: string, scene: Scene);
  52871. /**
  52872. * Get the effect name of the layer.
  52873. * @return The effect name
  52874. */
  52875. abstract getEffectName(): string;
  52876. /**
  52877. * Checks for the readiness of the element composing the layer.
  52878. * @param subMesh the mesh to check for
  52879. * @param useInstances specify wether or not to use instances to render the mesh
  52880. * @return true if ready otherwise, false
  52881. */
  52882. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52883. /**
  52884. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52885. * @returns true if the effect requires stencil during the main canvas render pass.
  52886. */
  52887. abstract needStencil(): boolean;
  52888. /**
  52889. * Create the merge effect. This is the shader use to blit the information back
  52890. * to the main canvas at the end of the scene rendering.
  52891. * @returns The effect containing the shader used to merge the effect on the main canvas
  52892. */
  52893. protected abstract _createMergeEffect(): Effect;
  52894. /**
  52895. * Creates the render target textures and post processes used in the effect layer.
  52896. */
  52897. protected abstract _createTextureAndPostProcesses(): void;
  52898. /**
  52899. * Implementation specific of rendering the generating effect on the main canvas.
  52900. * @param effect The effect used to render through
  52901. */
  52902. protected abstract _internalRender(effect: Effect): void;
  52903. /**
  52904. * Sets the required values for both the emissive texture and and the main color.
  52905. */
  52906. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52907. /**
  52908. * Free any resources and references associated to a mesh.
  52909. * Internal use
  52910. * @param mesh The mesh to free.
  52911. */
  52912. abstract _disposeMesh(mesh: Mesh): void;
  52913. /**
  52914. * Serializes this layer (Glow or Highlight for example)
  52915. * @returns a serialized layer object
  52916. */
  52917. abstract serialize?(): any;
  52918. /**
  52919. * Initializes the effect layer with the required options.
  52920. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  52921. */
  52922. protected _init(options: Partial<IEffectLayerOptions>): void;
  52923. /**
  52924. * Generates the index buffer of the full screen quad blending to the main canvas.
  52925. */
  52926. private _generateIndexBuffer;
  52927. /**
  52928. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  52929. */
  52930. private _generateVertexBuffer;
  52931. /**
  52932. * Sets the main texture desired size which is the closest power of two
  52933. * of the engine canvas size.
  52934. */
  52935. private _setMainTextureSize;
  52936. /**
  52937. * Creates the main texture for the effect layer.
  52938. */
  52939. protected _createMainTexture(): void;
  52940. /**
  52941. * Adds specific effects defines.
  52942. * @param defines The defines to add specifics to.
  52943. */
  52944. protected _addCustomEffectDefines(defines: string[]): void;
  52945. /**
  52946. * Checks for the readiness of the element composing the layer.
  52947. * @param subMesh the mesh to check for
  52948. * @param useInstances specify wether or not to use instances to render the mesh
  52949. * @param emissiveTexture the associated emissive texture used to generate the glow
  52950. * @return true if ready otherwise, false
  52951. */
  52952. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  52953. /**
  52954. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  52955. */
  52956. render(): void;
  52957. /**
  52958. * Determine if a given mesh will be used in the current effect.
  52959. * @param mesh mesh to test
  52960. * @returns true if the mesh will be used
  52961. */
  52962. hasMesh(mesh: AbstractMesh): boolean;
  52963. /**
  52964. * Returns true if the layer contains information to display, otherwise false.
  52965. * @returns true if the glow layer should be rendered
  52966. */
  52967. shouldRender(): boolean;
  52968. /**
  52969. * Returns true if the mesh should render, otherwise false.
  52970. * @param mesh The mesh to render
  52971. * @returns true if it should render otherwise false
  52972. */
  52973. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  52974. /**
  52975. * Returns true if the mesh can be rendered, otherwise false.
  52976. * @param mesh The mesh to render
  52977. * @param material The material used on the mesh
  52978. * @returns true if it can be rendered otherwise false
  52979. */
  52980. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  52981. /**
  52982. * Returns true if the mesh should render, otherwise false.
  52983. * @param mesh The mesh to render
  52984. * @returns true if it should render otherwise false
  52985. */
  52986. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  52987. /**
  52988. * Renders the submesh passed in parameter to the generation map.
  52989. */
  52990. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  52991. /**
  52992. * Defines wether the current material of the mesh should be use to render the effect.
  52993. * @param mesh defines the current mesh to render
  52994. */
  52995. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  52996. /**
  52997. * Rebuild the required buffers.
  52998. * @hidden Internal use only.
  52999. */
  53000. _rebuild(): void;
  53001. /**
  53002. * Dispose only the render target textures and post process.
  53003. */
  53004. private _disposeTextureAndPostProcesses;
  53005. /**
  53006. * Dispose the highlight layer and free resources.
  53007. */
  53008. dispose(): void;
  53009. /**
  53010. * Gets the class name of the effect layer
  53011. * @returns the string with the class name of the effect layer
  53012. */
  53013. getClassName(): string;
  53014. /**
  53015. * Creates an effect layer from parsed effect layer data
  53016. * @param parsedEffectLayer defines effect layer data
  53017. * @param scene defines the current scene
  53018. * @param rootUrl defines the root URL containing the effect layer information
  53019. * @returns a parsed effect Layer
  53020. */
  53021. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  53022. }
  53023. }
  53024. declare module BABYLON {
  53025. interface AbstractScene {
  53026. /**
  53027. * The list of effect layers (highlights/glow) added to the scene
  53028. * @see http://doc.babylonjs.com/how_to/highlight_layer
  53029. * @see http://doc.babylonjs.com/how_to/glow_layer
  53030. */
  53031. effectLayers: Array<EffectLayer>;
  53032. /**
  53033. * Removes the given effect layer from this scene.
  53034. * @param toRemove defines the effect layer to remove
  53035. * @returns the index of the removed effect layer
  53036. */
  53037. removeEffectLayer(toRemove: EffectLayer): number;
  53038. /**
  53039. * Adds the given effect layer to this scene
  53040. * @param newEffectLayer defines the effect layer to add
  53041. */
  53042. addEffectLayer(newEffectLayer: EffectLayer): void;
  53043. }
  53044. /**
  53045. * Defines the layer scene component responsible to manage any effect layers
  53046. * in a given scene.
  53047. */
  53048. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  53049. /**
  53050. * The component name helpfull to identify the component in the list of scene components.
  53051. */
  53052. readonly name: string;
  53053. /**
  53054. * The scene the component belongs to.
  53055. */
  53056. scene: Scene;
  53057. private _engine;
  53058. private _renderEffects;
  53059. private _needStencil;
  53060. private _previousStencilState;
  53061. /**
  53062. * Creates a new instance of the component for the given scene
  53063. * @param scene Defines the scene to register the component in
  53064. */
  53065. constructor(scene: Scene);
  53066. /**
  53067. * Registers the component in a given scene
  53068. */
  53069. register(): void;
  53070. /**
  53071. * Rebuilds the elements related to this component in case of
  53072. * context lost for instance.
  53073. */
  53074. rebuild(): void;
  53075. /**
  53076. * Serializes the component data to the specified json object
  53077. * @param serializationObject The object to serialize to
  53078. */
  53079. serialize(serializationObject: any): void;
  53080. /**
  53081. * Adds all the elements from the container to the scene
  53082. * @param container the container holding the elements
  53083. */
  53084. addFromContainer(container: AbstractScene): void;
  53085. /**
  53086. * Removes all the elements in the container from the scene
  53087. * @param container contains the elements to remove
  53088. * @param dispose if the removed element should be disposed (default: false)
  53089. */
  53090. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53091. /**
  53092. * Disposes the component and the associated ressources.
  53093. */
  53094. dispose(): void;
  53095. private _isReadyForMesh;
  53096. private _renderMainTexture;
  53097. private _setStencil;
  53098. private _setStencilBack;
  53099. private _draw;
  53100. private _drawCamera;
  53101. private _drawRenderingGroup;
  53102. }
  53103. }
  53104. declare module BABYLON {
  53105. /** @hidden */
  53106. export var glowMapMergePixelShader: {
  53107. name: string;
  53108. shader: string;
  53109. };
  53110. }
  53111. declare module BABYLON {
  53112. /** @hidden */
  53113. export var glowMapMergeVertexShader: {
  53114. name: string;
  53115. shader: string;
  53116. };
  53117. }
  53118. declare module BABYLON {
  53119. interface AbstractScene {
  53120. /**
  53121. * Return a the first highlight layer of the scene with a given name.
  53122. * @param name The name of the highlight layer to look for.
  53123. * @return The highlight layer if found otherwise null.
  53124. */
  53125. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  53126. }
  53127. /**
  53128. * Glow layer options. This helps customizing the behaviour
  53129. * of the glow layer.
  53130. */
  53131. export interface IGlowLayerOptions {
  53132. /**
  53133. * Multiplication factor apply to the canvas size to compute the render target size
  53134. * used to generated the glowing objects (the smaller the faster).
  53135. */
  53136. mainTextureRatio: number;
  53137. /**
  53138. * Enforces a fixed size texture to ensure resize independant blur.
  53139. */
  53140. mainTextureFixedSize?: number;
  53141. /**
  53142. * How big is the kernel of the blur texture.
  53143. */
  53144. blurKernelSize: number;
  53145. /**
  53146. * The camera attached to the layer.
  53147. */
  53148. camera: Nullable<Camera>;
  53149. /**
  53150. * Enable MSAA by chosing the number of samples.
  53151. */
  53152. mainTextureSamples?: number;
  53153. /**
  53154. * The rendering group to draw the layer in.
  53155. */
  53156. renderingGroupId: number;
  53157. }
  53158. /**
  53159. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  53160. *
  53161. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  53162. *
  53163. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  53164. */
  53165. export class GlowLayer extends EffectLayer {
  53166. /**
  53167. * Effect Name of the layer.
  53168. */
  53169. static readonly EffectName: string;
  53170. /**
  53171. * The default blur kernel size used for the glow.
  53172. */
  53173. static DefaultBlurKernelSize: number;
  53174. /**
  53175. * The default texture size ratio used for the glow.
  53176. */
  53177. static DefaultTextureRatio: number;
  53178. /**
  53179. * Sets the kernel size of the blur.
  53180. */
  53181. set blurKernelSize(value: number);
  53182. /**
  53183. * Gets the kernel size of the blur.
  53184. */
  53185. get blurKernelSize(): number;
  53186. /**
  53187. * Sets the glow intensity.
  53188. */
  53189. set intensity(value: number);
  53190. /**
  53191. * Gets the glow intensity.
  53192. */
  53193. get intensity(): number;
  53194. private _options;
  53195. private _intensity;
  53196. private _horizontalBlurPostprocess1;
  53197. private _verticalBlurPostprocess1;
  53198. private _horizontalBlurPostprocess2;
  53199. private _verticalBlurPostprocess2;
  53200. private _blurTexture1;
  53201. private _blurTexture2;
  53202. private _postProcesses1;
  53203. private _postProcesses2;
  53204. private _includedOnlyMeshes;
  53205. private _excludedMeshes;
  53206. private _meshesUsingTheirOwnMaterials;
  53207. /**
  53208. * Callback used to let the user override the color selection on a per mesh basis
  53209. */
  53210. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  53211. /**
  53212. * Callback used to let the user override the texture selection on a per mesh basis
  53213. */
  53214. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  53215. /**
  53216. * Instantiates a new glow Layer and references it to the scene.
  53217. * @param name The name of the layer
  53218. * @param scene The scene to use the layer in
  53219. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  53220. */
  53221. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  53222. /**
  53223. * Get the effect name of the layer.
  53224. * @return The effect name
  53225. */
  53226. getEffectName(): string;
  53227. /**
  53228. * Create the merge effect. This is the shader use to blit the information back
  53229. * to the main canvas at the end of the scene rendering.
  53230. */
  53231. protected _createMergeEffect(): Effect;
  53232. /**
  53233. * Creates the render target textures and post processes used in the glow layer.
  53234. */
  53235. protected _createTextureAndPostProcesses(): void;
  53236. /**
  53237. * Checks for the readiness of the element composing the layer.
  53238. * @param subMesh the mesh to check for
  53239. * @param useInstances specify wether or not to use instances to render the mesh
  53240. * @param emissiveTexture the associated emissive texture used to generate the glow
  53241. * @return true if ready otherwise, false
  53242. */
  53243. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53244. /**
  53245. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  53246. */
  53247. needStencil(): boolean;
  53248. /**
  53249. * Returns true if the mesh can be rendered, otherwise false.
  53250. * @param mesh The mesh to render
  53251. * @param material The material used on the mesh
  53252. * @returns true if it can be rendered otherwise false
  53253. */
  53254. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53255. /**
  53256. * Implementation specific of rendering the generating effect on the main canvas.
  53257. * @param effect The effect used to render through
  53258. */
  53259. protected _internalRender(effect: Effect): void;
  53260. /**
  53261. * Sets the required values for both the emissive texture and and the main color.
  53262. */
  53263. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53264. /**
  53265. * Returns true if the mesh should render, otherwise false.
  53266. * @param mesh The mesh to render
  53267. * @returns true if it should render otherwise false
  53268. */
  53269. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53270. /**
  53271. * Adds specific effects defines.
  53272. * @param defines The defines to add specifics to.
  53273. */
  53274. protected _addCustomEffectDefines(defines: string[]): void;
  53275. /**
  53276. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  53277. * @param mesh The mesh to exclude from the glow layer
  53278. */
  53279. addExcludedMesh(mesh: Mesh): void;
  53280. /**
  53281. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  53282. * @param mesh The mesh to remove
  53283. */
  53284. removeExcludedMesh(mesh: Mesh): void;
  53285. /**
  53286. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  53287. * @param mesh The mesh to include in the glow layer
  53288. */
  53289. addIncludedOnlyMesh(mesh: Mesh): void;
  53290. /**
  53291. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  53292. * @param mesh The mesh to remove
  53293. */
  53294. removeIncludedOnlyMesh(mesh: Mesh): void;
  53295. /**
  53296. * Determine if a given mesh will be used in the glow layer
  53297. * @param mesh The mesh to test
  53298. * @returns true if the mesh will be highlighted by the current glow layer
  53299. */
  53300. hasMesh(mesh: AbstractMesh): boolean;
  53301. /**
  53302. * Defines wether the current material of the mesh should be use to render the effect.
  53303. * @param mesh defines the current mesh to render
  53304. */
  53305. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53306. /**
  53307. * Add a mesh to be rendered through its own material and not with emissive only.
  53308. * @param mesh The mesh for which we need to use its material
  53309. */
  53310. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  53311. /**
  53312. * Remove a mesh from being rendered through its own material and not with emissive only.
  53313. * @param mesh The mesh for which we need to not use its material
  53314. */
  53315. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  53316. /**
  53317. * Free any resources and references associated to a mesh.
  53318. * Internal use
  53319. * @param mesh The mesh to free.
  53320. * @hidden
  53321. */
  53322. _disposeMesh(mesh: Mesh): void;
  53323. /**
  53324. * Gets the class name of the effect layer
  53325. * @returns the string with the class name of the effect layer
  53326. */
  53327. getClassName(): string;
  53328. /**
  53329. * Serializes this glow layer
  53330. * @returns a serialized glow layer object
  53331. */
  53332. serialize(): any;
  53333. /**
  53334. * Creates a Glow Layer from parsed glow layer data
  53335. * @param parsedGlowLayer defines glow layer data
  53336. * @param scene defines the current scene
  53337. * @param rootUrl defines the root URL containing the glow layer information
  53338. * @returns a parsed Glow Layer
  53339. */
  53340. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  53341. }
  53342. }
  53343. declare module BABYLON {
  53344. /** @hidden */
  53345. export var glowBlurPostProcessPixelShader: {
  53346. name: string;
  53347. shader: string;
  53348. };
  53349. }
  53350. declare module BABYLON {
  53351. interface AbstractScene {
  53352. /**
  53353. * Return a the first highlight layer of the scene with a given name.
  53354. * @param name The name of the highlight layer to look for.
  53355. * @return The highlight layer if found otherwise null.
  53356. */
  53357. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  53358. }
  53359. /**
  53360. * Highlight layer options. This helps customizing the behaviour
  53361. * of the highlight layer.
  53362. */
  53363. export interface IHighlightLayerOptions {
  53364. /**
  53365. * Multiplication factor apply to the canvas size to compute the render target size
  53366. * used to generated the glowing objects (the smaller the faster).
  53367. */
  53368. mainTextureRatio: number;
  53369. /**
  53370. * Enforces a fixed size texture to ensure resize independant blur.
  53371. */
  53372. mainTextureFixedSize?: number;
  53373. /**
  53374. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  53375. * of the picture to blur (the smaller the faster).
  53376. */
  53377. blurTextureSizeRatio: number;
  53378. /**
  53379. * How big in texel of the blur texture is the vertical blur.
  53380. */
  53381. blurVerticalSize: number;
  53382. /**
  53383. * How big in texel of the blur texture is the horizontal blur.
  53384. */
  53385. blurHorizontalSize: number;
  53386. /**
  53387. * Alpha blending mode used to apply the blur. Default is combine.
  53388. */
  53389. alphaBlendingMode: number;
  53390. /**
  53391. * The camera attached to the layer.
  53392. */
  53393. camera: Nullable<Camera>;
  53394. /**
  53395. * Should we display highlight as a solid stroke?
  53396. */
  53397. isStroke?: boolean;
  53398. /**
  53399. * The rendering group to draw the layer in.
  53400. */
  53401. renderingGroupId: number;
  53402. }
  53403. /**
  53404. * The highlight layer Helps adding a glow effect around a mesh.
  53405. *
  53406. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  53407. * glowy meshes to your scene.
  53408. *
  53409. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  53410. */
  53411. export class HighlightLayer extends EffectLayer {
  53412. name: string;
  53413. /**
  53414. * Effect Name of the highlight layer.
  53415. */
  53416. static readonly EffectName: string;
  53417. /**
  53418. * The neutral color used during the preparation of the glow effect.
  53419. * This is black by default as the blend operation is a blend operation.
  53420. */
  53421. static NeutralColor: Color4;
  53422. /**
  53423. * Stencil value used for glowing meshes.
  53424. */
  53425. static GlowingMeshStencilReference: number;
  53426. /**
  53427. * Stencil value used for the other meshes in the scene.
  53428. */
  53429. static NormalMeshStencilReference: number;
  53430. /**
  53431. * Specifies whether or not the inner glow is ACTIVE in the layer.
  53432. */
  53433. innerGlow: boolean;
  53434. /**
  53435. * Specifies whether or not the outer glow is ACTIVE in the layer.
  53436. */
  53437. outerGlow: boolean;
  53438. /**
  53439. * Specifies the horizontal size of the blur.
  53440. */
  53441. set blurHorizontalSize(value: number);
  53442. /**
  53443. * Specifies the vertical size of the blur.
  53444. */
  53445. set blurVerticalSize(value: number);
  53446. /**
  53447. * Gets the horizontal size of the blur.
  53448. */
  53449. get blurHorizontalSize(): number;
  53450. /**
  53451. * Gets the vertical size of the blur.
  53452. */
  53453. get blurVerticalSize(): number;
  53454. /**
  53455. * An event triggered when the highlight layer is being blurred.
  53456. */
  53457. onBeforeBlurObservable: Observable<HighlightLayer>;
  53458. /**
  53459. * An event triggered when the highlight layer has been blurred.
  53460. */
  53461. onAfterBlurObservable: Observable<HighlightLayer>;
  53462. private _instanceGlowingMeshStencilReference;
  53463. private _options;
  53464. private _downSamplePostprocess;
  53465. private _horizontalBlurPostprocess;
  53466. private _verticalBlurPostprocess;
  53467. private _blurTexture;
  53468. private _meshes;
  53469. private _excludedMeshes;
  53470. /**
  53471. * Instantiates a new highlight Layer and references it to the scene..
  53472. * @param name The name of the layer
  53473. * @param scene The scene to use the layer in
  53474. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  53475. */
  53476. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  53477. /**
  53478. * Get the effect name of the layer.
  53479. * @return The effect name
  53480. */
  53481. getEffectName(): string;
  53482. /**
  53483. * Create the merge effect. This is the shader use to blit the information back
  53484. * to the main canvas at the end of the scene rendering.
  53485. */
  53486. protected _createMergeEffect(): Effect;
  53487. /**
  53488. * Creates the render target textures and post processes used in the highlight layer.
  53489. */
  53490. protected _createTextureAndPostProcesses(): void;
  53491. /**
  53492. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  53493. */
  53494. needStencil(): boolean;
  53495. /**
  53496. * Checks for the readiness of the element composing the layer.
  53497. * @param subMesh the mesh to check for
  53498. * @param useInstances specify wether or not to use instances to render the mesh
  53499. * @param emissiveTexture the associated emissive texture used to generate the glow
  53500. * @return true if ready otherwise, false
  53501. */
  53502. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53503. /**
  53504. * Implementation specific of rendering the generating effect on the main canvas.
  53505. * @param effect The effect used to render through
  53506. */
  53507. protected _internalRender(effect: Effect): void;
  53508. /**
  53509. * Returns true if the layer contains information to display, otherwise false.
  53510. */
  53511. shouldRender(): boolean;
  53512. /**
  53513. * Returns true if the mesh should render, otherwise false.
  53514. * @param mesh The mesh to render
  53515. * @returns true if it should render otherwise false
  53516. */
  53517. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53518. /**
  53519. * Sets the required values for both the emissive texture and and the main color.
  53520. */
  53521. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53522. /**
  53523. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  53524. * @param mesh The mesh to exclude from the highlight layer
  53525. */
  53526. addExcludedMesh(mesh: Mesh): void;
  53527. /**
  53528. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  53529. * @param mesh The mesh to highlight
  53530. */
  53531. removeExcludedMesh(mesh: Mesh): void;
  53532. /**
  53533. * Determine if a given mesh will be highlighted by the current HighlightLayer
  53534. * @param mesh mesh to test
  53535. * @returns true if the mesh will be highlighted by the current HighlightLayer
  53536. */
  53537. hasMesh(mesh: AbstractMesh): boolean;
  53538. /**
  53539. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  53540. * @param mesh The mesh to highlight
  53541. * @param color The color of the highlight
  53542. * @param glowEmissiveOnly Extract the glow from the emissive texture
  53543. */
  53544. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  53545. /**
  53546. * Remove a mesh from the highlight layer in order to make it stop glowing.
  53547. * @param mesh The mesh to highlight
  53548. */
  53549. removeMesh(mesh: Mesh): void;
  53550. /**
  53551. * Force the stencil to the normal expected value for none glowing parts
  53552. */
  53553. private _defaultStencilReference;
  53554. /**
  53555. * Free any resources and references associated to a mesh.
  53556. * Internal use
  53557. * @param mesh The mesh to free.
  53558. * @hidden
  53559. */
  53560. _disposeMesh(mesh: Mesh): void;
  53561. /**
  53562. * Dispose the highlight layer and free resources.
  53563. */
  53564. dispose(): void;
  53565. /**
  53566. * Gets the class name of the effect layer
  53567. * @returns the string with the class name of the effect layer
  53568. */
  53569. getClassName(): string;
  53570. /**
  53571. * Serializes this Highlight layer
  53572. * @returns a serialized Highlight layer object
  53573. */
  53574. serialize(): any;
  53575. /**
  53576. * Creates a Highlight layer from parsed Highlight layer data
  53577. * @param parsedHightlightLayer defines the Highlight layer data
  53578. * @param scene defines the current scene
  53579. * @param rootUrl defines the root URL containing the Highlight layer information
  53580. * @returns a parsed Highlight layer
  53581. */
  53582. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  53583. }
  53584. }
  53585. declare module BABYLON {
  53586. interface AbstractScene {
  53587. /**
  53588. * The list of layers (background and foreground) of the scene
  53589. */
  53590. layers: Array<Layer>;
  53591. }
  53592. /**
  53593. * Defines the layer scene component responsible to manage any layers
  53594. * in a given scene.
  53595. */
  53596. export class LayerSceneComponent implements ISceneComponent {
  53597. /**
  53598. * The component name helpfull to identify the component in the list of scene components.
  53599. */
  53600. readonly name: string;
  53601. /**
  53602. * The scene the component belongs to.
  53603. */
  53604. scene: Scene;
  53605. private _engine;
  53606. /**
  53607. * Creates a new instance of the component for the given scene
  53608. * @param scene Defines the scene to register the component in
  53609. */
  53610. constructor(scene: Scene);
  53611. /**
  53612. * Registers the component in a given scene
  53613. */
  53614. register(): void;
  53615. /**
  53616. * Rebuilds the elements related to this component in case of
  53617. * context lost for instance.
  53618. */
  53619. rebuild(): void;
  53620. /**
  53621. * Disposes the component and the associated ressources.
  53622. */
  53623. dispose(): void;
  53624. private _draw;
  53625. private _drawCameraPredicate;
  53626. private _drawCameraBackground;
  53627. private _drawCameraForeground;
  53628. private _drawRenderTargetPredicate;
  53629. private _drawRenderTargetBackground;
  53630. private _drawRenderTargetForeground;
  53631. /**
  53632. * Adds all the elements from the container to the scene
  53633. * @param container the container holding the elements
  53634. */
  53635. addFromContainer(container: AbstractScene): void;
  53636. /**
  53637. * Removes all the elements in the container from the scene
  53638. * @param container contains the elements to remove
  53639. * @param dispose if the removed element should be disposed (default: false)
  53640. */
  53641. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53642. }
  53643. }
  53644. declare module BABYLON {
  53645. /** @hidden */
  53646. export var layerPixelShader: {
  53647. name: string;
  53648. shader: string;
  53649. };
  53650. }
  53651. declare module BABYLON {
  53652. /** @hidden */
  53653. export var layerVertexShader: {
  53654. name: string;
  53655. shader: string;
  53656. };
  53657. }
  53658. declare module BABYLON {
  53659. /**
  53660. * This represents a full screen 2d layer.
  53661. * This can be useful to display a picture in the background of your scene for instance.
  53662. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53663. */
  53664. export class Layer {
  53665. /**
  53666. * Define the name of the layer.
  53667. */
  53668. name: string;
  53669. /**
  53670. * Define the texture the layer should display.
  53671. */
  53672. texture: Nullable<Texture>;
  53673. /**
  53674. * Is the layer in background or foreground.
  53675. */
  53676. isBackground: boolean;
  53677. /**
  53678. * Define the color of the layer (instead of texture).
  53679. */
  53680. color: Color4;
  53681. /**
  53682. * Define the scale of the layer in order to zoom in out of the texture.
  53683. */
  53684. scale: Vector2;
  53685. /**
  53686. * Define an offset for the layer in order to shift the texture.
  53687. */
  53688. offset: Vector2;
  53689. /**
  53690. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  53691. */
  53692. alphaBlendingMode: number;
  53693. /**
  53694. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  53695. * Alpha test will not mix with the background color in case of transparency.
  53696. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  53697. */
  53698. alphaTest: boolean;
  53699. /**
  53700. * Define a mask to restrict the layer to only some of the scene cameras.
  53701. */
  53702. layerMask: number;
  53703. /**
  53704. * Define the list of render target the layer is visible into.
  53705. */
  53706. renderTargetTextures: RenderTargetTexture[];
  53707. /**
  53708. * Define if the layer is only used in renderTarget or if it also
  53709. * renders in the main frame buffer of the canvas.
  53710. */
  53711. renderOnlyInRenderTargetTextures: boolean;
  53712. private _scene;
  53713. private _vertexBuffers;
  53714. private _indexBuffer;
  53715. private _effect;
  53716. private _previousDefines;
  53717. /**
  53718. * An event triggered when the layer is disposed.
  53719. */
  53720. onDisposeObservable: Observable<Layer>;
  53721. private _onDisposeObserver;
  53722. /**
  53723. * Back compatibility with callback before the onDisposeObservable existed.
  53724. * The set callback will be triggered when the layer has been disposed.
  53725. */
  53726. set onDispose(callback: () => void);
  53727. /**
  53728. * An event triggered before rendering the scene
  53729. */
  53730. onBeforeRenderObservable: Observable<Layer>;
  53731. private _onBeforeRenderObserver;
  53732. /**
  53733. * Back compatibility with callback before the onBeforeRenderObservable existed.
  53734. * The set callback will be triggered just before rendering the layer.
  53735. */
  53736. set onBeforeRender(callback: () => void);
  53737. /**
  53738. * An event triggered after rendering the scene
  53739. */
  53740. onAfterRenderObservable: Observable<Layer>;
  53741. private _onAfterRenderObserver;
  53742. /**
  53743. * Back compatibility with callback before the onAfterRenderObservable existed.
  53744. * The set callback will be triggered just after rendering the layer.
  53745. */
  53746. set onAfterRender(callback: () => void);
  53747. /**
  53748. * Instantiates a new layer.
  53749. * This represents a full screen 2d layer.
  53750. * This can be useful to display a picture in the background of your scene for instance.
  53751. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53752. * @param name Define the name of the layer in the scene
  53753. * @param imgUrl Define the url of the texture to display in the layer
  53754. * @param scene Define the scene the layer belongs to
  53755. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  53756. * @param color Defines a color for the layer
  53757. */
  53758. constructor(
  53759. /**
  53760. * Define the name of the layer.
  53761. */
  53762. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  53763. private _createIndexBuffer;
  53764. /** @hidden */
  53765. _rebuild(): void;
  53766. /**
  53767. * Renders the layer in the scene.
  53768. */
  53769. render(): void;
  53770. /**
  53771. * Disposes and releases the associated ressources.
  53772. */
  53773. dispose(): void;
  53774. }
  53775. }
  53776. declare module BABYLON {
  53777. /** @hidden */
  53778. export var lensFlarePixelShader: {
  53779. name: string;
  53780. shader: string;
  53781. };
  53782. }
  53783. declare module BABYLON {
  53784. /** @hidden */
  53785. export var lensFlareVertexShader: {
  53786. name: string;
  53787. shader: string;
  53788. };
  53789. }
  53790. declare module BABYLON {
  53791. /**
  53792. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53793. * It is usually composed of several `lensFlare`.
  53794. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53795. */
  53796. export class LensFlareSystem {
  53797. /**
  53798. * Define the name of the lens flare system
  53799. */
  53800. name: string;
  53801. /**
  53802. * List of lens flares used in this system.
  53803. */
  53804. lensFlares: LensFlare[];
  53805. /**
  53806. * Define a limit from the border the lens flare can be visible.
  53807. */
  53808. borderLimit: number;
  53809. /**
  53810. * Define a viewport border we do not want to see the lens flare in.
  53811. */
  53812. viewportBorder: number;
  53813. /**
  53814. * Define a predicate which could limit the list of meshes able to occlude the effect.
  53815. */
  53816. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  53817. /**
  53818. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  53819. */
  53820. layerMask: number;
  53821. /**
  53822. * Define the id of the lens flare system in the scene.
  53823. * (equal to name by default)
  53824. */
  53825. id: string;
  53826. private _scene;
  53827. private _emitter;
  53828. private _vertexBuffers;
  53829. private _indexBuffer;
  53830. private _effect;
  53831. private _positionX;
  53832. private _positionY;
  53833. private _isEnabled;
  53834. /** @hidden */
  53835. static _SceneComponentInitialization: (scene: Scene) => void;
  53836. /**
  53837. * Instantiates a lens flare system.
  53838. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53839. * It is usually composed of several `lensFlare`.
  53840. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53841. * @param name Define the name of the lens flare system in the scene
  53842. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  53843. * @param scene Define the scene the lens flare system belongs to
  53844. */
  53845. constructor(
  53846. /**
  53847. * Define the name of the lens flare system
  53848. */
  53849. name: string, emitter: any, scene: Scene);
  53850. /**
  53851. * Define if the lens flare system is enabled.
  53852. */
  53853. get isEnabled(): boolean;
  53854. set isEnabled(value: boolean);
  53855. /**
  53856. * Get the scene the effects belongs to.
  53857. * @returns the scene holding the lens flare system
  53858. */
  53859. getScene(): Scene;
  53860. /**
  53861. * Get the emitter of the lens flare system.
  53862. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53863. * @returns the emitter of the lens flare system
  53864. */
  53865. getEmitter(): any;
  53866. /**
  53867. * Set the emitter of the lens flare system.
  53868. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53869. * @param newEmitter Define the new emitter of the system
  53870. */
  53871. setEmitter(newEmitter: any): void;
  53872. /**
  53873. * Get the lens flare system emitter position.
  53874. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  53875. * @returns the position
  53876. */
  53877. getEmitterPosition(): Vector3;
  53878. /**
  53879. * @hidden
  53880. */
  53881. computeEffectivePosition(globalViewport: Viewport): boolean;
  53882. /** @hidden */
  53883. _isVisible(): boolean;
  53884. /**
  53885. * @hidden
  53886. */
  53887. render(): boolean;
  53888. /**
  53889. * Dispose and release the lens flare with its associated resources.
  53890. */
  53891. dispose(): void;
  53892. /**
  53893. * Parse a lens flare system from a JSON repressentation
  53894. * @param parsedLensFlareSystem Define the JSON to parse
  53895. * @param scene Define the scene the parsed system should be instantiated in
  53896. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  53897. * @returns the parsed system
  53898. */
  53899. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  53900. /**
  53901. * Serialize the current Lens Flare System into a JSON representation.
  53902. * @returns the serialized JSON
  53903. */
  53904. serialize(): any;
  53905. }
  53906. }
  53907. declare module BABYLON {
  53908. /**
  53909. * This represents one of the lens effect in a `lensFlareSystem`.
  53910. * It controls one of the indiviual texture used in the effect.
  53911. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53912. */
  53913. export class LensFlare {
  53914. /**
  53915. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53916. */
  53917. size: number;
  53918. /**
  53919. * 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.
  53920. */
  53921. position: number;
  53922. /**
  53923. * Define the lens color.
  53924. */
  53925. color: Color3;
  53926. /**
  53927. * Define the lens texture.
  53928. */
  53929. texture: Nullable<Texture>;
  53930. /**
  53931. * Define the alpha mode to render this particular lens.
  53932. */
  53933. alphaMode: number;
  53934. private _system;
  53935. /**
  53936. * Creates a new Lens Flare.
  53937. * This represents one of the lens effect in a `lensFlareSystem`.
  53938. * It controls one of the indiviual texture used in the effect.
  53939. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53940. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  53941. * @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.
  53942. * @param color Define the lens color
  53943. * @param imgUrl Define the lens texture url
  53944. * @param system Define the `lensFlareSystem` this flare is part of
  53945. * @returns The newly created Lens Flare
  53946. */
  53947. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  53948. /**
  53949. * Instantiates a new Lens Flare.
  53950. * This represents one of the lens effect in a `lensFlareSystem`.
  53951. * It controls one of the indiviual texture used in the effect.
  53952. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53953. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  53954. * @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.
  53955. * @param color Define the lens color
  53956. * @param imgUrl Define the lens texture url
  53957. * @param system Define the `lensFlareSystem` this flare is part of
  53958. */
  53959. constructor(
  53960. /**
  53961. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53962. */
  53963. size: number,
  53964. /**
  53965. * 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.
  53966. */
  53967. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  53968. /**
  53969. * Dispose and release the lens flare with its associated resources.
  53970. */
  53971. dispose(): void;
  53972. }
  53973. }
  53974. declare module BABYLON {
  53975. interface AbstractScene {
  53976. /**
  53977. * The list of lens flare system added to the scene
  53978. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53979. */
  53980. lensFlareSystems: Array<LensFlareSystem>;
  53981. /**
  53982. * Removes the given lens flare system from this scene.
  53983. * @param toRemove The lens flare system to remove
  53984. * @returns The index of the removed lens flare system
  53985. */
  53986. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  53987. /**
  53988. * Adds the given lens flare system to this scene
  53989. * @param newLensFlareSystem The lens flare system to add
  53990. */
  53991. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  53992. /**
  53993. * Gets a lens flare system using its name
  53994. * @param name defines the name to look for
  53995. * @returns the lens flare system or null if not found
  53996. */
  53997. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  53998. /**
  53999. * Gets a lens flare system using its id
  54000. * @param id defines the id to look for
  54001. * @returns the lens flare system or null if not found
  54002. */
  54003. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  54004. }
  54005. /**
  54006. * Defines the lens flare scene component responsible to manage any lens flares
  54007. * in a given scene.
  54008. */
  54009. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  54010. /**
  54011. * The component name helpfull to identify the component in the list of scene components.
  54012. */
  54013. readonly name: string;
  54014. /**
  54015. * The scene the component belongs to.
  54016. */
  54017. scene: Scene;
  54018. /**
  54019. * Creates a new instance of the component for the given scene
  54020. * @param scene Defines the scene to register the component in
  54021. */
  54022. constructor(scene: Scene);
  54023. /**
  54024. * Registers the component in a given scene
  54025. */
  54026. register(): void;
  54027. /**
  54028. * Rebuilds the elements related to this component in case of
  54029. * context lost for instance.
  54030. */
  54031. rebuild(): void;
  54032. /**
  54033. * Adds all the elements from the container to the scene
  54034. * @param container the container holding the elements
  54035. */
  54036. addFromContainer(container: AbstractScene): void;
  54037. /**
  54038. * Removes all the elements in the container from the scene
  54039. * @param container contains the elements to remove
  54040. * @param dispose if the removed element should be disposed (default: false)
  54041. */
  54042. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54043. /**
  54044. * Serializes the component data to the specified json object
  54045. * @param serializationObject The object to serialize to
  54046. */
  54047. serialize(serializationObject: any): void;
  54048. /**
  54049. * Disposes the component and the associated ressources.
  54050. */
  54051. dispose(): void;
  54052. private _draw;
  54053. }
  54054. }
  54055. declare module BABYLON {
  54056. /** @hidden */
  54057. export var depthPixelShader: {
  54058. name: string;
  54059. shader: string;
  54060. };
  54061. }
  54062. declare module BABYLON {
  54063. /** @hidden */
  54064. export var depthVertexShader: {
  54065. name: string;
  54066. shader: string;
  54067. };
  54068. }
  54069. declare module BABYLON {
  54070. /**
  54071. * This represents a depth renderer in Babylon.
  54072. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  54073. */
  54074. export class DepthRenderer {
  54075. private _scene;
  54076. private _depthMap;
  54077. private _effect;
  54078. private readonly _storeNonLinearDepth;
  54079. private readonly _clearColor;
  54080. /** Get if the depth renderer is using packed depth or not */
  54081. readonly isPacked: boolean;
  54082. private _cachedDefines;
  54083. private _camera;
  54084. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  54085. enabled: boolean;
  54086. /**
  54087. * Specifiess that the depth renderer will only be used within
  54088. * the camera it is created for.
  54089. * This can help forcing its rendering during the camera processing.
  54090. */
  54091. useOnlyInActiveCamera: boolean;
  54092. /** @hidden */
  54093. static _SceneComponentInitialization: (scene: Scene) => void;
  54094. /**
  54095. * Instantiates a depth renderer
  54096. * @param scene The scene the renderer belongs to
  54097. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  54098. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  54099. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  54100. */
  54101. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  54102. /**
  54103. * Creates the depth rendering effect and checks if the effect is ready.
  54104. * @param subMesh The submesh to be used to render the depth map of
  54105. * @param useInstances If multiple world instances should be used
  54106. * @returns if the depth renderer is ready to render the depth map
  54107. */
  54108. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54109. /**
  54110. * Gets the texture which the depth map will be written to.
  54111. * @returns The depth map texture
  54112. */
  54113. getDepthMap(): RenderTargetTexture;
  54114. /**
  54115. * Disposes of the depth renderer.
  54116. */
  54117. dispose(): void;
  54118. }
  54119. }
  54120. declare module BABYLON {
  54121. /** @hidden */
  54122. export var minmaxReduxPixelShader: {
  54123. name: string;
  54124. shader: string;
  54125. };
  54126. }
  54127. declare module BABYLON {
  54128. /**
  54129. * This class computes a min/max reduction from a texture: it means it computes the minimum
  54130. * and maximum values from all values of the texture.
  54131. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  54132. * The source values are read from the red channel of the texture.
  54133. */
  54134. export class MinMaxReducer {
  54135. /**
  54136. * Observable triggered when the computation has been performed
  54137. */
  54138. onAfterReductionPerformed: Observable<{
  54139. min: number;
  54140. max: number;
  54141. }>;
  54142. protected _camera: Camera;
  54143. protected _sourceTexture: Nullable<RenderTargetTexture>;
  54144. protected _reductionSteps: Nullable<Array<PostProcess>>;
  54145. protected _postProcessManager: PostProcessManager;
  54146. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  54147. protected _forceFullscreenViewport: boolean;
  54148. /**
  54149. * Creates a min/max reducer
  54150. * @param camera The camera to use for the post processes
  54151. */
  54152. constructor(camera: Camera);
  54153. /**
  54154. * Gets the texture used to read the values from.
  54155. */
  54156. get sourceTexture(): Nullable<RenderTargetTexture>;
  54157. /**
  54158. * Sets the source texture to read the values from.
  54159. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  54160. * because in such textures '1' value must not be taken into account to compute the maximum
  54161. * as this value is used to clear the texture.
  54162. * Note that the computation is not activated by calling this function, you must call activate() for that!
  54163. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  54164. * @param depthRedux Indicates if the texture is a depth texture or not
  54165. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  54166. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54167. */
  54168. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54169. /**
  54170. * Defines the refresh rate of the computation.
  54171. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54172. */
  54173. get refreshRate(): number;
  54174. set refreshRate(value: number);
  54175. protected _activated: boolean;
  54176. /**
  54177. * Gets the activation status of the reducer
  54178. */
  54179. get activated(): boolean;
  54180. /**
  54181. * Activates the reduction computation.
  54182. * When activated, the observers registered in onAfterReductionPerformed are
  54183. * called after the compuation is performed
  54184. */
  54185. activate(): void;
  54186. /**
  54187. * Deactivates the reduction computation.
  54188. */
  54189. deactivate(): void;
  54190. /**
  54191. * Disposes the min/max reducer
  54192. * @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.
  54193. */
  54194. dispose(disposeAll?: boolean): void;
  54195. }
  54196. }
  54197. declare module BABYLON {
  54198. /**
  54199. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  54200. */
  54201. export class DepthReducer extends MinMaxReducer {
  54202. private _depthRenderer;
  54203. private _depthRendererId;
  54204. /**
  54205. * Gets the depth renderer used for the computation.
  54206. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  54207. */
  54208. get depthRenderer(): Nullable<DepthRenderer>;
  54209. /**
  54210. * Creates a depth reducer
  54211. * @param camera The camera used to render the depth texture
  54212. */
  54213. constructor(camera: Camera);
  54214. /**
  54215. * Sets the depth renderer to use to generate the depth map
  54216. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  54217. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  54218. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54219. */
  54220. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  54221. /** @hidden */
  54222. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54223. /**
  54224. * Activates the reduction computation.
  54225. * When activated, the observers registered in onAfterReductionPerformed are
  54226. * called after the compuation is performed
  54227. */
  54228. activate(): void;
  54229. /**
  54230. * Deactivates the reduction computation.
  54231. */
  54232. deactivate(): void;
  54233. /**
  54234. * Disposes the depth reducer
  54235. * @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.
  54236. */
  54237. dispose(disposeAll?: boolean): void;
  54238. }
  54239. }
  54240. declare module BABYLON {
  54241. /**
  54242. * A CSM implementation allowing casting shadows on large scenes.
  54243. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54244. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  54245. */
  54246. export class CascadedShadowGenerator implements IShadowGenerator {
  54247. private static readonly frustumCornersNDCSpace;
  54248. /**
  54249. * Defines the default number of cascades used by the CSM.
  54250. */
  54251. static readonly DEFAULT_CASCADES_COUNT: number;
  54252. /**
  54253. * Defines the minimum number of cascades used by the CSM.
  54254. */
  54255. static readonly MIN_CASCADES_COUNT: number;
  54256. /**
  54257. * Defines the maximum number of cascades used by the CSM.
  54258. */
  54259. static readonly MAX_CASCADES_COUNT: number;
  54260. /**
  54261. * Shadow generator mode None: no filtering applied.
  54262. */
  54263. static readonly FILTER_NONE: number;
  54264. /**
  54265. * Shadow generator mode PCF: Percentage Closer Filtering
  54266. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  54267. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  54268. */
  54269. static readonly FILTER_PCF: number;
  54270. /**
  54271. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  54272. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  54273. * Contact Hardening
  54274. */
  54275. static readonly FILTER_PCSS: number;
  54276. /**
  54277. * Reserved for PCF and PCSS
  54278. * Highest Quality.
  54279. *
  54280. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  54281. *
  54282. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  54283. */
  54284. static readonly QUALITY_HIGH: number;
  54285. /**
  54286. * Reserved for PCF and PCSS
  54287. * Good tradeoff for quality/perf cross devices
  54288. *
  54289. * Execute PCF on a 3*3 kernel.
  54290. *
  54291. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  54292. */
  54293. static readonly QUALITY_MEDIUM: number;
  54294. /**
  54295. * Reserved for PCF and PCSS
  54296. * The lowest quality but the fastest.
  54297. *
  54298. * Execute PCF on a 1*1 kernel.
  54299. *
  54300. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  54301. */
  54302. static readonly QUALITY_LOW: number;
  54303. private static readonly _CLEARONE;
  54304. /**
  54305. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  54306. */
  54307. onBeforeShadowMapRenderObservable: Observable<Effect>;
  54308. /**
  54309. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  54310. */
  54311. onAfterShadowMapRenderObservable: Observable<Effect>;
  54312. /**
  54313. * Observable triggered before a mesh is rendered in the shadow map.
  54314. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  54315. */
  54316. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  54317. /**
  54318. * Observable triggered after a mesh is rendered in the shadow map.
  54319. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  54320. */
  54321. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  54322. private _bias;
  54323. /**
  54324. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  54325. */
  54326. get bias(): number;
  54327. /**
  54328. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  54329. */
  54330. set bias(bias: number);
  54331. private _normalBias;
  54332. /**
  54333. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  54334. */
  54335. get normalBias(): number;
  54336. /**
  54337. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  54338. */
  54339. set normalBias(normalBias: number);
  54340. private _filter;
  54341. /**
  54342. * Gets the current mode of the shadow generator (normal, PCF, PCSS...).
  54343. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  54344. */
  54345. get filter(): number;
  54346. /**
  54347. * Sets the current mode of the shadow generator (normal, PCF, PCSS...).
  54348. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  54349. */
  54350. set filter(value: number);
  54351. /**
  54352. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  54353. */
  54354. get usePercentageCloserFiltering(): boolean;
  54355. /**
  54356. * Sets the current filter to "PCF" (percentage closer filtering).
  54357. */
  54358. set usePercentageCloserFiltering(value: boolean);
  54359. private _filteringQuality;
  54360. /**
  54361. * Gets the PCF or PCSS Quality.
  54362. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  54363. */
  54364. get filteringQuality(): number;
  54365. /**
  54366. * Sets the PCF or PCSS Quality.
  54367. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  54368. */
  54369. set filteringQuality(filteringQuality: number);
  54370. /**
  54371. * Gets if the current filter is set to "PCSS" (contact hardening).
  54372. */
  54373. get useContactHardeningShadow(): boolean;
  54374. /**
  54375. * Sets the current filter to "PCSS" (contact hardening).
  54376. */
  54377. set useContactHardeningShadow(value: boolean);
  54378. private _contactHardeningLightSizeUVRatio;
  54379. /**
  54380. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  54381. * Using a ratio helps keeping shape stability independently of the map size.
  54382. *
  54383. * It does not account for the light projection as it was having too much
  54384. * instability during the light setup or during light position changes.
  54385. *
  54386. * Only valid if useContactHardeningShadow is true.
  54387. */
  54388. get contactHardeningLightSizeUVRatio(): number;
  54389. /**
  54390. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  54391. * Using a ratio helps keeping shape stability independently of the map size.
  54392. *
  54393. * It does not account for the light projection as it was having too much
  54394. * instability during the light setup or during light position changes.
  54395. *
  54396. * Only valid if useContactHardeningShadow is true.
  54397. */
  54398. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  54399. private _darkness;
  54400. /** Gets or sets the actual darkness of a shadow */
  54401. get darkness(): number;
  54402. set darkness(value: number);
  54403. /**
  54404. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  54405. * 0 means strongest and 1 would means no shadow.
  54406. * @returns the darkness.
  54407. */
  54408. getDarkness(): number;
  54409. /**
  54410. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  54411. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  54412. * @returns the shadow generator allowing fluent coding.
  54413. */
  54414. setDarkness(darkness: number): CascadedShadowGenerator;
  54415. /**
  54416. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  54417. */
  54418. penumbraDarkness: number;
  54419. private _transparencyShadow;
  54420. /** Gets or sets the ability to have transparent shadow */
  54421. get transparencyShadow(): boolean;
  54422. set transparencyShadow(value: boolean);
  54423. /**
  54424. * Sets the ability to have transparent shadow (boolean).
  54425. * @param transparent True if transparent else False
  54426. * @returns the shadow generator allowing fluent coding
  54427. */
  54428. setTransparencyShadow(transparent: boolean): CascadedShadowGenerator;
  54429. private _numCascades;
  54430. /**
  54431. * Gets or set the number of cascades used by the CSM.
  54432. */
  54433. get numCascades(): number;
  54434. set numCascades(value: number);
  54435. /**
  54436. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  54437. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  54438. */
  54439. stabilizeCascades: boolean;
  54440. private _shadowMap;
  54441. /**
  54442. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  54443. * @returns The render target texture if present otherwise, null
  54444. */
  54445. getShadowMap(): Nullable<RenderTargetTexture>;
  54446. protected _freezeShadowCastersBoundingInfo: boolean;
  54447. private _freezeShadowCastersBoundingInfoObservable;
  54448. /**
  54449. * Enables or disables the shadow casters bounding info computation.
  54450. * If your shadow casters don't move, you can disable this feature.
  54451. * If it is enabled, the bounding box computation is done every frame.
  54452. */
  54453. get freezeShadowCastersBoundingInfo(): boolean;
  54454. set freezeShadowCastersBoundingInfo(freeze: boolean);
  54455. private _scbiMin;
  54456. private _scbiMax;
  54457. protected _computeShadowCastersBoundingInfo(): void;
  54458. protected _shadowCastersBoundingInfo: BoundingInfo;
  54459. /**
  54460. * Gets or sets the shadow casters bounding info.
  54461. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  54462. * so that the system won't overwrite the bounds you provide
  54463. */
  54464. get shadowCastersBoundingInfo(): BoundingInfo;
  54465. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  54466. protected _breaksAreDirty: boolean;
  54467. protected _minDistance: number;
  54468. protected _maxDistance: number;
  54469. /**
  54470. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  54471. *
  54472. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  54473. * If you don't know these values, simply leave them to their defaults and don't call this function.
  54474. * @param min minimal distance for the breaks (default to 0.)
  54475. * @param max maximal distance for the breaks (default to 1.)
  54476. */
  54477. setMinMaxDistance(min: number, max: number): void;
  54478. /**
  54479. * Gets the class name of that object
  54480. * @returns "ShadowGenerator"
  54481. */
  54482. getClassName(): string;
  54483. /**
  54484. * Helper function to add a mesh and its descendants to the list of shadow casters.
  54485. * @param mesh Mesh to add
  54486. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  54487. * @returns the Shadow Generator itself
  54488. */
  54489. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): CascadedShadowGenerator;
  54490. /**
  54491. * Helper function to remove a mesh and its descendants from the list of shadow casters
  54492. * @param mesh Mesh to remove
  54493. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  54494. * @returns the Shadow Generator itself
  54495. */
  54496. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): CascadedShadowGenerator;
  54497. /**
  54498. * Controls the extent to which the shadows fade out at the edge of the frustum
  54499. */
  54500. frustumEdgeFalloff: number;
  54501. private _light;
  54502. /**
  54503. * Returns the associated light object.
  54504. * @returns the light generating the shadow
  54505. */
  54506. getLight(): DirectionalLight;
  54507. /**
  54508. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  54509. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  54510. * It might on the other hand introduce peter panning.
  54511. */
  54512. forceBackFacesOnly: boolean;
  54513. private _cascadeMinExtents;
  54514. private _cascadeMaxExtents;
  54515. /**
  54516. * Gets a cascade minimum extents
  54517. * @param cascadeIndex index of the cascade
  54518. * @returns the minimum cascade extents
  54519. */
  54520. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  54521. /**
  54522. * Gets a cascade maximum extents
  54523. * @param cascadeIndex index of the cascade
  54524. * @returns the maximum cascade extents
  54525. */
  54526. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  54527. private _scene;
  54528. private _lightDirection;
  54529. private _effect;
  54530. private _cascades;
  54531. private _cachedPosition;
  54532. private _cachedDirection;
  54533. private _cachedDefines;
  54534. private _currentRenderID;
  54535. private _mapSize;
  54536. private _currentLayer;
  54537. private _textureType;
  54538. private _defaultTextureMatrix;
  54539. private _storedUniqueId;
  54540. private _viewSpaceFrustumsZ;
  54541. private _viewMatrices;
  54542. private _projectionMatrices;
  54543. private _transformMatrices;
  54544. private _transformMatricesAsArray;
  54545. private _frustumLengths;
  54546. private _lightSizeUVCorrection;
  54547. private _depthCorrection;
  54548. private _frustumCornersWorldSpace;
  54549. private _frustumCenter;
  54550. private _shadowCameraPos;
  54551. private _shadowMaxZ;
  54552. /**
  54553. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  54554. * It defaults to camera.maxZ
  54555. */
  54556. get shadowMaxZ(): number;
  54557. /**
  54558. * Sets the shadow max z distance.
  54559. */
  54560. set shadowMaxZ(value: number);
  54561. protected _debug: boolean;
  54562. /**
  54563. * Gets or sets the debug flag.
  54564. * When enabled, the cascades are materialized by different colors on the screen.
  54565. */
  54566. get debug(): boolean;
  54567. set debug(dbg: boolean);
  54568. private _depthClamp;
  54569. /**
  54570. * Gets or sets the depth clamping value.
  54571. *
  54572. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  54573. * to account for the shadow casters far away.
  54574. *
  54575. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  54576. */
  54577. get depthClamp(): boolean;
  54578. set depthClamp(value: boolean);
  54579. private _cascadeBlendPercentage;
  54580. /**
  54581. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  54582. * It defaults to 0.1 (10% blending).
  54583. */
  54584. get cascadeBlendPercentage(): number;
  54585. set cascadeBlendPercentage(value: number);
  54586. private _lambda;
  54587. /**
  54588. * Gets or set the lambda parameter.
  54589. * This parameter is used to split the camera frustum and create the cascades.
  54590. * 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.
  54591. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  54592. */
  54593. get lambda(): number;
  54594. set lambda(value: number);
  54595. /**
  54596. * Gets the view matrix corresponding to a given cascade
  54597. * @param cascadeNum cascade to retrieve the view matrix from
  54598. * @returns the cascade view matrix
  54599. */
  54600. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  54601. private _depthRenderer;
  54602. /**
  54603. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  54604. *
  54605. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  54606. *
  54607. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  54608. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  54609. * @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
  54610. */
  54611. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  54612. private _depthReducer;
  54613. private _autoCalcDepthBounds;
  54614. /**
  54615. * Gets or sets the autoCalcDepthBounds property.
  54616. *
  54617. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  54618. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  54619. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  54620. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  54621. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  54622. */
  54623. get autoCalcDepthBounds(): boolean;
  54624. set autoCalcDepthBounds(value: boolean);
  54625. /**
  54626. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  54627. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54628. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  54629. * for setting the refresh rate on the renderer yourself!
  54630. */
  54631. get autoCalcDepthBoundsRefreshRate(): number;
  54632. set autoCalcDepthBoundsRefreshRate(value: number);
  54633. /**
  54634. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  54635. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  54636. * you change the camera near/far planes!
  54637. */
  54638. splitFrustum(): void;
  54639. private _splitFrustum;
  54640. /**
  54641. * Gets the CSM transformation matrix used to project the meshes into the map from the light point of view.
  54642. * (eq to view projection * shadow projection matrices)
  54643. * @param cascadeIndex index number of the cascaded shadow map
  54644. * @returns The transform matrix used to create the CSM shadow map
  54645. */
  54646. getCSMTransformMatrix(cascadeIndex: number): Matrix;
  54647. private _computeFrustumInWorldSpace;
  54648. private _computeCascadeFrustum;
  54649. /** @hidden */
  54650. static _SceneComponentInitialization: (scene: Scene) => void;
  54651. /**
  54652. * Creates a Cascaded Shadow Generator object.
  54653. * A ShadowGenerator is the required tool to use the shadows.
  54654. * Each directional light casting shadows needs to use its own ShadowGenerator.
  54655. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54656. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  54657. * @param light The directional light object generating the shadows.
  54658. * @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.
  54659. */
  54660. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  54661. private _initializeGenerator;
  54662. private _initializeShadowMap;
  54663. private _renderForShadowMap;
  54664. private _renderSubMeshForShadowMap;
  54665. private _applyFilterValues;
  54666. /**
  54667. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  54668. * @param onCompiled Callback triggered at the and of the effects compilation
  54669. * @param options Sets of optional options forcing the compilation with different modes
  54670. */
  54671. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  54672. useInstances: boolean;
  54673. }>): void;
  54674. /**
  54675. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  54676. * @param options Sets of optional options forcing the compilation with different modes
  54677. * @returns A promise that resolves when the compilation completes
  54678. */
  54679. forceCompilationAsync(options?: Partial<{
  54680. useInstances: boolean;
  54681. }>): Promise<void>;
  54682. /**
  54683. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  54684. * @param subMesh The submesh we want to render in the shadow map
  54685. * @param useInstances Defines wether will draw in the map using instances
  54686. * @returns true if ready otherwise, false
  54687. */
  54688. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54689. /**
  54690. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  54691. * @param defines Defines of the material we want to update
  54692. * @param lightIndex Index of the light in the enabled light list of the material
  54693. */
  54694. prepareDefines(defines: any, lightIndex: number): void;
  54695. /**
  54696. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  54697. * defined in the generator but impacting the effect).
  54698. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  54699. * @param effect The effect we are binfing the information for
  54700. */
  54701. bindShadowLight(lightIndex: string, effect: Effect): void;
  54702. /**
  54703. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  54704. * (eq to view projection * shadow projection matrices)
  54705. * @returns The transform matrix used to create the shadow map
  54706. */
  54707. getTransformMatrix(): Matrix;
  54708. /**
  54709. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  54710. * Cube and 2D textures for instance.
  54711. */
  54712. recreateShadowMap(): void;
  54713. private _disposeRTT;
  54714. /**
  54715. * Disposes the ShadowGenerator.
  54716. * Returns nothing.
  54717. */
  54718. dispose(): void;
  54719. /**
  54720. * Serializes the shadow generator setup to a json object.
  54721. * @returns The serialized JSON object
  54722. */
  54723. serialize(): any;
  54724. /**
  54725. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  54726. * @param parsedShadowGenerator The JSON object to parse
  54727. * @param scene The scene to create the shadow map for
  54728. * @returns The parsed shadow generator
  54729. */
  54730. static Parse(parsedShadowGenerator: any, scene: Scene): CascadedShadowGenerator;
  54731. }
  54732. }
  54733. declare module BABYLON {
  54734. /**
  54735. * Defines the shadow generator component responsible to manage any shadow generators
  54736. * in a given scene.
  54737. */
  54738. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  54739. /**
  54740. * The component name helpfull to identify the component in the list of scene components.
  54741. */
  54742. readonly name: string;
  54743. /**
  54744. * The scene the component belongs to.
  54745. */
  54746. scene: Scene;
  54747. /**
  54748. * Creates a new instance of the component for the given scene
  54749. * @param scene Defines the scene to register the component in
  54750. */
  54751. constructor(scene: Scene);
  54752. /**
  54753. * Registers the component in a given scene
  54754. */
  54755. register(): void;
  54756. /**
  54757. * Rebuilds the elements related to this component in case of
  54758. * context lost for instance.
  54759. */
  54760. rebuild(): void;
  54761. /**
  54762. * Serializes the component data to the specified json object
  54763. * @param serializationObject The object to serialize to
  54764. */
  54765. serialize(serializationObject: any): void;
  54766. /**
  54767. * Adds all the elements from the container to the scene
  54768. * @param container the container holding the elements
  54769. */
  54770. addFromContainer(container: AbstractScene): void;
  54771. /**
  54772. * Removes all the elements in the container from the scene
  54773. * @param container contains the elements to remove
  54774. * @param dispose if the removed element should be disposed (default: false)
  54775. */
  54776. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54777. /**
  54778. * Rebuilds the elements related to this component in case of
  54779. * context lost for instance.
  54780. */
  54781. dispose(): void;
  54782. private _gatherRenderTargets;
  54783. }
  54784. }
  54785. declare module BABYLON {
  54786. /**
  54787. * A point light is a light defined by an unique point in world space.
  54788. * The light is emitted in every direction from this point.
  54789. * A good example of a point light is a standard light bulb.
  54790. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54791. */
  54792. export class PointLight extends ShadowLight {
  54793. private _shadowAngle;
  54794. /**
  54795. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54796. * This specifies what angle the shadow will use to be created.
  54797. *
  54798. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  54799. */
  54800. get shadowAngle(): number;
  54801. /**
  54802. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54803. * This specifies what angle the shadow will use to be created.
  54804. *
  54805. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  54806. */
  54807. set shadowAngle(value: number);
  54808. /**
  54809. * Gets the direction if it has been set.
  54810. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54811. */
  54812. get direction(): Vector3;
  54813. /**
  54814. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54815. */
  54816. set direction(value: Vector3);
  54817. /**
  54818. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  54819. * A PointLight emits the light in every direction.
  54820. * It can cast shadows.
  54821. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  54822. * ```javascript
  54823. * var pointLight = new PointLight("pl", camera.position, scene);
  54824. * ```
  54825. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54826. * @param name The light friendly name
  54827. * @param position The position of the point light in the scene
  54828. * @param scene The scene the lights belongs to
  54829. */
  54830. constructor(name: string, position: Vector3, scene: Scene);
  54831. /**
  54832. * Returns the string "PointLight"
  54833. * @returns the class name
  54834. */
  54835. getClassName(): string;
  54836. /**
  54837. * Returns the integer 0.
  54838. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54839. */
  54840. getTypeID(): number;
  54841. /**
  54842. * Specifies wether or not the shadowmap should be a cube texture.
  54843. * @returns true if the shadowmap needs to be a cube texture.
  54844. */
  54845. needCube(): boolean;
  54846. /**
  54847. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  54848. * @param faceIndex The index of the face we are computed the direction to generate shadow
  54849. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  54850. */
  54851. getShadowDirection(faceIndex?: number): Vector3;
  54852. /**
  54853. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  54854. * - fov = PI / 2
  54855. * - aspect ratio : 1.0
  54856. * - z-near and far equal to the active camera minZ and maxZ.
  54857. * Returns the PointLight.
  54858. */
  54859. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54860. protected _buildUniformLayout(): void;
  54861. /**
  54862. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  54863. * @param effect The effect to update
  54864. * @param lightIndex The index of the light in the effect to update
  54865. * @returns The point light
  54866. */
  54867. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  54868. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  54869. /**
  54870. * Prepares the list of defines specific to the light type.
  54871. * @param defines the list of defines
  54872. * @param lightIndex defines the index of the light for the effect
  54873. */
  54874. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54875. }
  54876. }
  54877. declare module BABYLON {
  54878. /**
  54879. * Header information of HDR texture files.
  54880. */
  54881. export interface HDRInfo {
  54882. /**
  54883. * The height of the texture in pixels.
  54884. */
  54885. height: number;
  54886. /**
  54887. * The width of the texture in pixels.
  54888. */
  54889. width: number;
  54890. /**
  54891. * The index of the beginning of the data in the binary file.
  54892. */
  54893. dataPosition: number;
  54894. }
  54895. /**
  54896. * This groups tools to convert HDR texture to native colors array.
  54897. */
  54898. export class HDRTools {
  54899. private static Ldexp;
  54900. private static Rgbe2float;
  54901. private static readStringLine;
  54902. /**
  54903. * Reads header information from an RGBE texture stored in a native array.
  54904. * More information on this format are available here:
  54905. * https://en.wikipedia.org/wiki/RGBE_image_format
  54906. *
  54907. * @param uint8array The binary file stored in native array.
  54908. * @return The header information.
  54909. */
  54910. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  54911. /**
  54912. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  54913. * This RGBE texture needs to store the information as a panorama.
  54914. *
  54915. * More information on this format are available here:
  54916. * https://en.wikipedia.org/wiki/RGBE_image_format
  54917. *
  54918. * @param buffer The binary file stored in an array buffer.
  54919. * @param size The expected size of the extracted cubemap.
  54920. * @return The Cube Map information.
  54921. */
  54922. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  54923. /**
  54924. * Returns the pixels data extracted from an RGBE texture.
  54925. * This pixels will be stored left to right up to down in the R G B order in one array.
  54926. *
  54927. * More information on this format are available here:
  54928. * https://en.wikipedia.org/wiki/RGBE_image_format
  54929. *
  54930. * @param uint8array The binary file stored in an array buffer.
  54931. * @param hdrInfo The header information of the file.
  54932. * @return The pixels data in RGB right to left up to down order.
  54933. */
  54934. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  54935. private static RGBE_ReadPixels_RLE;
  54936. }
  54937. }
  54938. declare module BABYLON {
  54939. /**
  54940. * This represents a texture coming from an HDR input.
  54941. *
  54942. * The only supported format is currently panorama picture stored in RGBE format.
  54943. * Example of such files can be found on HDRLib: http://hdrlib.com/
  54944. */
  54945. export class HDRCubeTexture extends BaseTexture {
  54946. private static _facesMapping;
  54947. private _generateHarmonics;
  54948. private _noMipmap;
  54949. private _textureMatrix;
  54950. private _size;
  54951. private _onLoad;
  54952. private _onError;
  54953. /**
  54954. * The texture URL.
  54955. */
  54956. url: string;
  54957. /**
  54958. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  54959. */
  54960. coordinatesMode: number;
  54961. protected _isBlocking: boolean;
  54962. /**
  54963. * Sets wether or not the texture is blocking during loading.
  54964. */
  54965. set isBlocking(value: boolean);
  54966. /**
  54967. * Gets wether or not the texture is blocking during loading.
  54968. */
  54969. get isBlocking(): boolean;
  54970. protected _rotationY: number;
  54971. /**
  54972. * Sets texture matrix rotation angle around Y axis in radians.
  54973. */
  54974. set rotationY(value: number);
  54975. /**
  54976. * Gets texture matrix rotation angle around Y axis radians.
  54977. */
  54978. get rotationY(): number;
  54979. /**
  54980. * Gets or sets the center of the bounding box associated with the cube texture
  54981. * It must define where the camera used to render the texture was set
  54982. */
  54983. boundingBoxPosition: Vector3;
  54984. private _boundingBoxSize;
  54985. /**
  54986. * Gets or sets the size of the bounding box associated with the cube texture
  54987. * When defined, the cubemap will switch to local mode
  54988. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  54989. * @example https://www.babylonjs-playground.com/#RNASML
  54990. */
  54991. set boundingBoxSize(value: Vector3);
  54992. get boundingBoxSize(): Vector3;
  54993. /**
  54994. * Instantiates an HDRTexture from the following parameters.
  54995. *
  54996. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  54997. * @param scene The scene the texture will be used in
  54998. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  54999. * @param noMipmap Forces to not generate the mipmap if true
  55000. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  55001. * @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)
  55002. * @param reserved Reserved flag for internal use.
  55003. */
  55004. 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>);
  55005. /**
  55006. * Get the current class name of the texture useful for serialization or dynamic coding.
  55007. * @returns "HDRCubeTexture"
  55008. */
  55009. getClassName(): string;
  55010. /**
  55011. * Occurs when the file is raw .hdr file.
  55012. */
  55013. private loadTexture;
  55014. clone(): HDRCubeTexture;
  55015. delayLoad(): void;
  55016. /**
  55017. * Get the texture reflection matrix used to rotate/transform the reflection.
  55018. * @returns the reflection matrix
  55019. */
  55020. getReflectionTextureMatrix(): Matrix;
  55021. /**
  55022. * Set the texture reflection matrix used to rotate/transform the reflection.
  55023. * @param value Define the reflection matrix to set
  55024. */
  55025. setReflectionTextureMatrix(value: Matrix): void;
  55026. /**
  55027. * Parses a JSON representation of an HDR Texture in order to create the texture
  55028. * @param parsedTexture Define the JSON representation
  55029. * @param scene Define the scene the texture should be created in
  55030. * @param rootUrl Define the root url in case we need to load relative dependencies
  55031. * @returns the newly created texture after parsing
  55032. */
  55033. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  55034. serialize(): any;
  55035. }
  55036. }
  55037. declare module BABYLON {
  55038. /**
  55039. * Class used to control physics engine
  55040. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  55041. */
  55042. export class PhysicsEngine implements IPhysicsEngine {
  55043. private _physicsPlugin;
  55044. /**
  55045. * Global value used to control the smallest number supported by the simulation
  55046. */
  55047. static Epsilon: number;
  55048. private _impostors;
  55049. private _joints;
  55050. private _subTimeStep;
  55051. /**
  55052. * Gets the gravity vector used by the simulation
  55053. */
  55054. gravity: Vector3;
  55055. /**
  55056. * Factory used to create the default physics plugin.
  55057. * @returns The default physics plugin
  55058. */
  55059. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  55060. /**
  55061. * Creates a new Physics Engine
  55062. * @param gravity defines the gravity vector used by the simulation
  55063. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  55064. */
  55065. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  55066. /**
  55067. * Sets the gravity vector used by the simulation
  55068. * @param gravity defines the gravity vector to use
  55069. */
  55070. setGravity(gravity: Vector3): void;
  55071. /**
  55072. * Set the time step of the physics engine.
  55073. * Default is 1/60.
  55074. * To slow it down, enter 1/600 for example.
  55075. * To speed it up, 1/30
  55076. * @param newTimeStep defines the new timestep to apply to this world.
  55077. */
  55078. setTimeStep(newTimeStep?: number): void;
  55079. /**
  55080. * Get the time step of the physics engine.
  55081. * @returns the current time step
  55082. */
  55083. getTimeStep(): number;
  55084. /**
  55085. * Set the sub time step of the physics engine.
  55086. * Default is 0 meaning there is no sub steps
  55087. * To increase physics resolution precision, set a small value (like 1 ms)
  55088. * @param subTimeStep defines the new sub timestep used for physics resolution.
  55089. */
  55090. setSubTimeStep(subTimeStep?: number): void;
  55091. /**
  55092. * Get the sub time step of the physics engine.
  55093. * @returns the current sub time step
  55094. */
  55095. getSubTimeStep(): number;
  55096. /**
  55097. * Release all resources
  55098. */
  55099. dispose(): void;
  55100. /**
  55101. * Gets the name of the current physics plugin
  55102. * @returns the name of the plugin
  55103. */
  55104. getPhysicsPluginName(): string;
  55105. /**
  55106. * Adding a new impostor for the impostor tracking.
  55107. * This will be done by the impostor itself.
  55108. * @param impostor the impostor to add
  55109. */
  55110. addImpostor(impostor: PhysicsImpostor): void;
  55111. /**
  55112. * Remove an impostor from the engine.
  55113. * This impostor and its mesh will not longer be updated by the physics engine.
  55114. * @param impostor the impostor to remove
  55115. */
  55116. removeImpostor(impostor: PhysicsImpostor): void;
  55117. /**
  55118. * Add a joint to the physics engine
  55119. * @param mainImpostor defines the main impostor to which the joint is added.
  55120. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  55121. * @param joint defines the joint that will connect both impostors.
  55122. */
  55123. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55124. /**
  55125. * Removes a joint from the simulation
  55126. * @param mainImpostor defines the impostor used with the joint
  55127. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  55128. * @param joint defines the joint to remove
  55129. */
  55130. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  55131. /**
  55132. * Called by the scene. No need to call it.
  55133. * @param delta defines the timespam between frames
  55134. */
  55135. _step(delta: number): void;
  55136. /**
  55137. * Gets the current plugin used to run the simulation
  55138. * @returns current plugin
  55139. */
  55140. getPhysicsPlugin(): IPhysicsEnginePlugin;
  55141. /**
  55142. * Gets the list of physic impostors
  55143. * @returns an array of PhysicsImpostor
  55144. */
  55145. getImpostors(): Array<PhysicsImpostor>;
  55146. /**
  55147. * Gets the impostor for a physics enabled object
  55148. * @param object defines the object impersonated by the impostor
  55149. * @returns the PhysicsImpostor or null if not found
  55150. */
  55151. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  55152. /**
  55153. * Gets the impostor for a physics body object
  55154. * @param body defines physics body used by the impostor
  55155. * @returns the PhysicsImpostor or null if not found
  55156. */
  55157. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  55158. /**
  55159. * Does a raycast in the physics world
  55160. * @param from when should the ray start?
  55161. * @param to when should the ray end?
  55162. * @returns PhysicsRaycastResult
  55163. */
  55164. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55165. }
  55166. }
  55167. declare module BABYLON {
  55168. /** @hidden */
  55169. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  55170. private _useDeltaForWorldStep;
  55171. world: any;
  55172. name: string;
  55173. private _physicsMaterials;
  55174. private _fixedTimeStep;
  55175. private _cannonRaycastResult;
  55176. private _raycastResult;
  55177. private _physicsBodysToRemoveAfterStep;
  55178. BJSCANNON: any;
  55179. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  55180. setGravity(gravity: Vector3): void;
  55181. setTimeStep(timeStep: number): void;
  55182. getTimeStep(): number;
  55183. executeStep(delta: number): void;
  55184. private _removeMarkedPhysicsBodiesFromWorld;
  55185. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55186. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55187. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55188. private _processChildMeshes;
  55189. removePhysicsBody(impostor: PhysicsImpostor): void;
  55190. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55191. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55192. private _addMaterial;
  55193. private _checkWithEpsilon;
  55194. private _createShape;
  55195. private _createHeightmap;
  55196. private _minus90X;
  55197. private _plus90X;
  55198. private _tmpPosition;
  55199. private _tmpDeltaPosition;
  55200. private _tmpUnityRotation;
  55201. private _updatePhysicsBodyTransformation;
  55202. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55203. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55204. isSupported(): boolean;
  55205. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55206. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55207. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55208. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55209. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55210. getBodyMass(impostor: PhysicsImpostor): number;
  55211. getBodyFriction(impostor: PhysicsImpostor): number;
  55212. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55213. getBodyRestitution(impostor: PhysicsImpostor): number;
  55214. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55215. sleepBody(impostor: PhysicsImpostor): void;
  55216. wakeUpBody(impostor: PhysicsImpostor): void;
  55217. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  55218. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55219. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55220. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55221. getRadius(impostor: PhysicsImpostor): number;
  55222. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55223. dispose(): void;
  55224. private _extendNamespace;
  55225. /**
  55226. * Does a raycast in the physics world
  55227. * @param from when should the ray start?
  55228. * @param to when should the ray end?
  55229. * @returns PhysicsRaycastResult
  55230. */
  55231. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55232. }
  55233. }
  55234. declare module BABYLON {
  55235. /** @hidden */
  55236. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  55237. world: any;
  55238. name: string;
  55239. BJSOIMO: any;
  55240. private _raycastResult;
  55241. constructor(iterations?: number, oimoInjection?: any);
  55242. setGravity(gravity: Vector3): void;
  55243. setTimeStep(timeStep: number): void;
  55244. getTimeStep(): number;
  55245. private _tmpImpostorsArray;
  55246. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55247. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55248. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55249. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55250. private _tmpPositionVector;
  55251. removePhysicsBody(impostor: PhysicsImpostor): void;
  55252. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55253. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55254. isSupported(): boolean;
  55255. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55256. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55257. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55258. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55259. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55260. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55261. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55262. getBodyMass(impostor: PhysicsImpostor): number;
  55263. getBodyFriction(impostor: PhysicsImpostor): number;
  55264. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55265. getBodyRestitution(impostor: PhysicsImpostor): number;
  55266. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55267. sleepBody(impostor: PhysicsImpostor): void;
  55268. wakeUpBody(impostor: PhysicsImpostor): void;
  55269. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55270. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  55271. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  55272. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55273. getRadius(impostor: PhysicsImpostor): number;
  55274. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55275. dispose(): void;
  55276. /**
  55277. * Does a raycast in the physics world
  55278. * @param from when should the ray start?
  55279. * @param to when should the ray end?
  55280. * @returns PhysicsRaycastResult
  55281. */
  55282. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55283. }
  55284. }
  55285. declare module BABYLON {
  55286. /**
  55287. * Class containing static functions to help procedurally build meshes
  55288. */
  55289. export class RibbonBuilder {
  55290. /**
  55291. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55292. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  55293. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  55294. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  55295. * * 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
  55296. * * 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
  55297. * * 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
  55298. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55299. * * 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
  55300. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55301. * * 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
  55302. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  55303. * * 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
  55304. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  55305. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55306. * @param name defines the name of the mesh
  55307. * @param options defines the options used to create the mesh
  55308. * @param scene defines the hosting scene
  55309. * @returns the ribbon mesh
  55310. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  55311. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55312. */
  55313. static CreateRibbon(name: string, options: {
  55314. pathArray: Vector3[][];
  55315. closeArray?: boolean;
  55316. closePath?: boolean;
  55317. offset?: number;
  55318. updatable?: boolean;
  55319. sideOrientation?: number;
  55320. frontUVs?: Vector4;
  55321. backUVs?: Vector4;
  55322. instance?: Mesh;
  55323. invertUV?: boolean;
  55324. uvs?: Vector2[];
  55325. colors?: Color4[];
  55326. }, scene?: Nullable<Scene>): Mesh;
  55327. }
  55328. }
  55329. declare module BABYLON {
  55330. /**
  55331. * Class containing static functions to help procedurally build meshes
  55332. */
  55333. export class ShapeBuilder {
  55334. /**
  55335. * 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.
  55336. * * 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.
  55337. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55338. * * 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.
  55339. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55340. * * 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
  55341. * * 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
  55342. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55343. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55344. * * 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
  55345. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55346. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55347. * @param name defines the name of the mesh
  55348. * @param options defines the options used to create the mesh
  55349. * @param scene defines the hosting scene
  55350. * @returns the extruded shape mesh
  55351. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55352. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55353. */
  55354. static ExtrudeShape(name: string, options: {
  55355. shape: Vector3[];
  55356. path: Vector3[];
  55357. scale?: number;
  55358. rotation?: number;
  55359. cap?: number;
  55360. updatable?: boolean;
  55361. sideOrientation?: number;
  55362. frontUVs?: Vector4;
  55363. backUVs?: Vector4;
  55364. instance?: Mesh;
  55365. invertUV?: boolean;
  55366. }, scene?: Nullable<Scene>): Mesh;
  55367. /**
  55368. * Creates an custom extruded shape mesh.
  55369. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55370. * * 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.
  55371. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55372. * * 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
  55373. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55374. * * 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
  55375. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55376. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55377. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55378. * * 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
  55379. * * 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
  55380. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55381. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55382. * * 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
  55383. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55384. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55385. * @param name defines the name of the mesh
  55386. * @param options defines the options used to create the mesh
  55387. * @param scene defines the hosting scene
  55388. * @returns the custom extruded shape mesh
  55389. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55390. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55391. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55392. */
  55393. static ExtrudeShapeCustom(name: string, options: {
  55394. shape: Vector3[];
  55395. path: Vector3[];
  55396. scaleFunction?: any;
  55397. rotationFunction?: any;
  55398. ribbonCloseArray?: boolean;
  55399. ribbonClosePath?: boolean;
  55400. cap?: number;
  55401. updatable?: boolean;
  55402. sideOrientation?: number;
  55403. frontUVs?: Vector4;
  55404. backUVs?: Vector4;
  55405. instance?: Mesh;
  55406. invertUV?: boolean;
  55407. }, scene?: Nullable<Scene>): Mesh;
  55408. private static _ExtrudeShapeGeneric;
  55409. }
  55410. }
  55411. declare module BABYLON {
  55412. /**
  55413. * AmmoJS Physics plugin
  55414. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  55415. * @see https://github.com/kripken/ammo.js/
  55416. */
  55417. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  55418. private _useDeltaForWorldStep;
  55419. /**
  55420. * Reference to the Ammo library
  55421. */
  55422. bjsAMMO: any;
  55423. /**
  55424. * Created ammoJS world which physics bodies are added to
  55425. */
  55426. world: any;
  55427. /**
  55428. * Name of the plugin
  55429. */
  55430. name: string;
  55431. private _timeStep;
  55432. private _fixedTimeStep;
  55433. private _maxSteps;
  55434. private _tmpQuaternion;
  55435. private _tmpAmmoTransform;
  55436. private _tmpAmmoQuaternion;
  55437. private _tmpAmmoConcreteContactResultCallback;
  55438. private _collisionConfiguration;
  55439. private _dispatcher;
  55440. private _overlappingPairCache;
  55441. private _solver;
  55442. private _softBodySolver;
  55443. private _tmpAmmoVectorA;
  55444. private _tmpAmmoVectorB;
  55445. private _tmpAmmoVectorC;
  55446. private _tmpAmmoVectorD;
  55447. private _tmpContactCallbackResult;
  55448. private _tmpAmmoVectorRCA;
  55449. private _tmpAmmoVectorRCB;
  55450. private _raycastResult;
  55451. private static readonly DISABLE_COLLISION_FLAG;
  55452. private static readonly KINEMATIC_FLAG;
  55453. private static readonly DISABLE_DEACTIVATION_FLAG;
  55454. /**
  55455. * Initializes the ammoJS plugin
  55456. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  55457. * @param ammoInjection can be used to inject your own ammo reference
  55458. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  55459. */
  55460. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  55461. /**
  55462. * Sets the gravity of the physics world (m/(s^2))
  55463. * @param gravity Gravity to set
  55464. */
  55465. setGravity(gravity: Vector3): void;
  55466. /**
  55467. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  55468. * @param timeStep timestep to use in seconds
  55469. */
  55470. setTimeStep(timeStep: number): void;
  55471. /**
  55472. * 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)
  55473. * @param fixedTimeStep fixedTimeStep to use in seconds
  55474. */
  55475. setFixedTimeStep(fixedTimeStep: number): void;
  55476. /**
  55477. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  55478. * @param maxSteps the maximum number of steps by the physics engine per frame
  55479. */
  55480. setMaxSteps(maxSteps: number): void;
  55481. /**
  55482. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  55483. * @returns the current timestep in seconds
  55484. */
  55485. getTimeStep(): number;
  55486. /**
  55487. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  55488. */
  55489. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  55490. private _isImpostorInContact;
  55491. private _isImpostorPairInContact;
  55492. private _stepSimulation;
  55493. /**
  55494. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  55495. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  55496. * After the step the babylon meshes are set to the position of the physics imposters
  55497. * @param delta amount of time to step forward
  55498. * @param impostors array of imposters to update before/after the step
  55499. */
  55500. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55501. /**
  55502. * Update babylon mesh to match physics world object
  55503. * @param impostor imposter to match
  55504. */
  55505. private _afterSoftStep;
  55506. /**
  55507. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55508. * @param impostor imposter to match
  55509. */
  55510. private _ropeStep;
  55511. /**
  55512. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55513. * @param impostor imposter to match
  55514. */
  55515. private _softbodyOrClothStep;
  55516. private _tmpVector;
  55517. private _tmpMatrix;
  55518. /**
  55519. * Applies an impulse on the imposter
  55520. * @param impostor imposter to apply impulse to
  55521. * @param force amount of force to be applied to the imposter
  55522. * @param contactPoint the location to apply the impulse on the imposter
  55523. */
  55524. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55525. /**
  55526. * Applies a force on the imposter
  55527. * @param impostor imposter to apply force
  55528. * @param force amount of force to be applied to the imposter
  55529. * @param contactPoint the location to apply the force on the imposter
  55530. */
  55531. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55532. /**
  55533. * Creates a physics body using the plugin
  55534. * @param impostor the imposter to create the physics body on
  55535. */
  55536. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55537. /**
  55538. * Removes the physics body from the imposter and disposes of the body's memory
  55539. * @param impostor imposter to remove the physics body from
  55540. */
  55541. removePhysicsBody(impostor: PhysicsImpostor): void;
  55542. /**
  55543. * Generates a joint
  55544. * @param impostorJoint the imposter joint to create the joint with
  55545. */
  55546. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55547. /**
  55548. * Removes a joint
  55549. * @param impostorJoint the imposter joint to remove the joint from
  55550. */
  55551. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55552. private _addMeshVerts;
  55553. /**
  55554. * Initialise the soft body vertices to match its object's (mesh) vertices
  55555. * Softbody vertices (nodes) are in world space and to match this
  55556. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  55557. * @param impostor to create the softbody for
  55558. */
  55559. private _softVertexData;
  55560. /**
  55561. * Create an impostor's soft body
  55562. * @param impostor to create the softbody for
  55563. */
  55564. private _createSoftbody;
  55565. /**
  55566. * Create cloth for an impostor
  55567. * @param impostor to create the softbody for
  55568. */
  55569. private _createCloth;
  55570. /**
  55571. * Create rope for an impostor
  55572. * @param impostor to create the softbody for
  55573. */
  55574. private _createRope;
  55575. /**
  55576. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  55577. * @param impostor to create the custom physics shape for
  55578. */
  55579. private _createCustom;
  55580. private _addHullVerts;
  55581. private _createShape;
  55582. /**
  55583. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  55584. * @param impostor imposter containing the physics body and babylon object
  55585. */
  55586. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55587. /**
  55588. * Sets the babylon object's position/rotation from the physics body's position/rotation
  55589. * @param impostor imposter containing the physics body and babylon object
  55590. * @param newPosition new position
  55591. * @param newRotation new rotation
  55592. */
  55593. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55594. /**
  55595. * If this plugin is supported
  55596. * @returns true if its supported
  55597. */
  55598. isSupported(): boolean;
  55599. /**
  55600. * Sets the linear velocity of the physics body
  55601. * @param impostor imposter to set the velocity on
  55602. * @param velocity velocity to set
  55603. */
  55604. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55605. /**
  55606. * Sets the angular velocity of the physics body
  55607. * @param impostor imposter to set the velocity on
  55608. * @param velocity velocity to set
  55609. */
  55610. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55611. /**
  55612. * gets the linear velocity
  55613. * @param impostor imposter to get linear velocity from
  55614. * @returns linear velocity
  55615. */
  55616. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55617. /**
  55618. * gets the angular velocity
  55619. * @param impostor imposter to get angular velocity from
  55620. * @returns angular velocity
  55621. */
  55622. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55623. /**
  55624. * Sets the mass of physics body
  55625. * @param impostor imposter to set the mass on
  55626. * @param mass mass to set
  55627. */
  55628. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55629. /**
  55630. * Gets the mass of the physics body
  55631. * @param impostor imposter to get the mass from
  55632. * @returns mass
  55633. */
  55634. getBodyMass(impostor: PhysicsImpostor): number;
  55635. /**
  55636. * Gets friction of the impostor
  55637. * @param impostor impostor to get friction from
  55638. * @returns friction value
  55639. */
  55640. getBodyFriction(impostor: PhysicsImpostor): number;
  55641. /**
  55642. * Sets friction of the impostor
  55643. * @param impostor impostor to set friction on
  55644. * @param friction friction value
  55645. */
  55646. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55647. /**
  55648. * Gets restitution of the impostor
  55649. * @param impostor impostor to get restitution from
  55650. * @returns restitution value
  55651. */
  55652. getBodyRestitution(impostor: PhysicsImpostor): number;
  55653. /**
  55654. * Sets resitution of the impostor
  55655. * @param impostor impostor to set resitution on
  55656. * @param restitution resitution value
  55657. */
  55658. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55659. /**
  55660. * Gets pressure inside the impostor
  55661. * @param impostor impostor to get pressure from
  55662. * @returns pressure value
  55663. */
  55664. getBodyPressure(impostor: PhysicsImpostor): number;
  55665. /**
  55666. * Sets pressure inside a soft body impostor
  55667. * Cloth and rope must remain 0 pressure
  55668. * @param impostor impostor to set pressure on
  55669. * @param pressure pressure value
  55670. */
  55671. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  55672. /**
  55673. * Gets stiffness of the impostor
  55674. * @param impostor impostor to get stiffness from
  55675. * @returns pressure value
  55676. */
  55677. getBodyStiffness(impostor: PhysicsImpostor): number;
  55678. /**
  55679. * Sets stiffness of the impostor
  55680. * @param impostor impostor to set stiffness on
  55681. * @param stiffness stiffness value from 0 to 1
  55682. */
  55683. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  55684. /**
  55685. * Gets velocityIterations of the impostor
  55686. * @param impostor impostor to get velocity iterations from
  55687. * @returns velocityIterations value
  55688. */
  55689. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  55690. /**
  55691. * Sets velocityIterations of the impostor
  55692. * @param impostor impostor to set velocity iterations on
  55693. * @param velocityIterations velocityIterations value
  55694. */
  55695. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  55696. /**
  55697. * Gets positionIterations of the impostor
  55698. * @param impostor impostor to get position iterations from
  55699. * @returns positionIterations value
  55700. */
  55701. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  55702. /**
  55703. * Sets positionIterations of the impostor
  55704. * @param impostor impostor to set position on
  55705. * @param positionIterations positionIterations value
  55706. */
  55707. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  55708. /**
  55709. * Append an anchor to a cloth object
  55710. * @param impostor is the cloth impostor to add anchor to
  55711. * @param otherImpostor is the rigid impostor to anchor to
  55712. * @param width ratio across width from 0 to 1
  55713. * @param height ratio up height from 0 to 1
  55714. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  55715. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55716. */
  55717. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55718. /**
  55719. * Append an hook to a rope object
  55720. * @param impostor is the rope impostor to add hook to
  55721. * @param otherImpostor is the rigid impostor to hook to
  55722. * @param length ratio along the rope from 0 to 1
  55723. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  55724. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55725. */
  55726. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55727. /**
  55728. * Sleeps the physics body and stops it from being active
  55729. * @param impostor impostor to sleep
  55730. */
  55731. sleepBody(impostor: PhysicsImpostor): void;
  55732. /**
  55733. * Activates the physics body
  55734. * @param impostor impostor to activate
  55735. */
  55736. wakeUpBody(impostor: PhysicsImpostor): void;
  55737. /**
  55738. * Updates the distance parameters of the joint
  55739. * @param joint joint to update
  55740. * @param maxDistance maximum distance of the joint
  55741. * @param minDistance minimum distance of the joint
  55742. */
  55743. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55744. /**
  55745. * Sets a motor on the joint
  55746. * @param joint joint to set motor on
  55747. * @param speed speed of the motor
  55748. * @param maxForce maximum force of the motor
  55749. * @param motorIndex index of the motor
  55750. */
  55751. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55752. /**
  55753. * Sets the motors limit
  55754. * @param joint joint to set limit on
  55755. * @param upperLimit upper limit
  55756. * @param lowerLimit lower limit
  55757. */
  55758. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55759. /**
  55760. * Syncs the position and rotation of a mesh with the impostor
  55761. * @param mesh mesh to sync
  55762. * @param impostor impostor to update the mesh with
  55763. */
  55764. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55765. /**
  55766. * Gets the radius of the impostor
  55767. * @param impostor impostor to get radius from
  55768. * @returns the radius
  55769. */
  55770. getRadius(impostor: PhysicsImpostor): number;
  55771. /**
  55772. * Gets the box size of the impostor
  55773. * @param impostor impostor to get box size from
  55774. * @param result the resulting box size
  55775. */
  55776. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55777. /**
  55778. * Disposes of the impostor
  55779. */
  55780. dispose(): void;
  55781. /**
  55782. * Does a raycast in the physics world
  55783. * @param from when should the ray start?
  55784. * @param to when should the ray end?
  55785. * @returns PhysicsRaycastResult
  55786. */
  55787. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55788. }
  55789. }
  55790. declare module BABYLON {
  55791. interface AbstractScene {
  55792. /**
  55793. * The list of reflection probes added to the scene
  55794. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  55795. */
  55796. reflectionProbes: Array<ReflectionProbe>;
  55797. /**
  55798. * Removes the given reflection probe from this scene.
  55799. * @param toRemove The reflection probe to remove
  55800. * @returns The index of the removed reflection probe
  55801. */
  55802. removeReflectionProbe(toRemove: ReflectionProbe): number;
  55803. /**
  55804. * Adds the given reflection probe to this scene.
  55805. * @param newReflectionProbe The reflection probe to add
  55806. */
  55807. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  55808. }
  55809. /**
  55810. * Class used to generate realtime reflection / refraction cube textures
  55811. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  55812. */
  55813. export class ReflectionProbe {
  55814. /** defines the name of the probe */
  55815. name: string;
  55816. private _scene;
  55817. private _renderTargetTexture;
  55818. private _projectionMatrix;
  55819. private _viewMatrix;
  55820. private _target;
  55821. private _add;
  55822. private _attachedMesh;
  55823. private _invertYAxis;
  55824. /** Gets or sets probe position (center of the cube map) */
  55825. position: Vector3;
  55826. /**
  55827. * Creates a new reflection probe
  55828. * @param name defines the name of the probe
  55829. * @param size defines the texture resolution (for each face)
  55830. * @param scene defines the hosting scene
  55831. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  55832. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  55833. */
  55834. constructor(
  55835. /** defines the name of the probe */
  55836. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  55837. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  55838. get samples(): number;
  55839. set samples(value: number);
  55840. /** Gets or sets the refresh rate to use (on every frame by default) */
  55841. get refreshRate(): number;
  55842. set refreshRate(value: number);
  55843. /**
  55844. * Gets the hosting scene
  55845. * @returns a Scene
  55846. */
  55847. getScene(): Scene;
  55848. /** Gets the internal CubeTexture used to render to */
  55849. get cubeTexture(): RenderTargetTexture;
  55850. /** Gets the list of meshes to render */
  55851. get renderList(): Nullable<AbstractMesh[]>;
  55852. /**
  55853. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  55854. * @param mesh defines the mesh to attach to
  55855. */
  55856. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  55857. /**
  55858. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  55859. * @param renderingGroupId The rendering group id corresponding to its index
  55860. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  55861. */
  55862. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  55863. /**
  55864. * Clean all associated resources
  55865. */
  55866. dispose(): void;
  55867. /**
  55868. * Converts the reflection probe information to a readable string for debug purpose.
  55869. * @param fullDetails Supports for multiple levels of logging within scene loading
  55870. * @returns the human readable reflection probe info
  55871. */
  55872. toString(fullDetails?: boolean): string;
  55873. /**
  55874. * Get the class name of the relfection probe.
  55875. * @returns "ReflectionProbe"
  55876. */
  55877. getClassName(): string;
  55878. /**
  55879. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  55880. * @returns The JSON representation of the texture
  55881. */
  55882. serialize(): any;
  55883. /**
  55884. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  55885. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  55886. * @param scene Define the scene the parsed reflection probe should be instantiated in
  55887. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  55888. * @returns The parsed reflection probe if successful
  55889. */
  55890. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  55891. }
  55892. }
  55893. declare module BABYLON {
  55894. /** @hidden */
  55895. export var _BabylonLoaderRegistered: boolean;
  55896. /**
  55897. * Helps setting up some configuration for the babylon file loader.
  55898. */
  55899. export class BabylonFileLoaderConfiguration {
  55900. /**
  55901. * The loader does not allow injecting custom physix engine into the plugins.
  55902. * Unfortunately in ES6, we need to manually inject them into the plugin.
  55903. * So you could set this variable to your engine import to make it work.
  55904. */
  55905. static LoaderInjectedPhysicsEngine: any;
  55906. }
  55907. }
  55908. declare module BABYLON {
  55909. /**
  55910. * The Physically based simple base material of BJS.
  55911. *
  55912. * This enables better naming and convention enforcements on top of the pbrMaterial.
  55913. * It is used as the base class for both the specGloss and metalRough conventions.
  55914. */
  55915. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  55916. /**
  55917. * Number of Simultaneous lights allowed on the material.
  55918. */
  55919. maxSimultaneousLights: number;
  55920. /**
  55921. * If sets to true, disables all the lights affecting the material.
  55922. */
  55923. disableLighting: boolean;
  55924. /**
  55925. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  55926. */
  55927. environmentTexture: BaseTexture;
  55928. /**
  55929. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  55930. */
  55931. invertNormalMapX: boolean;
  55932. /**
  55933. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  55934. */
  55935. invertNormalMapY: boolean;
  55936. /**
  55937. * Normal map used in the model.
  55938. */
  55939. normalTexture: BaseTexture;
  55940. /**
  55941. * Emissivie color used to self-illuminate the model.
  55942. */
  55943. emissiveColor: Color3;
  55944. /**
  55945. * Emissivie texture used to self-illuminate the model.
  55946. */
  55947. emissiveTexture: BaseTexture;
  55948. /**
  55949. * Occlusion Channel Strenght.
  55950. */
  55951. occlusionStrength: number;
  55952. /**
  55953. * Occlusion Texture of the material (adding extra occlusion effects).
  55954. */
  55955. occlusionTexture: BaseTexture;
  55956. /**
  55957. * Defines the alpha limits in alpha test mode.
  55958. */
  55959. alphaCutOff: number;
  55960. /**
  55961. * Gets the current double sided mode.
  55962. */
  55963. get doubleSided(): boolean;
  55964. /**
  55965. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55966. */
  55967. set doubleSided(value: boolean);
  55968. /**
  55969. * Stores the pre-calculated light information of a mesh in a texture.
  55970. */
  55971. lightmapTexture: BaseTexture;
  55972. /**
  55973. * If true, the light map contains occlusion information instead of lighting info.
  55974. */
  55975. useLightmapAsShadowmap: boolean;
  55976. /**
  55977. * Instantiates a new PBRMaterial instance.
  55978. *
  55979. * @param name The material name
  55980. * @param scene The scene the material will be use in.
  55981. */
  55982. constructor(name: string, scene: Scene);
  55983. getClassName(): string;
  55984. }
  55985. }
  55986. declare module BABYLON {
  55987. /**
  55988. * The PBR material of BJS following the metal roughness convention.
  55989. *
  55990. * This fits to the PBR convention in the GLTF definition:
  55991. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  55992. */
  55993. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  55994. /**
  55995. * The base color has two different interpretations depending on the value of metalness.
  55996. * When the material is a metal, the base color is the specific measured reflectance value
  55997. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  55998. * of the material.
  55999. */
  56000. baseColor: Color3;
  56001. /**
  56002. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  56003. * well as opacity information in the alpha channel.
  56004. */
  56005. baseTexture: BaseTexture;
  56006. /**
  56007. * Specifies the metallic scalar value of the material.
  56008. * Can also be used to scale the metalness values of the metallic texture.
  56009. */
  56010. metallic: number;
  56011. /**
  56012. * Specifies the roughness scalar value of the material.
  56013. * Can also be used to scale the roughness values of the metallic texture.
  56014. */
  56015. roughness: number;
  56016. /**
  56017. * Texture containing both the metallic value in the B channel and the
  56018. * roughness value in the G channel to keep better precision.
  56019. */
  56020. metallicRoughnessTexture: BaseTexture;
  56021. /**
  56022. * Instantiates a new PBRMetalRoughnessMaterial instance.
  56023. *
  56024. * @param name The material name
  56025. * @param scene The scene the material will be use in.
  56026. */
  56027. constructor(name: string, scene: Scene);
  56028. /**
  56029. * Return the currrent class name of the material.
  56030. */
  56031. getClassName(): string;
  56032. /**
  56033. * Makes a duplicate of the current material.
  56034. * @param name - name to use for the new material.
  56035. */
  56036. clone(name: string): PBRMetallicRoughnessMaterial;
  56037. /**
  56038. * Serialize the material to a parsable JSON object.
  56039. */
  56040. serialize(): any;
  56041. /**
  56042. * Parses a JSON object correponding to the serialize function.
  56043. */
  56044. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  56045. }
  56046. }
  56047. declare module BABYLON {
  56048. /**
  56049. * The PBR material of BJS following the specular glossiness convention.
  56050. *
  56051. * This fits to the PBR convention in the GLTF definition:
  56052. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  56053. */
  56054. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  56055. /**
  56056. * Specifies the diffuse color of the material.
  56057. */
  56058. diffuseColor: Color3;
  56059. /**
  56060. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  56061. * channel.
  56062. */
  56063. diffuseTexture: BaseTexture;
  56064. /**
  56065. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  56066. */
  56067. specularColor: Color3;
  56068. /**
  56069. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  56070. */
  56071. glossiness: number;
  56072. /**
  56073. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  56074. */
  56075. specularGlossinessTexture: BaseTexture;
  56076. /**
  56077. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  56078. *
  56079. * @param name The material name
  56080. * @param scene The scene the material will be use in.
  56081. */
  56082. constructor(name: string, scene: Scene);
  56083. /**
  56084. * Return the currrent class name of the material.
  56085. */
  56086. getClassName(): string;
  56087. /**
  56088. * Makes a duplicate of the current material.
  56089. * @param name - name to use for the new material.
  56090. */
  56091. clone(name: string): PBRSpecularGlossinessMaterial;
  56092. /**
  56093. * Serialize the material to a parsable JSON object.
  56094. */
  56095. serialize(): any;
  56096. /**
  56097. * Parses a JSON object correponding to the serialize function.
  56098. */
  56099. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  56100. }
  56101. }
  56102. declare module BABYLON {
  56103. /**
  56104. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  56105. * It can help converting any input color in a desired output one. This can then be used to create effects
  56106. * from sepia, black and white to sixties or futuristic rendering...
  56107. *
  56108. * The only supported format is currently 3dl.
  56109. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  56110. */
  56111. export class ColorGradingTexture extends BaseTexture {
  56112. /**
  56113. * The current texture matrix. (will always be identity in color grading texture)
  56114. */
  56115. private _textureMatrix;
  56116. /**
  56117. * The texture URL.
  56118. */
  56119. url: string;
  56120. /**
  56121. * Empty line regex stored for GC.
  56122. */
  56123. private static _noneEmptyLineRegex;
  56124. private _engine;
  56125. /**
  56126. * Instantiates a ColorGradingTexture from the following parameters.
  56127. *
  56128. * @param url The location of the color gradind data (currently only supporting 3dl)
  56129. * @param scene The scene the texture will be used in
  56130. */
  56131. constructor(url: string, scene: Scene);
  56132. /**
  56133. * Returns the texture matrix used in most of the material.
  56134. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  56135. */
  56136. getTextureMatrix(): Matrix;
  56137. /**
  56138. * Occurs when the file being loaded is a .3dl LUT file.
  56139. */
  56140. private load3dlTexture;
  56141. /**
  56142. * Starts the loading process of the texture.
  56143. */
  56144. private loadTexture;
  56145. /**
  56146. * Clones the color gradind texture.
  56147. */
  56148. clone(): ColorGradingTexture;
  56149. /**
  56150. * Called during delayed load for textures.
  56151. */
  56152. delayLoad(): void;
  56153. /**
  56154. * Parses a color grading texture serialized by Babylon.
  56155. * @param parsedTexture The texture information being parsedTexture
  56156. * @param scene The scene to load the texture in
  56157. * @param rootUrl The root url of the data assets to load
  56158. * @return A color gradind texture
  56159. */
  56160. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  56161. /**
  56162. * Serializes the LUT texture to json format.
  56163. */
  56164. serialize(): any;
  56165. }
  56166. }
  56167. declare module BABYLON {
  56168. /**
  56169. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  56170. */
  56171. export class EquiRectangularCubeTexture extends BaseTexture {
  56172. /** The six faces of the cube. */
  56173. private static _FacesMapping;
  56174. private _noMipmap;
  56175. private _onLoad;
  56176. private _onError;
  56177. /** The size of the cubemap. */
  56178. private _size;
  56179. /** The buffer of the image. */
  56180. private _buffer;
  56181. /** The width of the input image. */
  56182. private _width;
  56183. /** The height of the input image. */
  56184. private _height;
  56185. /** The URL to the image. */
  56186. url: string;
  56187. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  56188. coordinatesMode: number;
  56189. /**
  56190. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  56191. * @param url The location of the image
  56192. * @param scene The scene the texture will be used in
  56193. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  56194. * @param noMipmap Forces to not generate the mipmap if true
  56195. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  56196. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  56197. * @param onLoad — defines a callback called when texture is loaded
  56198. * @param onError — defines a callback called if there is an error
  56199. */
  56200. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  56201. /**
  56202. * Load the image data, by putting the image on a canvas and extracting its buffer.
  56203. */
  56204. private loadImage;
  56205. /**
  56206. * Convert the image buffer into a cubemap and create a CubeTexture.
  56207. */
  56208. private loadTexture;
  56209. /**
  56210. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  56211. * @param buffer The ArrayBuffer that should be converted.
  56212. * @returns The buffer as Float32Array.
  56213. */
  56214. private getFloat32ArrayFromArrayBuffer;
  56215. /**
  56216. * Get the current class name of the texture useful for serialization or dynamic coding.
  56217. * @returns "EquiRectangularCubeTexture"
  56218. */
  56219. getClassName(): string;
  56220. /**
  56221. * Create a clone of the current EquiRectangularCubeTexture and return it.
  56222. * @returns A clone of the current EquiRectangularCubeTexture.
  56223. */
  56224. clone(): EquiRectangularCubeTexture;
  56225. }
  56226. }
  56227. declare module BABYLON {
  56228. /**
  56229. * Based on jsTGALoader - Javascript loader for TGA file
  56230. * By Vincent Thibault
  56231. * @see http://blog.robrowser.com/javascript-tga-loader.html
  56232. */
  56233. export class TGATools {
  56234. private static _TYPE_INDEXED;
  56235. private static _TYPE_RGB;
  56236. private static _TYPE_GREY;
  56237. private static _TYPE_RLE_INDEXED;
  56238. private static _TYPE_RLE_RGB;
  56239. private static _TYPE_RLE_GREY;
  56240. private static _ORIGIN_MASK;
  56241. private static _ORIGIN_SHIFT;
  56242. private static _ORIGIN_BL;
  56243. private static _ORIGIN_BR;
  56244. private static _ORIGIN_UL;
  56245. private static _ORIGIN_UR;
  56246. /**
  56247. * Gets the header of a TGA file
  56248. * @param data defines the TGA data
  56249. * @returns the header
  56250. */
  56251. static GetTGAHeader(data: Uint8Array): any;
  56252. /**
  56253. * Uploads TGA content to a Babylon Texture
  56254. * @hidden
  56255. */
  56256. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  56257. /** @hidden */
  56258. 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;
  56259. /** @hidden */
  56260. 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;
  56261. /** @hidden */
  56262. 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;
  56263. /** @hidden */
  56264. 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;
  56265. /** @hidden */
  56266. 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;
  56267. /** @hidden */
  56268. 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;
  56269. }
  56270. }
  56271. declare module BABYLON {
  56272. /**
  56273. * Implementation of the TGA Texture Loader.
  56274. * @hidden
  56275. */
  56276. export class _TGATextureLoader implements IInternalTextureLoader {
  56277. /**
  56278. * Defines wether the loader supports cascade loading the different faces.
  56279. */
  56280. readonly supportCascades: boolean;
  56281. /**
  56282. * This returns if the loader support the current file information.
  56283. * @param extension defines the file extension of the file being loaded
  56284. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56285. * @param fallback defines the fallback internal texture if any
  56286. * @param isBase64 defines whether the texture is encoded as a base64
  56287. * @param isBuffer defines whether the texture data are stored as a buffer
  56288. * @returns true if the loader can load the specified file
  56289. */
  56290. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  56291. /**
  56292. * Transform the url before loading if required.
  56293. * @param rootUrl the url of the texture
  56294. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56295. * @returns the transformed texture
  56296. */
  56297. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  56298. /**
  56299. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  56300. * @param rootUrl the url of the texture
  56301. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56302. * @returns the fallback texture
  56303. */
  56304. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  56305. /**
  56306. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  56307. * @param data contains the texture data
  56308. * @param texture defines the BabylonJS internal texture
  56309. * @param createPolynomials will be true if polynomials have been requested
  56310. * @param onLoad defines the callback to trigger once the texture is ready
  56311. * @param onError defines the callback to trigger in case of error
  56312. */
  56313. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56314. /**
  56315. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  56316. * @param data contains the texture data
  56317. * @param texture defines the BabylonJS internal texture
  56318. * @param callback defines the method to call once ready to upload
  56319. */
  56320. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56321. }
  56322. }
  56323. declare module BABYLON {
  56324. /**
  56325. * Info about the .basis files
  56326. */
  56327. class BasisFileInfo {
  56328. /**
  56329. * If the file has alpha
  56330. */
  56331. hasAlpha: boolean;
  56332. /**
  56333. * Info about each image of the basis file
  56334. */
  56335. images: Array<{
  56336. levels: Array<{
  56337. width: number;
  56338. height: number;
  56339. transcodedPixels: ArrayBufferView;
  56340. }>;
  56341. }>;
  56342. }
  56343. /**
  56344. * Result of transcoding a basis file
  56345. */
  56346. class TranscodeResult {
  56347. /**
  56348. * Info about the .basis file
  56349. */
  56350. fileInfo: BasisFileInfo;
  56351. /**
  56352. * Format to use when loading the file
  56353. */
  56354. format: number;
  56355. }
  56356. /**
  56357. * Configuration options for the Basis transcoder
  56358. */
  56359. export class BasisTranscodeConfiguration {
  56360. /**
  56361. * Supported compression formats used to determine the supported output format of the transcoder
  56362. */
  56363. supportedCompressionFormats?: {
  56364. /**
  56365. * etc1 compression format
  56366. */
  56367. etc1?: boolean;
  56368. /**
  56369. * s3tc compression format
  56370. */
  56371. s3tc?: boolean;
  56372. /**
  56373. * pvrtc compression format
  56374. */
  56375. pvrtc?: boolean;
  56376. /**
  56377. * etc2 compression format
  56378. */
  56379. etc2?: boolean;
  56380. };
  56381. /**
  56382. * If mipmap levels should be loaded for transcoded images (Default: true)
  56383. */
  56384. loadMipmapLevels?: boolean;
  56385. /**
  56386. * Index of a single image to load (Default: all images)
  56387. */
  56388. loadSingleImage?: number;
  56389. }
  56390. /**
  56391. * Used to load .Basis files
  56392. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  56393. */
  56394. export class BasisTools {
  56395. private static _IgnoreSupportedFormats;
  56396. /**
  56397. * URL to use when loading the basis transcoder
  56398. */
  56399. static JSModuleURL: string;
  56400. /**
  56401. * URL to use when loading the wasm module for the transcoder
  56402. */
  56403. static WasmModuleURL: string;
  56404. /**
  56405. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  56406. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  56407. * @returns internal format corresponding to the Basis format
  56408. */
  56409. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  56410. private static _WorkerPromise;
  56411. private static _Worker;
  56412. private static _actionId;
  56413. private static _CreateWorkerAsync;
  56414. /**
  56415. * Transcodes a loaded image file to compressed pixel data
  56416. * @param imageData image data to transcode
  56417. * @param config configuration options for the transcoding
  56418. * @returns a promise resulting in the transcoded image
  56419. */
  56420. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  56421. /**
  56422. * Loads a texture from the transcode result
  56423. * @param texture texture load to
  56424. * @param transcodeResult the result of transcoding the basis file to load from
  56425. */
  56426. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  56427. }
  56428. }
  56429. declare module BABYLON {
  56430. /**
  56431. * Loader for .basis file format
  56432. */
  56433. export class _BasisTextureLoader implements IInternalTextureLoader {
  56434. /**
  56435. * Defines whether the loader supports cascade loading the different faces.
  56436. */
  56437. readonly supportCascades: boolean;
  56438. /**
  56439. * This returns if the loader support the current file information.
  56440. * @param extension defines the file extension of the file being loaded
  56441. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56442. * @param fallback defines the fallback internal texture if any
  56443. * @param isBase64 defines whether the texture is encoded as a base64
  56444. * @param isBuffer defines whether the texture data are stored as a buffer
  56445. * @returns true if the loader can load the specified file
  56446. */
  56447. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  56448. /**
  56449. * Transform the url before loading if required.
  56450. * @param rootUrl the url of the texture
  56451. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56452. * @returns the transformed texture
  56453. */
  56454. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  56455. /**
  56456. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  56457. * @param rootUrl the url of the texture
  56458. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56459. * @returns the fallback texture
  56460. */
  56461. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  56462. /**
  56463. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  56464. * @param data contains the texture data
  56465. * @param texture defines the BabylonJS internal texture
  56466. * @param createPolynomials will be true if polynomials have been requested
  56467. * @param onLoad defines the callback to trigger once the texture is ready
  56468. * @param onError defines the callback to trigger in case of error
  56469. */
  56470. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56471. /**
  56472. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  56473. * @param data contains the texture data
  56474. * @param texture defines the BabylonJS internal texture
  56475. * @param callback defines the method to call once ready to upload
  56476. */
  56477. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56478. }
  56479. }
  56480. declare module BABYLON {
  56481. /**
  56482. * 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.
  56483. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56484. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56485. */
  56486. export class CustomProceduralTexture extends ProceduralTexture {
  56487. private _animate;
  56488. private _time;
  56489. private _config;
  56490. private _texturePath;
  56491. /**
  56492. * Instantiates a new Custom Procedural Texture.
  56493. * 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.
  56494. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56495. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56496. * @param name Define the name of the texture
  56497. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  56498. * @param size Define the size of the texture to create
  56499. * @param scene Define the scene the texture belongs to
  56500. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  56501. * @param generateMipMaps Define if the texture should creates mip maps or not
  56502. */
  56503. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56504. private _loadJson;
  56505. /**
  56506. * Is the texture ready to be used ? (rendered at least once)
  56507. * @returns true if ready, otherwise, false.
  56508. */
  56509. isReady(): boolean;
  56510. /**
  56511. * Render the texture to its associated render target.
  56512. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  56513. */
  56514. render(useCameraPostProcess?: boolean): void;
  56515. /**
  56516. * Update the list of dependant textures samplers in the shader.
  56517. */
  56518. updateTextures(): void;
  56519. /**
  56520. * Update the uniform values of the procedural texture in the shader.
  56521. */
  56522. updateShaderUniforms(): void;
  56523. /**
  56524. * Define if the texture animates or not.
  56525. */
  56526. get animate(): boolean;
  56527. set animate(value: boolean);
  56528. }
  56529. }
  56530. declare module BABYLON {
  56531. /** @hidden */
  56532. export var noisePixelShader: {
  56533. name: string;
  56534. shader: string;
  56535. };
  56536. }
  56537. declare module BABYLON {
  56538. /**
  56539. * Class used to generate noise procedural textures
  56540. */
  56541. export class NoiseProceduralTexture extends ProceduralTexture {
  56542. private _time;
  56543. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  56544. brightness: number;
  56545. /** Defines the number of octaves to process */
  56546. octaves: number;
  56547. /** Defines the level of persistence (0.8 by default) */
  56548. persistence: number;
  56549. /** Gets or sets animation speed factor (default is 1) */
  56550. animationSpeedFactor: number;
  56551. /**
  56552. * Creates a new NoiseProceduralTexture
  56553. * @param name defines the name fo the texture
  56554. * @param size defines the size of the texture (default is 256)
  56555. * @param scene defines the hosting scene
  56556. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  56557. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  56558. */
  56559. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56560. private _updateShaderUniforms;
  56561. protected _getDefines(): string;
  56562. /** Generate the current state of the procedural texture */
  56563. render(useCameraPostProcess?: boolean): void;
  56564. /**
  56565. * Serializes this noise procedural texture
  56566. * @returns a serialized noise procedural texture object
  56567. */
  56568. serialize(): any;
  56569. /**
  56570. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  56571. * @param parsedTexture defines parsed texture data
  56572. * @param scene defines the current scene
  56573. * @param rootUrl defines the root URL containing noise procedural texture information
  56574. * @returns a parsed NoiseProceduralTexture
  56575. */
  56576. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  56577. }
  56578. }
  56579. declare module BABYLON {
  56580. /**
  56581. * Raw cube texture where the raw buffers are passed in
  56582. */
  56583. export class RawCubeTexture extends CubeTexture {
  56584. /**
  56585. * Creates a cube texture where the raw buffers are passed in.
  56586. * @param scene defines the scene the texture is attached to
  56587. * @param data defines the array of data to use to create each face
  56588. * @param size defines the size of the textures
  56589. * @param format defines the format of the data
  56590. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  56591. * @param generateMipMaps defines if the engine should generate the mip levels
  56592. * @param invertY defines if data must be stored with Y axis inverted
  56593. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  56594. * @param compression defines the compression used (null by default)
  56595. */
  56596. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  56597. /**
  56598. * Updates the raw cube texture.
  56599. * @param data defines the data to store
  56600. * @param format defines the data format
  56601. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  56602. * @param invertY defines if data must be stored with Y axis inverted
  56603. * @param compression defines the compression used (null by default)
  56604. * @param level defines which level of the texture to update
  56605. */
  56606. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  56607. /**
  56608. * Updates a raw cube texture with RGBD encoded data.
  56609. * @param data defines the array of data [mipmap][face] to use to create each face
  56610. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  56611. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  56612. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  56613. * @returns a promsie that resolves when the operation is complete
  56614. */
  56615. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  56616. /**
  56617. * Clones the raw cube texture.
  56618. * @return a new cube texture
  56619. */
  56620. clone(): CubeTexture;
  56621. /** @hidden */
  56622. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  56623. }
  56624. }
  56625. declare module BABYLON {
  56626. /**
  56627. * Class used to store 3D textures containing user data
  56628. */
  56629. export class RawTexture3D extends Texture {
  56630. /** Gets or sets the texture format to use */
  56631. format: number;
  56632. private _engine;
  56633. /**
  56634. * Create a new RawTexture3D
  56635. * @param data defines the data of the texture
  56636. * @param width defines the width of the texture
  56637. * @param height defines the height of the texture
  56638. * @param depth defines the depth of the texture
  56639. * @param format defines the texture format to use
  56640. * @param scene defines the hosting scene
  56641. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56642. * @param invertY defines if texture must be stored with Y axis inverted
  56643. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56644. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56645. */
  56646. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56647. /** Gets or sets the texture format to use */
  56648. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56649. /**
  56650. * Update the texture with new data
  56651. * @param data defines the data to store in the texture
  56652. */
  56653. update(data: ArrayBufferView): void;
  56654. }
  56655. }
  56656. declare module BABYLON {
  56657. /**
  56658. * Class used to store 2D array textures containing user data
  56659. */
  56660. export class RawTexture2DArray extends Texture {
  56661. /** Gets or sets the texture format to use */
  56662. format: number;
  56663. private _engine;
  56664. /**
  56665. * Create a new RawTexture2DArray
  56666. * @param data defines the data of the texture
  56667. * @param width defines the width of the texture
  56668. * @param height defines the height of the texture
  56669. * @param depth defines the number of layers of the texture
  56670. * @param format defines the texture format to use
  56671. * @param scene defines the hosting scene
  56672. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56673. * @param invertY defines if texture must be stored with Y axis inverted
  56674. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56675. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56676. */
  56677. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56678. /** Gets or sets the texture format to use */
  56679. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56680. /**
  56681. * Update the texture with new data
  56682. * @param data defines the data to store in the texture
  56683. */
  56684. update(data: ArrayBufferView): void;
  56685. }
  56686. }
  56687. declare module BABYLON {
  56688. /**
  56689. * Creates a refraction texture used by refraction channel of the standard material.
  56690. * It is like a mirror but to see through a material.
  56691. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56692. */
  56693. export class RefractionTexture extends RenderTargetTexture {
  56694. /**
  56695. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  56696. * 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.
  56697. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56698. */
  56699. refractionPlane: Plane;
  56700. /**
  56701. * Define how deep under the surface we should see.
  56702. */
  56703. depth: number;
  56704. /**
  56705. * Creates a refraction texture used by refraction channel of the standard material.
  56706. * It is like a mirror but to see through a material.
  56707. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56708. * @param name Define the texture name
  56709. * @param size Define the size of the underlying texture
  56710. * @param scene Define the scene the refraction belongs to
  56711. * @param generateMipMaps Define if we need to generate mips level for the refraction
  56712. */
  56713. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  56714. /**
  56715. * Clone the refraction texture.
  56716. * @returns the cloned texture
  56717. */
  56718. clone(): RefractionTexture;
  56719. /**
  56720. * Serialize the texture to a JSON representation you could use in Parse later on
  56721. * @returns the serialized JSON representation
  56722. */
  56723. serialize(): any;
  56724. }
  56725. }
  56726. declare module BABYLON {
  56727. /**
  56728. * Defines the options related to the creation of an HtmlElementTexture
  56729. */
  56730. export interface IHtmlElementTextureOptions {
  56731. /**
  56732. * Defines wether mip maps should be created or not.
  56733. */
  56734. generateMipMaps?: boolean;
  56735. /**
  56736. * Defines the sampling mode of the texture.
  56737. */
  56738. samplingMode?: number;
  56739. /**
  56740. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  56741. */
  56742. engine: Nullable<ThinEngine>;
  56743. /**
  56744. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  56745. */
  56746. scene: Nullable<Scene>;
  56747. }
  56748. /**
  56749. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  56750. * To be as efficient as possible depending on your constraints nothing aside the first upload
  56751. * is automatically managed.
  56752. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  56753. * in your application.
  56754. *
  56755. * As the update is not automatic, you need to call them manually.
  56756. */
  56757. export class HtmlElementTexture extends BaseTexture {
  56758. /**
  56759. * The texture URL.
  56760. */
  56761. element: HTMLVideoElement | HTMLCanvasElement;
  56762. private static readonly DefaultOptions;
  56763. private _textureMatrix;
  56764. private _engine;
  56765. private _isVideo;
  56766. private _generateMipMaps;
  56767. private _samplingMode;
  56768. /**
  56769. * Instantiates a HtmlElementTexture from the following parameters.
  56770. *
  56771. * @param name Defines the name of the texture
  56772. * @param element Defines the video or canvas the texture is filled with
  56773. * @param options Defines the other none mandatory texture creation options
  56774. */
  56775. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  56776. private _createInternalTexture;
  56777. /**
  56778. * Returns the texture matrix used in most of the material.
  56779. */
  56780. getTextureMatrix(): Matrix;
  56781. /**
  56782. * Updates the content of the texture.
  56783. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  56784. */
  56785. update(invertY?: Nullable<boolean>): void;
  56786. }
  56787. }
  56788. declare module BABYLON {
  56789. /**
  56790. * Enum used to define the target of a block
  56791. */
  56792. export enum NodeMaterialBlockTargets {
  56793. /** Vertex shader */
  56794. Vertex = 1,
  56795. /** Fragment shader */
  56796. Fragment = 2,
  56797. /** Neutral */
  56798. Neutral = 4,
  56799. /** Vertex and Fragment */
  56800. VertexAndFragment = 3
  56801. }
  56802. }
  56803. declare module BABYLON {
  56804. /**
  56805. * Defines the kind of connection point for node based material
  56806. */
  56807. export enum NodeMaterialBlockConnectionPointTypes {
  56808. /** Float */
  56809. Float = 1,
  56810. /** Int */
  56811. Int = 2,
  56812. /** Vector2 */
  56813. Vector2 = 4,
  56814. /** Vector3 */
  56815. Vector3 = 8,
  56816. /** Vector4 */
  56817. Vector4 = 16,
  56818. /** Color3 */
  56819. Color3 = 32,
  56820. /** Color4 */
  56821. Color4 = 64,
  56822. /** Matrix */
  56823. Matrix = 128,
  56824. /** Detect type based on connection */
  56825. AutoDetect = 1024,
  56826. /** Output type that will be defined by input type */
  56827. BasedOnInput = 2048
  56828. }
  56829. }
  56830. declare module BABYLON {
  56831. /**
  56832. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  56833. */
  56834. export enum NodeMaterialBlockConnectionPointMode {
  56835. /** Value is an uniform */
  56836. Uniform = 0,
  56837. /** Value is a mesh attribute */
  56838. Attribute = 1,
  56839. /** Value is a varying between vertex and fragment shaders */
  56840. Varying = 2,
  56841. /** Mode is undefined */
  56842. Undefined = 3
  56843. }
  56844. }
  56845. declare module BABYLON {
  56846. /**
  56847. * Enum used to define system values e.g. values automatically provided by the system
  56848. */
  56849. export enum NodeMaterialSystemValues {
  56850. /** World */
  56851. World = 1,
  56852. /** View */
  56853. View = 2,
  56854. /** Projection */
  56855. Projection = 3,
  56856. /** ViewProjection */
  56857. ViewProjection = 4,
  56858. /** WorldView */
  56859. WorldView = 5,
  56860. /** WorldViewProjection */
  56861. WorldViewProjection = 6,
  56862. /** CameraPosition */
  56863. CameraPosition = 7,
  56864. /** Fog Color */
  56865. FogColor = 8,
  56866. /** Delta time */
  56867. DeltaTime = 9
  56868. }
  56869. }
  56870. declare module BABYLON {
  56871. /**
  56872. * Root class for all node material optimizers
  56873. */
  56874. export class NodeMaterialOptimizer {
  56875. /**
  56876. * Function used to optimize a NodeMaterial graph
  56877. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  56878. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  56879. */
  56880. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  56881. }
  56882. }
  56883. declare module BABYLON {
  56884. /**
  56885. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  56886. */
  56887. export class TransformBlock extends NodeMaterialBlock {
  56888. /**
  56889. * Defines the value to use to complement W value to transform it to a Vector4
  56890. */
  56891. complementW: number;
  56892. /**
  56893. * Defines the value to use to complement z value to transform it to a Vector4
  56894. */
  56895. complementZ: number;
  56896. /**
  56897. * Creates a new TransformBlock
  56898. * @param name defines the block name
  56899. */
  56900. constructor(name: string);
  56901. /**
  56902. * Gets the current class name
  56903. * @returns the class name
  56904. */
  56905. getClassName(): string;
  56906. /**
  56907. * Gets the vector input
  56908. */
  56909. get vector(): NodeMaterialConnectionPoint;
  56910. /**
  56911. * Gets the output component
  56912. */
  56913. get output(): NodeMaterialConnectionPoint;
  56914. /**
  56915. * Gets the matrix transform input
  56916. */
  56917. get transform(): NodeMaterialConnectionPoint;
  56918. protected _buildBlock(state: NodeMaterialBuildState): this;
  56919. serialize(): any;
  56920. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56921. protected _dumpPropertiesCode(): string;
  56922. }
  56923. }
  56924. declare module BABYLON {
  56925. /**
  56926. * Block used to output the vertex position
  56927. */
  56928. export class VertexOutputBlock extends NodeMaterialBlock {
  56929. /**
  56930. * Creates a new VertexOutputBlock
  56931. * @param name defines the block name
  56932. */
  56933. constructor(name: string);
  56934. /**
  56935. * Gets the current class name
  56936. * @returns the class name
  56937. */
  56938. getClassName(): string;
  56939. /**
  56940. * Gets the vector input component
  56941. */
  56942. get vector(): NodeMaterialConnectionPoint;
  56943. protected _buildBlock(state: NodeMaterialBuildState): this;
  56944. }
  56945. }
  56946. declare module BABYLON {
  56947. /**
  56948. * Block used to output the final color
  56949. */
  56950. export class FragmentOutputBlock extends NodeMaterialBlock {
  56951. /**
  56952. * Create a new FragmentOutputBlock
  56953. * @param name defines the block name
  56954. */
  56955. constructor(name: string);
  56956. /**
  56957. * Gets the current class name
  56958. * @returns the class name
  56959. */
  56960. getClassName(): string;
  56961. /**
  56962. * Gets the rgba input component
  56963. */
  56964. get rgba(): NodeMaterialConnectionPoint;
  56965. /**
  56966. * Gets the rgb input component
  56967. */
  56968. get rgb(): NodeMaterialConnectionPoint;
  56969. /**
  56970. * Gets the a input component
  56971. */
  56972. get a(): NodeMaterialConnectionPoint;
  56973. protected _buildBlock(state: NodeMaterialBuildState): this;
  56974. }
  56975. }
  56976. declare module BABYLON {
  56977. /**
  56978. * Block used to read a reflection texture from a sampler
  56979. */
  56980. export class ReflectionTextureBlock extends NodeMaterialBlock {
  56981. private _define3DName;
  56982. private _defineCubicName;
  56983. private _defineExplicitName;
  56984. private _defineProjectionName;
  56985. private _defineLocalCubicName;
  56986. private _defineSphericalName;
  56987. private _definePlanarName;
  56988. private _defineEquirectangularName;
  56989. private _defineMirroredEquirectangularFixedName;
  56990. private _defineEquirectangularFixedName;
  56991. private _defineSkyboxName;
  56992. private _cubeSamplerName;
  56993. private _2DSamplerName;
  56994. private _positionUVWName;
  56995. private _directionWName;
  56996. private _reflectionCoordsName;
  56997. private _reflection2DCoordsName;
  56998. private _reflectionColorName;
  56999. private _reflectionMatrixName;
  57000. /**
  57001. * Gets or sets the texture associated with the node
  57002. */
  57003. texture: Nullable<BaseTexture>;
  57004. /**
  57005. * Create a new TextureBlock
  57006. * @param name defines the block name
  57007. */
  57008. constructor(name: string);
  57009. /**
  57010. * Gets the current class name
  57011. * @returns the class name
  57012. */
  57013. getClassName(): string;
  57014. /**
  57015. * Gets the world position input component
  57016. */
  57017. get position(): NodeMaterialConnectionPoint;
  57018. /**
  57019. * Gets the world position input component
  57020. */
  57021. get worldPosition(): NodeMaterialConnectionPoint;
  57022. /**
  57023. * Gets the world normal input component
  57024. */
  57025. get worldNormal(): NodeMaterialConnectionPoint;
  57026. /**
  57027. * Gets the world input component
  57028. */
  57029. get world(): NodeMaterialConnectionPoint;
  57030. /**
  57031. * Gets the camera (or eye) position component
  57032. */
  57033. get cameraPosition(): NodeMaterialConnectionPoint;
  57034. /**
  57035. * Gets the view input component
  57036. */
  57037. get view(): NodeMaterialConnectionPoint;
  57038. /**
  57039. * Gets the rgb output component
  57040. */
  57041. get rgb(): NodeMaterialConnectionPoint;
  57042. /**
  57043. * Gets the r output component
  57044. */
  57045. get r(): NodeMaterialConnectionPoint;
  57046. /**
  57047. * Gets the g output component
  57048. */
  57049. get g(): NodeMaterialConnectionPoint;
  57050. /**
  57051. * Gets the b output component
  57052. */
  57053. get b(): NodeMaterialConnectionPoint;
  57054. autoConfigure(material: NodeMaterial): void;
  57055. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57056. isReady(): boolean;
  57057. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57058. private _injectVertexCode;
  57059. private _writeOutput;
  57060. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57061. protected _dumpPropertiesCode(): string;
  57062. serialize(): any;
  57063. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57064. }
  57065. }
  57066. declare module BABYLON {
  57067. /**
  57068. * Interface used to configure the node material editor
  57069. */
  57070. export interface INodeMaterialEditorOptions {
  57071. /** Define the URl to load node editor script */
  57072. editorURL?: string;
  57073. }
  57074. /** @hidden */
  57075. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  57076. /** BONES */
  57077. NUM_BONE_INFLUENCERS: number;
  57078. BonesPerMesh: number;
  57079. BONETEXTURE: boolean;
  57080. /** MORPH TARGETS */
  57081. MORPHTARGETS: boolean;
  57082. MORPHTARGETS_NORMAL: boolean;
  57083. MORPHTARGETS_TANGENT: boolean;
  57084. MORPHTARGETS_UV: boolean;
  57085. NUM_MORPH_INFLUENCERS: number;
  57086. /** IMAGE PROCESSING */
  57087. IMAGEPROCESSING: boolean;
  57088. VIGNETTE: boolean;
  57089. VIGNETTEBLENDMODEMULTIPLY: boolean;
  57090. VIGNETTEBLENDMODEOPAQUE: boolean;
  57091. TONEMAPPING: boolean;
  57092. TONEMAPPING_ACES: boolean;
  57093. CONTRAST: boolean;
  57094. EXPOSURE: boolean;
  57095. COLORCURVES: boolean;
  57096. COLORGRADING: boolean;
  57097. COLORGRADING3D: boolean;
  57098. SAMPLER3DGREENDEPTH: boolean;
  57099. SAMPLER3DBGRMAP: boolean;
  57100. IMAGEPROCESSINGPOSTPROCESS: boolean;
  57101. /** MISC. */
  57102. BUMPDIRECTUV: number;
  57103. constructor();
  57104. setValue(name: string, value: boolean): void;
  57105. }
  57106. /**
  57107. * Class used to configure NodeMaterial
  57108. */
  57109. export interface INodeMaterialOptions {
  57110. /**
  57111. * Defines if blocks should emit comments
  57112. */
  57113. emitComments: boolean;
  57114. }
  57115. /**
  57116. * Class used to create a node based material built by assembling shader blocks
  57117. */
  57118. export class NodeMaterial extends PushMaterial {
  57119. private static _BuildIdGenerator;
  57120. private _options;
  57121. private _vertexCompilationState;
  57122. private _fragmentCompilationState;
  57123. private _sharedData;
  57124. private _buildId;
  57125. private _buildWasSuccessful;
  57126. private _cachedWorldViewMatrix;
  57127. private _cachedWorldViewProjectionMatrix;
  57128. private _optimizers;
  57129. private _animationFrame;
  57130. /** Define the URl to load node editor script */
  57131. static EditorURL: string;
  57132. private BJSNODEMATERIALEDITOR;
  57133. /** Get the inspector from bundle or global */
  57134. private _getGlobalNodeMaterialEditor;
  57135. /**
  57136. * Gets or sets data used by visual editor
  57137. * @see https://nme.babylonjs.com
  57138. */
  57139. editorData: any;
  57140. /**
  57141. * 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)
  57142. */
  57143. ignoreAlpha: boolean;
  57144. /**
  57145. * Defines the maximum number of lights that can be used in the material
  57146. */
  57147. maxSimultaneousLights: number;
  57148. /**
  57149. * Observable raised when the material is built
  57150. */
  57151. onBuildObservable: Observable<NodeMaterial>;
  57152. /**
  57153. * Gets or sets the root nodes of the material vertex shader
  57154. */
  57155. _vertexOutputNodes: NodeMaterialBlock[];
  57156. /**
  57157. * Gets or sets the root nodes of the material fragment (pixel) shader
  57158. */
  57159. _fragmentOutputNodes: NodeMaterialBlock[];
  57160. /** Gets or sets options to control the node material overall behavior */
  57161. get options(): INodeMaterialOptions;
  57162. set options(options: INodeMaterialOptions);
  57163. /**
  57164. * Default configuration related to image processing available in the standard Material.
  57165. */
  57166. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57167. /**
  57168. * Gets the image processing configuration used either in this material.
  57169. */
  57170. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  57171. /**
  57172. * Sets the Default image processing configuration used either in the this material.
  57173. *
  57174. * If sets to null, the scene one is in use.
  57175. */
  57176. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  57177. /**
  57178. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  57179. */
  57180. attachedBlocks: NodeMaterialBlock[];
  57181. /**
  57182. * Create a new node based material
  57183. * @param name defines the material name
  57184. * @param scene defines the hosting scene
  57185. * @param options defines creation option
  57186. */
  57187. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  57188. /**
  57189. * Gets the current class name of the material e.g. "NodeMaterial"
  57190. * @returns the class name
  57191. */
  57192. getClassName(): string;
  57193. /**
  57194. * Keep track of the image processing observer to allow dispose and replace.
  57195. */
  57196. private _imageProcessingObserver;
  57197. /**
  57198. * Attaches a new image processing configuration to the Standard Material.
  57199. * @param configuration
  57200. */
  57201. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57202. /**
  57203. * Get a block by its name
  57204. * @param name defines the name of the block to retrieve
  57205. * @returns the required block or null if not found
  57206. */
  57207. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  57208. /**
  57209. * Get a block by its name
  57210. * @param predicate defines the predicate used to find the good candidate
  57211. * @returns the required block or null if not found
  57212. */
  57213. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  57214. /**
  57215. * Get an input block by its name
  57216. * @param predicate defines the predicate used to find the good candidate
  57217. * @returns the required input block or null if not found
  57218. */
  57219. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  57220. /**
  57221. * Gets the list of input blocks attached to this material
  57222. * @returns an array of InputBlocks
  57223. */
  57224. getInputBlocks(): InputBlock[];
  57225. /**
  57226. * Adds a new optimizer to the list of optimizers
  57227. * @param optimizer defines the optimizers to add
  57228. * @returns the current material
  57229. */
  57230. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57231. /**
  57232. * Remove an optimizer from the list of optimizers
  57233. * @param optimizer defines the optimizers to remove
  57234. * @returns the current material
  57235. */
  57236. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57237. /**
  57238. * Add a new block to the list of output nodes
  57239. * @param node defines the node to add
  57240. * @returns the current material
  57241. */
  57242. addOutputNode(node: NodeMaterialBlock): this;
  57243. /**
  57244. * Remove a block from the list of root nodes
  57245. * @param node defines the node to remove
  57246. * @returns the current material
  57247. */
  57248. removeOutputNode(node: NodeMaterialBlock): this;
  57249. private _addVertexOutputNode;
  57250. private _removeVertexOutputNode;
  57251. private _addFragmentOutputNode;
  57252. private _removeFragmentOutputNode;
  57253. /**
  57254. * Specifies if the material will require alpha blending
  57255. * @returns a boolean specifying if alpha blending is needed
  57256. */
  57257. needAlphaBlending(): boolean;
  57258. /**
  57259. * Specifies if this material should be rendered in alpha test mode
  57260. * @returns a boolean specifying if an alpha test is needed.
  57261. */
  57262. needAlphaTesting(): boolean;
  57263. private _initializeBlock;
  57264. private _resetDualBlocks;
  57265. /**
  57266. * Remove a block from the current node material
  57267. * @param block defines the block to remove
  57268. */
  57269. removeBlock(block: NodeMaterialBlock): void;
  57270. /**
  57271. * Build the material and generates the inner effect
  57272. * @param verbose defines if the build should log activity
  57273. */
  57274. build(verbose?: boolean): void;
  57275. /**
  57276. * Runs an otpimization phase to try to improve the shader code
  57277. */
  57278. optimize(): void;
  57279. private _prepareDefinesForAttributes;
  57280. /**
  57281. * Get if the submesh is ready to be used and all its information available.
  57282. * Child classes can use it to update shaders
  57283. * @param mesh defines the mesh to check
  57284. * @param subMesh defines which submesh to check
  57285. * @param useInstances specifies that instances should be used
  57286. * @returns a boolean indicating that the submesh is ready or not
  57287. */
  57288. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57289. /**
  57290. * Get a string representing the shaders built by the current node graph
  57291. */
  57292. get compiledShaders(): string;
  57293. /**
  57294. * Binds the world matrix to the material
  57295. * @param world defines the world transformation matrix
  57296. */
  57297. bindOnlyWorldMatrix(world: Matrix): void;
  57298. /**
  57299. * Binds the submesh to this material by preparing the effect and shader to draw
  57300. * @param world defines the world transformation matrix
  57301. * @param mesh defines the mesh containing the submesh
  57302. * @param subMesh defines the submesh to bind the material to
  57303. */
  57304. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57305. /**
  57306. * Gets the active textures from the material
  57307. * @returns an array of textures
  57308. */
  57309. getActiveTextures(): BaseTexture[];
  57310. /**
  57311. * Gets the list of texture blocks
  57312. * @returns an array of texture blocks
  57313. */
  57314. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  57315. /**
  57316. * Specifies if the material uses a texture
  57317. * @param texture defines the texture to check against the material
  57318. * @returns a boolean specifying if the material uses the texture
  57319. */
  57320. hasTexture(texture: BaseTexture): boolean;
  57321. /**
  57322. * Disposes the material
  57323. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  57324. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  57325. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  57326. */
  57327. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  57328. /** Creates the node editor window. */
  57329. private _createNodeEditor;
  57330. /**
  57331. * Launch the node material editor
  57332. * @param config Define the configuration of the editor
  57333. * @return a promise fulfilled when the node editor is visible
  57334. */
  57335. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  57336. /**
  57337. * Clear the current material
  57338. */
  57339. clear(): void;
  57340. /**
  57341. * Clear the current material and set it to a default state
  57342. */
  57343. setToDefault(): void;
  57344. /**
  57345. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  57346. * @param url defines the url to load from
  57347. * @returns a promise that will fullfil when the material is fully loaded
  57348. */
  57349. loadAsync(url: string): Promise<void>;
  57350. private _gatherBlocks;
  57351. /**
  57352. * Generate a string containing the code declaration required to create an equivalent of this material
  57353. * @returns a string
  57354. */
  57355. generateCode(): string;
  57356. /**
  57357. * Serializes this material in a JSON representation
  57358. * @returns the serialized material object
  57359. */
  57360. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  57361. private _restoreConnections;
  57362. /**
  57363. * Clear the current graph and load a new one from a serialization object
  57364. * @param source defines the JSON representation of the material
  57365. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57366. */
  57367. loadFromSerialization(source: any, rootUrl?: string): void;
  57368. /**
  57369. * Creates a node material from parsed material data
  57370. * @param source defines the JSON representation of the material
  57371. * @param scene defines the hosting scene
  57372. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57373. * @returns a new node material
  57374. */
  57375. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  57376. /**
  57377. * Creates a new node material set to default basic configuration
  57378. * @param name defines the name of the material
  57379. * @param scene defines the hosting scene
  57380. * @returns a new NodeMaterial
  57381. */
  57382. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  57383. }
  57384. }
  57385. declare module BABYLON {
  57386. /**
  57387. * Block used to read a texture from a sampler
  57388. */
  57389. export class TextureBlock extends NodeMaterialBlock {
  57390. private _defineName;
  57391. private _linearDefineName;
  57392. private _tempTextureRead;
  57393. private _samplerName;
  57394. private _transformedUVName;
  57395. private _textureTransformName;
  57396. private _textureInfoName;
  57397. private _mainUVName;
  57398. private _mainUVDefineName;
  57399. /**
  57400. * Gets or sets the texture associated with the node
  57401. */
  57402. texture: Nullable<Texture>;
  57403. /**
  57404. * Create a new TextureBlock
  57405. * @param name defines the block name
  57406. */
  57407. constructor(name: string);
  57408. /**
  57409. * Gets the current class name
  57410. * @returns the class name
  57411. */
  57412. getClassName(): string;
  57413. /**
  57414. * Gets the uv input component
  57415. */
  57416. get uv(): NodeMaterialConnectionPoint;
  57417. /**
  57418. * Gets the rgba output component
  57419. */
  57420. get rgba(): NodeMaterialConnectionPoint;
  57421. /**
  57422. * Gets the rgb output component
  57423. */
  57424. get rgb(): NodeMaterialConnectionPoint;
  57425. /**
  57426. * Gets the r output component
  57427. */
  57428. get r(): NodeMaterialConnectionPoint;
  57429. /**
  57430. * Gets the g output component
  57431. */
  57432. get g(): NodeMaterialConnectionPoint;
  57433. /**
  57434. * Gets the b output component
  57435. */
  57436. get b(): NodeMaterialConnectionPoint;
  57437. /**
  57438. * Gets the a output component
  57439. */
  57440. get a(): NodeMaterialConnectionPoint;
  57441. get target(): NodeMaterialBlockTargets;
  57442. autoConfigure(material: NodeMaterial): void;
  57443. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57444. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57445. private _getTextureBase;
  57446. isReady(): boolean;
  57447. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57448. private get _isMixed();
  57449. private _injectVertexCode;
  57450. private _writeTextureRead;
  57451. private _writeOutput;
  57452. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57453. protected _dumpPropertiesCode(): string;
  57454. serialize(): any;
  57455. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57456. }
  57457. }
  57458. declare module BABYLON {
  57459. /**
  57460. * Class used to store shared data between 2 NodeMaterialBuildState
  57461. */
  57462. export class NodeMaterialBuildStateSharedData {
  57463. /**
  57464. * Gets the list of emitted varyings
  57465. */
  57466. temps: string[];
  57467. /**
  57468. * Gets the list of emitted varyings
  57469. */
  57470. varyings: string[];
  57471. /**
  57472. * Gets the varying declaration string
  57473. */
  57474. varyingDeclaration: string;
  57475. /**
  57476. * Input blocks
  57477. */
  57478. inputBlocks: InputBlock[];
  57479. /**
  57480. * Input blocks
  57481. */
  57482. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  57483. /**
  57484. * Bindable blocks (Blocks that need to set data to the effect)
  57485. */
  57486. bindableBlocks: NodeMaterialBlock[];
  57487. /**
  57488. * List of blocks that can provide a compilation fallback
  57489. */
  57490. blocksWithFallbacks: NodeMaterialBlock[];
  57491. /**
  57492. * List of blocks that can provide a define update
  57493. */
  57494. blocksWithDefines: NodeMaterialBlock[];
  57495. /**
  57496. * List of blocks that can provide a repeatable content
  57497. */
  57498. repeatableContentBlocks: NodeMaterialBlock[];
  57499. /**
  57500. * List of blocks that can provide a dynamic list of uniforms
  57501. */
  57502. dynamicUniformBlocks: NodeMaterialBlock[];
  57503. /**
  57504. * List of blocks that can block the isReady function for the material
  57505. */
  57506. blockingBlocks: NodeMaterialBlock[];
  57507. /**
  57508. * Gets the list of animated inputs
  57509. */
  57510. animatedInputs: InputBlock[];
  57511. /**
  57512. * Build Id used to avoid multiple recompilations
  57513. */
  57514. buildId: number;
  57515. /** List of emitted variables */
  57516. variableNames: {
  57517. [key: string]: number;
  57518. };
  57519. /** List of emitted defines */
  57520. defineNames: {
  57521. [key: string]: number;
  57522. };
  57523. /** Should emit comments? */
  57524. emitComments: boolean;
  57525. /** Emit build activity */
  57526. verbose: boolean;
  57527. /** Gets or sets the hosting scene */
  57528. scene: Scene;
  57529. /**
  57530. * Gets the compilation hints emitted at compilation time
  57531. */
  57532. hints: {
  57533. needWorldViewMatrix: boolean;
  57534. needWorldViewProjectionMatrix: boolean;
  57535. needAlphaBlending: boolean;
  57536. needAlphaTesting: boolean;
  57537. };
  57538. /**
  57539. * List of compilation checks
  57540. */
  57541. checks: {
  57542. emitVertex: boolean;
  57543. emitFragment: boolean;
  57544. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  57545. };
  57546. /** Creates a new shared data */
  57547. constructor();
  57548. /**
  57549. * Emits console errors and exceptions if there is a failing check
  57550. */
  57551. emitErrors(): void;
  57552. }
  57553. }
  57554. declare module BABYLON {
  57555. /**
  57556. * Class used to store node based material build state
  57557. */
  57558. export class NodeMaterialBuildState {
  57559. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  57560. supportUniformBuffers: boolean;
  57561. /**
  57562. * Gets the list of emitted attributes
  57563. */
  57564. attributes: string[];
  57565. /**
  57566. * Gets the list of emitted uniforms
  57567. */
  57568. uniforms: string[];
  57569. /**
  57570. * Gets the list of emitted constants
  57571. */
  57572. constants: string[];
  57573. /**
  57574. * Gets the list of emitted samplers
  57575. */
  57576. samplers: string[];
  57577. /**
  57578. * Gets the list of emitted functions
  57579. */
  57580. functions: {
  57581. [key: string]: string;
  57582. };
  57583. /**
  57584. * Gets the list of emitted extensions
  57585. */
  57586. extensions: {
  57587. [key: string]: string;
  57588. };
  57589. /**
  57590. * Gets the target of the compilation state
  57591. */
  57592. target: NodeMaterialBlockTargets;
  57593. /**
  57594. * Gets the list of emitted counters
  57595. */
  57596. counters: {
  57597. [key: string]: number;
  57598. };
  57599. /**
  57600. * Shared data between multiple NodeMaterialBuildState instances
  57601. */
  57602. sharedData: NodeMaterialBuildStateSharedData;
  57603. /** @hidden */
  57604. _vertexState: NodeMaterialBuildState;
  57605. /** @hidden */
  57606. _attributeDeclaration: string;
  57607. /** @hidden */
  57608. _uniformDeclaration: string;
  57609. /** @hidden */
  57610. _constantDeclaration: string;
  57611. /** @hidden */
  57612. _samplerDeclaration: string;
  57613. /** @hidden */
  57614. _varyingTransfer: string;
  57615. private _repeatableContentAnchorIndex;
  57616. /** @hidden */
  57617. _builtCompilationString: string;
  57618. /**
  57619. * Gets the emitted compilation strings
  57620. */
  57621. compilationString: string;
  57622. /**
  57623. * Finalize the compilation strings
  57624. * @param state defines the current compilation state
  57625. */
  57626. finalize(state: NodeMaterialBuildState): void;
  57627. /** @hidden */
  57628. get _repeatableContentAnchor(): string;
  57629. /** @hidden */
  57630. _getFreeVariableName(prefix: string): string;
  57631. /** @hidden */
  57632. _getFreeDefineName(prefix: string): string;
  57633. /** @hidden */
  57634. _excludeVariableName(name: string): void;
  57635. /** @hidden */
  57636. _emit2DSampler(name: string): void;
  57637. /** @hidden */
  57638. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  57639. /** @hidden */
  57640. _emitExtension(name: string, extension: string): void;
  57641. /** @hidden */
  57642. _emitFunction(name: string, code: string, comments: string): void;
  57643. /** @hidden */
  57644. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  57645. replaceStrings?: {
  57646. search: RegExp;
  57647. replace: string;
  57648. }[];
  57649. repeatKey?: string;
  57650. }): string;
  57651. /** @hidden */
  57652. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  57653. repeatKey?: string;
  57654. removeAttributes?: boolean;
  57655. removeUniforms?: boolean;
  57656. removeVaryings?: boolean;
  57657. removeIfDef?: boolean;
  57658. replaceStrings?: {
  57659. search: RegExp;
  57660. replace: string;
  57661. }[];
  57662. }, storeKey?: string): void;
  57663. /** @hidden */
  57664. _registerTempVariable(name: string): boolean;
  57665. /** @hidden */
  57666. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  57667. /** @hidden */
  57668. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  57669. /** @hidden */
  57670. _emitFloat(value: number): string;
  57671. }
  57672. }
  57673. declare module BABYLON {
  57674. /**
  57675. * Defines a block that can be used inside a node based material
  57676. */
  57677. export class NodeMaterialBlock {
  57678. private _buildId;
  57679. private _buildTarget;
  57680. private _target;
  57681. private _isFinalMerger;
  57682. private _isInput;
  57683. protected _isUnique: boolean;
  57684. /** @hidden */
  57685. _codeVariableName: string;
  57686. /** @hidden */
  57687. _inputs: NodeMaterialConnectionPoint[];
  57688. /** @hidden */
  57689. _outputs: NodeMaterialConnectionPoint[];
  57690. /** @hidden */
  57691. _preparationId: number;
  57692. /**
  57693. * Gets or sets the name of the block
  57694. */
  57695. name: string;
  57696. /**
  57697. * Gets or sets the unique id of the node
  57698. */
  57699. uniqueId: number;
  57700. /**
  57701. * Gets or sets the comments associated with this block
  57702. */
  57703. comments: string;
  57704. /**
  57705. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  57706. */
  57707. get isUnique(): boolean;
  57708. /**
  57709. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  57710. */
  57711. get isFinalMerger(): boolean;
  57712. /**
  57713. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  57714. */
  57715. get isInput(): boolean;
  57716. /**
  57717. * Gets or sets the build Id
  57718. */
  57719. get buildId(): number;
  57720. set buildId(value: number);
  57721. /**
  57722. * Gets or sets the target of the block
  57723. */
  57724. get target(): NodeMaterialBlockTargets;
  57725. set target(value: NodeMaterialBlockTargets);
  57726. /**
  57727. * Gets the list of input points
  57728. */
  57729. get inputs(): NodeMaterialConnectionPoint[];
  57730. /** Gets the list of output points */
  57731. get outputs(): NodeMaterialConnectionPoint[];
  57732. /**
  57733. * Find an input by its name
  57734. * @param name defines the name of the input to look for
  57735. * @returns the input or null if not found
  57736. */
  57737. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  57738. /**
  57739. * Find an output by its name
  57740. * @param name defines the name of the outputto look for
  57741. * @returns the output or null if not found
  57742. */
  57743. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  57744. /**
  57745. * Creates a new NodeMaterialBlock
  57746. * @param name defines the block name
  57747. * @param target defines the target of that block (Vertex by default)
  57748. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  57749. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  57750. */
  57751. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  57752. /**
  57753. * Initialize the block and prepare the context for build
  57754. * @param state defines the state that will be used for the build
  57755. */
  57756. initialize(state: NodeMaterialBuildState): void;
  57757. /**
  57758. * Bind data to effect. Will only be called for blocks with isBindable === true
  57759. * @param effect defines the effect to bind data to
  57760. * @param nodeMaterial defines the hosting NodeMaterial
  57761. * @param mesh defines the mesh that will be rendered
  57762. */
  57763. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57764. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  57765. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  57766. protected _writeFloat(value: number): string;
  57767. /**
  57768. * Gets the current class name e.g. "NodeMaterialBlock"
  57769. * @returns the class name
  57770. */
  57771. getClassName(): string;
  57772. /**
  57773. * Register a new input. Must be called inside a block constructor
  57774. * @param name defines the connection point name
  57775. * @param type defines the connection point type
  57776. * @param isOptional defines a boolean indicating that this input can be omitted
  57777. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  57778. * @returns the current block
  57779. */
  57780. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  57781. /**
  57782. * Register a new output. Must be called inside a block constructor
  57783. * @param name defines the connection point name
  57784. * @param type defines the connection point type
  57785. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  57786. * @returns the current block
  57787. */
  57788. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  57789. /**
  57790. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  57791. * @param forOutput defines an optional connection point to check compatibility with
  57792. * @returns the first available input or null
  57793. */
  57794. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  57795. /**
  57796. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  57797. * @param forBlock defines an optional block to check compatibility with
  57798. * @returns the first available input or null
  57799. */
  57800. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  57801. /**
  57802. * Gets the sibling of the given output
  57803. * @param current defines the current output
  57804. * @returns the next output in the list or null
  57805. */
  57806. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  57807. /**
  57808. * Connect current block with another block
  57809. * @param other defines the block to connect with
  57810. * @param options define the various options to help pick the right connections
  57811. * @returns the current block
  57812. */
  57813. connectTo(other: NodeMaterialBlock, options?: {
  57814. input?: string;
  57815. output?: string;
  57816. outputSwizzle?: string;
  57817. }): this | undefined;
  57818. protected _buildBlock(state: NodeMaterialBuildState): void;
  57819. /**
  57820. * Add uniforms, samplers and uniform buffers at compilation time
  57821. * @param state defines the state to update
  57822. * @param nodeMaterial defines the node material requesting the update
  57823. * @param defines defines the material defines to update
  57824. * @param uniformBuffers defines the list of uniform buffer names
  57825. */
  57826. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  57827. /**
  57828. * Add potential fallbacks if shader compilation fails
  57829. * @param mesh defines the mesh to be rendered
  57830. * @param fallbacks defines the current prioritized list of fallbacks
  57831. */
  57832. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  57833. /**
  57834. * Initialize defines for shader compilation
  57835. * @param mesh defines the mesh to be rendered
  57836. * @param nodeMaterial defines the node material requesting the update
  57837. * @param defines defines the material defines to update
  57838. * @param useInstances specifies that instances should be used
  57839. */
  57840. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57841. /**
  57842. * Update defines for shader compilation
  57843. * @param mesh defines the mesh to be rendered
  57844. * @param nodeMaterial defines the node material requesting the update
  57845. * @param defines defines the material defines to update
  57846. * @param useInstances specifies that instances should be used
  57847. */
  57848. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57849. /**
  57850. * Lets the block try to connect some inputs automatically
  57851. * @param material defines the hosting NodeMaterial
  57852. */
  57853. autoConfigure(material: NodeMaterial): void;
  57854. /**
  57855. * Function called when a block is declared as repeatable content generator
  57856. * @param vertexShaderState defines the current compilation state for the vertex shader
  57857. * @param fragmentShaderState defines the current compilation state for the fragment shader
  57858. * @param mesh defines the mesh to be rendered
  57859. * @param defines defines the material defines to update
  57860. */
  57861. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  57862. /**
  57863. * Checks if the block is ready
  57864. * @param mesh defines the mesh to be rendered
  57865. * @param nodeMaterial defines the node material requesting the update
  57866. * @param defines defines the material defines to update
  57867. * @param useInstances specifies that instances should be used
  57868. * @returns true if the block is ready
  57869. */
  57870. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  57871. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  57872. private _processBuild;
  57873. /**
  57874. * Compile the current node and generate the shader code
  57875. * @param state defines the current compilation state (uniforms, samplers, current string)
  57876. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  57877. * @returns true if already built
  57878. */
  57879. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  57880. protected _inputRename(name: string): string;
  57881. protected _outputRename(name: string): string;
  57882. protected _dumpPropertiesCode(): string;
  57883. /** @hidden */
  57884. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  57885. /** @hidden */
  57886. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  57887. /**
  57888. * Clone the current block to a new identical block
  57889. * @param scene defines the hosting scene
  57890. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57891. * @returns a copy of the current block
  57892. */
  57893. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  57894. /**
  57895. * Serializes this block in a JSON representation
  57896. * @returns the serialized block object
  57897. */
  57898. serialize(): any;
  57899. /** @hidden */
  57900. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57901. /**
  57902. * Release resources
  57903. */
  57904. dispose(): void;
  57905. }
  57906. }
  57907. declare module BABYLON {
  57908. /**
  57909. * Enum defining the type of animations supported by InputBlock
  57910. */
  57911. export enum AnimatedInputBlockTypes {
  57912. /** No animation */
  57913. None = 0,
  57914. /** Time based animation. Will only work for floats */
  57915. Time = 1
  57916. }
  57917. }
  57918. declare module BABYLON {
  57919. /**
  57920. * Block used to expose an input value
  57921. */
  57922. export class InputBlock extends NodeMaterialBlock {
  57923. private _mode;
  57924. private _associatedVariableName;
  57925. private _storedValue;
  57926. private _valueCallback;
  57927. private _type;
  57928. private _animationType;
  57929. /** Gets or set a value used to limit the range of float values */
  57930. min: number;
  57931. /** Gets or set a value used to limit the range of float values */
  57932. max: number;
  57933. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  57934. matrixMode: number;
  57935. /** @hidden */
  57936. _systemValue: Nullable<NodeMaterialSystemValues>;
  57937. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  57938. visibleInInspector: boolean;
  57939. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  57940. isConstant: boolean;
  57941. /** Gets or sets the group to use to display this block in the Inspector */
  57942. groupInInspector: string;
  57943. /**
  57944. * Gets or sets the connection point type (default is float)
  57945. */
  57946. get type(): NodeMaterialBlockConnectionPointTypes;
  57947. /**
  57948. * Creates a new InputBlock
  57949. * @param name defines the block name
  57950. * @param target defines the target of that block (Vertex by default)
  57951. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  57952. */
  57953. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  57954. /**
  57955. * Gets the output component
  57956. */
  57957. get output(): NodeMaterialConnectionPoint;
  57958. /**
  57959. * Set the source of this connection point to a vertex attribute
  57960. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  57961. * @returns the current connection point
  57962. */
  57963. setAsAttribute(attributeName?: string): InputBlock;
  57964. /**
  57965. * Set the source of this connection point to a system value
  57966. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  57967. * @returns the current connection point
  57968. */
  57969. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  57970. /**
  57971. * Gets or sets the value of that point.
  57972. * Please note that this value will be ignored if valueCallback is defined
  57973. */
  57974. get value(): any;
  57975. set value(value: any);
  57976. /**
  57977. * Gets or sets a callback used to get the value of that point.
  57978. * Please note that setting this value will force the connection point to ignore the value property
  57979. */
  57980. get valueCallback(): () => any;
  57981. set valueCallback(value: () => any);
  57982. /**
  57983. * Gets or sets the associated variable name in the shader
  57984. */
  57985. get associatedVariableName(): string;
  57986. set associatedVariableName(value: string);
  57987. /** Gets or sets the type of animation applied to the input */
  57988. get animationType(): AnimatedInputBlockTypes;
  57989. set animationType(value: AnimatedInputBlockTypes);
  57990. /**
  57991. * Gets a boolean indicating that this connection point not defined yet
  57992. */
  57993. get isUndefined(): boolean;
  57994. /**
  57995. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  57996. * In this case the connection point name must be the name of the uniform to use.
  57997. * Can only be set on inputs
  57998. */
  57999. get isUniform(): boolean;
  58000. set isUniform(value: boolean);
  58001. /**
  58002. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  58003. * In this case the connection point name must be the name of the attribute to use
  58004. * Can only be set on inputs
  58005. */
  58006. get isAttribute(): boolean;
  58007. set isAttribute(value: boolean);
  58008. /**
  58009. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  58010. * Can only be set on exit points
  58011. */
  58012. get isVarying(): boolean;
  58013. set isVarying(value: boolean);
  58014. /**
  58015. * Gets a boolean indicating that the current connection point is a system value
  58016. */
  58017. get isSystemValue(): boolean;
  58018. /**
  58019. * Gets or sets the current well known value or null if not defined as a system value
  58020. */
  58021. get systemValue(): Nullable<NodeMaterialSystemValues>;
  58022. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  58023. /**
  58024. * Gets the current class name
  58025. * @returns the class name
  58026. */
  58027. getClassName(): string;
  58028. /**
  58029. * Animate the input if animationType !== None
  58030. * @param scene defines the rendering scene
  58031. */
  58032. animate(scene: Scene): void;
  58033. private _emitDefine;
  58034. initialize(state: NodeMaterialBuildState): void;
  58035. /**
  58036. * Set the input block to its default value (based on its type)
  58037. */
  58038. setDefaultValue(): void;
  58039. private _emitConstant;
  58040. private _emit;
  58041. /** @hidden */
  58042. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  58043. /** @hidden */
  58044. _transmit(effect: Effect, scene: Scene): void;
  58045. protected _buildBlock(state: NodeMaterialBuildState): void;
  58046. protected _dumpPropertiesCode(): string;
  58047. serialize(): any;
  58048. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58049. }
  58050. }
  58051. declare module BABYLON {
  58052. /**
  58053. * Enum used to define the compatibility state between two connection points
  58054. */
  58055. export enum NodeMaterialConnectionPointCompatibilityStates {
  58056. /** Points are compatibles */
  58057. Compatible = 0,
  58058. /** Points are incompatible because of their types */
  58059. TypeIncompatible = 1,
  58060. /** Points are incompatible because of their targets (vertex vs fragment) */
  58061. TargetIncompatible = 2
  58062. }
  58063. /**
  58064. * Defines the direction of a connection point
  58065. */
  58066. export enum NodeMaterialConnectionPointDirection {
  58067. /** Input */
  58068. Input = 0,
  58069. /** Output */
  58070. Output = 1
  58071. }
  58072. /**
  58073. * Defines a connection point for a block
  58074. */
  58075. export class NodeMaterialConnectionPoint {
  58076. /** @hidden */
  58077. _ownerBlock: NodeMaterialBlock;
  58078. /** @hidden */
  58079. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  58080. private _endpoints;
  58081. private _associatedVariableName;
  58082. private _direction;
  58083. /** @hidden */
  58084. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58085. /** @hidden */
  58086. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  58087. private _type;
  58088. /** @hidden */
  58089. _enforceAssociatedVariableName: boolean;
  58090. /** Gets the direction of the point */
  58091. get direction(): NodeMaterialConnectionPointDirection;
  58092. /**
  58093. * Gets or sets the additional types supported by this connection point
  58094. */
  58095. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58096. /**
  58097. * Gets or sets the additional types excluded by this connection point
  58098. */
  58099. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58100. /**
  58101. * Observable triggered when this point is connected
  58102. */
  58103. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  58104. /**
  58105. * Gets or sets the associated variable name in the shader
  58106. */
  58107. get associatedVariableName(): string;
  58108. set associatedVariableName(value: string);
  58109. /**
  58110. * Gets or sets the connection point type (default is float)
  58111. */
  58112. get type(): NodeMaterialBlockConnectionPointTypes;
  58113. set type(value: NodeMaterialBlockConnectionPointTypes);
  58114. /**
  58115. * Gets or sets the connection point name
  58116. */
  58117. name: string;
  58118. /**
  58119. * Gets or sets a boolean indicating that this connection point can be omitted
  58120. */
  58121. isOptional: boolean;
  58122. /**
  58123. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  58124. */
  58125. define: string;
  58126. /** @hidden */
  58127. _prioritizeVertex: boolean;
  58128. private _target;
  58129. /** Gets or sets the target of that connection point */
  58130. get target(): NodeMaterialBlockTargets;
  58131. set target(value: NodeMaterialBlockTargets);
  58132. /**
  58133. * Gets a boolean indicating that the current point is connected
  58134. */
  58135. get isConnected(): boolean;
  58136. /**
  58137. * Gets a boolean indicating that the current point is connected to an input block
  58138. */
  58139. get isConnectedToInputBlock(): boolean;
  58140. /**
  58141. * Gets a the connected input block (if any)
  58142. */
  58143. get connectInputBlock(): Nullable<InputBlock>;
  58144. /** Get the other side of the connection (if any) */
  58145. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  58146. /** Get the block that owns this connection point */
  58147. get ownerBlock(): NodeMaterialBlock;
  58148. /** Get the block connected on the other side of this connection (if any) */
  58149. get sourceBlock(): Nullable<NodeMaterialBlock>;
  58150. /** Get the block connected on the endpoints of this connection (if any) */
  58151. get connectedBlocks(): Array<NodeMaterialBlock>;
  58152. /** Gets the list of connected endpoints */
  58153. get endpoints(): NodeMaterialConnectionPoint[];
  58154. /** Gets a boolean indicating if that output point is connected to at least one input */
  58155. get hasEndpoints(): boolean;
  58156. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  58157. get isConnectedInVertexShader(): boolean;
  58158. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  58159. get isConnectedInFragmentShader(): boolean;
  58160. /**
  58161. * Creates a new connection point
  58162. * @param name defines the connection point name
  58163. * @param ownerBlock defines the block hosting this connection point
  58164. * @param direction defines the direction of the connection point
  58165. */
  58166. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  58167. /**
  58168. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  58169. * @returns the class name
  58170. */
  58171. getClassName(): string;
  58172. /**
  58173. * Gets a boolean indicating if the current point can be connected to another point
  58174. * @param connectionPoint defines the other connection point
  58175. * @returns a boolean
  58176. */
  58177. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  58178. /**
  58179. * Gets a number indicating if the current point can be connected to another point
  58180. * @param connectionPoint defines the other connection point
  58181. * @returns a number defining the compatibility state
  58182. */
  58183. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  58184. /**
  58185. * Connect this point to another connection point
  58186. * @param connectionPoint defines the other connection point
  58187. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  58188. * @returns the current connection point
  58189. */
  58190. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  58191. /**
  58192. * Disconnect this point from one of his endpoint
  58193. * @param endpoint defines the other connection point
  58194. * @returns the current connection point
  58195. */
  58196. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  58197. /**
  58198. * Serializes this point in a JSON representation
  58199. * @returns the serialized point object
  58200. */
  58201. serialize(): any;
  58202. /**
  58203. * Release resources
  58204. */
  58205. dispose(): void;
  58206. }
  58207. }
  58208. declare module BABYLON {
  58209. /**
  58210. * Block used to add support for vertex skinning (bones)
  58211. */
  58212. export class BonesBlock extends NodeMaterialBlock {
  58213. /**
  58214. * Creates a new BonesBlock
  58215. * @param name defines the block name
  58216. */
  58217. constructor(name: string);
  58218. /**
  58219. * Initialize the block and prepare the context for build
  58220. * @param state defines the state that will be used for the build
  58221. */
  58222. initialize(state: NodeMaterialBuildState): void;
  58223. /**
  58224. * Gets the current class name
  58225. * @returns the class name
  58226. */
  58227. getClassName(): string;
  58228. /**
  58229. * Gets the matrix indices input component
  58230. */
  58231. get matricesIndices(): NodeMaterialConnectionPoint;
  58232. /**
  58233. * Gets the matrix weights input component
  58234. */
  58235. get matricesWeights(): NodeMaterialConnectionPoint;
  58236. /**
  58237. * Gets the extra matrix indices input component
  58238. */
  58239. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  58240. /**
  58241. * Gets the extra matrix weights input component
  58242. */
  58243. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  58244. /**
  58245. * Gets the world input component
  58246. */
  58247. get world(): NodeMaterialConnectionPoint;
  58248. /**
  58249. * Gets the output component
  58250. */
  58251. get output(): NodeMaterialConnectionPoint;
  58252. autoConfigure(material: NodeMaterial): void;
  58253. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58254. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58255. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58256. protected _buildBlock(state: NodeMaterialBuildState): this;
  58257. }
  58258. }
  58259. declare module BABYLON {
  58260. /**
  58261. * Block used to add support for instances
  58262. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  58263. */
  58264. export class InstancesBlock extends NodeMaterialBlock {
  58265. /**
  58266. * Creates a new InstancesBlock
  58267. * @param name defines the block name
  58268. */
  58269. constructor(name: string);
  58270. /**
  58271. * Gets the current class name
  58272. * @returns the class name
  58273. */
  58274. getClassName(): string;
  58275. /**
  58276. * Gets the first world row input component
  58277. */
  58278. get world0(): NodeMaterialConnectionPoint;
  58279. /**
  58280. * Gets the second world row input component
  58281. */
  58282. get world1(): NodeMaterialConnectionPoint;
  58283. /**
  58284. * Gets the third world row input component
  58285. */
  58286. get world2(): NodeMaterialConnectionPoint;
  58287. /**
  58288. * Gets the forth world row input component
  58289. */
  58290. get world3(): NodeMaterialConnectionPoint;
  58291. /**
  58292. * Gets the world input component
  58293. */
  58294. get world(): NodeMaterialConnectionPoint;
  58295. /**
  58296. * Gets the output component
  58297. */
  58298. get output(): NodeMaterialConnectionPoint;
  58299. autoConfigure(material: NodeMaterial): void;
  58300. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58301. protected _buildBlock(state: NodeMaterialBuildState): this;
  58302. }
  58303. }
  58304. declare module BABYLON {
  58305. /**
  58306. * Block used to add morph targets support to vertex shader
  58307. */
  58308. export class MorphTargetsBlock extends NodeMaterialBlock {
  58309. private _repeatableContentAnchor;
  58310. private _repeatebleContentGenerated;
  58311. /**
  58312. * Create a new MorphTargetsBlock
  58313. * @param name defines the block name
  58314. */
  58315. constructor(name: string);
  58316. /**
  58317. * Gets the current class name
  58318. * @returns the class name
  58319. */
  58320. getClassName(): string;
  58321. /**
  58322. * Gets the position input component
  58323. */
  58324. get position(): NodeMaterialConnectionPoint;
  58325. /**
  58326. * Gets the normal input component
  58327. */
  58328. get normal(): NodeMaterialConnectionPoint;
  58329. /**
  58330. * Gets the tangent input component
  58331. */
  58332. get tangent(): NodeMaterialConnectionPoint;
  58333. /**
  58334. * Gets the tangent input component
  58335. */
  58336. get uv(): NodeMaterialConnectionPoint;
  58337. /**
  58338. * Gets the position output component
  58339. */
  58340. get positionOutput(): NodeMaterialConnectionPoint;
  58341. /**
  58342. * Gets the normal output component
  58343. */
  58344. get normalOutput(): NodeMaterialConnectionPoint;
  58345. /**
  58346. * Gets the tangent output component
  58347. */
  58348. get tangentOutput(): NodeMaterialConnectionPoint;
  58349. /**
  58350. * Gets the tangent output component
  58351. */
  58352. get uvOutput(): NodeMaterialConnectionPoint;
  58353. initialize(state: NodeMaterialBuildState): void;
  58354. autoConfigure(material: NodeMaterial): void;
  58355. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58356. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58357. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  58358. protected _buildBlock(state: NodeMaterialBuildState): this;
  58359. }
  58360. }
  58361. declare module BABYLON {
  58362. /**
  58363. * Block used to get data information from a light
  58364. */
  58365. export class LightInformationBlock extends NodeMaterialBlock {
  58366. private _lightDataUniformName;
  58367. private _lightColorUniformName;
  58368. private _lightTypeDefineName;
  58369. /**
  58370. * Gets or sets the light associated with this block
  58371. */
  58372. light: Nullable<Light>;
  58373. /**
  58374. * Creates a new LightInformationBlock
  58375. * @param name defines the block name
  58376. */
  58377. constructor(name: string);
  58378. /**
  58379. * Gets the current class name
  58380. * @returns the class name
  58381. */
  58382. getClassName(): string;
  58383. /**
  58384. * Gets the world position input component
  58385. */
  58386. get worldPosition(): NodeMaterialConnectionPoint;
  58387. /**
  58388. * Gets the direction output component
  58389. */
  58390. get direction(): NodeMaterialConnectionPoint;
  58391. /**
  58392. * Gets the direction output component
  58393. */
  58394. get color(): NodeMaterialConnectionPoint;
  58395. /**
  58396. * Gets the direction output component
  58397. */
  58398. get intensity(): NodeMaterialConnectionPoint;
  58399. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58400. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58401. protected _buildBlock(state: NodeMaterialBuildState): this;
  58402. serialize(): any;
  58403. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58404. }
  58405. }
  58406. declare module BABYLON {
  58407. /**
  58408. * Block used to add image processing support to fragment shader
  58409. */
  58410. export class ImageProcessingBlock extends NodeMaterialBlock {
  58411. /**
  58412. * Create a new ImageProcessingBlock
  58413. * @param name defines the block name
  58414. */
  58415. constructor(name: string);
  58416. /**
  58417. * Gets the current class name
  58418. * @returns the class name
  58419. */
  58420. getClassName(): string;
  58421. /**
  58422. * Gets the color input component
  58423. */
  58424. get color(): NodeMaterialConnectionPoint;
  58425. /**
  58426. * Gets the output component
  58427. */
  58428. get output(): NodeMaterialConnectionPoint;
  58429. /**
  58430. * Initialize the block and prepare the context for build
  58431. * @param state defines the state that will be used for the build
  58432. */
  58433. initialize(state: NodeMaterialBuildState): void;
  58434. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  58435. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58436. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58437. protected _buildBlock(state: NodeMaterialBuildState): this;
  58438. }
  58439. }
  58440. declare module BABYLON {
  58441. /**
  58442. * Block used to pertub normals based on a normal map
  58443. */
  58444. export class PerturbNormalBlock extends NodeMaterialBlock {
  58445. private _tangentSpaceParameterName;
  58446. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  58447. invertX: boolean;
  58448. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  58449. invertY: boolean;
  58450. /**
  58451. * Create a new PerturbNormalBlock
  58452. * @param name defines the block name
  58453. */
  58454. constructor(name: string);
  58455. /**
  58456. * Gets the current class name
  58457. * @returns the class name
  58458. */
  58459. getClassName(): string;
  58460. /**
  58461. * Gets the world position input component
  58462. */
  58463. get worldPosition(): NodeMaterialConnectionPoint;
  58464. /**
  58465. * Gets the world normal input component
  58466. */
  58467. get worldNormal(): NodeMaterialConnectionPoint;
  58468. /**
  58469. * Gets the uv input component
  58470. */
  58471. get uv(): NodeMaterialConnectionPoint;
  58472. /**
  58473. * Gets the normal map color input component
  58474. */
  58475. get normalMapColor(): NodeMaterialConnectionPoint;
  58476. /**
  58477. * Gets the strength input component
  58478. */
  58479. get strength(): NodeMaterialConnectionPoint;
  58480. /**
  58481. * Gets the output component
  58482. */
  58483. get output(): NodeMaterialConnectionPoint;
  58484. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58485. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58486. autoConfigure(material: NodeMaterial): void;
  58487. protected _buildBlock(state: NodeMaterialBuildState): this;
  58488. protected _dumpPropertiesCode(): string;
  58489. serialize(): any;
  58490. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58491. }
  58492. }
  58493. declare module BABYLON {
  58494. /**
  58495. * Block used to discard a pixel if a value is smaller than a cutoff
  58496. */
  58497. export class DiscardBlock extends NodeMaterialBlock {
  58498. /**
  58499. * Create a new DiscardBlock
  58500. * @param name defines the block name
  58501. */
  58502. constructor(name: string);
  58503. /**
  58504. * Gets the current class name
  58505. * @returns the class name
  58506. */
  58507. getClassName(): string;
  58508. /**
  58509. * Gets the color input component
  58510. */
  58511. get value(): NodeMaterialConnectionPoint;
  58512. /**
  58513. * Gets the cutoff input component
  58514. */
  58515. get cutoff(): NodeMaterialConnectionPoint;
  58516. protected _buildBlock(state: NodeMaterialBuildState): this;
  58517. }
  58518. }
  58519. declare module BABYLON {
  58520. /**
  58521. * Block used to test if the fragment shader is front facing
  58522. */
  58523. export class FrontFacingBlock extends NodeMaterialBlock {
  58524. /**
  58525. * Creates a new FrontFacingBlock
  58526. * @param name defines the block name
  58527. */
  58528. constructor(name: string);
  58529. /**
  58530. * Gets the current class name
  58531. * @returns the class name
  58532. */
  58533. getClassName(): string;
  58534. /**
  58535. * Gets the output component
  58536. */
  58537. get output(): NodeMaterialConnectionPoint;
  58538. protected _buildBlock(state: NodeMaterialBuildState): this;
  58539. }
  58540. }
  58541. declare module BABYLON {
  58542. /**
  58543. * Block used to get the derivative value on x and y of a given input
  58544. */
  58545. export class DerivativeBlock extends NodeMaterialBlock {
  58546. /**
  58547. * Create a new DerivativeBlock
  58548. * @param name defines the block name
  58549. */
  58550. constructor(name: string);
  58551. /**
  58552. * Gets the current class name
  58553. * @returns the class name
  58554. */
  58555. getClassName(): string;
  58556. /**
  58557. * Gets the input component
  58558. */
  58559. get input(): NodeMaterialConnectionPoint;
  58560. /**
  58561. * Gets the derivative output on x
  58562. */
  58563. get dx(): NodeMaterialConnectionPoint;
  58564. /**
  58565. * Gets the derivative output on y
  58566. */
  58567. get dy(): NodeMaterialConnectionPoint;
  58568. protected _buildBlock(state: NodeMaterialBuildState): this;
  58569. }
  58570. }
  58571. declare module BABYLON {
  58572. /**
  58573. * Block used to add support for scene fog
  58574. */
  58575. export class FogBlock extends NodeMaterialBlock {
  58576. private _fogDistanceName;
  58577. private _fogParameters;
  58578. /**
  58579. * Create a new FogBlock
  58580. * @param name defines the block name
  58581. */
  58582. constructor(name: string);
  58583. /**
  58584. * Gets the current class name
  58585. * @returns the class name
  58586. */
  58587. getClassName(): string;
  58588. /**
  58589. * Gets the world position input component
  58590. */
  58591. get worldPosition(): NodeMaterialConnectionPoint;
  58592. /**
  58593. * Gets the view input component
  58594. */
  58595. get view(): NodeMaterialConnectionPoint;
  58596. /**
  58597. * Gets the color input component
  58598. */
  58599. get input(): NodeMaterialConnectionPoint;
  58600. /**
  58601. * Gets the fog color input component
  58602. */
  58603. get fogColor(): NodeMaterialConnectionPoint;
  58604. /**
  58605. * Gets the output component
  58606. */
  58607. get output(): NodeMaterialConnectionPoint;
  58608. autoConfigure(material: NodeMaterial): void;
  58609. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58610. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58611. protected _buildBlock(state: NodeMaterialBuildState): this;
  58612. }
  58613. }
  58614. declare module BABYLON {
  58615. /**
  58616. * Block used to add light in the fragment shader
  58617. */
  58618. export class LightBlock extends NodeMaterialBlock {
  58619. private _lightId;
  58620. /**
  58621. * Gets or sets the light associated with this block
  58622. */
  58623. light: Nullable<Light>;
  58624. /**
  58625. * Create a new LightBlock
  58626. * @param name defines the block name
  58627. */
  58628. constructor(name: string);
  58629. /**
  58630. * Gets the current class name
  58631. * @returns the class name
  58632. */
  58633. getClassName(): string;
  58634. /**
  58635. * Gets the world position input component
  58636. */
  58637. get worldPosition(): NodeMaterialConnectionPoint;
  58638. /**
  58639. * Gets the world normal input component
  58640. */
  58641. get worldNormal(): NodeMaterialConnectionPoint;
  58642. /**
  58643. * Gets the camera (or eye) position component
  58644. */
  58645. get cameraPosition(): NodeMaterialConnectionPoint;
  58646. /**
  58647. * Gets the glossiness component
  58648. */
  58649. get glossiness(): NodeMaterialConnectionPoint;
  58650. /**
  58651. * Gets the glossinness power component
  58652. */
  58653. get glossPower(): NodeMaterialConnectionPoint;
  58654. /**
  58655. * Gets the diffuse color component
  58656. */
  58657. get diffuseColor(): NodeMaterialConnectionPoint;
  58658. /**
  58659. * Gets the specular color component
  58660. */
  58661. get specularColor(): NodeMaterialConnectionPoint;
  58662. /**
  58663. * Gets the diffuse output component
  58664. */
  58665. get diffuseOutput(): NodeMaterialConnectionPoint;
  58666. /**
  58667. * Gets the specular output component
  58668. */
  58669. get specularOutput(): NodeMaterialConnectionPoint;
  58670. /**
  58671. * Gets the shadow output component
  58672. */
  58673. get shadow(): NodeMaterialConnectionPoint;
  58674. autoConfigure(material: NodeMaterial): void;
  58675. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58676. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  58677. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58678. private _injectVertexCode;
  58679. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58680. serialize(): any;
  58681. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58682. }
  58683. }
  58684. declare module BABYLON {
  58685. /**
  58686. * Block used to multiply 2 values
  58687. */
  58688. export class MultiplyBlock extends NodeMaterialBlock {
  58689. /**
  58690. * Creates a new MultiplyBlock
  58691. * @param name defines the block name
  58692. */
  58693. constructor(name: string);
  58694. /**
  58695. * Gets the current class name
  58696. * @returns the class name
  58697. */
  58698. getClassName(): string;
  58699. /**
  58700. * Gets the left operand input component
  58701. */
  58702. get left(): NodeMaterialConnectionPoint;
  58703. /**
  58704. * Gets the right operand input component
  58705. */
  58706. get right(): NodeMaterialConnectionPoint;
  58707. /**
  58708. * Gets the output component
  58709. */
  58710. get output(): NodeMaterialConnectionPoint;
  58711. protected _buildBlock(state: NodeMaterialBuildState): this;
  58712. }
  58713. }
  58714. declare module BABYLON {
  58715. /**
  58716. * Block used to add 2 vectors
  58717. */
  58718. export class AddBlock extends NodeMaterialBlock {
  58719. /**
  58720. * Creates a new AddBlock
  58721. * @param name defines the block name
  58722. */
  58723. constructor(name: string);
  58724. /**
  58725. * Gets the current class name
  58726. * @returns the class name
  58727. */
  58728. getClassName(): string;
  58729. /**
  58730. * Gets the left operand input component
  58731. */
  58732. get left(): NodeMaterialConnectionPoint;
  58733. /**
  58734. * Gets the right operand input component
  58735. */
  58736. get right(): NodeMaterialConnectionPoint;
  58737. /**
  58738. * Gets the output component
  58739. */
  58740. get output(): NodeMaterialConnectionPoint;
  58741. protected _buildBlock(state: NodeMaterialBuildState): this;
  58742. }
  58743. }
  58744. declare module BABYLON {
  58745. /**
  58746. * Block used to scale a vector by a float
  58747. */
  58748. export class ScaleBlock extends NodeMaterialBlock {
  58749. /**
  58750. * Creates a new ScaleBlock
  58751. * @param name defines the block name
  58752. */
  58753. constructor(name: string);
  58754. /**
  58755. * Gets the current class name
  58756. * @returns the class name
  58757. */
  58758. getClassName(): string;
  58759. /**
  58760. * Gets the input component
  58761. */
  58762. get input(): NodeMaterialConnectionPoint;
  58763. /**
  58764. * Gets the factor input component
  58765. */
  58766. get factor(): NodeMaterialConnectionPoint;
  58767. /**
  58768. * Gets the output component
  58769. */
  58770. get output(): NodeMaterialConnectionPoint;
  58771. protected _buildBlock(state: NodeMaterialBuildState): this;
  58772. }
  58773. }
  58774. declare module BABYLON {
  58775. /**
  58776. * Block used to clamp a float
  58777. */
  58778. export class ClampBlock extends NodeMaterialBlock {
  58779. /** Gets or sets the minimum range */
  58780. minimum: number;
  58781. /** Gets or sets the maximum range */
  58782. maximum: number;
  58783. /**
  58784. * Creates a new ClampBlock
  58785. * @param name defines the block name
  58786. */
  58787. constructor(name: string);
  58788. /**
  58789. * Gets the current class name
  58790. * @returns the class name
  58791. */
  58792. getClassName(): string;
  58793. /**
  58794. * Gets the value input component
  58795. */
  58796. get value(): NodeMaterialConnectionPoint;
  58797. /**
  58798. * Gets the output component
  58799. */
  58800. get output(): NodeMaterialConnectionPoint;
  58801. protected _buildBlock(state: NodeMaterialBuildState): this;
  58802. protected _dumpPropertiesCode(): string;
  58803. serialize(): any;
  58804. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58805. }
  58806. }
  58807. declare module BABYLON {
  58808. /**
  58809. * Block used to apply a cross product between 2 vectors
  58810. */
  58811. export class CrossBlock extends NodeMaterialBlock {
  58812. /**
  58813. * Creates a new CrossBlock
  58814. * @param name defines the block name
  58815. */
  58816. constructor(name: string);
  58817. /**
  58818. * Gets the current class name
  58819. * @returns the class name
  58820. */
  58821. getClassName(): string;
  58822. /**
  58823. * Gets the left operand input component
  58824. */
  58825. get left(): NodeMaterialConnectionPoint;
  58826. /**
  58827. * Gets the right operand input component
  58828. */
  58829. get right(): NodeMaterialConnectionPoint;
  58830. /**
  58831. * Gets the output component
  58832. */
  58833. get output(): NodeMaterialConnectionPoint;
  58834. protected _buildBlock(state: NodeMaterialBuildState): this;
  58835. }
  58836. }
  58837. declare module BABYLON {
  58838. /**
  58839. * Block used to apply a dot product between 2 vectors
  58840. */
  58841. export class DotBlock extends NodeMaterialBlock {
  58842. /**
  58843. * Creates a new DotBlock
  58844. * @param name defines the block name
  58845. */
  58846. constructor(name: string);
  58847. /**
  58848. * Gets the current class name
  58849. * @returns the class name
  58850. */
  58851. getClassName(): string;
  58852. /**
  58853. * Gets the left operand input component
  58854. */
  58855. get left(): NodeMaterialConnectionPoint;
  58856. /**
  58857. * Gets the right operand input component
  58858. */
  58859. get right(): NodeMaterialConnectionPoint;
  58860. /**
  58861. * Gets the output component
  58862. */
  58863. get output(): NodeMaterialConnectionPoint;
  58864. protected _buildBlock(state: NodeMaterialBuildState): this;
  58865. }
  58866. }
  58867. declare module BABYLON {
  58868. /**
  58869. * Block used to remap a float from a range to a new one
  58870. */
  58871. export class RemapBlock extends NodeMaterialBlock {
  58872. /**
  58873. * Gets or sets the source range
  58874. */
  58875. sourceRange: Vector2;
  58876. /**
  58877. * Gets or sets the target range
  58878. */
  58879. targetRange: Vector2;
  58880. /**
  58881. * Creates a new RemapBlock
  58882. * @param name defines the block name
  58883. */
  58884. constructor(name: string);
  58885. /**
  58886. * Gets the current class name
  58887. * @returns the class name
  58888. */
  58889. getClassName(): string;
  58890. /**
  58891. * Gets the input component
  58892. */
  58893. get input(): NodeMaterialConnectionPoint;
  58894. /**
  58895. * Gets the source min input component
  58896. */
  58897. get sourceMin(): NodeMaterialConnectionPoint;
  58898. /**
  58899. * Gets the source max input component
  58900. */
  58901. get sourceMax(): NodeMaterialConnectionPoint;
  58902. /**
  58903. * Gets the target min input component
  58904. */
  58905. get targetMin(): NodeMaterialConnectionPoint;
  58906. /**
  58907. * Gets the target max input component
  58908. */
  58909. get targetMax(): NodeMaterialConnectionPoint;
  58910. /**
  58911. * Gets the output component
  58912. */
  58913. get output(): NodeMaterialConnectionPoint;
  58914. protected _buildBlock(state: NodeMaterialBuildState): this;
  58915. protected _dumpPropertiesCode(): string;
  58916. serialize(): any;
  58917. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58918. }
  58919. }
  58920. declare module BABYLON {
  58921. /**
  58922. * Block used to normalize a vector
  58923. */
  58924. export class NormalizeBlock extends NodeMaterialBlock {
  58925. /**
  58926. * Creates a new NormalizeBlock
  58927. * @param name defines the block name
  58928. */
  58929. constructor(name: string);
  58930. /**
  58931. * Gets the current class name
  58932. * @returns the class name
  58933. */
  58934. getClassName(): string;
  58935. /**
  58936. * Gets the input component
  58937. */
  58938. get input(): NodeMaterialConnectionPoint;
  58939. /**
  58940. * Gets the output component
  58941. */
  58942. get output(): NodeMaterialConnectionPoint;
  58943. protected _buildBlock(state: NodeMaterialBuildState): this;
  58944. }
  58945. }
  58946. declare module BABYLON {
  58947. /**
  58948. * Operations supported by the Trigonometry block
  58949. */
  58950. export enum TrigonometryBlockOperations {
  58951. /** Cos */
  58952. Cos = 0,
  58953. /** Sin */
  58954. Sin = 1,
  58955. /** Abs */
  58956. Abs = 2,
  58957. /** Exp */
  58958. Exp = 3,
  58959. /** Exp2 */
  58960. Exp2 = 4,
  58961. /** Round */
  58962. Round = 5,
  58963. /** Floor */
  58964. Floor = 6,
  58965. /** Ceiling */
  58966. Ceiling = 7,
  58967. /** Square root */
  58968. Sqrt = 8,
  58969. /** Log */
  58970. Log = 9,
  58971. /** Tangent */
  58972. Tan = 10,
  58973. /** Arc tangent */
  58974. ArcTan = 11,
  58975. /** Arc cosinus */
  58976. ArcCos = 12,
  58977. /** Arc sinus */
  58978. ArcSin = 13,
  58979. /** Fraction */
  58980. Fract = 14,
  58981. /** Sign */
  58982. Sign = 15,
  58983. /** To radians (from degrees) */
  58984. Radians = 16,
  58985. /** To degrees (from radians) */
  58986. Degrees = 17
  58987. }
  58988. /**
  58989. * Block used to apply trigonometry operation to floats
  58990. */
  58991. export class TrigonometryBlock extends NodeMaterialBlock {
  58992. /**
  58993. * Gets or sets the operation applied by the block
  58994. */
  58995. operation: TrigonometryBlockOperations;
  58996. /**
  58997. * Creates a new TrigonometryBlock
  58998. * @param name defines the block name
  58999. */
  59000. constructor(name: string);
  59001. /**
  59002. * Gets the current class name
  59003. * @returns the class name
  59004. */
  59005. getClassName(): string;
  59006. /**
  59007. * Gets the input component
  59008. */
  59009. get input(): NodeMaterialConnectionPoint;
  59010. /**
  59011. * Gets the output component
  59012. */
  59013. get output(): NodeMaterialConnectionPoint;
  59014. protected _buildBlock(state: NodeMaterialBuildState): this;
  59015. serialize(): any;
  59016. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59017. protected _dumpPropertiesCode(): string;
  59018. }
  59019. }
  59020. declare module BABYLON {
  59021. /**
  59022. * Block used to create a Color3/4 out of individual inputs (one for each component)
  59023. */
  59024. export class ColorMergerBlock extends NodeMaterialBlock {
  59025. /**
  59026. * Create a new ColorMergerBlock
  59027. * @param name defines the block name
  59028. */
  59029. constructor(name: string);
  59030. /**
  59031. * Gets the current class name
  59032. * @returns the class name
  59033. */
  59034. getClassName(): string;
  59035. /**
  59036. * Gets the rgb component (input)
  59037. */
  59038. get rgbIn(): NodeMaterialConnectionPoint;
  59039. /**
  59040. * Gets the r component (input)
  59041. */
  59042. get r(): NodeMaterialConnectionPoint;
  59043. /**
  59044. * Gets the g component (input)
  59045. */
  59046. get g(): NodeMaterialConnectionPoint;
  59047. /**
  59048. * Gets the b component (input)
  59049. */
  59050. get b(): NodeMaterialConnectionPoint;
  59051. /**
  59052. * Gets the a component (input)
  59053. */
  59054. get a(): NodeMaterialConnectionPoint;
  59055. /**
  59056. * Gets the rgba component (output)
  59057. */
  59058. get rgba(): NodeMaterialConnectionPoint;
  59059. /**
  59060. * Gets the rgb component (output)
  59061. */
  59062. get rgbOut(): NodeMaterialConnectionPoint;
  59063. /**
  59064. * Gets the rgb component (output)
  59065. * @deprecated Please use rgbOut instead.
  59066. */
  59067. get rgb(): NodeMaterialConnectionPoint;
  59068. protected _buildBlock(state: NodeMaterialBuildState): this;
  59069. }
  59070. }
  59071. declare module BABYLON {
  59072. /**
  59073. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  59074. */
  59075. export class VectorMergerBlock extends NodeMaterialBlock {
  59076. /**
  59077. * Create a new VectorMergerBlock
  59078. * @param name defines the block name
  59079. */
  59080. constructor(name: string);
  59081. /**
  59082. * Gets the current class name
  59083. * @returns the class name
  59084. */
  59085. getClassName(): string;
  59086. /**
  59087. * Gets the xyz component (input)
  59088. */
  59089. get xyzIn(): NodeMaterialConnectionPoint;
  59090. /**
  59091. * Gets the xy component (input)
  59092. */
  59093. get xyIn(): NodeMaterialConnectionPoint;
  59094. /**
  59095. * Gets the x component (input)
  59096. */
  59097. get x(): NodeMaterialConnectionPoint;
  59098. /**
  59099. * Gets the y component (input)
  59100. */
  59101. get y(): NodeMaterialConnectionPoint;
  59102. /**
  59103. * Gets the z component (input)
  59104. */
  59105. get z(): NodeMaterialConnectionPoint;
  59106. /**
  59107. * Gets the w component (input)
  59108. */
  59109. get w(): NodeMaterialConnectionPoint;
  59110. /**
  59111. * Gets the xyzw component (output)
  59112. */
  59113. get xyzw(): NodeMaterialConnectionPoint;
  59114. /**
  59115. * Gets the xyz component (output)
  59116. */
  59117. get xyzOut(): NodeMaterialConnectionPoint;
  59118. /**
  59119. * Gets the xy component (output)
  59120. */
  59121. get xyOut(): NodeMaterialConnectionPoint;
  59122. /**
  59123. * Gets the xy component (output)
  59124. * @deprecated Please use xyOut instead.
  59125. */
  59126. get xy(): NodeMaterialConnectionPoint;
  59127. /**
  59128. * Gets the xyz component (output)
  59129. * @deprecated Please use xyzOut instead.
  59130. */
  59131. get xyz(): NodeMaterialConnectionPoint;
  59132. protected _buildBlock(state: NodeMaterialBuildState): this;
  59133. }
  59134. }
  59135. declare module BABYLON {
  59136. /**
  59137. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  59138. */
  59139. export class ColorSplitterBlock extends NodeMaterialBlock {
  59140. /**
  59141. * Create a new ColorSplitterBlock
  59142. * @param name defines the block name
  59143. */
  59144. constructor(name: string);
  59145. /**
  59146. * Gets the current class name
  59147. * @returns the class name
  59148. */
  59149. getClassName(): string;
  59150. /**
  59151. * Gets the rgba component (input)
  59152. */
  59153. get rgba(): NodeMaterialConnectionPoint;
  59154. /**
  59155. * Gets the rgb component (input)
  59156. */
  59157. get rgbIn(): NodeMaterialConnectionPoint;
  59158. /**
  59159. * Gets the rgb component (output)
  59160. */
  59161. get rgbOut(): NodeMaterialConnectionPoint;
  59162. /**
  59163. * Gets the r component (output)
  59164. */
  59165. get r(): NodeMaterialConnectionPoint;
  59166. /**
  59167. * Gets the g component (output)
  59168. */
  59169. get g(): NodeMaterialConnectionPoint;
  59170. /**
  59171. * Gets the b component (output)
  59172. */
  59173. get b(): NodeMaterialConnectionPoint;
  59174. /**
  59175. * Gets the a component (output)
  59176. */
  59177. get a(): NodeMaterialConnectionPoint;
  59178. protected _inputRename(name: string): string;
  59179. protected _outputRename(name: string): string;
  59180. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59181. }
  59182. }
  59183. declare module BABYLON {
  59184. /**
  59185. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  59186. */
  59187. export class VectorSplitterBlock extends NodeMaterialBlock {
  59188. /**
  59189. * Create a new VectorSplitterBlock
  59190. * @param name defines the block name
  59191. */
  59192. constructor(name: string);
  59193. /**
  59194. * Gets the current class name
  59195. * @returns the class name
  59196. */
  59197. getClassName(): string;
  59198. /**
  59199. * Gets the xyzw component (input)
  59200. */
  59201. get xyzw(): NodeMaterialConnectionPoint;
  59202. /**
  59203. * Gets the xyz component (input)
  59204. */
  59205. get xyzIn(): NodeMaterialConnectionPoint;
  59206. /**
  59207. * Gets the xy component (input)
  59208. */
  59209. get xyIn(): NodeMaterialConnectionPoint;
  59210. /**
  59211. * Gets the xyz component (output)
  59212. */
  59213. get xyzOut(): NodeMaterialConnectionPoint;
  59214. /**
  59215. * Gets the xy component (output)
  59216. */
  59217. get xyOut(): NodeMaterialConnectionPoint;
  59218. /**
  59219. * Gets the x component (output)
  59220. */
  59221. get x(): NodeMaterialConnectionPoint;
  59222. /**
  59223. * Gets the y component (output)
  59224. */
  59225. get y(): NodeMaterialConnectionPoint;
  59226. /**
  59227. * Gets the z component (output)
  59228. */
  59229. get z(): NodeMaterialConnectionPoint;
  59230. /**
  59231. * Gets the w component (output)
  59232. */
  59233. get w(): NodeMaterialConnectionPoint;
  59234. protected _inputRename(name: string): string;
  59235. protected _outputRename(name: string): string;
  59236. protected _buildBlock(state: NodeMaterialBuildState): this;
  59237. }
  59238. }
  59239. declare module BABYLON {
  59240. /**
  59241. * Block used to lerp between 2 values
  59242. */
  59243. export class LerpBlock extends NodeMaterialBlock {
  59244. /**
  59245. * Creates a new LerpBlock
  59246. * @param name defines the block name
  59247. */
  59248. constructor(name: string);
  59249. /**
  59250. * Gets the current class name
  59251. * @returns the class name
  59252. */
  59253. getClassName(): string;
  59254. /**
  59255. * Gets the left operand input component
  59256. */
  59257. get left(): NodeMaterialConnectionPoint;
  59258. /**
  59259. * Gets the right operand input component
  59260. */
  59261. get right(): NodeMaterialConnectionPoint;
  59262. /**
  59263. * Gets the gradient operand input component
  59264. */
  59265. get gradient(): NodeMaterialConnectionPoint;
  59266. /**
  59267. * Gets the output component
  59268. */
  59269. get output(): NodeMaterialConnectionPoint;
  59270. protected _buildBlock(state: NodeMaterialBuildState): this;
  59271. }
  59272. }
  59273. declare module BABYLON {
  59274. /**
  59275. * Block used to divide 2 vectors
  59276. */
  59277. export class DivideBlock extends NodeMaterialBlock {
  59278. /**
  59279. * Creates a new DivideBlock
  59280. * @param name defines the block name
  59281. */
  59282. constructor(name: string);
  59283. /**
  59284. * Gets the current class name
  59285. * @returns the class name
  59286. */
  59287. getClassName(): string;
  59288. /**
  59289. * Gets the left operand input component
  59290. */
  59291. get left(): NodeMaterialConnectionPoint;
  59292. /**
  59293. * Gets the right operand input component
  59294. */
  59295. get right(): NodeMaterialConnectionPoint;
  59296. /**
  59297. * Gets the output component
  59298. */
  59299. get output(): NodeMaterialConnectionPoint;
  59300. protected _buildBlock(state: NodeMaterialBuildState): this;
  59301. }
  59302. }
  59303. declare module BABYLON {
  59304. /**
  59305. * Block used to subtract 2 vectors
  59306. */
  59307. export class SubtractBlock extends NodeMaterialBlock {
  59308. /**
  59309. * Creates a new SubtractBlock
  59310. * @param name defines the block name
  59311. */
  59312. constructor(name: string);
  59313. /**
  59314. * Gets the current class name
  59315. * @returns the class name
  59316. */
  59317. getClassName(): string;
  59318. /**
  59319. * Gets the left operand input component
  59320. */
  59321. get left(): NodeMaterialConnectionPoint;
  59322. /**
  59323. * Gets the right operand input component
  59324. */
  59325. get right(): NodeMaterialConnectionPoint;
  59326. /**
  59327. * Gets the output component
  59328. */
  59329. get output(): NodeMaterialConnectionPoint;
  59330. protected _buildBlock(state: NodeMaterialBuildState): this;
  59331. }
  59332. }
  59333. declare module BABYLON {
  59334. /**
  59335. * Block used to step a value
  59336. */
  59337. export class StepBlock extends NodeMaterialBlock {
  59338. /**
  59339. * Creates a new StepBlock
  59340. * @param name defines the block name
  59341. */
  59342. constructor(name: string);
  59343. /**
  59344. * Gets the current class name
  59345. * @returns the class name
  59346. */
  59347. getClassName(): string;
  59348. /**
  59349. * Gets the value operand input component
  59350. */
  59351. get value(): NodeMaterialConnectionPoint;
  59352. /**
  59353. * Gets the edge operand input component
  59354. */
  59355. get edge(): NodeMaterialConnectionPoint;
  59356. /**
  59357. * Gets the output component
  59358. */
  59359. get output(): NodeMaterialConnectionPoint;
  59360. protected _buildBlock(state: NodeMaterialBuildState): this;
  59361. }
  59362. }
  59363. declare module BABYLON {
  59364. /**
  59365. * Block used to get the opposite (1 - x) of a value
  59366. */
  59367. export class OneMinusBlock extends NodeMaterialBlock {
  59368. /**
  59369. * Creates a new OneMinusBlock
  59370. * @param name defines the block name
  59371. */
  59372. constructor(name: string);
  59373. /**
  59374. * Gets the current class name
  59375. * @returns the class name
  59376. */
  59377. getClassName(): string;
  59378. /**
  59379. * Gets the input component
  59380. */
  59381. get input(): NodeMaterialConnectionPoint;
  59382. /**
  59383. * Gets the output component
  59384. */
  59385. get output(): NodeMaterialConnectionPoint;
  59386. protected _buildBlock(state: NodeMaterialBuildState): this;
  59387. }
  59388. }
  59389. declare module BABYLON {
  59390. /**
  59391. * Block used to get the view direction
  59392. */
  59393. export class ViewDirectionBlock extends NodeMaterialBlock {
  59394. /**
  59395. * Creates a new ViewDirectionBlock
  59396. * @param name defines the block name
  59397. */
  59398. constructor(name: string);
  59399. /**
  59400. * Gets the current class name
  59401. * @returns the class name
  59402. */
  59403. getClassName(): string;
  59404. /**
  59405. * Gets the world position component
  59406. */
  59407. get worldPosition(): NodeMaterialConnectionPoint;
  59408. /**
  59409. * Gets the camera position component
  59410. */
  59411. get cameraPosition(): NodeMaterialConnectionPoint;
  59412. /**
  59413. * Gets the output component
  59414. */
  59415. get output(): NodeMaterialConnectionPoint;
  59416. autoConfigure(material: NodeMaterial): void;
  59417. protected _buildBlock(state: NodeMaterialBuildState): this;
  59418. }
  59419. }
  59420. declare module BABYLON {
  59421. /**
  59422. * Block used to compute fresnel value
  59423. */
  59424. export class FresnelBlock extends NodeMaterialBlock {
  59425. /**
  59426. * Create a new FresnelBlock
  59427. * @param name defines the block name
  59428. */
  59429. constructor(name: string);
  59430. /**
  59431. * Gets the current class name
  59432. * @returns the class name
  59433. */
  59434. getClassName(): string;
  59435. /**
  59436. * Gets the world normal input component
  59437. */
  59438. get worldNormal(): NodeMaterialConnectionPoint;
  59439. /**
  59440. * Gets the view direction input component
  59441. */
  59442. get viewDirection(): NodeMaterialConnectionPoint;
  59443. /**
  59444. * Gets the bias input component
  59445. */
  59446. get bias(): NodeMaterialConnectionPoint;
  59447. /**
  59448. * Gets the camera (or eye) position component
  59449. */
  59450. get power(): NodeMaterialConnectionPoint;
  59451. /**
  59452. * Gets the fresnel output component
  59453. */
  59454. get fresnel(): NodeMaterialConnectionPoint;
  59455. autoConfigure(material: NodeMaterial): void;
  59456. protected _buildBlock(state: NodeMaterialBuildState): this;
  59457. }
  59458. }
  59459. declare module BABYLON {
  59460. /**
  59461. * Block used to get the max of 2 values
  59462. */
  59463. export class MaxBlock extends NodeMaterialBlock {
  59464. /**
  59465. * Creates a new MaxBlock
  59466. * @param name defines the block name
  59467. */
  59468. constructor(name: string);
  59469. /**
  59470. * Gets the current class name
  59471. * @returns the class name
  59472. */
  59473. getClassName(): string;
  59474. /**
  59475. * Gets the left operand input component
  59476. */
  59477. get left(): NodeMaterialConnectionPoint;
  59478. /**
  59479. * Gets the right operand input component
  59480. */
  59481. get right(): NodeMaterialConnectionPoint;
  59482. /**
  59483. * Gets the output component
  59484. */
  59485. get output(): NodeMaterialConnectionPoint;
  59486. protected _buildBlock(state: NodeMaterialBuildState): this;
  59487. }
  59488. }
  59489. declare module BABYLON {
  59490. /**
  59491. * Block used to get the min of 2 values
  59492. */
  59493. export class MinBlock extends NodeMaterialBlock {
  59494. /**
  59495. * Creates a new MinBlock
  59496. * @param name defines the block name
  59497. */
  59498. constructor(name: string);
  59499. /**
  59500. * Gets the current class name
  59501. * @returns the class name
  59502. */
  59503. getClassName(): string;
  59504. /**
  59505. * Gets the left operand input component
  59506. */
  59507. get left(): NodeMaterialConnectionPoint;
  59508. /**
  59509. * Gets the right operand input component
  59510. */
  59511. get right(): NodeMaterialConnectionPoint;
  59512. /**
  59513. * Gets the output component
  59514. */
  59515. get output(): NodeMaterialConnectionPoint;
  59516. protected _buildBlock(state: NodeMaterialBuildState): this;
  59517. }
  59518. }
  59519. declare module BABYLON {
  59520. /**
  59521. * Block used to get the distance between 2 values
  59522. */
  59523. export class DistanceBlock extends NodeMaterialBlock {
  59524. /**
  59525. * Creates a new DistanceBlock
  59526. * @param name defines the block name
  59527. */
  59528. constructor(name: string);
  59529. /**
  59530. * Gets the current class name
  59531. * @returns the class name
  59532. */
  59533. getClassName(): string;
  59534. /**
  59535. * Gets the left operand input component
  59536. */
  59537. get left(): NodeMaterialConnectionPoint;
  59538. /**
  59539. * Gets the right operand input component
  59540. */
  59541. get right(): NodeMaterialConnectionPoint;
  59542. /**
  59543. * Gets the output component
  59544. */
  59545. get output(): NodeMaterialConnectionPoint;
  59546. protected _buildBlock(state: NodeMaterialBuildState): this;
  59547. }
  59548. }
  59549. declare module BABYLON {
  59550. /**
  59551. * Block used to get the length of a vector
  59552. */
  59553. export class LengthBlock extends NodeMaterialBlock {
  59554. /**
  59555. * Creates a new LengthBlock
  59556. * @param name defines the block name
  59557. */
  59558. constructor(name: string);
  59559. /**
  59560. * Gets the current class name
  59561. * @returns the class name
  59562. */
  59563. getClassName(): string;
  59564. /**
  59565. * Gets the value input component
  59566. */
  59567. get value(): NodeMaterialConnectionPoint;
  59568. /**
  59569. * Gets the output component
  59570. */
  59571. get output(): NodeMaterialConnectionPoint;
  59572. protected _buildBlock(state: NodeMaterialBuildState): this;
  59573. }
  59574. }
  59575. declare module BABYLON {
  59576. /**
  59577. * Block used to get negative version of a value (i.e. x * -1)
  59578. */
  59579. export class NegateBlock extends NodeMaterialBlock {
  59580. /**
  59581. * Creates a new NegateBlock
  59582. * @param name defines the block name
  59583. */
  59584. constructor(name: string);
  59585. /**
  59586. * Gets the current class name
  59587. * @returns the class name
  59588. */
  59589. getClassName(): string;
  59590. /**
  59591. * Gets the value input component
  59592. */
  59593. get value(): NodeMaterialConnectionPoint;
  59594. /**
  59595. * Gets the output component
  59596. */
  59597. get output(): NodeMaterialConnectionPoint;
  59598. protected _buildBlock(state: NodeMaterialBuildState): this;
  59599. }
  59600. }
  59601. declare module BABYLON {
  59602. /**
  59603. * Block used to get the value of the first parameter raised to the power of the second
  59604. */
  59605. export class PowBlock extends NodeMaterialBlock {
  59606. /**
  59607. * Creates a new PowBlock
  59608. * @param name defines the block name
  59609. */
  59610. constructor(name: string);
  59611. /**
  59612. * Gets the current class name
  59613. * @returns the class name
  59614. */
  59615. getClassName(): string;
  59616. /**
  59617. * Gets the value operand input component
  59618. */
  59619. get value(): NodeMaterialConnectionPoint;
  59620. /**
  59621. * Gets the power operand input component
  59622. */
  59623. get power(): NodeMaterialConnectionPoint;
  59624. /**
  59625. * Gets the output component
  59626. */
  59627. get output(): NodeMaterialConnectionPoint;
  59628. protected _buildBlock(state: NodeMaterialBuildState): this;
  59629. }
  59630. }
  59631. declare module BABYLON {
  59632. /**
  59633. * Block used to get a random number
  59634. */
  59635. export class RandomNumberBlock extends NodeMaterialBlock {
  59636. /**
  59637. * Creates a new RandomNumberBlock
  59638. * @param name defines the block name
  59639. */
  59640. constructor(name: string);
  59641. /**
  59642. * Gets the current class name
  59643. * @returns the class name
  59644. */
  59645. getClassName(): string;
  59646. /**
  59647. * Gets the seed input component
  59648. */
  59649. get seed(): NodeMaterialConnectionPoint;
  59650. /**
  59651. * Gets the output component
  59652. */
  59653. get output(): NodeMaterialConnectionPoint;
  59654. protected _buildBlock(state: NodeMaterialBuildState): this;
  59655. }
  59656. }
  59657. declare module BABYLON {
  59658. /**
  59659. * Block used to compute arc tangent of 2 values
  59660. */
  59661. export class ArcTan2Block extends NodeMaterialBlock {
  59662. /**
  59663. * Creates a new ArcTan2Block
  59664. * @param name defines the block name
  59665. */
  59666. constructor(name: string);
  59667. /**
  59668. * Gets the current class name
  59669. * @returns the class name
  59670. */
  59671. getClassName(): string;
  59672. /**
  59673. * Gets the x operand input component
  59674. */
  59675. get x(): NodeMaterialConnectionPoint;
  59676. /**
  59677. * Gets the y operand input component
  59678. */
  59679. get y(): NodeMaterialConnectionPoint;
  59680. /**
  59681. * Gets the output component
  59682. */
  59683. get output(): NodeMaterialConnectionPoint;
  59684. protected _buildBlock(state: NodeMaterialBuildState): this;
  59685. }
  59686. }
  59687. declare module BABYLON {
  59688. /**
  59689. * Block used to smooth step a value
  59690. */
  59691. export class SmoothStepBlock extends NodeMaterialBlock {
  59692. /**
  59693. * Creates a new SmoothStepBlock
  59694. * @param name defines the block name
  59695. */
  59696. constructor(name: string);
  59697. /**
  59698. * Gets the current class name
  59699. * @returns the class name
  59700. */
  59701. getClassName(): string;
  59702. /**
  59703. * Gets the value operand input component
  59704. */
  59705. get value(): NodeMaterialConnectionPoint;
  59706. /**
  59707. * Gets the first edge operand input component
  59708. */
  59709. get edge0(): NodeMaterialConnectionPoint;
  59710. /**
  59711. * Gets the second edge operand input component
  59712. */
  59713. get edge1(): NodeMaterialConnectionPoint;
  59714. /**
  59715. * Gets the output component
  59716. */
  59717. get output(): NodeMaterialConnectionPoint;
  59718. protected _buildBlock(state: NodeMaterialBuildState): this;
  59719. }
  59720. }
  59721. declare module BABYLON {
  59722. /**
  59723. * Block used to get the reciprocal (1 / x) of a value
  59724. */
  59725. export class ReciprocalBlock extends NodeMaterialBlock {
  59726. /**
  59727. * Creates a new ReciprocalBlock
  59728. * @param name defines the block name
  59729. */
  59730. constructor(name: string);
  59731. /**
  59732. * Gets the current class name
  59733. * @returns the class name
  59734. */
  59735. getClassName(): string;
  59736. /**
  59737. * Gets the input component
  59738. */
  59739. get input(): NodeMaterialConnectionPoint;
  59740. /**
  59741. * Gets the output component
  59742. */
  59743. get output(): NodeMaterialConnectionPoint;
  59744. protected _buildBlock(state: NodeMaterialBuildState): this;
  59745. }
  59746. }
  59747. declare module BABYLON {
  59748. /**
  59749. * Block used to replace a color by another one
  59750. */
  59751. export class ReplaceColorBlock extends NodeMaterialBlock {
  59752. /**
  59753. * Creates a new ReplaceColorBlock
  59754. * @param name defines the block name
  59755. */
  59756. constructor(name: string);
  59757. /**
  59758. * Gets the current class name
  59759. * @returns the class name
  59760. */
  59761. getClassName(): string;
  59762. /**
  59763. * Gets the value input component
  59764. */
  59765. get value(): NodeMaterialConnectionPoint;
  59766. /**
  59767. * Gets the reference input component
  59768. */
  59769. get reference(): NodeMaterialConnectionPoint;
  59770. /**
  59771. * Gets the distance input component
  59772. */
  59773. get distance(): NodeMaterialConnectionPoint;
  59774. /**
  59775. * Gets the replacement input component
  59776. */
  59777. get replacement(): NodeMaterialConnectionPoint;
  59778. /**
  59779. * Gets the output component
  59780. */
  59781. get output(): NodeMaterialConnectionPoint;
  59782. protected _buildBlock(state: NodeMaterialBuildState): this;
  59783. }
  59784. }
  59785. declare module BABYLON {
  59786. /**
  59787. * Block used to posterize a value
  59788. * @see https://en.wikipedia.org/wiki/Posterization
  59789. */
  59790. export class PosterizeBlock extends NodeMaterialBlock {
  59791. /**
  59792. * Creates a new PosterizeBlock
  59793. * @param name defines the block name
  59794. */
  59795. constructor(name: string);
  59796. /**
  59797. * Gets the current class name
  59798. * @returns the class name
  59799. */
  59800. getClassName(): string;
  59801. /**
  59802. * Gets the value input component
  59803. */
  59804. get value(): NodeMaterialConnectionPoint;
  59805. /**
  59806. * Gets the steps input component
  59807. */
  59808. get steps(): NodeMaterialConnectionPoint;
  59809. /**
  59810. * Gets the output component
  59811. */
  59812. get output(): NodeMaterialConnectionPoint;
  59813. protected _buildBlock(state: NodeMaterialBuildState): this;
  59814. }
  59815. }
  59816. declare module BABYLON {
  59817. /**
  59818. * Operations supported by the Wave block
  59819. */
  59820. export enum WaveBlockKind {
  59821. /** SawTooth */
  59822. SawTooth = 0,
  59823. /** Square */
  59824. Square = 1,
  59825. /** Triangle */
  59826. Triangle = 2
  59827. }
  59828. /**
  59829. * Block used to apply wave operation to floats
  59830. */
  59831. export class WaveBlock extends NodeMaterialBlock {
  59832. /**
  59833. * Gets or sets the kibnd of wave to be applied by the block
  59834. */
  59835. kind: WaveBlockKind;
  59836. /**
  59837. * Creates a new WaveBlock
  59838. * @param name defines the block name
  59839. */
  59840. constructor(name: string);
  59841. /**
  59842. * Gets the current class name
  59843. * @returns the class name
  59844. */
  59845. getClassName(): string;
  59846. /**
  59847. * Gets the input component
  59848. */
  59849. get input(): NodeMaterialConnectionPoint;
  59850. /**
  59851. * Gets the output component
  59852. */
  59853. get output(): NodeMaterialConnectionPoint;
  59854. protected _buildBlock(state: NodeMaterialBuildState): this;
  59855. serialize(): any;
  59856. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59857. }
  59858. }
  59859. declare module BABYLON {
  59860. /**
  59861. * Class used to store a color step for the GradientBlock
  59862. */
  59863. export class GradientBlockColorStep {
  59864. /**
  59865. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59866. */
  59867. step: number;
  59868. /**
  59869. * Gets or sets the color associated with this step
  59870. */
  59871. color: Color3;
  59872. /**
  59873. * Creates a new GradientBlockColorStep
  59874. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  59875. * @param color defines the color associated with this step
  59876. */
  59877. constructor(
  59878. /**
  59879. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59880. */
  59881. step: number,
  59882. /**
  59883. * Gets or sets the color associated with this step
  59884. */
  59885. color: Color3);
  59886. }
  59887. /**
  59888. * Block used to return a color from a gradient based on an input value between 0 and 1
  59889. */
  59890. export class GradientBlock extends NodeMaterialBlock {
  59891. /**
  59892. * Gets or sets the list of color steps
  59893. */
  59894. colorSteps: GradientBlockColorStep[];
  59895. /**
  59896. * Creates a new GradientBlock
  59897. * @param name defines the block name
  59898. */
  59899. constructor(name: string);
  59900. /**
  59901. * Gets the current class name
  59902. * @returns the class name
  59903. */
  59904. getClassName(): string;
  59905. /**
  59906. * Gets the gradient input component
  59907. */
  59908. get gradient(): NodeMaterialConnectionPoint;
  59909. /**
  59910. * Gets the output component
  59911. */
  59912. get output(): NodeMaterialConnectionPoint;
  59913. private _writeColorConstant;
  59914. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59915. serialize(): any;
  59916. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59917. protected _dumpPropertiesCode(): string;
  59918. }
  59919. }
  59920. declare module BABYLON {
  59921. /**
  59922. * Block used to normalize lerp between 2 values
  59923. */
  59924. export class NLerpBlock extends NodeMaterialBlock {
  59925. /**
  59926. * Creates a new NLerpBlock
  59927. * @param name defines the block name
  59928. */
  59929. constructor(name: string);
  59930. /**
  59931. * Gets the current class name
  59932. * @returns the class name
  59933. */
  59934. getClassName(): string;
  59935. /**
  59936. * Gets the left operand input component
  59937. */
  59938. get left(): NodeMaterialConnectionPoint;
  59939. /**
  59940. * Gets the right operand input component
  59941. */
  59942. get right(): NodeMaterialConnectionPoint;
  59943. /**
  59944. * Gets the gradient operand input component
  59945. */
  59946. get gradient(): NodeMaterialConnectionPoint;
  59947. /**
  59948. * Gets the output component
  59949. */
  59950. get output(): NodeMaterialConnectionPoint;
  59951. protected _buildBlock(state: NodeMaterialBuildState): this;
  59952. }
  59953. }
  59954. declare module BABYLON {
  59955. /**
  59956. * block used to Generate a Worley Noise 3D Noise Pattern
  59957. */
  59958. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  59959. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  59960. manhattanDistance: boolean;
  59961. /**
  59962. * Creates a new WorleyNoise3DBlock
  59963. * @param name defines the block name
  59964. */
  59965. constructor(name: string);
  59966. /**
  59967. * Gets the current class name
  59968. * @returns the class name
  59969. */
  59970. getClassName(): string;
  59971. /**
  59972. * Gets the seed input component
  59973. */
  59974. get seed(): NodeMaterialConnectionPoint;
  59975. /**
  59976. * Gets the jitter input component
  59977. */
  59978. get jitter(): NodeMaterialConnectionPoint;
  59979. /**
  59980. * Gets the output component
  59981. */
  59982. get output(): NodeMaterialConnectionPoint;
  59983. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59984. /**
  59985. * Exposes the properties to the UI?
  59986. */
  59987. protected _dumpPropertiesCode(): string;
  59988. /**
  59989. * Exposes the properties to the Seralize?
  59990. */
  59991. serialize(): any;
  59992. /**
  59993. * Exposes the properties to the deseralize?
  59994. */
  59995. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59996. }
  59997. }
  59998. declare module BABYLON {
  59999. /**
  60000. * block used to Generate a Simplex Perlin 3d Noise Pattern
  60001. */
  60002. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  60003. /**
  60004. * Creates a new SimplexPerlin3DBlock
  60005. * @param name defines the block name
  60006. */
  60007. constructor(name: string);
  60008. /**
  60009. * Gets the current class name
  60010. * @returns the class name
  60011. */
  60012. getClassName(): string;
  60013. /**
  60014. * Gets the seed operand input component
  60015. */
  60016. get seed(): NodeMaterialConnectionPoint;
  60017. /**
  60018. * Gets the output component
  60019. */
  60020. get output(): NodeMaterialConnectionPoint;
  60021. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60022. }
  60023. }
  60024. declare module BABYLON {
  60025. /**
  60026. * Block used to blend normals
  60027. */
  60028. export class NormalBlendBlock extends NodeMaterialBlock {
  60029. /**
  60030. * Creates a new NormalBlendBlock
  60031. * @param name defines the block name
  60032. */
  60033. constructor(name: string);
  60034. /**
  60035. * Gets the current class name
  60036. * @returns the class name
  60037. */
  60038. getClassName(): string;
  60039. /**
  60040. * Gets the first input component
  60041. */
  60042. get normalMap0(): NodeMaterialConnectionPoint;
  60043. /**
  60044. * Gets the second input component
  60045. */
  60046. get normalMap1(): NodeMaterialConnectionPoint;
  60047. /**
  60048. * Gets the output component
  60049. */
  60050. get output(): NodeMaterialConnectionPoint;
  60051. protected _buildBlock(state: NodeMaterialBuildState): this;
  60052. }
  60053. }
  60054. declare module BABYLON {
  60055. /**
  60056. * Block used to rotate a 2d vector by a given angle
  60057. */
  60058. export class Rotate2dBlock extends NodeMaterialBlock {
  60059. /**
  60060. * Creates a new Rotate2dBlock
  60061. * @param name defines the block name
  60062. */
  60063. constructor(name: string);
  60064. /**
  60065. * Gets the current class name
  60066. * @returns the class name
  60067. */
  60068. getClassName(): string;
  60069. /**
  60070. * Gets the input vector
  60071. */
  60072. get input(): NodeMaterialConnectionPoint;
  60073. /**
  60074. * Gets the input angle
  60075. */
  60076. get angle(): NodeMaterialConnectionPoint;
  60077. /**
  60078. * Gets the output component
  60079. */
  60080. get output(): NodeMaterialConnectionPoint;
  60081. autoConfigure(material: NodeMaterial): void;
  60082. protected _buildBlock(state: NodeMaterialBuildState): this;
  60083. }
  60084. }
  60085. declare module BABYLON {
  60086. /**
  60087. * Block used to get the reflected vector from a direction and a normal
  60088. */
  60089. export class ReflectBlock extends NodeMaterialBlock {
  60090. /**
  60091. * Creates a new ReflectBlock
  60092. * @param name defines the block name
  60093. */
  60094. constructor(name: string);
  60095. /**
  60096. * Gets the current class name
  60097. * @returns the class name
  60098. */
  60099. getClassName(): string;
  60100. /**
  60101. * Gets the incident component
  60102. */
  60103. get incident(): NodeMaterialConnectionPoint;
  60104. /**
  60105. * Gets the normal component
  60106. */
  60107. get normal(): NodeMaterialConnectionPoint;
  60108. /**
  60109. * Gets the output component
  60110. */
  60111. get output(): NodeMaterialConnectionPoint;
  60112. protected _buildBlock(state: NodeMaterialBuildState): this;
  60113. }
  60114. }
  60115. declare module BABYLON {
  60116. /**
  60117. * Block used to get the refracted vector from a direction and a normal
  60118. */
  60119. export class RefractBlock extends NodeMaterialBlock {
  60120. /**
  60121. * Creates a new RefractBlock
  60122. * @param name defines the block name
  60123. */
  60124. constructor(name: string);
  60125. /**
  60126. * Gets the current class name
  60127. * @returns the class name
  60128. */
  60129. getClassName(): string;
  60130. /**
  60131. * Gets the incident component
  60132. */
  60133. get incident(): NodeMaterialConnectionPoint;
  60134. /**
  60135. * Gets the normal component
  60136. */
  60137. get normal(): NodeMaterialConnectionPoint;
  60138. /**
  60139. * Gets the index of refraction component
  60140. */
  60141. get ior(): NodeMaterialConnectionPoint;
  60142. /**
  60143. * Gets the output component
  60144. */
  60145. get output(): NodeMaterialConnectionPoint;
  60146. protected _buildBlock(state: NodeMaterialBuildState): this;
  60147. }
  60148. }
  60149. declare module BABYLON {
  60150. /**
  60151. * Block used to desaturate a color
  60152. */
  60153. export class DesaturateBlock extends NodeMaterialBlock {
  60154. /**
  60155. * Creates a new DesaturateBlock
  60156. * @param name defines the block name
  60157. */
  60158. constructor(name: string);
  60159. /**
  60160. * Gets the current class name
  60161. * @returns the class name
  60162. */
  60163. getClassName(): string;
  60164. /**
  60165. * Gets the color operand input component
  60166. */
  60167. get color(): NodeMaterialConnectionPoint;
  60168. /**
  60169. * Gets the level operand input component
  60170. */
  60171. get level(): NodeMaterialConnectionPoint;
  60172. /**
  60173. * Gets the output component
  60174. */
  60175. get output(): NodeMaterialConnectionPoint;
  60176. protected _buildBlock(state: NodeMaterialBuildState): this;
  60177. }
  60178. }
  60179. declare module BABYLON {
  60180. /**
  60181. * Effect Render Options
  60182. */
  60183. export interface IEffectRendererOptions {
  60184. /**
  60185. * Defines the vertices positions.
  60186. */
  60187. positions?: number[];
  60188. /**
  60189. * Defines the indices.
  60190. */
  60191. indices?: number[];
  60192. }
  60193. /**
  60194. * Helper class to render one or more effects
  60195. */
  60196. export class EffectRenderer {
  60197. private engine;
  60198. private static _DefaultOptions;
  60199. private _vertexBuffers;
  60200. private _indexBuffer;
  60201. private _ringBufferIndex;
  60202. private _ringScreenBuffer;
  60203. private _fullscreenViewport;
  60204. private _getNextFrameBuffer;
  60205. /**
  60206. * Creates an effect renderer
  60207. * @param engine the engine to use for rendering
  60208. * @param options defines the options of the effect renderer
  60209. */
  60210. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  60211. /**
  60212. * Sets the current viewport in normalized coordinates 0-1
  60213. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  60214. */
  60215. setViewport(viewport?: Viewport): void;
  60216. /**
  60217. * Binds the embedded attributes buffer to the effect.
  60218. * @param effect Defines the effect to bind the attributes for
  60219. */
  60220. bindBuffers(effect: Effect): void;
  60221. /**
  60222. * Sets the current effect wrapper to use during draw.
  60223. * The effect needs to be ready before calling this api.
  60224. * This also sets the default full screen position attribute.
  60225. * @param effectWrapper Defines the effect to draw with
  60226. */
  60227. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  60228. /**
  60229. * Draws a full screen quad.
  60230. */
  60231. draw(): void;
  60232. /**
  60233. * renders one or more effects to a specified texture
  60234. * @param effectWrappers list of effects to renderer
  60235. * @param outputTexture texture to draw to, if null it will render to the screen
  60236. */
  60237. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  60238. /**
  60239. * Disposes of the effect renderer
  60240. */
  60241. dispose(): void;
  60242. }
  60243. /**
  60244. * Options to create an EffectWrapper
  60245. */
  60246. interface EffectWrapperCreationOptions {
  60247. /**
  60248. * Engine to use to create the effect
  60249. */
  60250. engine: ThinEngine;
  60251. /**
  60252. * Fragment shader for the effect
  60253. */
  60254. fragmentShader: string;
  60255. /**
  60256. * Vertex shader for the effect
  60257. */
  60258. vertexShader?: string;
  60259. /**
  60260. * Attributes to use in the shader
  60261. */
  60262. attributeNames?: Array<string>;
  60263. /**
  60264. * Uniforms to use in the shader
  60265. */
  60266. uniformNames?: Array<string>;
  60267. /**
  60268. * Texture sampler names to use in the shader
  60269. */
  60270. samplerNames?: Array<string>;
  60271. /**
  60272. * The friendly name of the effect displayed in Spector.
  60273. */
  60274. name?: string;
  60275. }
  60276. /**
  60277. * Wraps an effect to be used for rendering
  60278. */
  60279. export class EffectWrapper {
  60280. /**
  60281. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  60282. */
  60283. onApplyObservable: Observable<{}>;
  60284. /**
  60285. * The underlying effect
  60286. */
  60287. effect: Effect;
  60288. /**
  60289. * Creates an effect to be renderer
  60290. * @param creationOptions options to create the effect
  60291. */
  60292. constructor(creationOptions: EffectWrapperCreationOptions);
  60293. /**
  60294. * Disposes of the effect wrapper
  60295. */
  60296. dispose(): void;
  60297. }
  60298. }
  60299. declare module BABYLON {
  60300. /**
  60301. * Helper class to push actions to a pool of workers.
  60302. */
  60303. export class WorkerPool implements IDisposable {
  60304. private _workerInfos;
  60305. private _pendingActions;
  60306. /**
  60307. * Constructor
  60308. * @param workers Array of workers to use for actions
  60309. */
  60310. constructor(workers: Array<Worker>);
  60311. /**
  60312. * Terminates all workers and clears any pending actions.
  60313. */
  60314. dispose(): void;
  60315. /**
  60316. * Pushes an action to the worker pool. If all the workers are active, the action will be
  60317. * pended until a worker has completed its action.
  60318. * @param action The action to perform. Call onComplete when the action is complete.
  60319. */
  60320. push(action: (worker: Worker, onComplete: () => void) => void): void;
  60321. private _execute;
  60322. }
  60323. }
  60324. declare module BABYLON {
  60325. /**
  60326. * Configuration for Draco compression
  60327. */
  60328. export interface IDracoCompressionConfiguration {
  60329. /**
  60330. * Configuration for the decoder.
  60331. */
  60332. decoder: {
  60333. /**
  60334. * The url to the WebAssembly module.
  60335. */
  60336. wasmUrl?: string;
  60337. /**
  60338. * The url to the WebAssembly binary.
  60339. */
  60340. wasmBinaryUrl?: string;
  60341. /**
  60342. * The url to the fallback JavaScript module.
  60343. */
  60344. fallbackUrl?: string;
  60345. };
  60346. }
  60347. /**
  60348. * Draco compression (https://google.github.io/draco/)
  60349. *
  60350. * This class wraps the Draco module.
  60351. *
  60352. * **Encoder**
  60353. *
  60354. * The encoder is not currently implemented.
  60355. *
  60356. * **Decoder**
  60357. *
  60358. * 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.
  60359. *
  60360. * To update the configuration, use the following code:
  60361. * ```javascript
  60362. * DracoCompression.Configuration = {
  60363. * decoder: {
  60364. * wasmUrl: "<url to the WebAssembly library>",
  60365. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  60366. * fallbackUrl: "<url to the fallback JavaScript library>",
  60367. * }
  60368. * };
  60369. * ```
  60370. *
  60371. * 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.
  60372. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  60373. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  60374. *
  60375. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  60376. * ```javascript
  60377. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  60378. * ```
  60379. *
  60380. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  60381. */
  60382. export class DracoCompression implements IDisposable {
  60383. private _workerPoolPromise?;
  60384. private _decoderModulePromise?;
  60385. /**
  60386. * The configuration. Defaults to the following urls:
  60387. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  60388. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  60389. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  60390. */
  60391. static Configuration: IDracoCompressionConfiguration;
  60392. /**
  60393. * Returns true if the decoder configuration is available.
  60394. */
  60395. static get DecoderAvailable(): boolean;
  60396. /**
  60397. * Default number of workers to create when creating the draco compression object.
  60398. */
  60399. static DefaultNumWorkers: number;
  60400. private static GetDefaultNumWorkers;
  60401. private static _Default;
  60402. /**
  60403. * Default instance for the draco compression object.
  60404. */
  60405. static get Default(): DracoCompression;
  60406. /**
  60407. * Constructor
  60408. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  60409. */
  60410. constructor(numWorkers?: number);
  60411. /**
  60412. * Stop all async operations and release resources.
  60413. */
  60414. dispose(): void;
  60415. /**
  60416. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  60417. * @returns a promise that resolves when ready
  60418. */
  60419. whenReadyAsync(): Promise<void>;
  60420. /**
  60421. * Decode Draco compressed mesh data to vertex data.
  60422. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  60423. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  60424. * @returns A promise that resolves with the decoded vertex data
  60425. */
  60426. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  60427. [kind: string]: number;
  60428. }): Promise<VertexData>;
  60429. }
  60430. }
  60431. declare module BABYLON {
  60432. /**
  60433. * Class for building Constructive Solid Geometry
  60434. */
  60435. export class CSG {
  60436. private polygons;
  60437. /**
  60438. * The world matrix
  60439. */
  60440. matrix: Matrix;
  60441. /**
  60442. * Stores the position
  60443. */
  60444. position: Vector3;
  60445. /**
  60446. * Stores the rotation
  60447. */
  60448. rotation: Vector3;
  60449. /**
  60450. * Stores the rotation quaternion
  60451. */
  60452. rotationQuaternion: Nullable<Quaternion>;
  60453. /**
  60454. * Stores the scaling vector
  60455. */
  60456. scaling: Vector3;
  60457. /**
  60458. * Convert the Mesh to CSG
  60459. * @param mesh The Mesh to convert to CSG
  60460. * @returns A new CSG from the Mesh
  60461. */
  60462. static FromMesh(mesh: Mesh): CSG;
  60463. /**
  60464. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  60465. * @param polygons Polygons used to construct a CSG solid
  60466. */
  60467. private static FromPolygons;
  60468. /**
  60469. * Clones, or makes a deep copy, of the CSG
  60470. * @returns A new CSG
  60471. */
  60472. clone(): CSG;
  60473. /**
  60474. * Unions this CSG with another CSG
  60475. * @param csg The CSG to union against this CSG
  60476. * @returns The unioned CSG
  60477. */
  60478. union(csg: CSG): CSG;
  60479. /**
  60480. * Unions this CSG with another CSG in place
  60481. * @param csg The CSG to union against this CSG
  60482. */
  60483. unionInPlace(csg: CSG): void;
  60484. /**
  60485. * Subtracts this CSG with another CSG
  60486. * @param csg The CSG to subtract against this CSG
  60487. * @returns A new CSG
  60488. */
  60489. subtract(csg: CSG): CSG;
  60490. /**
  60491. * Subtracts this CSG with another CSG in place
  60492. * @param csg The CSG to subtact against this CSG
  60493. */
  60494. subtractInPlace(csg: CSG): void;
  60495. /**
  60496. * Intersect this CSG with another CSG
  60497. * @param csg The CSG to intersect against this CSG
  60498. * @returns A new CSG
  60499. */
  60500. intersect(csg: CSG): CSG;
  60501. /**
  60502. * Intersects this CSG with another CSG in place
  60503. * @param csg The CSG to intersect against this CSG
  60504. */
  60505. intersectInPlace(csg: CSG): void;
  60506. /**
  60507. * Return a new CSG solid with solid and empty space switched. This solid is
  60508. * not modified.
  60509. * @returns A new CSG solid with solid and empty space switched
  60510. */
  60511. inverse(): CSG;
  60512. /**
  60513. * Inverses the CSG in place
  60514. */
  60515. inverseInPlace(): void;
  60516. /**
  60517. * This is used to keep meshes transformations so they can be restored
  60518. * when we build back a Babylon Mesh
  60519. * NB : All CSG operations are performed in world coordinates
  60520. * @param csg The CSG to copy the transform attributes from
  60521. * @returns This CSG
  60522. */
  60523. copyTransformAttributes(csg: CSG): CSG;
  60524. /**
  60525. * Build Raw mesh from CSG
  60526. * Coordinates here are in world space
  60527. * @param name The name of the mesh geometry
  60528. * @param scene The Scene
  60529. * @param keepSubMeshes Specifies if the submeshes should be kept
  60530. * @returns A new Mesh
  60531. */
  60532. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  60533. /**
  60534. * Build Mesh from CSG taking material and transforms into account
  60535. * @param name The name of the Mesh
  60536. * @param material The material of the Mesh
  60537. * @param scene The Scene
  60538. * @param keepSubMeshes Specifies if submeshes should be kept
  60539. * @returns The new Mesh
  60540. */
  60541. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  60542. }
  60543. }
  60544. declare module BABYLON {
  60545. /**
  60546. * Class used to create a trail following a mesh
  60547. */
  60548. export class TrailMesh extends Mesh {
  60549. private _generator;
  60550. private _autoStart;
  60551. private _running;
  60552. private _diameter;
  60553. private _length;
  60554. private _sectionPolygonPointsCount;
  60555. private _sectionVectors;
  60556. private _sectionNormalVectors;
  60557. private _beforeRenderObserver;
  60558. /**
  60559. * @constructor
  60560. * @param name The value used by scene.getMeshByName() to do a lookup.
  60561. * @param generator The mesh to generate a trail.
  60562. * @param scene The scene to add this mesh to.
  60563. * @param diameter Diameter of trailing mesh. Default is 1.
  60564. * @param length Length of trailing mesh. Default is 60.
  60565. * @param autoStart Automatically start trailing mesh. Default true.
  60566. */
  60567. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  60568. /**
  60569. * "TrailMesh"
  60570. * @returns "TrailMesh"
  60571. */
  60572. getClassName(): string;
  60573. private _createMesh;
  60574. /**
  60575. * Start trailing mesh.
  60576. */
  60577. start(): void;
  60578. /**
  60579. * Stop trailing mesh.
  60580. */
  60581. stop(): void;
  60582. /**
  60583. * Update trailing mesh geometry.
  60584. */
  60585. update(): void;
  60586. /**
  60587. * Returns a new TrailMesh object.
  60588. * @param name is a string, the name given to the new mesh
  60589. * @param newGenerator use new generator object for cloned trail mesh
  60590. * @returns a new mesh
  60591. */
  60592. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  60593. /**
  60594. * Serializes this trail mesh
  60595. * @param serializationObject object to write serialization to
  60596. */
  60597. serialize(serializationObject: any): void;
  60598. /**
  60599. * Parses a serialized trail mesh
  60600. * @param parsedMesh the serialized mesh
  60601. * @param scene the scene to create the trail mesh in
  60602. * @returns the created trail mesh
  60603. */
  60604. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  60605. }
  60606. }
  60607. declare module BABYLON {
  60608. /**
  60609. * Class containing static functions to help procedurally build meshes
  60610. */
  60611. export class TiledBoxBuilder {
  60612. /**
  60613. * Creates a box mesh
  60614. * 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)
  60615. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60616. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60617. * * 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
  60618. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60619. * @param name defines the name of the mesh
  60620. * @param options defines the options used to create the mesh
  60621. * @param scene defines the hosting scene
  60622. * @returns the box mesh
  60623. */
  60624. static CreateTiledBox(name: string, options: {
  60625. pattern?: number;
  60626. width?: number;
  60627. height?: number;
  60628. depth?: number;
  60629. tileSize?: number;
  60630. tileWidth?: number;
  60631. tileHeight?: number;
  60632. alignHorizontal?: number;
  60633. alignVertical?: number;
  60634. faceUV?: Vector4[];
  60635. faceColors?: Color4[];
  60636. sideOrientation?: number;
  60637. updatable?: boolean;
  60638. }, scene?: Nullable<Scene>): Mesh;
  60639. }
  60640. }
  60641. declare module BABYLON {
  60642. /**
  60643. * Class containing static functions to help procedurally build meshes
  60644. */
  60645. export class TorusKnotBuilder {
  60646. /**
  60647. * Creates a torus knot mesh
  60648. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  60649. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  60650. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  60651. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  60652. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60653. * * 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
  60654. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60655. * @param name defines the name of the mesh
  60656. * @param options defines the options used to create the mesh
  60657. * @param scene defines the hosting scene
  60658. * @returns the torus knot mesh
  60659. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  60660. */
  60661. static CreateTorusKnot(name: string, options: {
  60662. radius?: number;
  60663. tube?: number;
  60664. radialSegments?: number;
  60665. tubularSegments?: number;
  60666. p?: number;
  60667. q?: number;
  60668. updatable?: boolean;
  60669. sideOrientation?: number;
  60670. frontUVs?: Vector4;
  60671. backUVs?: Vector4;
  60672. }, scene: any): Mesh;
  60673. }
  60674. }
  60675. declare module BABYLON {
  60676. /**
  60677. * Polygon
  60678. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  60679. */
  60680. export class Polygon {
  60681. /**
  60682. * Creates a rectangle
  60683. * @param xmin bottom X coord
  60684. * @param ymin bottom Y coord
  60685. * @param xmax top X coord
  60686. * @param ymax top Y coord
  60687. * @returns points that make the resulting rectation
  60688. */
  60689. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  60690. /**
  60691. * Creates a circle
  60692. * @param radius radius of circle
  60693. * @param cx scale in x
  60694. * @param cy scale in y
  60695. * @param numberOfSides number of sides that make up the circle
  60696. * @returns points that make the resulting circle
  60697. */
  60698. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  60699. /**
  60700. * Creates a polygon from input string
  60701. * @param input Input polygon data
  60702. * @returns the parsed points
  60703. */
  60704. static Parse(input: string): Vector2[];
  60705. /**
  60706. * Starts building a polygon from x and y coordinates
  60707. * @param x x coordinate
  60708. * @param y y coordinate
  60709. * @returns the started path2
  60710. */
  60711. static StartingAt(x: number, y: number): Path2;
  60712. }
  60713. /**
  60714. * Builds a polygon
  60715. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  60716. */
  60717. export class PolygonMeshBuilder {
  60718. private _points;
  60719. private _outlinepoints;
  60720. private _holes;
  60721. private _name;
  60722. private _scene;
  60723. private _epoints;
  60724. private _eholes;
  60725. private _addToepoint;
  60726. /**
  60727. * Babylon reference to the earcut plugin.
  60728. */
  60729. bjsEarcut: any;
  60730. /**
  60731. * Creates a PolygonMeshBuilder
  60732. * @param name name of the builder
  60733. * @param contours Path of the polygon
  60734. * @param scene scene to add to when creating the mesh
  60735. * @param earcutInjection can be used to inject your own earcut reference
  60736. */
  60737. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  60738. /**
  60739. * Adds a whole within the polygon
  60740. * @param hole Array of points defining the hole
  60741. * @returns this
  60742. */
  60743. addHole(hole: Vector2[]): PolygonMeshBuilder;
  60744. /**
  60745. * Creates the polygon
  60746. * @param updatable If the mesh should be updatable
  60747. * @param depth The depth of the mesh created
  60748. * @returns the created mesh
  60749. */
  60750. build(updatable?: boolean, depth?: number): Mesh;
  60751. /**
  60752. * Creates the polygon
  60753. * @param depth The depth of the mesh created
  60754. * @returns the created VertexData
  60755. */
  60756. buildVertexData(depth?: number): VertexData;
  60757. /**
  60758. * Adds a side to the polygon
  60759. * @param positions points that make the polygon
  60760. * @param normals normals of the polygon
  60761. * @param uvs uvs of the polygon
  60762. * @param indices indices of the polygon
  60763. * @param bounds bounds of the polygon
  60764. * @param points points of the polygon
  60765. * @param depth depth of the polygon
  60766. * @param flip flip of the polygon
  60767. */
  60768. private addSide;
  60769. }
  60770. }
  60771. declare module BABYLON {
  60772. /**
  60773. * Class containing static functions to help procedurally build meshes
  60774. */
  60775. export class PolygonBuilder {
  60776. /**
  60777. * Creates a polygon mesh
  60778. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  60779. * * 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
  60780. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60781. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60782. * * 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)
  60783. * * Remember you can only change the shape positions, not their number when updating a polygon
  60784. * @param name defines the name of the mesh
  60785. * @param options defines the options used to create the mesh
  60786. * @param scene defines the hosting scene
  60787. * @param earcutInjection can be used to inject your own earcut reference
  60788. * @returns the polygon mesh
  60789. */
  60790. static CreatePolygon(name: string, options: {
  60791. shape: Vector3[];
  60792. holes?: Vector3[][];
  60793. depth?: number;
  60794. faceUV?: Vector4[];
  60795. faceColors?: Color4[];
  60796. updatable?: boolean;
  60797. sideOrientation?: number;
  60798. frontUVs?: Vector4;
  60799. backUVs?: Vector4;
  60800. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60801. /**
  60802. * Creates an extruded polygon mesh, with depth in the Y direction.
  60803. * * 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)
  60804. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60805. * @param name defines the name of the mesh
  60806. * @param options defines the options used to create the mesh
  60807. * @param scene defines the hosting scene
  60808. * @param earcutInjection can be used to inject your own earcut reference
  60809. * @returns the polygon mesh
  60810. */
  60811. static ExtrudePolygon(name: string, options: {
  60812. shape: Vector3[];
  60813. holes?: Vector3[][];
  60814. depth?: number;
  60815. faceUV?: Vector4[];
  60816. faceColors?: Color4[];
  60817. updatable?: boolean;
  60818. sideOrientation?: number;
  60819. frontUVs?: Vector4;
  60820. backUVs?: Vector4;
  60821. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60822. }
  60823. }
  60824. declare module BABYLON {
  60825. /**
  60826. * Class containing static functions to help procedurally build meshes
  60827. */
  60828. export class LatheBuilder {
  60829. /**
  60830. * Creates lathe mesh.
  60831. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  60832. * * 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
  60833. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  60834. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  60835. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  60836. * * 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
  60837. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  60838. * * 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
  60839. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60840. * * 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
  60841. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60842. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60843. * @param name defines the name of the mesh
  60844. * @param options defines the options used to create the mesh
  60845. * @param scene defines the hosting scene
  60846. * @returns the lathe mesh
  60847. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  60848. */
  60849. static CreateLathe(name: string, options: {
  60850. shape: Vector3[];
  60851. radius?: number;
  60852. tessellation?: number;
  60853. clip?: number;
  60854. arc?: number;
  60855. closed?: boolean;
  60856. updatable?: boolean;
  60857. sideOrientation?: number;
  60858. frontUVs?: Vector4;
  60859. backUVs?: Vector4;
  60860. cap?: number;
  60861. invertUV?: boolean;
  60862. }, scene?: Nullable<Scene>): Mesh;
  60863. }
  60864. }
  60865. declare module BABYLON {
  60866. /**
  60867. * Class containing static functions to help procedurally build meshes
  60868. */
  60869. export class TiledPlaneBuilder {
  60870. /**
  60871. * Creates a tiled plane mesh
  60872. * * The parameter `pattern` will, depending on value, do nothing or
  60873. * * * flip (reflect about central vertical) alternate tiles across and up
  60874. * * * flip every tile on alternate rows
  60875. * * * rotate (180 degs) alternate tiles across and up
  60876. * * * rotate every tile on alternate rows
  60877. * * * flip and rotate alternate tiles across and up
  60878. * * * flip and rotate every tile on alternate rows
  60879. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  60880. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  60881. * * 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
  60882. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60883. * * 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)
  60884. * * 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)
  60885. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  60886. * @param name defines the name of the mesh
  60887. * @param options defines the options used to create the mesh
  60888. * @param scene defines the hosting scene
  60889. * @returns the box mesh
  60890. */
  60891. static CreateTiledPlane(name: string, options: {
  60892. pattern?: number;
  60893. tileSize?: number;
  60894. tileWidth?: number;
  60895. tileHeight?: number;
  60896. size?: number;
  60897. width?: number;
  60898. height?: number;
  60899. alignHorizontal?: number;
  60900. alignVertical?: number;
  60901. sideOrientation?: number;
  60902. frontUVs?: Vector4;
  60903. backUVs?: Vector4;
  60904. updatable?: boolean;
  60905. }, scene?: Nullable<Scene>): Mesh;
  60906. }
  60907. }
  60908. declare module BABYLON {
  60909. /**
  60910. * Class containing static functions to help procedurally build meshes
  60911. */
  60912. export class TubeBuilder {
  60913. /**
  60914. * Creates a tube mesh.
  60915. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60916. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  60917. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  60918. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  60919. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  60920. * * 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)
  60921. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  60922. * * 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
  60923. * * 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
  60924. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60925. * * 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
  60926. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60927. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60928. * @param name defines the name of the mesh
  60929. * @param options defines the options used to create the mesh
  60930. * @param scene defines the hosting scene
  60931. * @returns the tube mesh
  60932. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60933. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  60934. */
  60935. static CreateTube(name: string, options: {
  60936. path: Vector3[];
  60937. radius?: number;
  60938. tessellation?: number;
  60939. radiusFunction?: {
  60940. (i: number, distance: number): number;
  60941. };
  60942. cap?: number;
  60943. arc?: number;
  60944. updatable?: boolean;
  60945. sideOrientation?: number;
  60946. frontUVs?: Vector4;
  60947. backUVs?: Vector4;
  60948. instance?: Mesh;
  60949. invertUV?: boolean;
  60950. }, scene?: Nullable<Scene>): Mesh;
  60951. }
  60952. }
  60953. declare module BABYLON {
  60954. /**
  60955. * Class containing static functions to help procedurally build meshes
  60956. */
  60957. export class IcoSphereBuilder {
  60958. /**
  60959. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  60960. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  60961. * * 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`)
  60962. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  60963. * * 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
  60964. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60965. * * 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
  60966. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60967. * @param name defines the name of the mesh
  60968. * @param options defines the options used to create the mesh
  60969. * @param scene defines the hosting scene
  60970. * @returns the icosahedron mesh
  60971. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  60972. */
  60973. static CreateIcoSphere(name: string, options: {
  60974. radius?: number;
  60975. radiusX?: number;
  60976. radiusY?: number;
  60977. radiusZ?: number;
  60978. flat?: boolean;
  60979. subdivisions?: number;
  60980. sideOrientation?: number;
  60981. frontUVs?: Vector4;
  60982. backUVs?: Vector4;
  60983. updatable?: boolean;
  60984. }, scene?: Nullable<Scene>): Mesh;
  60985. }
  60986. }
  60987. declare module BABYLON {
  60988. /**
  60989. * Class containing static functions to help procedurally build meshes
  60990. */
  60991. export class DecalBuilder {
  60992. /**
  60993. * Creates a decal mesh.
  60994. * 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
  60995. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  60996. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  60997. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  60998. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  60999. * @param name defines the name of the mesh
  61000. * @param sourceMesh defines the mesh where the decal must be applied
  61001. * @param options defines the options used to create the mesh
  61002. * @param scene defines the hosting scene
  61003. * @returns the decal mesh
  61004. * @see https://doc.babylonjs.com/how_to/decals
  61005. */
  61006. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  61007. position?: Vector3;
  61008. normal?: Vector3;
  61009. size?: Vector3;
  61010. angle?: number;
  61011. }): Mesh;
  61012. }
  61013. }
  61014. declare module BABYLON {
  61015. /**
  61016. * Class containing static functions to help procedurally build meshes
  61017. */
  61018. export class MeshBuilder {
  61019. /**
  61020. * Creates a box mesh
  61021. * * The parameter `size` sets the size (float) of each box side (default 1)
  61022. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  61023. * * 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)
  61024. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61025. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61026. * * 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
  61027. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61028. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  61029. * @param name defines the name of the mesh
  61030. * @param options defines the options used to create the mesh
  61031. * @param scene defines the hosting scene
  61032. * @returns the box mesh
  61033. */
  61034. static CreateBox(name: string, options: {
  61035. size?: number;
  61036. width?: number;
  61037. height?: number;
  61038. depth?: number;
  61039. faceUV?: Vector4[];
  61040. faceColors?: Color4[];
  61041. sideOrientation?: number;
  61042. frontUVs?: Vector4;
  61043. backUVs?: Vector4;
  61044. updatable?: boolean;
  61045. }, scene?: Nullable<Scene>): Mesh;
  61046. /**
  61047. * Creates a tiled box mesh
  61048. * * faceTiles sets the pattern, tile size and number of tiles for a face
  61049. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61050. * @param name defines the name of the mesh
  61051. * @param options defines the options used to create the mesh
  61052. * @param scene defines the hosting scene
  61053. * @returns the tiled box mesh
  61054. */
  61055. static CreateTiledBox(name: string, options: {
  61056. pattern?: number;
  61057. size?: number;
  61058. width?: number;
  61059. height?: number;
  61060. depth: number;
  61061. tileSize?: number;
  61062. tileWidth?: number;
  61063. tileHeight?: number;
  61064. faceUV?: Vector4[];
  61065. faceColors?: Color4[];
  61066. alignHorizontal?: number;
  61067. alignVertical?: number;
  61068. sideOrientation?: number;
  61069. updatable?: boolean;
  61070. }, scene?: Nullable<Scene>): Mesh;
  61071. /**
  61072. * Creates a sphere mesh
  61073. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  61074. * * 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`)
  61075. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  61076. * * 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
  61077. * * 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)
  61078. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61079. * * 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
  61080. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61081. * @param name defines the name of the mesh
  61082. * @param options defines the options used to create the mesh
  61083. * @param scene defines the hosting scene
  61084. * @returns the sphere mesh
  61085. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  61086. */
  61087. static CreateSphere(name: string, options: {
  61088. segments?: number;
  61089. diameter?: number;
  61090. diameterX?: number;
  61091. diameterY?: number;
  61092. diameterZ?: number;
  61093. arc?: number;
  61094. slice?: number;
  61095. sideOrientation?: number;
  61096. frontUVs?: Vector4;
  61097. backUVs?: Vector4;
  61098. updatable?: boolean;
  61099. }, scene?: Nullable<Scene>): Mesh;
  61100. /**
  61101. * Creates a plane polygonal mesh. By default, this is a disc
  61102. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  61103. * * 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
  61104. * * 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
  61105. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61106. * * 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
  61107. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61108. * @param name defines the name of the mesh
  61109. * @param options defines the options used to create the mesh
  61110. * @param scene defines the hosting scene
  61111. * @returns the plane polygonal mesh
  61112. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  61113. */
  61114. static CreateDisc(name: string, options: {
  61115. radius?: number;
  61116. tessellation?: number;
  61117. arc?: number;
  61118. updatable?: boolean;
  61119. sideOrientation?: number;
  61120. frontUVs?: Vector4;
  61121. backUVs?: Vector4;
  61122. }, scene?: Nullable<Scene>): Mesh;
  61123. /**
  61124. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61125. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61126. * * 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`)
  61127. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61128. * * 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
  61129. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61130. * * 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
  61131. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61132. * @param name defines the name of the mesh
  61133. * @param options defines the options used to create the mesh
  61134. * @param scene defines the hosting scene
  61135. * @returns the icosahedron mesh
  61136. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61137. */
  61138. static CreateIcoSphere(name: string, options: {
  61139. radius?: number;
  61140. radiusX?: number;
  61141. radiusY?: number;
  61142. radiusZ?: number;
  61143. flat?: boolean;
  61144. subdivisions?: number;
  61145. sideOrientation?: number;
  61146. frontUVs?: Vector4;
  61147. backUVs?: Vector4;
  61148. updatable?: boolean;
  61149. }, scene?: Nullable<Scene>): Mesh;
  61150. /**
  61151. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61152. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  61153. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  61154. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  61155. * * 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
  61156. * * 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
  61157. * * 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
  61158. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61159. * * 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
  61160. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61161. * * 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
  61162. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  61163. * * 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
  61164. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  61165. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61166. * @param name defines the name of the mesh
  61167. * @param options defines the options used to create the mesh
  61168. * @param scene defines the hosting scene
  61169. * @returns the ribbon mesh
  61170. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  61171. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61172. */
  61173. static CreateRibbon(name: string, options: {
  61174. pathArray: Vector3[][];
  61175. closeArray?: boolean;
  61176. closePath?: boolean;
  61177. offset?: number;
  61178. updatable?: boolean;
  61179. sideOrientation?: number;
  61180. frontUVs?: Vector4;
  61181. backUVs?: Vector4;
  61182. instance?: Mesh;
  61183. invertUV?: boolean;
  61184. uvs?: Vector2[];
  61185. colors?: Color4[];
  61186. }, scene?: Nullable<Scene>): Mesh;
  61187. /**
  61188. * Creates a cylinder or a cone mesh
  61189. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  61190. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  61191. * * 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.
  61192. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  61193. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  61194. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  61195. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  61196. * * 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).
  61197. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  61198. * * 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).
  61199. * * 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
  61200. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  61201. * * 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
  61202. * * 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.
  61203. * * If `enclose` is false, a ring surface is one element.
  61204. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  61205. * * 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
  61206. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61207. * * 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
  61208. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61209. * @param name defines the name of the mesh
  61210. * @param options defines the options used to create the mesh
  61211. * @param scene defines the hosting scene
  61212. * @returns the cylinder mesh
  61213. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  61214. */
  61215. static CreateCylinder(name: string, options: {
  61216. height?: number;
  61217. diameterTop?: number;
  61218. diameterBottom?: number;
  61219. diameter?: number;
  61220. tessellation?: number;
  61221. subdivisions?: number;
  61222. arc?: number;
  61223. faceColors?: Color4[];
  61224. faceUV?: Vector4[];
  61225. updatable?: boolean;
  61226. hasRings?: boolean;
  61227. enclose?: boolean;
  61228. cap?: number;
  61229. sideOrientation?: number;
  61230. frontUVs?: Vector4;
  61231. backUVs?: Vector4;
  61232. }, scene?: Nullable<Scene>): Mesh;
  61233. /**
  61234. * Creates a torus mesh
  61235. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  61236. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  61237. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  61238. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61239. * * 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
  61240. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61241. * @param name defines the name of the mesh
  61242. * @param options defines the options used to create the mesh
  61243. * @param scene defines the hosting scene
  61244. * @returns the torus mesh
  61245. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  61246. */
  61247. static CreateTorus(name: string, options: {
  61248. diameter?: number;
  61249. thickness?: number;
  61250. tessellation?: number;
  61251. updatable?: boolean;
  61252. sideOrientation?: number;
  61253. frontUVs?: Vector4;
  61254. backUVs?: Vector4;
  61255. }, scene?: Nullable<Scene>): Mesh;
  61256. /**
  61257. * Creates a torus knot mesh
  61258. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61259. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61260. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61261. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61262. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61263. * * 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
  61264. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61265. * @param name defines the name of the mesh
  61266. * @param options defines the options used to create the mesh
  61267. * @param scene defines the hosting scene
  61268. * @returns the torus knot mesh
  61269. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61270. */
  61271. static CreateTorusKnot(name: string, options: {
  61272. radius?: number;
  61273. tube?: number;
  61274. radialSegments?: number;
  61275. tubularSegments?: number;
  61276. p?: number;
  61277. q?: number;
  61278. updatable?: boolean;
  61279. sideOrientation?: number;
  61280. frontUVs?: Vector4;
  61281. backUVs?: Vector4;
  61282. }, scene?: Nullable<Scene>): Mesh;
  61283. /**
  61284. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  61285. * * 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
  61286. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  61287. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  61288. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  61289. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  61290. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  61291. * * 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
  61292. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  61293. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61294. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  61295. * @param name defines the name of the new line system
  61296. * @param options defines the options used to create the line system
  61297. * @param scene defines the hosting scene
  61298. * @returns a new line system mesh
  61299. */
  61300. static CreateLineSystem(name: string, options: {
  61301. lines: Vector3[][];
  61302. updatable?: boolean;
  61303. instance?: Nullable<LinesMesh>;
  61304. colors?: Nullable<Color4[][]>;
  61305. useVertexAlpha?: boolean;
  61306. }, scene: Nullable<Scene>): LinesMesh;
  61307. /**
  61308. * Creates a line mesh
  61309. * 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
  61310. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61311. * * The parameter `points` is an array successive Vector3
  61312. * * 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
  61313. * * The optional parameter `colors` is an array of successive Color4, one per line point
  61314. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  61315. * * When updating an instance, remember that only point positions can change, not the number of points
  61316. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61317. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  61318. * @param name defines the name of the new line system
  61319. * @param options defines the options used to create the line system
  61320. * @param scene defines the hosting scene
  61321. * @returns a new line mesh
  61322. */
  61323. static CreateLines(name: string, options: {
  61324. points: Vector3[];
  61325. updatable?: boolean;
  61326. instance?: Nullable<LinesMesh>;
  61327. colors?: Color4[];
  61328. useVertexAlpha?: boolean;
  61329. }, scene?: Nullable<Scene>): LinesMesh;
  61330. /**
  61331. * Creates a dashed line mesh
  61332. * * 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
  61333. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61334. * * The parameter `points` is an array successive Vector3
  61335. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  61336. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  61337. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  61338. * * 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
  61339. * * When updating an instance, remember that only point positions can change, not the number of points
  61340. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61341. * @param name defines the name of the mesh
  61342. * @param options defines the options used to create the mesh
  61343. * @param scene defines the hosting scene
  61344. * @returns the dashed line mesh
  61345. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  61346. */
  61347. static CreateDashedLines(name: string, options: {
  61348. points: Vector3[];
  61349. dashSize?: number;
  61350. gapSize?: number;
  61351. dashNb?: number;
  61352. updatable?: boolean;
  61353. instance?: LinesMesh;
  61354. }, scene?: Nullable<Scene>): LinesMesh;
  61355. /**
  61356. * 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.
  61357. * * 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.
  61358. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61359. * * 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.
  61360. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  61361. * * 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
  61362. * * 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
  61363. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  61364. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61365. * * 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
  61366. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  61367. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61368. * @param name defines the name of the mesh
  61369. * @param options defines the options used to create the mesh
  61370. * @param scene defines the hosting scene
  61371. * @returns the extruded shape mesh
  61372. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61373. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61374. */
  61375. static ExtrudeShape(name: string, options: {
  61376. shape: Vector3[];
  61377. path: Vector3[];
  61378. scale?: number;
  61379. rotation?: number;
  61380. cap?: number;
  61381. updatable?: boolean;
  61382. sideOrientation?: number;
  61383. frontUVs?: Vector4;
  61384. backUVs?: Vector4;
  61385. instance?: Mesh;
  61386. invertUV?: boolean;
  61387. }, scene?: Nullable<Scene>): Mesh;
  61388. /**
  61389. * Creates an custom extruded shape mesh.
  61390. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  61391. * * 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.
  61392. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61393. * * 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
  61394. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  61395. * * 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
  61396. * * It must returns a float value that will be the scale value applied to the shape on each path point
  61397. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  61398. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  61399. * * 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
  61400. * * 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
  61401. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  61402. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61403. * * 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
  61404. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61405. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61406. * @param name defines the name of the mesh
  61407. * @param options defines the options used to create the mesh
  61408. * @param scene defines the hosting scene
  61409. * @returns the custom extruded shape mesh
  61410. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  61411. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61412. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61413. */
  61414. static ExtrudeShapeCustom(name: string, options: {
  61415. shape: Vector3[];
  61416. path: Vector3[];
  61417. scaleFunction?: any;
  61418. rotationFunction?: any;
  61419. ribbonCloseArray?: boolean;
  61420. ribbonClosePath?: boolean;
  61421. cap?: number;
  61422. updatable?: boolean;
  61423. sideOrientation?: number;
  61424. frontUVs?: Vector4;
  61425. backUVs?: Vector4;
  61426. instance?: Mesh;
  61427. invertUV?: boolean;
  61428. }, scene?: Nullable<Scene>): Mesh;
  61429. /**
  61430. * Creates lathe mesh.
  61431. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  61432. * * 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
  61433. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  61434. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  61435. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  61436. * * 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
  61437. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  61438. * * 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
  61439. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61440. * * 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
  61441. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61442. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61443. * @param name defines the name of the mesh
  61444. * @param options defines the options used to create the mesh
  61445. * @param scene defines the hosting scene
  61446. * @returns the lathe mesh
  61447. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  61448. */
  61449. static CreateLathe(name: string, options: {
  61450. shape: Vector3[];
  61451. radius?: number;
  61452. tessellation?: number;
  61453. clip?: number;
  61454. arc?: number;
  61455. closed?: boolean;
  61456. updatable?: boolean;
  61457. sideOrientation?: number;
  61458. frontUVs?: Vector4;
  61459. backUVs?: Vector4;
  61460. cap?: number;
  61461. invertUV?: boolean;
  61462. }, scene?: Nullable<Scene>): Mesh;
  61463. /**
  61464. * Creates a tiled plane mesh
  61465. * * You can set a limited pattern arrangement with the tiles
  61466. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61467. * * 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
  61468. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61469. * @param name defines the name of the mesh
  61470. * @param options defines the options used to create the mesh
  61471. * @param scene defines the hosting scene
  61472. * @returns the plane mesh
  61473. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61474. */
  61475. static CreateTiledPlane(name: string, options: {
  61476. pattern?: number;
  61477. tileSize?: number;
  61478. tileWidth?: number;
  61479. tileHeight?: number;
  61480. size?: number;
  61481. width?: number;
  61482. height?: number;
  61483. alignHorizontal?: number;
  61484. alignVertical?: number;
  61485. sideOrientation?: number;
  61486. frontUVs?: Vector4;
  61487. backUVs?: Vector4;
  61488. updatable?: boolean;
  61489. }, scene?: Nullable<Scene>): Mesh;
  61490. /**
  61491. * Creates a plane mesh
  61492. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  61493. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  61494. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  61495. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61496. * * 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
  61497. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61498. * @param name defines the name of the mesh
  61499. * @param options defines the options used to create the mesh
  61500. * @param scene defines the hosting scene
  61501. * @returns the plane mesh
  61502. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61503. */
  61504. static CreatePlane(name: string, options: {
  61505. size?: number;
  61506. width?: number;
  61507. height?: number;
  61508. sideOrientation?: number;
  61509. frontUVs?: Vector4;
  61510. backUVs?: Vector4;
  61511. updatable?: boolean;
  61512. sourcePlane?: Plane;
  61513. }, scene?: Nullable<Scene>): Mesh;
  61514. /**
  61515. * Creates a ground mesh
  61516. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  61517. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  61518. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61519. * @param name defines the name of the mesh
  61520. * @param options defines the options used to create the mesh
  61521. * @param scene defines the hosting scene
  61522. * @returns the ground mesh
  61523. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  61524. */
  61525. static CreateGround(name: string, options: {
  61526. width?: number;
  61527. height?: number;
  61528. subdivisions?: number;
  61529. subdivisionsX?: number;
  61530. subdivisionsY?: number;
  61531. updatable?: boolean;
  61532. }, scene?: Nullable<Scene>): Mesh;
  61533. /**
  61534. * Creates a tiled ground mesh
  61535. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  61536. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  61537. * * 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
  61538. * * 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
  61539. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61540. * @param name defines the name of the mesh
  61541. * @param options defines the options used to create the mesh
  61542. * @param scene defines the hosting scene
  61543. * @returns the tiled ground mesh
  61544. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  61545. */
  61546. static CreateTiledGround(name: string, options: {
  61547. xmin: number;
  61548. zmin: number;
  61549. xmax: number;
  61550. zmax: number;
  61551. subdivisions?: {
  61552. w: number;
  61553. h: number;
  61554. };
  61555. precision?: {
  61556. w: number;
  61557. h: number;
  61558. };
  61559. updatable?: boolean;
  61560. }, scene?: Nullable<Scene>): Mesh;
  61561. /**
  61562. * Creates a ground mesh from a height map
  61563. * * The parameter `url` sets the URL of the height map image resource.
  61564. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  61565. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  61566. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  61567. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  61568. * * 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.
  61569. * * 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).
  61570. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  61571. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61572. * @param name defines the name of the mesh
  61573. * @param url defines the url to the height map
  61574. * @param options defines the options used to create the mesh
  61575. * @param scene defines the hosting scene
  61576. * @returns the ground mesh
  61577. * @see https://doc.babylonjs.com/babylon101/height_map
  61578. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  61579. */
  61580. static CreateGroundFromHeightMap(name: string, url: string, options: {
  61581. width?: number;
  61582. height?: number;
  61583. subdivisions?: number;
  61584. minHeight?: number;
  61585. maxHeight?: number;
  61586. colorFilter?: Color3;
  61587. alphaFilter?: number;
  61588. updatable?: boolean;
  61589. onReady?: (mesh: GroundMesh) => void;
  61590. }, scene?: Nullable<Scene>): GroundMesh;
  61591. /**
  61592. * Creates a polygon mesh
  61593. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  61594. * * 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
  61595. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61596. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61597. * * 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)
  61598. * * Remember you can only change the shape positions, not their number when updating a polygon
  61599. * @param name defines the name of the mesh
  61600. * @param options defines the options used to create the mesh
  61601. * @param scene defines the hosting scene
  61602. * @param earcutInjection can be used to inject your own earcut reference
  61603. * @returns the polygon mesh
  61604. */
  61605. static CreatePolygon(name: string, options: {
  61606. shape: Vector3[];
  61607. holes?: Vector3[][];
  61608. depth?: number;
  61609. faceUV?: Vector4[];
  61610. faceColors?: Color4[];
  61611. updatable?: boolean;
  61612. sideOrientation?: number;
  61613. frontUVs?: Vector4;
  61614. backUVs?: Vector4;
  61615. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61616. /**
  61617. * Creates an extruded polygon mesh, with depth in the Y direction.
  61618. * * 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)
  61619. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  61620. * @param name defines the name of the mesh
  61621. * @param options defines the options used to create the mesh
  61622. * @param scene defines the hosting scene
  61623. * @param earcutInjection can be used to inject your own earcut reference
  61624. * @returns the polygon mesh
  61625. */
  61626. static ExtrudePolygon(name: string, options: {
  61627. shape: Vector3[];
  61628. holes?: Vector3[][];
  61629. depth?: number;
  61630. faceUV?: Vector4[];
  61631. faceColors?: Color4[];
  61632. updatable?: boolean;
  61633. sideOrientation?: number;
  61634. frontUVs?: Vector4;
  61635. backUVs?: Vector4;
  61636. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61637. /**
  61638. * Creates a tube mesh.
  61639. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61640. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  61641. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  61642. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  61643. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  61644. * * 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)
  61645. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  61646. * * 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
  61647. * * 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
  61648. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61649. * * 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
  61650. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61651. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61652. * @param name defines the name of the mesh
  61653. * @param options defines the options used to create the mesh
  61654. * @param scene defines the hosting scene
  61655. * @returns the tube mesh
  61656. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61657. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  61658. */
  61659. static CreateTube(name: string, options: {
  61660. path: Vector3[];
  61661. radius?: number;
  61662. tessellation?: number;
  61663. radiusFunction?: {
  61664. (i: number, distance: number): number;
  61665. };
  61666. cap?: number;
  61667. arc?: number;
  61668. updatable?: boolean;
  61669. sideOrientation?: number;
  61670. frontUVs?: Vector4;
  61671. backUVs?: Vector4;
  61672. instance?: Mesh;
  61673. invertUV?: boolean;
  61674. }, scene?: Nullable<Scene>): Mesh;
  61675. /**
  61676. * Creates a polyhedron mesh
  61677. * * 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
  61678. * * The parameter `size` (positive float, default 1) sets the polygon size
  61679. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  61680. * * 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`
  61681. * * 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
  61682. * * 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)`)
  61683. * * 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
  61684. * * 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
  61685. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61686. * * 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
  61687. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61688. * @param name defines the name of the mesh
  61689. * @param options defines the options used to create the mesh
  61690. * @param scene defines the hosting scene
  61691. * @returns the polyhedron mesh
  61692. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  61693. */
  61694. static CreatePolyhedron(name: string, options: {
  61695. type?: number;
  61696. size?: number;
  61697. sizeX?: number;
  61698. sizeY?: number;
  61699. sizeZ?: number;
  61700. custom?: any;
  61701. faceUV?: Vector4[];
  61702. faceColors?: Color4[];
  61703. flat?: boolean;
  61704. updatable?: boolean;
  61705. sideOrientation?: number;
  61706. frontUVs?: Vector4;
  61707. backUVs?: Vector4;
  61708. }, scene?: Nullable<Scene>): Mesh;
  61709. /**
  61710. * Creates a decal mesh.
  61711. * 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
  61712. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  61713. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  61714. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  61715. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  61716. * @param name defines the name of the mesh
  61717. * @param sourceMesh defines the mesh where the decal must be applied
  61718. * @param options defines the options used to create the mesh
  61719. * @param scene defines the hosting scene
  61720. * @returns the decal mesh
  61721. * @see https://doc.babylonjs.com/how_to/decals
  61722. */
  61723. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  61724. position?: Vector3;
  61725. normal?: Vector3;
  61726. size?: Vector3;
  61727. angle?: number;
  61728. }): Mesh;
  61729. }
  61730. }
  61731. declare module BABYLON {
  61732. /**
  61733. * A simplifier interface for future simplification implementations
  61734. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61735. */
  61736. export interface ISimplifier {
  61737. /**
  61738. * Simplification of a given mesh according to the given settings.
  61739. * Since this requires computation, it is assumed that the function runs async.
  61740. * @param settings The settings of the simplification, including quality and distance
  61741. * @param successCallback A callback that will be called after the mesh was simplified.
  61742. * @param errorCallback in case of an error, this callback will be called. optional.
  61743. */
  61744. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  61745. }
  61746. /**
  61747. * Expected simplification settings.
  61748. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  61749. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61750. */
  61751. export interface ISimplificationSettings {
  61752. /**
  61753. * Gets or sets the expected quality
  61754. */
  61755. quality: number;
  61756. /**
  61757. * Gets or sets the distance when this optimized version should be used
  61758. */
  61759. distance: number;
  61760. /**
  61761. * Gets an already optimized mesh
  61762. */
  61763. optimizeMesh?: boolean;
  61764. }
  61765. /**
  61766. * Class used to specify simplification options
  61767. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61768. */
  61769. export class SimplificationSettings implements ISimplificationSettings {
  61770. /** expected quality */
  61771. quality: number;
  61772. /** distance when this optimized version should be used */
  61773. distance: number;
  61774. /** already optimized mesh */
  61775. optimizeMesh?: boolean | undefined;
  61776. /**
  61777. * Creates a SimplificationSettings
  61778. * @param quality expected quality
  61779. * @param distance distance when this optimized version should be used
  61780. * @param optimizeMesh already optimized mesh
  61781. */
  61782. constructor(
  61783. /** expected quality */
  61784. quality: number,
  61785. /** distance when this optimized version should be used */
  61786. distance: number,
  61787. /** already optimized mesh */
  61788. optimizeMesh?: boolean | undefined);
  61789. }
  61790. /**
  61791. * Interface used to define a simplification task
  61792. */
  61793. export interface ISimplificationTask {
  61794. /**
  61795. * Array of settings
  61796. */
  61797. settings: Array<ISimplificationSettings>;
  61798. /**
  61799. * Simplification type
  61800. */
  61801. simplificationType: SimplificationType;
  61802. /**
  61803. * Mesh to simplify
  61804. */
  61805. mesh: Mesh;
  61806. /**
  61807. * Callback called on success
  61808. */
  61809. successCallback?: () => void;
  61810. /**
  61811. * Defines if parallel processing can be used
  61812. */
  61813. parallelProcessing: boolean;
  61814. }
  61815. /**
  61816. * Queue used to order the simplification tasks
  61817. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61818. */
  61819. export class SimplificationQueue {
  61820. private _simplificationArray;
  61821. /**
  61822. * Gets a boolean indicating that the process is still running
  61823. */
  61824. running: boolean;
  61825. /**
  61826. * Creates a new queue
  61827. */
  61828. constructor();
  61829. /**
  61830. * Adds a new simplification task
  61831. * @param task defines a task to add
  61832. */
  61833. addTask(task: ISimplificationTask): void;
  61834. /**
  61835. * Execute next task
  61836. */
  61837. executeNext(): void;
  61838. /**
  61839. * Execute a simplification task
  61840. * @param task defines the task to run
  61841. */
  61842. runSimplification(task: ISimplificationTask): void;
  61843. private getSimplifier;
  61844. }
  61845. /**
  61846. * The implemented types of simplification
  61847. * At the moment only Quadratic Error Decimation is implemented
  61848. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61849. */
  61850. export enum SimplificationType {
  61851. /** Quadratic error decimation */
  61852. QUADRATIC = 0
  61853. }
  61854. }
  61855. declare module BABYLON {
  61856. interface Scene {
  61857. /** @hidden (Backing field) */
  61858. _simplificationQueue: SimplificationQueue;
  61859. /**
  61860. * Gets or sets the simplification queue attached to the scene
  61861. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61862. */
  61863. simplificationQueue: SimplificationQueue;
  61864. }
  61865. interface Mesh {
  61866. /**
  61867. * Simplify the mesh according to the given array of settings.
  61868. * Function will return immediately and will simplify async
  61869. * @param settings a collection of simplification settings
  61870. * @param parallelProcessing should all levels calculate parallel or one after the other
  61871. * @param simplificationType the type of simplification to run
  61872. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  61873. * @returns the current mesh
  61874. */
  61875. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  61876. }
  61877. /**
  61878. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  61879. * created in a scene
  61880. */
  61881. export class SimplicationQueueSceneComponent implements ISceneComponent {
  61882. /**
  61883. * The component name helpfull to identify the component in the list of scene components.
  61884. */
  61885. readonly name: string;
  61886. /**
  61887. * The scene the component belongs to.
  61888. */
  61889. scene: Scene;
  61890. /**
  61891. * Creates a new instance of the component for the given scene
  61892. * @param scene Defines the scene to register the component in
  61893. */
  61894. constructor(scene: Scene);
  61895. /**
  61896. * Registers the component in a given scene
  61897. */
  61898. register(): void;
  61899. /**
  61900. * Rebuilds the elements related to this component in case of
  61901. * context lost for instance.
  61902. */
  61903. rebuild(): void;
  61904. /**
  61905. * Disposes the component and the associated ressources
  61906. */
  61907. dispose(): void;
  61908. private _beforeCameraUpdate;
  61909. }
  61910. }
  61911. declare module BABYLON {
  61912. /**
  61913. * Navigation plugin interface to add navigation constrained by a navigation mesh
  61914. */
  61915. export interface INavigationEnginePlugin {
  61916. /**
  61917. * plugin name
  61918. */
  61919. name: string;
  61920. /**
  61921. * Creates a navigation mesh
  61922. * @param meshes array of all the geometry used to compute the navigatio mesh
  61923. * @param parameters bunch of parameters used to filter geometry
  61924. */
  61925. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  61926. /**
  61927. * Create a navigation mesh debug mesh
  61928. * @param scene is where the mesh will be added
  61929. * @returns debug display mesh
  61930. */
  61931. createDebugNavMesh(scene: Scene): Mesh;
  61932. /**
  61933. * Get a navigation mesh constrained position, closest to the parameter position
  61934. * @param position world position
  61935. * @returns the closest point to position constrained by the navigation mesh
  61936. */
  61937. getClosestPoint(position: Vector3): Vector3;
  61938. /**
  61939. * Get a navigation mesh constrained position, within a particular radius
  61940. * @param position world position
  61941. * @param maxRadius the maximum distance to the constrained world position
  61942. * @returns the closest point to position constrained by the navigation mesh
  61943. */
  61944. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  61945. /**
  61946. * Compute the final position from a segment made of destination-position
  61947. * @param position world position
  61948. * @param destination world position
  61949. * @returns the resulting point along the navmesh
  61950. */
  61951. moveAlong(position: Vector3, destination: Vector3): Vector3;
  61952. /**
  61953. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  61954. * @param start world position
  61955. * @param end world position
  61956. * @returns array containing world position composing the path
  61957. */
  61958. computePath(start: Vector3, end: Vector3): Vector3[];
  61959. /**
  61960. * If this plugin is supported
  61961. * @returns true if plugin is supported
  61962. */
  61963. isSupported(): boolean;
  61964. /**
  61965. * Create a new Crowd so you can add agents
  61966. * @param maxAgents the maximum agent count in the crowd
  61967. * @param maxAgentRadius the maximum radius an agent can have
  61968. * @param scene to attach the crowd to
  61969. * @returns the crowd you can add agents to
  61970. */
  61971. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  61972. /**
  61973. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61974. * The queries will try to find a solution within those bounds
  61975. * default is (1,1,1)
  61976. * @param extent x,y,z value that define the extent around the queries point of reference
  61977. */
  61978. setDefaultQueryExtent(extent: Vector3): void;
  61979. /**
  61980. * Get the Bounding box extent specified by setDefaultQueryExtent
  61981. * @returns the box extent values
  61982. */
  61983. getDefaultQueryExtent(): Vector3;
  61984. /**
  61985. * Release all resources
  61986. */
  61987. dispose(): void;
  61988. }
  61989. /**
  61990. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  61991. */
  61992. export interface ICrowd {
  61993. /**
  61994. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  61995. * You can attach anything to that node. The node position is updated in the scene update tick.
  61996. * @param pos world position that will be constrained by the navigation mesh
  61997. * @param parameters agent parameters
  61998. * @param transform hooked to the agent that will be update by the scene
  61999. * @returns agent index
  62000. */
  62001. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  62002. /**
  62003. * Returns the agent position in world space
  62004. * @param index agent index returned by addAgent
  62005. * @returns world space position
  62006. */
  62007. getAgentPosition(index: number): Vector3;
  62008. /**
  62009. * Gets the agent velocity in world space
  62010. * @param index agent index returned by addAgent
  62011. * @returns world space velocity
  62012. */
  62013. getAgentVelocity(index: number): Vector3;
  62014. /**
  62015. * remove a particular agent previously created
  62016. * @param index agent index returned by addAgent
  62017. */
  62018. removeAgent(index: number): void;
  62019. /**
  62020. * get the list of all agents attached to this crowd
  62021. * @returns list of agent indices
  62022. */
  62023. getAgents(): number[];
  62024. /**
  62025. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  62026. * @param deltaTime in seconds
  62027. */
  62028. update(deltaTime: number): void;
  62029. /**
  62030. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62031. * @param index agent index returned by addAgent
  62032. * @param destination targeted world position
  62033. */
  62034. agentGoto(index: number, destination: Vector3): void;
  62035. /**
  62036. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62037. * The queries will try to find a solution within those bounds
  62038. * default is (1,1,1)
  62039. * @param extent x,y,z value that define the extent around the queries point of reference
  62040. */
  62041. setDefaultQueryExtent(extent: Vector3): void;
  62042. /**
  62043. * Get the Bounding box extent specified by setDefaultQueryExtent
  62044. * @returns the box extent values
  62045. */
  62046. getDefaultQueryExtent(): Vector3;
  62047. /**
  62048. * Release all resources
  62049. */
  62050. dispose(): void;
  62051. }
  62052. /**
  62053. * Configures an agent
  62054. */
  62055. export interface IAgentParameters {
  62056. /**
  62057. * Agent radius. [Limit: >= 0]
  62058. */
  62059. radius: number;
  62060. /**
  62061. * Agent height. [Limit: > 0]
  62062. */
  62063. height: number;
  62064. /**
  62065. * Maximum allowed acceleration. [Limit: >= 0]
  62066. */
  62067. maxAcceleration: number;
  62068. /**
  62069. * Maximum allowed speed. [Limit: >= 0]
  62070. */
  62071. maxSpeed: number;
  62072. /**
  62073. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  62074. */
  62075. collisionQueryRange: number;
  62076. /**
  62077. * The path visibility optimization range. [Limit: > 0]
  62078. */
  62079. pathOptimizationRange: number;
  62080. /**
  62081. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  62082. */
  62083. separationWeight: number;
  62084. }
  62085. /**
  62086. * Configures the navigation mesh creation
  62087. */
  62088. export interface INavMeshParameters {
  62089. /**
  62090. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  62091. */
  62092. cs: number;
  62093. /**
  62094. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  62095. */
  62096. ch: number;
  62097. /**
  62098. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  62099. */
  62100. walkableSlopeAngle: number;
  62101. /**
  62102. * Minimum floor to 'ceiling' height that will still allow the floor area to
  62103. * be considered walkable. [Limit: >= 3] [Units: vx]
  62104. */
  62105. walkableHeight: number;
  62106. /**
  62107. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  62108. */
  62109. walkableClimb: number;
  62110. /**
  62111. * The distance to erode/shrink the walkable area of the heightfield away from
  62112. * obstructions. [Limit: >=0] [Units: vx]
  62113. */
  62114. walkableRadius: number;
  62115. /**
  62116. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  62117. */
  62118. maxEdgeLen: number;
  62119. /**
  62120. * The maximum distance a simplfied contour's border edges should deviate
  62121. * the original raw contour. [Limit: >=0] [Units: vx]
  62122. */
  62123. maxSimplificationError: number;
  62124. /**
  62125. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  62126. */
  62127. minRegionArea: number;
  62128. /**
  62129. * Any regions with a span count smaller than this value will, if possible,
  62130. * be merged with larger regions. [Limit: >=0] [Units: vx]
  62131. */
  62132. mergeRegionArea: number;
  62133. /**
  62134. * The maximum number of vertices allowed for polygons generated during the
  62135. * contour to polygon conversion process. [Limit: >= 3]
  62136. */
  62137. maxVertsPerPoly: number;
  62138. /**
  62139. * Sets the sampling distance to use when generating the detail mesh.
  62140. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  62141. */
  62142. detailSampleDist: number;
  62143. /**
  62144. * The maximum distance the detail mesh surface should deviate from heightfield
  62145. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  62146. */
  62147. detailSampleMaxError: number;
  62148. }
  62149. }
  62150. declare module BABYLON {
  62151. /**
  62152. * RecastJS navigation plugin
  62153. */
  62154. export class RecastJSPlugin implements INavigationEnginePlugin {
  62155. /**
  62156. * Reference to the Recast library
  62157. */
  62158. bjsRECAST: any;
  62159. /**
  62160. * plugin name
  62161. */
  62162. name: string;
  62163. /**
  62164. * the first navmesh created. We might extend this to support multiple navmeshes
  62165. */
  62166. navMesh: any;
  62167. /**
  62168. * Initializes the recastJS plugin
  62169. * @param recastInjection can be used to inject your own recast reference
  62170. */
  62171. constructor(recastInjection?: any);
  62172. /**
  62173. * Creates a navigation mesh
  62174. * @param meshes array of all the geometry used to compute the navigatio mesh
  62175. * @param parameters bunch of parameters used to filter geometry
  62176. */
  62177. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62178. /**
  62179. * Create a navigation mesh debug mesh
  62180. * @param scene is where the mesh will be added
  62181. * @returns debug display mesh
  62182. */
  62183. createDebugNavMesh(scene: Scene): Mesh;
  62184. /**
  62185. * Get a navigation mesh constrained position, closest to the parameter position
  62186. * @param position world position
  62187. * @returns the closest point to position constrained by the navigation mesh
  62188. */
  62189. getClosestPoint(position: Vector3): Vector3;
  62190. /**
  62191. * Get a navigation mesh constrained position, within a particular radius
  62192. * @param position world position
  62193. * @param maxRadius the maximum distance to the constrained world position
  62194. * @returns the closest point to position constrained by the navigation mesh
  62195. */
  62196. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62197. /**
  62198. * Compute the final position from a segment made of destination-position
  62199. * @param position world position
  62200. * @param destination world position
  62201. * @returns the resulting point along the navmesh
  62202. */
  62203. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62204. /**
  62205. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62206. * @param start world position
  62207. * @param end world position
  62208. * @returns array containing world position composing the path
  62209. */
  62210. computePath(start: Vector3, end: Vector3): Vector3[];
  62211. /**
  62212. * Create a new Crowd so you can add agents
  62213. * @param maxAgents the maximum agent count in the crowd
  62214. * @param maxAgentRadius the maximum radius an agent can have
  62215. * @param scene to attach the crowd to
  62216. * @returns the crowd you can add agents to
  62217. */
  62218. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62219. /**
  62220. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62221. * The queries will try to find a solution within those bounds
  62222. * default is (1,1,1)
  62223. * @param extent x,y,z value that define the extent around the queries point of reference
  62224. */
  62225. setDefaultQueryExtent(extent: Vector3): void;
  62226. /**
  62227. * Get the Bounding box extent specified by setDefaultQueryExtent
  62228. * @returns the box extent values
  62229. */
  62230. getDefaultQueryExtent(): Vector3;
  62231. /**
  62232. * Disposes
  62233. */
  62234. dispose(): void;
  62235. /**
  62236. * If this plugin is supported
  62237. * @returns true if plugin is supported
  62238. */
  62239. isSupported(): boolean;
  62240. }
  62241. /**
  62242. * Recast detour crowd implementation
  62243. */
  62244. export class RecastJSCrowd implements ICrowd {
  62245. /**
  62246. * Recast/detour plugin
  62247. */
  62248. bjsRECASTPlugin: RecastJSPlugin;
  62249. /**
  62250. * Link to the detour crowd
  62251. */
  62252. recastCrowd: any;
  62253. /**
  62254. * One transform per agent
  62255. */
  62256. transforms: TransformNode[];
  62257. /**
  62258. * All agents created
  62259. */
  62260. agents: number[];
  62261. /**
  62262. * Link to the scene is kept to unregister the crowd from the scene
  62263. */
  62264. private _scene;
  62265. /**
  62266. * Observer for crowd updates
  62267. */
  62268. private _onBeforeAnimationsObserver;
  62269. /**
  62270. * Constructor
  62271. * @param plugin recastJS plugin
  62272. * @param maxAgents the maximum agent count in the crowd
  62273. * @param maxAgentRadius the maximum radius an agent can have
  62274. * @param scene to attach the crowd to
  62275. * @returns the crowd you can add agents to
  62276. */
  62277. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  62278. /**
  62279. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  62280. * You can attach anything to that node. The node position is updated in the scene update tick.
  62281. * @param pos world position that will be constrained by the navigation mesh
  62282. * @param parameters agent parameters
  62283. * @param transform hooked to the agent that will be update by the scene
  62284. * @returns agent index
  62285. */
  62286. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  62287. /**
  62288. * Returns the agent position in world space
  62289. * @param index agent index returned by addAgent
  62290. * @returns world space position
  62291. */
  62292. getAgentPosition(index: number): Vector3;
  62293. /**
  62294. * Returns the agent velocity in world space
  62295. * @param index agent index returned by addAgent
  62296. * @returns world space velocity
  62297. */
  62298. getAgentVelocity(index: number): Vector3;
  62299. /**
  62300. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62301. * @param index agent index returned by addAgent
  62302. * @param destination targeted world position
  62303. */
  62304. agentGoto(index: number, destination: Vector3): void;
  62305. /**
  62306. * remove a particular agent previously created
  62307. * @param index agent index returned by addAgent
  62308. */
  62309. removeAgent(index: number): void;
  62310. /**
  62311. * get the list of all agents attached to this crowd
  62312. * @returns list of agent indices
  62313. */
  62314. getAgents(): number[];
  62315. /**
  62316. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  62317. * @param deltaTime in seconds
  62318. */
  62319. update(deltaTime: number): void;
  62320. /**
  62321. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62322. * The queries will try to find a solution within those bounds
  62323. * default is (1,1,1)
  62324. * @param extent x,y,z value that define the extent around the queries point of reference
  62325. */
  62326. setDefaultQueryExtent(extent: Vector3): void;
  62327. /**
  62328. * Get the Bounding box extent specified by setDefaultQueryExtent
  62329. * @returns the box extent values
  62330. */
  62331. getDefaultQueryExtent(): Vector3;
  62332. /**
  62333. * Release all resources
  62334. */
  62335. dispose(): void;
  62336. }
  62337. }
  62338. declare module BABYLON {
  62339. /**
  62340. * Class used to enable access to IndexedDB
  62341. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  62342. */
  62343. export class Database implements IOfflineProvider {
  62344. private _callbackManifestChecked;
  62345. private _currentSceneUrl;
  62346. private _db;
  62347. private _enableSceneOffline;
  62348. private _enableTexturesOffline;
  62349. private _manifestVersionFound;
  62350. private _mustUpdateRessources;
  62351. private _hasReachedQuota;
  62352. private _isSupported;
  62353. private _idbFactory;
  62354. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  62355. private static IsUASupportingBlobStorage;
  62356. /**
  62357. * Gets a boolean indicating if Database storate is enabled (off by default)
  62358. */
  62359. static IDBStorageEnabled: boolean;
  62360. /**
  62361. * Gets a boolean indicating if scene must be saved in the database
  62362. */
  62363. get enableSceneOffline(): boolean;
  62364. /**
  62365. * Gets a boolean indicating if textures must be saved in the database
  62366. */
  62367. get enableTexturesOffline(): boolean;
  62368. /**
  62369. * Creates a new Database
  62370. * @param urlToScene defines the url to load the scene
  62371. * @param callbackManifestChecked defines the callback to use when manifest is checked
  62372. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  62373. */
  62374. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  62375. private static _ParseURL;
  62376. private static _ReturnFullUrlLocation;
  62377. private _checkManifestFile;
  62378. /**
  62379. * Open the database and make it available
  62380. * @param successCallback defines the callback to call on success
  62381. * @param errorCallback defines the callback to call on error
  62382. */
  62383. open(successCallback: () => void, errorCallback: () => void): void;
  62384. /**
  62385. * Loads an image from the database
  62386. * @param url defines the url to load from
  62387. * @param image defines the target DOM image
  62388. */
  62389. loadImage(url: string, image: HTMLImageElement): void;
  62390. private _loadImageFromDBAsync;
  62391. private _saveImageIntoDBAsync;
  62392. private _checkVersionFromDB;
  62393. private _loadVersionFromDBAsync;
  62394. private _saveVersionIntoDBAsync;
  62395. /**
  62396. * Loads a file from database
  62397. * @param url defines the URL to load from
  62398. * @param sceneLoaded defines a callback to call on success
  62399. * @param progressCallBack defines a callback to call when progress changed
  62400. * @param errorCallback defines a callback to call on error
  62401. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  62402. */
  62403. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  62404. private _loadFileAsync;
  62405. private _saveFileAsync;
  62406. /**
  62407. * Validates if xhr data is correct
  62408. * @param xhr defines the request to validate
  62409. * @param dataType defines the expected data type
  62410. * @returns true if data is correct
  62411. */
  62412. private static _ValidateXHRData;
  62413. }
  62414. }
  62415. declare module BABYLON {
  62416. /** @hidden */
  62417. export var gpuUpdateParticlesPixelShader: {
  62418. name: string;
  62419. shader: string;
  62420. };
  62421. }
  62422. declare module BABYLON {
  62423. /** @hidden */
  62424. export var gpuUpdateParticlesVertexShader: {
  62425. name: string;
  62426. shader: string;
  62427. };
  62428. }
  62429. declare module BABYLON {
  62430. /** @hidden */
  62431. export var clipPlaneFragmentDeclaration2: {
  62432. name: string;
  62433. shader: string;
  62434. };
  62435. }
  62436. declare module BABYLON {
  62437. /** @hidden */
  62438. export var gpuRenderParticlesPixelShader: {
  62439. name: string;
  62440. shader: string;
  62441. };
  62442. }
  62443. declare module BABYLON {
  62444. /** @hidden */
  62445. export var clipPlaneVertexDeclaration2: {
  62446. name: string;
  62447. shader: string;
  62448. };
  62449. }
  62450. declare module BABYLON {
  62451. /** @hidden */
  62452. export var gpuRenderParticlesVertexShader: {
  62453. name: string;
  62454. shader: string;
  62455. };
  62456. }
  62457. declare module BABYLON {
  62458. /**
  62459. * This represents a GPU particle system in Babylon
  62460. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  62461. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  62462. */
  62463. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  62464. /**
  62465. * The layer mask we are rendering the particles through.
  62466. */
  62467. layerMask: number;
  62468. private _capacity;
  62469. private _activeCount;
  62470. private _currentActiveCount;
  62471. private _accumulatedCount;
  62472. private _renderEffect;
  62473. private _updateEffect;
  62474. private _buffer0;
  62475. private _buffer1;
  62476. private _spriteBuffer;
  62477. private _updateVAO;
  62478. private _renderVAO;
  62479. private _targetIndex;
  62480. private _sourceBuffer;
  62481. private _targetBuffer;
  62482. private _engine;
  62483. private _currentRenderId;
  62484. private _started;
  62485. private _stopped;
  62486. private _timeDelta;
  62487. private _randomTexture;
  62488. private _randomTexture2;
  62489. private _attributesStrideSize;
  62490. private _updateEffectOptions;
  62491. private _randomTextureSize;
  62492. private _actualFrame;
  62493. private readonly _rawTextureWidth;
  62494. /**
  62495. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  62496. */
  62497. static get IsSupported(): boolean;
  62498. /**
  62499. * An event triggered when the system is disposed.
  62500. */
  62501. onDisposeObservable: Observable<GPUParticleSystem>;
  62502. /**
  62503. * Gets the maximum number of particles active at the same time.
  62504. * @returns The max number of active particles.
  62505. */
  62506. getCapacity(): number;
  62507. /**
  62508. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  62509. * to override the particles.
  62510. */
  62511. forceDepthWrite: boolean;
  62512. /**
  62513. * Gets or set the number of active particles
  62514. */
  62515. get activeParticleCount(): number;
  62516. set activeParticleCount(value: number);
  62517. private _preWarmDone;
  62518. /**
  62519. * Is this system ready to be used/rendered
  62520. * @return true if the system is ready
  62521. */
  62522. isReady(): boolean;
  62523. /**
  62524. * Gets if the system has been started. (Note: this will still be true after stop is called)
  62525. * @returns True if it has been started, otherwise false.
  62526. */
  62527. isStarted(): boolean;
  62528. /**
  62529. * Starts the particle system and begins to emit
  62530. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  62531. */
  62532. start(delay?: number): void;
  62533. /**
  62534. * Stops the particle system.
  62535. */
  62536. stop(): void;
  62537. /**
  62538. * Remove all active particles
  62539. */
  62540. reset(): void;
  62541. /**
  62542. * Returns the string "GPUParticleSystem"
  62543. * @returns a string containing the class name
  62544. */
  62545. getClassName(): string;
  62546. private _colorGradientsTexture;
  62547. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  62548. /**
  62549. * Adds a new color gradient
  62550. * @param gradient defines the gradient to use (between 0 and 1)
  62551. * @param color1 defines the color to affect to the specified gradient
  62552. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  62553. * @returns the current particle system
  62554. */
  62555. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  62556. /**
  62557. * Remove a specific color gradient
  62558. * @param gradient defines the gradient to remove
  62559. * @returns the current particle system
  62560. */
  62561. removeColorGradient(gradient: number): GPUParticleSystem;
  62562. private _angularSpeedGradientsTexture;
  62563. private _sizeGradientsTexture;
  62564. private _velocityGradientsTexture;
  62565. private _limitVelocityGradientsTexture;
  62566. private _dragGradientsTexture;
  62567. private _addFactorGradient;
  62568. /**
  62569. * Adds a new size gradient
  62570. * @param gradient defines the gradient to use (between 0 and 1)
  62571. * @param factor defines the size factor to affect to the specified gradient
  62572. * @returns the current particle system
  62573. */
  62574. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  62575. /**
  62576. * Remove a specific size gradient
  62577. * @param gradient defines the gradient to remove
  62578. * @returns the current particle system
  62579. */
  62580. removeSizeGradient(gradient: number): GPUParticleSystem;
  62581. /**
  62582. * Adds a new angular speed gradient
  62583. * @param gradient defines the gradient to use (between 0 and 1)
  62584. * @param factor defines the angular speed to affect to the specified gradient
  62585. * @returns the current particle system
  62586. */
  62587. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  62588. /**
  62589. * Remove a specific angular speed gradient
  62590. * @param gradient defines the gradient to remove
  62591. * @returns the current particle system
  62592. */
  62593. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  62594. /**
  62595. * Adds a new velocity gradient
  62596. * @param gradient defines the gradient to use (between 0 and 1)
  62597. * @param factor defines the velocity to affect to the specified gradient
  62598. * @returns the current particle system
  62599. */
  62600. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  62601. /**
  62602. * Remove a specific velocity gradient
  62603. * @param gradient defines the gradient to remove
  62604. * @returns the current particle system
  62605. */
  62606. removeVelocityGradient(gradient: number): GPUParticleSystem;
  62607. /**
  62608. * Adds a new limit velocity gradient
  62609. * @param gradient defines the gradient to use (between 0 and 1)
  62610. * @param factor defines the limit velocity value to affect to the specified gradient
  62611. * @returns the current particle system
  62612. */
  62613. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  62614. /**
  62615. * Remove a specific limit velocity gradient
  62616. * @param gradient defines the gradient to remove
  62617. * @returns the current particle system
  62618. */
  62619. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  62620. /**
  62621. * Adds a new drag gradient
  62622. * @param gradient defines the gradient to use (between 0 and 1)
  62623. * @param factor defines the drag value to affect to the specified gradient
  62624. * @returns the current particle system
  62625. */
  62626. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  62627. /**
  62628. * Remove a specific drag gradient
  62629. * @param gradient defines the gradient to remove
  62630. * @returns the current particle system
  62631. */
  62632. removeDragGradient(gradient: number): GPUParticleSystem;
  62633. /**
  62634. * Not supported by GPUParticleSystem
  62635. * @param gradient defines the gradient to use (between 0 and 1)
  62636. * @param factor defines the emit rate value to affect to the specified gradient
  62637. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62638. * @returns the current particle system
  62639. */
  62640. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62641. /**
  62642. * Not supported by GPUParticleSystem
  62643. * @param gradient defines the gradient to remove
  62644. * @returns the current particle system
  62645. */
  62646. removeEmitRateGradient(gradient: number): IParticleSystem;
  62647. /**
  62648. * Not supported by GPUParticleSystem
  62649. * @param gradient defines the gradient to use (between 0 and 1)
  62650. * @param factor defines the start size value to affect to the specified gradient
  62651. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62652. * @returns the current particle system
  62653. */
  62654. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62655. /**
  62656. * Not supported by GPUParticleSystem
  62657. * @param gradient defines the gradient to remove
  62658. * @returns the current particle system
  62659. */
  62660. removeStartSizeGradient(gradient: number): IParticleSystem;
  62661. /**
  62662. * Not supported by GPUParticleSystem
  62663. * @param gradient defines the gradient to use (between 0 and 1)
  62664. * @param min defines the color remap minimal range
  62665. * @param max defines the color remap maximal range
  62666. * @returns the current particle system
  62667. */
  62668. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  62669. /**
  62670. * Not supported by GPUParticleSystem
  62671. * @param gradient defines the gradient to remove
  62672. * @returns the current particle system
  62673. */
  62674. removeColorRemapGradient(): IParticleSystem;
  62675. /**
  62676. * Not supported by GPUParticleSystem
  62677. * @param gradient defines the gradient to use (between 0 and 1)
  62678. * @param min defines the alpha remap minimal range
  62679. * @param max defines the alpha remap maximal range
  62680. * @returns the current particle system
  62681. */
  62682. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  62683. /**
  62684. * Not supported by GPUParticleSystem
  62685. * @param gradient defines the gradient to remove
  62686. * @returns the current particle system
  62687. */
  62688. removeAlphaRemapGradient(): IParticleSystem;
  62689. /**
  62690. * Not supported by GPUParticleSystem
  62691. * @param gradient defines the gradient to use (between 0 and 1)
  62692. * @param color defines the color to affect to the specified gradient
  62693. * @returns the current particle system
  62694. */
  62695. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  62696. /**
  62697. * Not supported by GPUParticleSystem
  62698. * @param gradient defines the gradient to remove
  62699. * @returns the current particle system
  62700. */
  62701. removeRampGradient(): IParticleSystem;
  62702. /**
  62703. * Not supported by GPUParticleSystem
  62704. * @returns the list of ramp gradients
  62705. */
  62706. getRampGradients(): Nullable<Array<Color3Gradient>>;
  62707. /**
  62708. * Not supported by GPUParticleSystem
  62709. * Gets or sets a boolean indicating that ramp gradients must be used
  62710. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  62711. */
  62712. get useRampGradients(): boolean;
  62713. set useRampGradients(value: boolean);
  62714. /**
  62715. * Not supported by GPUParticleSystem
  62716. * @param gradient defines the gradient to use (between 0 and 1)
  62717. * @param factor defines the life time factor to affect to the specified gradient
  62718. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62719. * @returns the current particle system
  62720. */
  62721. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62722. /**
  62723. * Not supported by GPUParticleSystem
  62724. * @param gradient defines the gradient to remove
  62725. * @returns the current particle system
  62726. */
  62727. removeLifeTimeGradient(gradient: number): IParticleSystem;
  62728. /**
  62729. * Instantiates a GPU particle system.
  62730. * 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.
  62731. * @param name The name of the particle system
  62732. * @param options The options used to create the system
  62733. * @param scene The scene the particle system belongs to
  62734. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  62735. */
  62736. constructor(name: string, options: Partial<{
  62737. capacity: number;
  62738. randomTextureSize: number;
  62739. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  62740. protected _reset(): void;
  62741. private _createUpdateVAO;
  62742. private _createRenderVAO;
  62743. private _initialize;
  62744. /** @hidden */
  62745. _recreateUpdateEffect(): void;
  62746. /** @hidden */
  62747. _recreateRenderEffect(): void;
  62748. /**
  62749. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  62750. * @param preWarm defines if we are in the pre-warmimg phase
  62751. */
  62752. animate(preWarm?: boolean): void;
  62753. private _createFactorGradientTexture;
  62754. private _createSizeGradientTexture;
  62755. private _createAngularSpeedGradientTexture;
  62756. private _createVelocityGradientTexture;
  62757. private _createLimitVelocityGradientTexture;
  62758. private _createDragGradientTexture;
  62759. private _createColorGradientTexture;
  62760. /**
  62761. * Renders the particle system in its current state
  62762. * @param preWarm defines if the system should only update the particles but not render them
  62763. * @returns the current number of particles
  62764. */
  62765. render(preWarm?: boolean): number;
  62766. /**
  62767. * Rebuilds the particle system
  62768. */
  62769. rebuild(): void;
  62770. private _releaseBuffers;
  62771. private _releaseVAOs;
  62772. /**
  62773. * Disposes the particle system and free the associated resources
  62774. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  62775. */
  62776. dispose(disposeTexture?: boolean): void;
  62777. /**
  62778. * Clones the particle system.
  62779. * @param name The name of the cloned object
  62780. * @param newEmitter The new emitter to use
  62781. * @returns the cloned particle system
  62782. */
  62783. clone(name: string, newEmitter: any): GPUParticleSystem;
  62784. /**
  62785. * Serializes the particle system to a JSON object.
  62786. * @returns the JSON object
  62787. */
  62788. serialize(): any;
  62789. /**
  62790. * Parses a JSON object to create a GPU particle system.
  62791. * @param parsedParticleSystem The JSON object to parse
  62792. * @param scene The scene to create the particle system in
  62793. * @param rootUrl The root url to use to load external dependencies like texture
  62794. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  62795. * @returns the parsed GPU particle system
  62796. */
  62797. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  62798. }
  62799. }
  62800. declare module BABYLON {
  62801. /**
  62802. * Represents a set of particle systems working together to create a specific effect
  62803. */
  62804. export class ParticleSystemSet implements IDisposable {
  62805. /**
  62806. * Gets or sets base Assets URL
  62807. */
  62808. static BaseAssetsUrl: string;
  62809. private _emitterCreationOptions;
  62810. private _emitterNode;
  62811. /**
  62812. * Gets the particle system list
  62813. */
  62814. systems: IParticleSystem[];
  62815. /**
  62816. * Gets the emitter node used with this set
  62817. */
  62818. get emitterNode(): Nullable<TransformNode>;
  62819. /**
  62820. * Creates a new emitter mesh as a sphere
  62821. * @param options defines the options used to create the sphere
  62822. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  62823. * @param scene defines the hosting scene
  62824. */
  62825. setEmitterAsSphere(options: {
  62826. diameter: number;
  62827. segments: number;
  62828. color: Color3;
  62829. }, renderingGroupId: number, scene: Scene): void;
  62830. /**
  62831. * Starts all particle systems of the set
  62832. * @param emitter defines an optional mesh to use as emitter for the particle systems
  62833. */
  62834. start(emitter?: AbstractMesh): void;
  62835. /**
  62836. * Release all associated resources
  62837. */
  62838. dispose(): void;
  62839. /**
  62840. * Serialize the set into a JSON compatible object
  62841. * @returns a JSON compatible representation of the set
  62842. */
  62843. serialize(): any;
  62844. /**
  62845. * Parse a new ParticleSystemSet from a serialized source
  62846. * @param data defines a JSON compatible representation of the set
  62847. * @param scene defines the hosting scene
  62848. * @param gpu defines if we want GPU particles or CPU particles
  62849. * @returns a new ParticleSystemSet
  62850. */
  62851. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  62852. }
  62853. }
  62854. declare module BABYLON {
  62855. /**
  62856. * This class is made for on one-liner static method to help creating particle system set.
  62857. */
  62858. export class ParticleHelper {
  62859. /**
  62860. * Gets or sets base Assets URL
  62861. */
  62862. static BaseAssetsUrl: string;
  62863. /**
  62864. * Create a default particle system that you can tweak
  62865. * @param emitter defines the emitter to use
  62866. * @param capacity defines the system capacity (default is 500 particles)
  62867. * @param scene defines the hosting scene
  62868. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  62869. * @returns the new Particle system
  62870. */
  62871. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  62872. /**
  62873. * This is the main static method (one-liner) of this helper to create different particle systems
  62874. * @param type This string represents the type to the particle system to create
  62875. * @param scene The scene where the particle system should live
  62876. * @param gpu If the system will use gpu
  62877. * @returns the ParticleSystemSet created
  62878. */
  62879. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  62880. /**
  62881. * Static function used to export a particle system to a ParticleSystemSet variable.
  62882. * Please note that the emitter shape is not exported
  62883. * @param systems defines the particle systems to export
  62884. * @returns the created particle system set
  62885. */
  62886. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  62887. }
  62888. }
  62889. declare module BABYLON {
  62890. interface Engine {
  62891. /**
  62892. * Create an effect to use with particle systems.
  62893. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  62894. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  62895. * @param uniformsNames defines a list of attribute names
  62896. * @param samplers defines an array of string used to represent textures
  62897. * @param defines defines the string containing the defines to use to compile the shaders
  62898. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  62899. * @param onCompiled defines a function to call when the effect creation is successful
  62900. * @param onError defines a function to call when the effect creation has failed
  62901. * @returns the new Effect
  62902. */
  62903. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  62904. }
  62905. interface Mesh {
  62906. /**
  62907. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  62908. * @returns an array of IParticleSystem
  62909. */
  62910. getEmittedParticleSystems(): IParticleSystem[];
  62911. /**
  62912. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  62913. * @returns an array of IParticleSystem
  62914. */
  62915. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  62916. }
  62917. /**
  62918. * @hidden
  62919. */
  62920. export var _IDoNeedToBeInTheBuild: number;
  62921. }
  62922. declare module BABYLON {
  62923. /** Defines the 4 color options */
  62924. export enum PointColor {
  62925. /** color value */
  62926. Color = 2,
  62927. /** uv value */
  62928. UV = 1,
  62929. /** random value */
  62930. Random = 0,
  62931. /** stated value */
  62932. Stated = 3
  62933. }
  62934. /**
  62935. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  62936. * 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.
  62937. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  62938. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  62939. *
  62940. * Full documentation here : TO BE ENTERED
  62941. */
  62942. export class PointsCloudSystem implements IDisposable {
  62943. /**
  62944. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  62945. * Example : var p = SPS.particles[i];
  62946. */
  62947. particles: CloudPoint[];
  62948. /**
  62949. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  62950. */
  62951. nbParticles: number;
  62952. /**
  62953. * This a counter for your own usage. It's not set by any SPS functions.
  62954. */
  62955. counter: number;
  62956. /**
  62957. * The PCS name. This name is also given to the underlying mesh.
  62958. */
  62959. name: string;
  62960. /**
  62961. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  62962. */
  62963. mesh: Mesh;
  62964. /**
  62965. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  62966. * Please read :
  62967. */
  62968. vars: any;
  62969. /**
  62970. * @hidden
  62971. */
  62972. _size: number;
  62973. private _scene;
  62974. private _promises;
  62975. private _positions;
  62976. private _indices;
  62977. private _normals;
  62978. private _colors;
  62979. private _uvs;
  62980. private _indices32;
  62981. private _positions32;
  62982. private _colors32;
  62983. private _uvs32;
  62984. private _updatable;
  62985. private _isVisibilityBoxLocked;
  62986. private _alwaysVisible;
  62987. private _groups;
  62988. private _groupCounter;
  62989. private _computeParticleColor;
  62990. private _computeParticleTexture;
  62991. private _computeParticleRotation;
  62992. private _computeBoundingBox;
  62993. private _isReady;
  62994. /**
  62995. * Creates a PCS (Points Cloud System) object
  62996. * @param name (String) is the PCS name, this will be the underlying mesh name
  62997. * @param pointSize (number) is the size for each point
  62998. * @param scene (Scene) is the scene in which the PCS is added
  62999. * @param options defines the options of the PCS e.g.
  63000. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  63001. */
  63002. constructor(name: string, pointSize: number, scene: Scene, options?: {
  63003. updatable?: boolean;
  63004. });
  63005. /**
  63006. * Builds the PCS underlying mesh. Returns a standard Mesh.
  63007. * If no points were added to the PCS, the returned mesh is just a single point.
  63008. * @returns a promise for the created mesh
  63009. */
  63010. buildMeshAsync(): Promise<Mesh>;
  63011. /**
  63012. * @hidden
  63013. */
  63014. private _buildMesh;
  63015. private _addParticle;
  63016. private _randomUnitVector;
  63017. private _getColorIndicesForCoord;
  63018. private _setPointsColorOrUV;
  63019. private _colorFromTexture;
  63020. private _calculateDensity;
  63021. /**
  63022. * Adds points to the PCS in random positions within a unit sphere
  63023. * @param nb (positive integer) the number of particles to be created from this model
  63024. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  63025. * @returns the number of groups in the system
  63026. */
  63027. addPoints(nb: number, pointFunction?: any): number;
  63028. /**
  63029. * Adds points to the PCS from the surface of the model shape
  63030. * @param mesh is any Mesh object that will be used as a surface model for the points
  63031. * @param nb (positive integer) the number of particles to be created from this model
  63032. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63033. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63034. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63035. * @returns the number of groups in the system
  63036. */
  63037. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63038. /**
  63039. * Adds points to the PCS inside the model shape
  63040. * @param mesh is any Mesh object that will be used as a surface model for the points
  63041. * @param nb (positive integer) the number of particles to be created from this model
  63042. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  63043. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  63044. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  63045. * @returns the number of groups in the system
  63046. */
  63047. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  63048. /**
  63049. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  63050. * This method calls `updateParticle()` for each particle of the SPS.
  63051. * For an animated SPS, it is usually called within the render loop.
  63052. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  63053. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  63054. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  63055. * @returns the PCS.
  63056. */
  63057. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  63058. /**
  63059. * Disposes the PCS.
  63060. */
  63061. dispose(): void;
  63062. /**
  63063. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  63064. * doc :
  63065. * @returns the PCS.
  63066. */
  63067. refreshVisibleSize(): PointsCloudSystem;
  63068. /**
  63069. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  63070. * @param size the size (float) of the visibility box
  63071. * note : this doesn't lock the PCS mesh bounding box.
  63072. * doc :
  63073. */
  63074. setVisibilityBox(size: number): void;
  63075. /**
  63076. * Gets whether the PCS is always visible or not
  63077. * doc :
  63078. */
  63079. get isAlwaysVisible(): boolean;
  63080. /**
  63081. * Sets the PCS as always visible or not
  63082. * doc :
  63083. */
  63084. set isAlwaysVisible(val: boolean);
  63085. /**
  63086. * Tells to `setParticles()` to compute the particle rotations or not
  63087. * Default value : false. The PCS is faster when it's set to false
  63088. * Note : particle rotations are only applied to parent particles
  63089. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  63090. */
  63091. set computeParticleRotation(val: boolean);
  63092. /**
  63093. * Tells to `setParticles()` to compute the particle colors or not.
  63094. * Default value : true. The PCS is faster when it's set to false.
  63095. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63096. */
  63097. set computeParticleColor(val: boolean);
  63098. set computeParticleTexture(val: boolean);
  63099. /**
  63100. * Gets if `setParticles()` computes the particle colors or not.
  63101. * Default value : false. The PCS is faster when it's set to false.
  63102. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63103. */
  63104. get computeParticleColor(): boolean;
  63105. /**
  63106. * Gets if `setParticles()` computes the particle textures or not.
  63107. * Default value : false. The PCS is faster when it's set to false.
  63108. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  63109. */
  63110. get computeParticleTexture(): boolean;
  63111. /**
  63112. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  63113. */
  63114. set computeBoundingBox(val: boolean);
  63115. /**
  63116. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  63117. */
  63118. get computeBoundingBox(): boolean;
  63119. /**
  63120. * This function does nothing. It may be overwritten to set all the particle first values.
  63121. * The PCS doesn't call this function, you may have to call it by your own.
  63122. * doc :
  63123. */
  63124. initParticles(): void;
  63125. /**
  63126. * This function does nothing. It may be overwritten to recycle a particle
  63127. * The PCS doesn't call this function, you can to call it
  63128. * doc :
  63129. * @param particle The particle to recycle
  63130. * @returns the recycled particle
  63131. */
  63132. recycleParticle(particle: CloudPoint): CloudPoint;
  63133. /**
  63134. * Updates a particle : this function should be overwritten by the user.
  63135. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  63136. * doc :
  63137. * @example : just set a particle position or velocity and recycle conditions
  63138. * @param particle The particle to update
  63139. * @returns the updated particle
  63140. */
  63141. updateParticle(particle: CloudPoint): CloudPoint;
  63142. /**
  63143. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  63144. * This does nothing and may be overwritten by the user.
  63145. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63146. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63147. * @param update the boolean update value actually passed to setParticles()
  63148. */
  63149. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63150. /**
  63151. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  63152. * This will be passed three parameters.
  63153. * This does nothing and may be overwritten by the user.
  63154. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63155. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63156. * @param update the boolean update value actually passed to setParticles()
  63157. */
  63158. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63159. }
  63160. }
  63161. declare module BABYLON {
  63162. /**
  63163. * Represents one particle of a points cloud system.
  63164. */
  63165. export class CloudPoint {
  63166. /**
  63167. * particle global index
  63168. */
  63169. idx: number;
  63170. /**
  63171. * The color of the particle
  63172. */
  63173. color: Nullable<Color4>;
  63174. /**
  63175. * The world space position of the particle.
  63176. */
  63177. position: Vector3;
  63178. /**
  63179. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  63180. */
  63181. rotation: Vector3;
  63182. /**
  63183. * The world space rotation quaternion of the particle.
  63184. */
  63185. rotationQuaternion: Nullable<Quaternion>;
  63186. /**
  63187. * The uv of the particle.
  63188. */
  63189. uv: Nullable<Vector2>;
  63190. /**
  63191. * The current speed of the particle.
  63192. */
  63193. velocity: Vector3;
  63194. /**
  63195. * The pivot point in the particle local space.
  63196. */
  63197. pivot: Vector3;
  63198. /**
  63199. * Must the particle be translated from its pivot point in its local space ?
  63200. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  63201. * Default : false
  63202. */
  63203. translateFromPivot: boolean;
  63204. /**
  63205. * Index of this particle in the global "positions" array (Internal use)
  63206. * @hidden
  63207. */
  63208. _pos: number;
  63209. /**
  63210. * @hidden Index of this particle in the global "indices" array (Internal use)
  63211. */
  63212. _ind: number;
  63213. /**
  63214. * Group this particle belongs to
  63215. */
  63216. _group: PointsGroup;
  63217. /**
  63218. * Group id of this particle
  63219. */
  63220. groupId: number;
  63221. /**
  63222. * Index of the particle in its group id (Internal use)
  63223. */
  63224. idxInGroup: number;
  63225. /**
  63226. * @hidden Particle BoundingInfo object (Internal use)
  63227. */
  63228. _boundingInfo: BoundingInfo;
  63229. /**
  63230. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  63231. */
  63232. _pcs: PointsCloudSystem;
  63233. /**
  63234. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  63235. */
  63236. _stillInvisible: boolean;
  63237. /**
  63238. * @hidden Last computed particle rotation matrix
  63239. */
  63240. _rotationMatrix: number[];
  63241. /**
  63242. * Parent particle Id, if any.
  63243. * Default null.
  63244. */
  63245. parentId: Nullable<number>;
  63246. /**
  63247. * @hidden Internal global position in the PCS.
  63248. */
  63249. _globalPosition: Vector3;
  63250. /**
  63251. * Creates a Point Cloud object.
  63252. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  63253. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  63254. * @param group (PointsGroup) is the group the particle belongs to
  63255. * @param groupId (integer) is the group identifier in the PCS.
  63256. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  63257. * @param pcs defines the PCS it is associated to
  63258. */
  63259. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  63260. /**
  63261. * get point size
  63262. */
  63263. get size(): Vector3;
  63264. /**
  63265. * Set point size
  63266. */
  63267. set size(scale: Vector3);
  63268. /**
  63269. * Legacy support, changed quaternion to rotationQuaternion
  63270. */
  63271. get quaternion(): Nullable<Quaternion>;
  63272. /**
  63273. * Legacy support, changed quaternion to rotationQuaternion
  63274. */
  63275. set quaternion(q: Nullable<Quaternion>);
  63276. /**
  63277. * Returns a boolean. True if the particle intersects a mesh, else false
  63278. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  63279. * @param target is the object (point or mesh) what the intersection is computed against
  63280. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  63281. * @returns true if it intersects
  63282. */
  63283. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  63284. /**
  63285. * get the rotation matrix of the particle
  63286. * @hidden
  63287. */
  63288. getRotationMatrix(m: Matrix): void;
  63289. }
  63290. /**
  63291. * Represents a group of points in a points cloud system
  63292. * * PCS internal tool, don't use it manually.
  63293. */
  63294. export class PointsGroup {
  63295. /**
  63296. * The group id
  63297. * @hidden
  63298. */
  63299. groupID: number;
  63300. /**
  63301. * image data for group (internal use)
  63302. * @hidden
  63303. */
  63304. _groupImageData: Nullable<ArrayBufferView>;
  63305. /**
  63306. * Image Width (internal use)
  63307. * @hidden
  63308. */
  63309. _groupImgWidth: number;
  63310. /**
  63311. * Image Height (internal use)
  63312. * @hidden
  63313. */
  63314. _groupImgHeight: number;
  63315. /**
  63316. * Custom position function (internal use)
  63317. * @hidden
  63318. */
  63319. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  63320. /**
  63321. * density per facet for surface points
  63322. * @hidden
  63323. */
  63324. _groupDensity: number[];
  63325. /**
  63326. * Only when points are colored by texture carries pointer to texture list array
  63327. * @hidden
  63328. */
  63329. _textureNb: number;
  63330. /**
  63331. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  63332. * PCS internal tool, don't use it manually.
  63333. * @hidden
  63334. */
  63335. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  63336. }
  63337. }
  63338. declare module BABYLON {
  63339. interface Scene {
  63340. /** @hidden (Backing field) */
  63341. _physicsEngine: Nullable<IPhysicsEngine>;
  63342. /** @hidden */
  63343. _physicsTimeAccumulator: number;
  63344. /**
  63345. * Gets the current physics engine
  63346. * @returns a IPhysicsEngine or null if none attached
  63347. */
  63348. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  63349. /**
  63350. * Enables physics to the current scene
  63351. * @param gravity defines the scene's gravity for the physics engine
  63352. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  63353. * @return a boolean indicating if the physics engine was initialized
  63354. */
  63355. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  63356. /**
  63357. * Disables and disposes the physics engine associated with the scene
  63358. */
  63359. disablePhysicsEngine(): void;
  63360. /**
  63361. * Gets a boolean indicating if there is an active physics engine
  63362. * @returns a boolean indicating if there is an active physics engine
  63363. */
  63364. isPhysicsEnabled(): boolean;
  63365. /**
  63366. * Deletes a physics compound impostor
  63367. * @param compound defines the compound to delete
  63368. */
  63369. deleteCompoundImpostor(compound: any): void;
  63370. /**
  63371. * An event triggered when physic simulation is about to be run
  63372. */
  63373. onBeforePhysicsObservable: Observable<Scene>;
  63374. /**
  63375. * An event triggered when physic simulation has been done
  63376. */
  63377. onAfterPhysicsObservable: Observable<Scene>;
  63378. }
  63379. interface AbstractMesh {
  63380. /** @hidden */
  63381. _physicsImpostor: Nullable<PhysicsImpostor>;
  63382. /**
  63383. * Gets or sets impostor used for physic simulation
  63384. * @see http://doc.babylonjs.com/features/physics_engine
  63385. */
  63386. physicsImpostor: Nullable<PhysicsImpostor>;
  63387. /**
  63388. * Gets the current physics impostor
  63389. * @see http://doc.babylonjs.com/features/physics_engine
  63390. * @returns a physics impostor or null
  63391. */
  63392. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  63393. /** Apply a physic impulse to the mesh
  63394. * @param force defines the force to apply
  63395. * @param contactPoint defines where to apply the force
  63396. * @returns the current mesh
  63397. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  63398. */
  63399. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  63400. /**
  63401. * Creates a physic joint between two meshes
  63402. * @param otherMesh defines the other mesh to use
  63403. * @param pivot1 defines the pivot to use on this mesh
  63404. * @param pivot2 defines the pivot to use on the other mesh
  63405. * @param options defines additional options (can be plugin dependent)
  63406. * @returns the current mesh
  63407. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  63408. */
  63409. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  63410. /** @hidden */
  63411. _disposePhysicsObserver: Nullable<Observer<Node>>;
  63412. }
  63413. /**
  63414. * Defines the physics engine scene component responsible to manage a physics engine
  63415. */
  63416. export class PhysicsEngineSceneComponent implements ISceneComponent {
  63417. /**
  63418. * The component name helpful to identify the component in the list of scene components.
  63419. */
  63420. readonly name: string;
  63421. /**
  63422. * The scene the component belongs to.
  63423. */
  63424. scene: Scene;
  63425. /**
  63426. * Creates a new instance of the component for the given scene
  63427. * @param scene Defines the scene to register the component in
  63428. */
  63429. constructor(scene: Scene);
  63430. /**
  63431. * Registers the component in a given scene
  63432. */
  63433. register(): void;
  63434. /**
  63435. * Rebuilds the elements related to this component in case of
  63436. * context lost for instance.
  63437. */
  63438. rebuild(): void;
  63439. /**
  63440. * Disposes the component and the associated ressources
  63441. */
  63442. dispose(): void;
  63443. }
  63444. }
  63445. declare module BABYLON {
  63446. /**
  63447. * A helper for physics simulations
  63448. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63449. */
  63450. export class PhysicsHelper {
  63451. private _scene;
  63452. private _physicsEngine;
  63453. /**
  63454. * Initializes the Physics helper
  63455. * @param scene Babylon.js scene
  63456. */
  63457. constructor(scene: Scene);
  63458. /**
  63459. * Applies a radial explosion impulse
  63460. * @param origin the origin of the explosion
  63461. * @param radiusOrEventOptions the radius or the options of radial explosion
  63462. * @param strength the explosion strength
  63463. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63464. * @returns A physics radial explosion event, or null
  63465. */
  63466. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  63467. /**
  63468. * Applies a radial explosion force
  63469. * @param origin the origin of the explosion
  63470. * @param radiusOrEventOptions the radius or the options of radial explosion
  63471. * @param strength the explosion strength
  63472. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63473. * @returns A physics radial explosion event, or null
  63474. */
  63475. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  63476. /**
  63477. * Creates a gravitational field
  63478. * @param origin the origin of the explosion
  63479. * @param radiusOrEventOptions the radius or the options of radial explosion
  63480. * @param strength the explosion strength
  63481. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63482. * @returns A physics gravitational field event, or null
  63483. */
  63484. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  63485. /**
  63486. * Creates a physics updraft event
  63487. * @param origin the origin of the updraft
  63488. * @param radiusOrEventOptions the radius or the options of the updraft
  63489. * @param strength the strength of the updraft
  63490. * @param height the height of the updraft
  63491. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  63492. * @returns A physics updraft event, or null
  63493. */
  63494. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  63495. /**
  63496. * Creates a physics vortex event
  63497. * @param origin the of the vortex
  63498. * @param radiusOrEventOptions the radius or the options of the vortex
  63499. * @param strength the strength of the vortex
  63500. * @param height the height of the vortex
  63501. * @returns a Physics vortex event, or null
  63502. * A physics vortex event or null
  63503. */
  63504. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  63505. }
  63506. /**
  63507. * Represents a physics radial explosion event
  63508. */
  63509. class PhysicsRadialExplosionEvent {
  63510. private _scene;
  63511. private _options;
  63512. private _sphere;
  63513. private _dataFetched;
  63514. /**
  63515. * Initializes a radial explosioin event
  63516. * @param _scene BabylonJS scene
  63517. * @param _options The options for the vortex event
  63518. */
  63519. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  63520. /**
  63521. * Returns the data related to the radial explosion event (sphere).
  63522. * @returns The radial explosion event data
  63523. */
  63524. getData(): PhysicsRadialExplosionEventData;
  63525. /**
  63526. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  63527. * @param impostor A physics imposter
  63528. * @param origin the origin of the explosion
  63529. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  63530. */
  63531. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  63532. /**
  63533. * Triggers affecterd impostors callbacks
  63534. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  63535. */
  63536. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  63537. /**
  63538. * Disposes the sphere.
  63539. * @param force Specifies if the sphere should be disposed by force
  63540. */
  63541. dispose(force?: boolean): void;
  63542. /*** Helpers ***/
  63543. private _prepareSphere;
  63544. private _intersectsWithSphere;
  63545. }
  63546. /**
  63547. * Represents a gravitational field event
  63548. */
  63549. class PhysicsGravitationalFieldEvent {
  63550. private _physicsHelper;
  63551. private _scene;
  63552. private _origin;
  63553. private _options;
  63554. private _tickCallback;
  63555. private _sphere;
  63556. private _dataFetched;
  63557. /**
  63558. * Initializes the physics gravitational field event
  63559. * @param _physicsHelper A physics helper
  63560. * @param _scene BabylonJS scene
  63561. * @param _origin The origin position of the gravitational field event
  63562. * @param _options The options for the vortex event
  63563. */
  63564. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  63565. /**
  63566. * Returns the data related to the gravitational field event (sphere).
  63567. * @returns A gravitational field event
  63568. */
  63569. getData(): PhysicsGravitationalFieldEventData;
  63570. /**
  63571. * Enables the gravitational field.
  63572. */
  63573. enable(): void;
  63574. /**
  63575. * Disables the gravitational field.
  63576. */
  63577. disable(): void;
  63578. /**
  63579. * Disposes the sphere.
  63580. * @param force The force to dispose from the gravitational field event
  63581. */
  63582. dispose(force?: boolean): void;
  63583. private _tick;
  63584. }
  63585. /**
  63586. * Represents a physics updraft event
  63587. */
  63588. class PhysicsUpdraftEvent {
  63589. private _scene;
  63590. private _origin;
  63591. private _options;
  63592. private _physicsEngine;
  63593. private _originTop;
  63594. private _originDirection;
  63595. private _tickCallback;
  63596. private _cylinder;
  63597. private _cylinderPosition;
  63598. private _dataFetched;
  63599. /**
  63600. * Initializes the physics updraft event
  63601. * @param _scene BabylonJS scene
  63602. * @param _origin The origin position of the updraft
  63603. * @param _options The options for the updraft event
  63604. */
  63605. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  63606. /**
  63607. * Returns the data related to the updraft event (cylinder).
  63608. * @returns A physics updraft event
  63609. */
  63610. getData(): PhysicsUpdraftEventData;
  63611. /**
  63612. * Enables the updraft.
  63613. */
  63614. enable(): void;
  63615. /**
  63616. * Disables the updraft.
  63617. */
  63618. disable(): void;
  63619. /**
  63620. * Disposes the cylinder.
  63621. * @param force Specifies if the updraft should be disposed by force
  63622. */
  63623. dispose(force?: boolean): void;
  63624. private getImpostorHitData;
  63625. private _tick;
  63626. /*** Helpers ***/
  63627. private _prepareCylinder;
  63628. private _intersectsWithCylinder;
  63629. }
  63630. /**
  63631. * Represents a physics vortex event
  63632. */
  63633. class PhysicsVortexEvent {
  63634. private _scene;
  63635. private _origin;
  63636. private _options;
  63637. private _physicsEngine;
  63638. private _originTop;
  63639. private _tickCallback;
  63640. private _cylinder;
  63641. private _cylinderPosition;
  63642. private _dataFetched;
  63643. /**
  63644. * Initializes the physics vortex event
  63645. * @param _scene The BabylonJS scene
  63646. * @param _origin The origin position of the vortex
  63647. * @param _options The options for the vortex event
  63648. */
  63649. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  63650. /**
  63651. * Returns the data related to the vortex event (cylinder).
  63652. * @returns The physics vortex event data
  63653. */
  63654. getData(): PhysicsVortexEventData;
  63655. /**
  63656. * Enables the vortex.
  63657. */
  63658. enable(): void;
  63659. /**
  63660. * Disables the cortex.
  63661. */
  63662. disable(): void;
  63663. /**
  63664. * Disposes the sphere.
  63665. * @param force
  63666. */
  63667. dispose(force?: boolean): void;
  63668. private getImpostorHitData;
  63669. private _tick;
  63670. /*** Helpers ***/
  63671. private _prepareCylinder;
  63672. private _intersectsWithCylinder;
  63673. }
  63674. /**
  63675. * Options fot the radial explosion event
  63676. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63677. */
  63678. export class PhysicsRadialExplosionEventOptions {
  63679. /**
  63680. * The radius of the sphere for the radial explosion.
  63681. */
  63682. radius: number;
  63683. /**
  63684. * The strenth of the explosion.
  63685. */
  63686. strength: number;
  63687. /**
  63688. * The strenght of the force in correspondence to the distance of the affected object
  63689. */
  63690. falloff: PhysicsRadialImpulseFalloff;
  63691. /**
  63692. * Sphere options for the radial explosion.
  63693. */
  63694. sphere: {
  63695. segments: number;
  63696. diameter: number;
  63697. };
  63698. /**
  63699. * Sphere options for the radial explosion.
  63700. */
  63701. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  63702. }
  63703. /**
  63704. * Options fot the updraft event
  63705. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63706. */
  63707. export class PhysicsUpdraftEventOptions {
  63708. /**
  63709. * The radius of the cylinder for the vortex
  63710. */
  63711. radius: number;
  63712. /**
  63713. * The strenth of the updraft.
  63714. */
  63715. strength: number;
  63716. /**
  63717. * The height of the cylinder for the updraft.
  63718. */
  63719. height: number;
  63720. /**
  63721. * The mode for the the updraft.
  63722. */
  63723. updraftMode: PhysicsUpdraftMode;
  63724. }
  63725. /**
  63726. * Options fot the vortex event
  63727. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63728. */
  63729. export class PhysicsVortexEventOptions {
  63730. /**
  63731. * The radius of the cylinder for the vortex
  63732. */
  63733. radius: number;
  63734. /**
  63735. * The strenth of the vortex.
  63736. */
  63737. strength: number;
  63738. /**
  63739. * The height of the cylinder for the vortex.
  63740. */
  63741. height: number;
  63742. /**
  63743. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  63744. */
  63745. centripetalForceThreshold: number;
  63746. /**
  63747. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  63748. */
  63749. centripetalForceMultiplier: number;
  63750. /**
  63751. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  63752. */
  63753. centrifugalForceMultiplier: number;
  63754. /**
  63755. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  63756. */
  63757. updraftForceMultiplier: number;
  63758. }
  63759. /**
  63760. * The strenght of the force in correspondence to the distance of the affected object
  63761. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63762. */
  63763. export enum PhysicsRadialImpulseFalloff {
  63764. /** Defines that impulse is constant in strength across it's whole radius */
  63765. Constant = 0,
  63766. /** Defines that impulse gets weaker if it's further from the origin */
  63767. Linear = 1
  63768. }
  63769. /**
  63770. * The strength of the force in correspondence to the distance of the affected object
  63771. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63772. */
  63773. export enum PhysicsUpdraftMode {
  63774. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  63775. Center = 0,
  63776. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  63777. Perpendicular = 1
  63778. }
  63779. /**
  63780. * Interface for a physics hit data
  63781. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63782. */
  63783. export interface PhysicsHitData {
  63784. /**
  63785. * The force applied at the contact point
  63786. */
  63787. force: Vector3;
  63788. /**
  63789. * The contact point
  63790. */
  63791. contactPoint: Vector3;
  63792. /**
  63793. * The distance from the origin to the contact point
  63794. */
  63795. distanceFromOrigin: number;
  63796. }
  63797. /**
  63798. * Interface for radial explosion event data
  63799. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63800. */
  63801. export interface PhysicsRadialExplosionEventData {
  63802. /**
  63803. * A sphere used for the radial explosion event
  63804. */
  63805. sphere: Mesh;
  63806. }
  63807. /**
  63808. * Interface for gravitational field event data
  63809. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63810. */
  63811. export interface PhysicsGravitationalFieldEventData {
  63812. /**
  63813. * A sphere mesh used for the gravitational field event
  63814. */
  63815. sphere: Mesh;
  63816. }
  63817. /**
  63818. * Interface for updraft event data
  63819. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63820. */
  63821. export interface PhysicsUpdraftEventData {
  63822. /**
  63823. * A cylinder used for the updraft event
  63824. */
  63825. cylinder: Mesh;
  63826. }
  63827. /**
  63828. * Interface for vortex event data
  63829. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63830. */
  63831. export interface PhysicsVortexEventData {
  63832. /**
  63833. * A cylinder used for the vortex event
  63834. */
  63835. cylinder: Mesh;
  63836. }
  63837. /**
  63838. * Interface for an affected physics impostor
  63839. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63840. */
  63841. export interface PhysicsAffectedImpostorWithData {
  63842. /**
  63843. * The impostor affected by the effect
  63844. */
  63845. impostor: PhysicsImpostor;
  63846. /**
  63847. * The data about the hit/horce from the explosion
  63848. */
  63849. hitData: PhysicsHitData;
  63850. }
  63851. }
  63852. declare module BABYLON {
  63853. /** @hidden */
  63854. export var blackAndWhitePixelShader: {
  63855. name: string;
  63856. shader: string;
  63857. };
  63858. }
  63859. declare module BABYLON {
  63860. /**
  63861. * Post process used to render in black and white
  63862. */
  63863. export class BlackAndWhitePostProcess extends PostProcess {
  63864. /**
  63865. * Linear about to convert he result to black and white (default: 1)
  63866. */
  63867. degree: number;
  63868. /**
  63869. * Creates a black and white post process
  63870. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  63871. * @param name The name of the effect.
  63872. * @param options The required width/height ratio to downsize to before computing the render pass.
  63873. * @param camera The camera to apply the render pass to.
  63874. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63875. * @param engine The engine which the post process will be applied. (default: current engine)
  63876. * @param reusable If the post process can be reused on the same frame. (default: false)
  63877. */
  63878. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63879. }
  63880. }
  63881. declare module BABYLON {
  63882. /**
  63883. * This represents a set of one or more post processes in Babylon.
  63884. * A post process can be used to apply a shader to a texture after it is rendered.
  63885. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63886. */
  63887. export class PostProcessRenderEffect {
  63888. private _postProcesses;
  63889. private _getPostProcesses;
  63890. private _singleInstance;
  63891. private _cameras;
  63892. private _indicesForCamera;
  63893. /**
  63894. * Name of the effect
  63895. * @hidden
  63896. */
  63897. _name: string;
  63898. /**
  63899. * Instantiates a post process render effect.
  63900. * A post process can be used to apply a shader to a texture after it is rendered.
  63901. * @param engine The engine the effect is tied to
  63902. * @param name The name of the effect
  63903. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  63904. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  63905. */
  63906. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  63907. /**
  63908. * Checks if all the post processes in the effect are supported.
  63909. */
  63910. get isSupported(): boolean;
  63911. /**
  63912. * Updates the current state of the effect
  63913. * @hidden
  63914. */
  63915. _update(): void;
  63916. /**
  63917. * Attaches the effect on cameras
  63918. * @param cameras The camera to attach to.
  63919. * @hidden
  63920. */
  63921. _attachCameras(cameras: Camera): void;
  63922. /**
  63923. * Attaches the effect on cameras
  63924. * @param cameras The camera to attach to.
  63925. * @hidden
  63926. */
  63927. _attachCameras(cameras: Camera[]): void;
  63928. /**
  63929. * Detaches the effect on cameras
  63930. * @param cameras The camera to detatch from.
  63931. * @hidden
  63932. */
  63933. _detachCameras(cameras: Camera): void;
  63934. /**
  63935. * Detatches the effect on cameras
  63936. * @param cameras The camera to detatch from.
  63937. * @hidden
  63938. */
  63939. _detachCameras(cameras: Camera[]): void;
  63940. /**
  63941. * Enables the effect on given cameras
  63942. * @param cameras The camera to enable.
  63943. * @hidden
  63944. */
  63945. _enable(cameras: Camera): void;
  63946. /**
  63947. * Enables the effect on given cameras
  63948. * @param cameras The camera to enable.
  63949. * @hidden
  63950. */
  63951. _enable(cameras: Nullable<Camera[]>): void;
  63952. /**
  63953. * Disables the effect on the given cameras
  63954. * @param cameras The camera to disable.
  63955. * @hidden
  63956. */
  63957. _disable(cameras: Camera): void;
  63958. /**
  63959. * Disables the effect on the given cameras
  63960. * @param cameras The camera to disable.
  63961. * @hidden
  63962. */
  63963. _disable(cameras: Nullable<Camera[]>): void;
  63964. /**
  63965. * Gets a list of the post processes contained in the effect.
  63966. * @param camera The camera to get the post processes on.
  63967. * @returns The list of the post processes in the effect.
  63968. */
  63969. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  63970. }
  63971. }
  63972. declare module BABYLON {
  63973. /** @hidden */
  63974. export var extractHighlightsPixelShader: {
  63975. name: string;
  63976. shader: string;
  63977. };
  63978. }
  63979. declare module BABYLON {
  63980. /**
  63981. * 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.
  63982. */
  63983. export class ExtractHighlightsPostProcess extends PostProcess {
  63984. /**
  63985. * The luminance threshold, pixels below this value will be set to black.
  63986. */
  63987. threshold: number;
  63988. /** @hidden */
  63989. _exposure: number;
  63990. /**
  63991. * Post process which has the input texture to be used when performing highlight extraction
  63992. * @hidden
  63993. */
  63994. _inputPostProcess: Nullable<PostProcess>;
  63995. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63996. }
  63997. }
  63998. declare module BABYLON {
  63999. /** @hidden */
  64000. export var bloomMergePixelShader: {
  64001. name: string;
  64002. shader: string;
  64003. };
  64004. }
  64005. declare module BABYLON {
  64006. /**
  64007. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64008. */
  64009. export class BloomMergePostProcess extends PostProcess {
  64010. /** Weight of the bloom to be added to the original input. */
  64011. weight: number;
  64012. /**
  64013. * Creates a new instance of @see BloomMergePostProcess
  64014. * @param name The name of the effect.
  64015. * @param originalFromInput Post process which's input will be used for the merge.
  64016. * @param blurred Blurred highlights post process which's output will be used.
  64017. * @param weight Weight of the bloom to be added to the original input.
  64018. * @param options The required width/height ratio to downsize to before computing the render pass.
  64019. * @param camera The camera to apply the render pass to.
  64020. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64021. * @param engine The engine which the post process will be applied. (default: current engine)
  64022. * @param reusable If the post process can be reused on the same frame. (default: false)
  64023. * @param textureType Type of textures used when performing the post process. (default: 0)
  64024. * @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)
  64025. */
  64026. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  64027. /** Weight of the bloom to be added to the original input. */
  64028. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64029. }
  64030. }
  64031. declare module BABYLON {
  64032. /**
  64033. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  64034. */
  64035. export class BloomEffect extends PostProcessRenderEffect {
  64036. private bloomScale;
  64037. /**
  64038. * @hidden Internal
  64039. */
  64040. _effects: Array<PostProcess>;
  64041. /**
  64042. * @hidden Internal
  64043. */
  64044. _downscale: ExtractHighlightsPostProcess;
  64045. private _blurX;
  64046. private _blurY;
  64047. private _merge;
  64048. /**
  64049. * The luminance threshold to find bright areas of the image to bloom.
  64050. */
  64051. get threshold(): number;
  64052. set threshold(value: number);
  64053. /**
  64054. * The strength of the bloom.
  64055. */
  64056. get weight(): number;
  64057. set weight(value: number);
  64058. /**
  64059. * Specifies the size of the bloom blur kernel, relative to the final output size
  64060. */
  64061. get kernel(): number;
  64062. set kernel(value: number);
  64063. /**
  64064. * Creates a new instance of @see BloomEffect
  64065. * @param scene The scene the effect belongs to.
  64066. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  64067. * @param bloomKernel The size of the kernel to be used when applying the blur.
  64068. * @param bloomWeight The the strength of bloom.
  64069. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64070. * @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)
  64071. */
  64072. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  64073. /**
  64074. * Disposes each of the internal effects for a given camera.
  64075. * @param camera The camera to dispose the effect on.
  64076. */
  64077. disposeEffects(camera: Camera): void;
  64078. /**
  64079. * @hidden Internal
  64080. */
  64081. _updateEffects(): void;
  64082. /**
  64083. * Internal
  64084. * @returns if all the contained post processes are ready.
  64085. * @hidden
  64086. */
  64087. _isReady(): boolean;
  64088. }
  64089. }
  64090. declare module BABYLON {
  64091. /** @hidden */
  64092. export var chromaticAberrationPixelShader: {
  64093. name: string;
  64094. shader: string;
  64095. };
  64096. }
  64097. declare module BABYLON {
  64098. /**
  64099. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  64100. */
  64101. export class ChromaticAberrationPostProcess extends PostProcess {
  64102. /**
  64103. * The amount of seperation of rgb channels (default: 30)
  64104. */
  64105. aberrationAmount: number;
  64106. /**
  64107. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  64108. */
  64109. radialIntensity: number;
  64110. /**
  64111. * 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))
  64112. */
  64113. direction: Vector2;
  64114. /**
  64115. * 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))
  64116. */
  64117. centerPosition: Vector2;
  64118. /**
  64119. * Creates a new instance ChromaticAberrationPostProcess
  64120. * @param name The name of the effect.
  64121. * @param screenWidth The width of the screen to apply the effect on.
  64122. * @param screenHeight The height of the screen to apply the effect on.
  64123. * @param options The required width/height ratio to downsize to before computing the render pass.
  64124. * @param camera The camera to apply the render pass to.
  64125. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64126. * @param engine The engine which the post process will be applied. (default: current engine)
  64127. * @param reusable If the post process can be reused on the same frame. (default: false)
  64128. * @param textureType Type of textures used when performing the post process. (default: 0)
  64129. * @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)
  64130. */
  64131. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64132. }
  64133. }
  64134. declare module BABYLON {
  64135. /** @hidden */
  64136. export var circleOfConfusionPixelShader: {
  64137. name: string;
  64138. shader: string;
  64139. };
  64140. }
  64141. declare module BABYLON {
  64142. /**
  64143. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  64144. */
  64145. export class CircleOfConfusionPostProcess extends PostProcess {
  64146. /**
  64147. * 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.
  64148. */
  64149. lensSize: number;
  64150. /**
  64151. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64152. */
  64153. fStop: number;
  64154. /**
  64155. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64156. */
  64157. focusDistance: number;
  64158. /**
  64159. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  64160. */
  64161. focalLength: number;
  64162. private _depthTexture;
  64163. /**
  64164. * Creates a new instance CircleOfConfusionPostProcess
  64165. * @param name The name of the effect.
  64166. * @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.
  64167. * @param options The required width/height ratio to downsize to before computing the render pass.
  64168. * @param camera The camera to apply the render pass to.
  64169. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64170. * @param engine The engine which the post process will be applied. (default: current engine)
  64171. * @param reusable If the post process can be reused on the same frame. (default: false)
  64172. * @param textureType Type of textures used when performing the post process. (default: 0)
  64173. * @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)
  64174. */
  64175. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64176. /**
  64177. * 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.
  64178. */
  64179. set depthTexture(value: RenderTargetTexture);
  64180. }
  64181. }
  64182. declare module BABYLON {
  64183. /** @hidden */
  64184. export var colorCorrectionPixelShader: {
  64185. name: string;
  64186. shader: string;
  64187. };
  64188. }
  64189. declare module BABYLON {
  64190. /**
  64191. *
  64192. * This post-process allows the modification of rendered colors by using
  64193. * a 'look-up table' (LUT). This effect is also called Color Grading.
  64194. *
  64195. * The object needs to be provided an url to a texture containing the color
  64196. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  64197. * Use an image editing software to tweak the LUT to match your needs.
  64198. *
  64199. * For an example of a color LUT, see here:
  64200. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  64201. * For explanations on color grading, see here:
  64202. * @see http://udn.epicgames.com/Three/ColorGrading.html
  64203. *
  64204. */
  64205. export class ColorCorrectionPostProcess extends PostProcess {
  64206. private _colorTableTexture;
  64207. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64208. }
  64209. }
  64210. declare module BABYLON {
  64211. /** @hidden */
  64212. export var convolutionPixelShader: {
  64213. name: string;
  64214. shader: string;
  64215. };
  64216. }
  64217. declare module BABYLON {
  64218. /**
  64219. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  64220. * input texture to perform effects such as edge detection or sharpening
  64221. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  64222. */
  64223. export class ConvolutionPostProcess extends PostProcess {
  64224. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64225. kernel: number[];
  64226. /**
  64227. * Creates a new instance ConvolutionPostProcess
  64228. * @param name The name of the effect.
  64229. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  64230. * @param options The required width/height ratio to downsize to before computing the render pass.
  64231. * @param camera The camera to apply the render pass to.
  64232. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64233. * @param engine The engine which the post process will be applied. (default: current engine)
  64234. * @param reusable If the post process can be reused on the same frame. (default: false)
  64235. * @param textureType Type of textures used when performing the post process. (default: 0)
  64236. */
  64237. constructor(name: string,
  64238. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64239. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64240. /**
  64241. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64242. */
  64243. static EdgeDetect0Kernel: number[];
  64244. /**
  64245. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64246. */
  64247. static EdgeDetect1Kernel: number[];
  64248. /**
  64249. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64250. */
  64251. static EdgeDetect2Kernel: number[];
  64252. /**
  64253. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64254. */
  64255. static SharpenKernel: number[];
  64256. /**
  64257. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64258. */
  64259. static EmbossKernel: number[];
  64260. /**
  64261. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64262. */
  64263. static GaussianKernel: number[];
  64264. }
  64265. }
  64266. declare module BABYLON {
  64267. /**
  64268. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  64269. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  64270. * based on samples that have a large difference in distance than the center pixel.
  64271. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  64272. */
  64273. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  64274. direction: Vector2;
  64275. /**
  64276. * Creates a new instance CircleOfConfusionPostProcess
  64277. * @param name The name of the effect.
  64278. * @param scene The scene the effect belongs to.
  64279. * @param direction The direction the blur should be applied.
  64280. * @param kernel The size of the kernel used to blur.
  64281. * @param options The required width/height ratio to downsize to before computing the render pass.
  64282. * @param camera The camera to apply the render pass to.
  64283. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  64284. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  64285. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64286. * @param engine The engine which the post process will be applied. (default: current engine)
  64287. * @param reusable If the post process can be reused on the same frame. (default: false)
  64288. * @param textureType Type of textures used when performing the post process. (default: 0)
  64289. * @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)
  64290. */
  64291. 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);
  64292. }
  64293. }
  64294. declare module BABYLON {
  64295. /** @hidden */
  64296. export var depthOfFieldMergePixelShader: {
  64297. name: string;
  64298. shader: string;
  64299. };
  64300. }
  64301. declare module BABYLON {
  64302. /**
  64303. * Options to be set when merging outputs from the default pipeline.
  64304. */
  64305. export class DepthOfFieldMergePostProcessOptions {
  64306. /**
  64307. * The original image to merge on top of
  64308. */
  64309. originalFromInput: PostProcess;
  64310. /**
  64311. * Parameters to perform the merge of the depth of field effect
  64312. */
  64313. depthOfField?: {
  64314. circleOfConfusion: PostProcess;
  64315. blurSteps: Array<PostProcess>;
  64316. };
  64317. /**
  64318. * Parameters to perform the merge of bloom effect
  64319. */
  64320. bloom?: {
  64321. blurred: PostProcess;
  64322. weight: number;
  64323. };
  64324. }
  64325. /**
  64326. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64327. */
  64328. export class DepthOfFieldMergePostProcess extends PostProcess {
  64329. private blurSteps;
  64330. /**
  64331. * Creates a new instance of DepthOfFieldMergePostProcess
  64332. * @param name The name of the effect.
  64333. * @param originalFromInput Post process which's input will be used for the merge.
  64334. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  64335. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  64336. * @param options The required width/height ratio to downsize to before computing the render pass.
  64337. * @param camera The camera to apply the render pass to.
  64338. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64339. * @param engine The engine which the post process will be applied. (default: current engine)
  64340. * @param reusable If the post process can be reused on the same frame. (default: false)
  64341. * @param textureType Type of textures used when performing the post process. (default: 0)
  64342. * @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)
  64343. */
  64344. 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);
  64345. /**
  64346. * Updates the effect with the current post process compile time values and recompiles the shader.
  64347. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  64348. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  64349. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  64350. * @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
  64351. * @param onCompiled Called when the shader has been compiled.
  64352. * @param onError Called if there is an error when compiling a shader.
  64353. */
  64354. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  64355. }
  64356. }
  64357. declare module BABYLON {
  64358. /**
  64359. * Specifies the level of max blur that should be applied when using the depth of field effect
  64360. */
  64361. export enum DepthOfFieldEffectBlurLevel {
  64362. /**
  64363. * Subtle blur
  64364. */
  64365. Low = 0,
  64366. /**
  64367. * Medium blur
  64368. */
  64369. Medium = 1,
  64370. /**
  64371. * Large blur
  64372. */
  64373. High = 2
  64374. }
  64375. /**
  64376. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  64377. */
  64378. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  64379. private _circleOfConfusion;
  64380. /**
  64381. * @hidden Internal, blurs from high to low
  64382. */
  64383. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  64384. private _depthOfFieldBlurY;
  64385. private _dofMerge;
  64386. /**
  64387. * @hidden Internal post processes in depth of field effect
  64388. */
  64389. _effects: Array<PostProcess>;
  64390. /**
  64391. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  64392. */
  64393. set focalLength(value: number);
  64394. get focalLength(): number;
  64395. /**
  64396. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64397. */
  64398. set fStop(value: number);
  64399. get fStop(): number;
  64400. /**
  64401. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64402. */
  64403. set focusDistance(value: number);
  64404. get focusDistance(): number;
  64405. /**
  64406. * 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.
  64407. */
  64408. set lensSize(value: number);
  64409. get lensSize(): number;
  64410. /**
  64411. * Creates a new instance DepthOfFieldEffect
  64412. * @param scene The scene the effect belongs to.
  64413. * @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.
  64414. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64415. * @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)
  64416. */
  64417. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  64418. /**
  64419. * Get the current class name of the current effet
  64420. * @returns "DepthOfFieldEffect"
  64421. */
  64422. getClassName(): string;
  64423. /**
  64424. * 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.
  64425. */
  64426. set depthTexture(value: RenderTargetTexture);
  64427. /**
  64428. * Disposes each of the internal effects for a given camera.
  64429. * @param camera The camera to dispose the effect on.
  64430. */
  64431. disposeEffects(camera: Camera): void;
  64432. /**
  64433. * @hidden Internal
  64434. */
  64435. _updateEffects(): void;
  64436. /**
  64437. * Internal
  64438. * @returns if all the contained post processes are ready.
  64439. * @hidden
  64440. */
  64441. _isReady(): boolean;
  64442. }
  64443. }
  64444. declare module BABYLON {
  64445. /** @hidden */
  64446. export var displayPassPixelShader: {
  64447. name: string;
  64448. shader: string;
  64449. };
  64450. }
  64451. declare module BABYLON {
  64452. /**
  64453. * DisplayPassPostProcess which produces an output the same as it's input
  64454. */
  64455. export class DisplayPassPostProcess extends PostProcess {
  64456. /**
  64457. * Creates the DisplayPassPostProcess
  64458. * @param name The name of the effect.
  64459. * @param options The required width/height ratio to downsize to before computing the render pass.
  64460. * @param camera The camera to apply the render pass to.
  64461. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64462. * @param engine The engine which the post process will be applied. (default: current engine)
  64463. * @param reusable If the post process can be reused on the same frame. (default: false)
  64464. */
  64465. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64466. }
  64467. }
  64468. declare module BABYLON {
  64469. /** @hidden */
  64470. export var filterPixelShader: {
  64471. name: string;
  64472. shader: string;
  64473. };
  64474. }
  64475. declare module BABYLON {
  64476. /**
  64477. * Applies a kernel filter to the image
  64478. */
  64479. export class FilterPostProcess extends PostProcess {
  64480. /** The matrix to be applied to the image */
  64481. kernelMatrix: Matrix;
  64482. /**
  64483. *
  64484. * @param name The name of the effect.
  64485. * @param kernelMatrix The matrix to be applied to the image
  64486. * @param options The required width/height ratio to downsize to before computing the render pass.
  64487. * @param camera The camera to apply the render pass to.
  64488. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64489. * @param engine The engine which the post process will be applied. (default: current engine)
  64490. * @param reusable If the post process can be reused on the same frame. (default: false)
  64491. */
  64492. constructor(name: string,
  64493. /** The matrix to be applied to the image */
  64494. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64495. }
  64496. }
  64497. declare module BABYLON {
  64498. /** @hidden */
  64499. export var fxaaPixelShader: {
  64500. name: string;
  64501. shader: string;
  64502. };
  64503. }
  64504. declare module BABYLON {
  64505. /** @hidden */
  64506. export var fxaaVertexShader: {
  64507. name: string;
  64508. shader: string;
  64509. };
  64510. }
  64511. declare module BABYLON {
  64512. /**
  64513. * Fxaa post process
  64514. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  64515. */
  64516. export class FxaaPostProcess extends PostProcess {
  64517. /** @hidden */
  64518. texelWidth: number;
  64519. /** @hidden */
  64520. texelHeight: number;
  64521. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64522. private _getDefines;
  64523. }
  64524. }
  64525. declare module BABYLON {
  64526. /** @hidden */
  64527. export var grainPixelShader: {
  64528. name: string;
  64529. shader: string;
  64530. };
  64531. }
  64532. declare module BABYLON {
  64533. /**
  64534. * The GrainPostProcess adds noise to the image at mid luminance levels
  64535. */
  64536. export class GrainPostProcess extends PostProcess {
  64537. /**
  64538. * The intensity of the grain added (default: 30)
  64539. */
  64540. intensity: number;
  64541. /**
  64542. * If the grain should be randomized on every frame
  64543. */
  64544. animated: boolean;
  64545. /**
  64546. * Creates a new instance of @see GrainPostProcess
  64547. * @param name The name of the effect.
  64548. * @param options The required width/height ratio to downsize to before computing the render pass.
  64549. * @param camera The camera to apply the render pass to.
  64550. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64551. * @param engine The engine which the post process will be applied. (default: current engine)
  64552. * @param reusable If the post process can be reused on the same frame. (default: false)
  64553. * @param textureType Type of textures used when performing the post process. (default: 0)
  64554. * @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)
  64555. */
  64556. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64557. }
  64558. }
  64559. declare module BABYLON {
  64560. /** @hidden */
  64561. export var highlightsPixelShader: {
  64562. name: string;
  64563. shader: string;
  64564. };
  64565. }
  64566. declare module BABYLON {
  64567. /**
  64568. * Extracts highlights from the image
  64569. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  64570. */
  64571. export class HighlightsPostProcess extends PostProcess {
  64572. /**
  64573. * Extracts highlights from the image
  64574. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  64575. * @param name The name of the effect.
  64576. * @param options The required width/height ratio to downsize to before computing the render pass.
  64577. * @param camera The camera to apply the render pass to.
  64578. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64579. * @param engine The engine which the post process will be applied. (default: current engine)
  64580. * @param reusable If the post process can be reused on the same frame. (default: false)
  64581. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  64582. */
  64583. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64584. }
  64585. }
  64586. declare module BABYLON {
  64587. /** @hidden */
  64588. export var mrtFragmentDeclaration: {
  64589. name: string;
  64590. shader: string;
  64591. };
  64592. }
  64593. declare module BABYLON {
  64594. /** @hidden */
  64595. export var geometryPixelShader: {
  64596. name: string;
  64597. shader: string;
  64598. };
  64599. }
  64600. declare module BABYLON {
  64601. /** @hidden */
  64602. export var geometryVertexShader: {
  64603. name: string;
  64604. shader: string;
  64605. };
  64606. }
  64607. declare module BABYLON {
  64608. /** @hidden */
  64609. interface ISavedTransformationMatrix {
  64610. world: Matrix;
  64611. viewProjection: Matrix;
  64612. }
  64613. /**
  64614. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  64615. */
  64616. export class GeometryBufferRenderer {
  64617. /**
  64618. * Constant used to retrieve the position texture index in the G-Buffer textures array
  64619. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  64620. */
  64621. static readonly POSITION_TEXTURE_TYPE: number;
  64622. /**
  64623. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  64624. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  64625. */
  64626. static readonly VELOCITY_TEXTURE_TYPE: number;
  64627. /**
  64628. * Dictionary used to store the previous transformation matrices of each rendered mesh
  64629. * in order to compute objects velocities when enableVelocity is set to "true"
  64630. * @hidden
  64631. */
  64632. _previousTransformationMatrices: {
  64633. [index: number]: ISavedTransformationMatrix;
  64634. };
  64635. /**
  64636. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  64637. * in order to compute objects velocities when enableVelocity is set to "true"
  64638. * @hidden
  64639. */
  64640. _previousBonesTransformationMatrices: {
  64641. [index: number]: Float32Array;
  64642. };
  64643. /**
  64644. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  64645. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  64646. */
  64647. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  64648. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  64649. renderTransparentMeshes: boolean;
  64650. private _scene;
  64651. private _multiRenderTarget;
  64652. private _ratio;
  64653. private _enablePosition;
  64654. private _enableVelocity;
  64655. private _positionIndex;
  64656. private _velocityIndex;
  64657. protected _effect: Effect;
  64658. protected _cachedDefines: string;
  64659. /**
  64660. * Set the render list (meshes to be rendered) used in the G buffer.
  64661. */
  64662. set renderList(meshes: Mesh[]);
  64663. /**
  64664. * Gets wether or not G buffer are supported by the running hardware.
  64665. * This requires draw buffer supports
  64666. */
  64667. get isSupported(): boolean;
  64668. /**
  64669. * Returns the index of the given texture type in the G-Buffer textures array
  64670. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  64671. * @returns the index of the given texture type in the G-Buffer textures array
  64672. */
  64673. getTextureIndex(textureType: number): number;
  64674. /**
  64675. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  64676. */
  64677. get enablePosition(): boolean;
  64678. /**
  64679. * Sets whether or not objects positions are enabled for the G buffer.
  64680. */
  64681. set enablePosition(enable: boolean);
  64682. /**
  64683. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  64684. */
  64685. get enableVelocity(): boolean;
  64686. /**
  64687. * Sets wether or not objects velocities are enabled for the G buffer.
  64688. */
  64689. set enableVelocity(enable: boolean);
  64690. /**
  64691. * Gets the scene associated with the buffer.
  64692. */
  64693. get scene(): Scene;
  64694. /**
  64695. * Gets the ratio used by the buffer during its creation.
  64696. * How big is the buffer related to the main canvas.
  64697. */
  64698. get ratio(): number;
  64699. /** @hidden */
  64700. static _SceneComponentInitialization: (scene: Scene) => void;
  64701. /**
  64702. * Creates a new G Buffer for the scene
  64703. * @param scene The scene the buffer belongs to
  64704. * @param ratio How big is the buffer related to the main canvas.
  64705. */
  64706. constructor(scene: Scene, ratio?: number);
  64707. /**
  64708. * Checks wether everything is ready to render a submesh to the G buffer.
  64709. * @param subMesh the submesh to check readiness for
  64710. * @param useInstances is the mesh drawn using instance or not
  64711. * @returns true if ready otherwise false
  64712. */
  64713. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64714. /**
  64715. * Gets the current underlying G Buffer.
  64716. * @returns the buffer
  64717. */
  64718. getGBuffer(): MultiRenderTarget;
  64719. /**
  64720. * Gets the number of samples used to render the buffer (anti aliasing).
  64721. */
  64722. get samples(): number;
  64723. /**
  64724. * Sets the number of samples used to render the buffer (anti aliasing).
  64725. */
  64726. set samples(value: number);
  64727. /**
  64728. * Disposes the renderer and frees up associated resources.
  64729. */
  64730. dispose(): void;
  64731. protected _createRenderTargets(): void;
  64732. private _copyBonesTransformationMatrices;
  64733. }
  64734. }
  64735. declare module BABYLON {
  64736. interface Scene {
  64737. /** @hidden (Backing field) */
  64738. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  64739. /**
  64740. * Gets or Sets the current geometry buffer associated to the scene.
  64741. */
  64742. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  64743. /**
  64744. * Enables a GeometryBufferRender and associates it with the scene
  64745. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  64746. * @returns the GeometryBufferRenderer
  64747. */
  64748. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  64749. /**
  64750. * Disables the GeometryBufferRender associated with the scene
  64751. */
  64752. disableGeometryBufferRenderer(): void;
  64753. }
  64754. /**
  64755. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  64756. * in several rendering techniques.
  64757. */
  64758. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  64759. /**
  64760. * The component name helpful to identify the component in the list of scene components.
  64761. */
  64762. readonly name: string;
  64763. /**
  64764. * The scene the component belongs to.
  64765. */
  64766. scene: Scene;
  64767. /**
  64768. * Creates a new instance of the component for the given scene
  64769. * @param scene Defines the scene to register the component in
  64770. */
  64771. constructor(scene: Scene);
  64772. /**
  64773. * Registers the component in a given scene
  64774. */
  64775. register(): void;
  64776. /**
  64777. * Rebuilds the elements related to this component in case of
  64778. * context lost for instance.
  64779. */
  64780. rebuild(): void;
  64781. /**
  64782. * Disposes the component and the associated ressources
  64783. */
  64784. dispose(): void;
  64785. private _gatherRenderTargets;
  64786. }
  64787. }
  64788. declare module BABYLON {
  64789. /** @hidden */
  64790. export var motionBlurPixelShader: {
  64791. name: string;
  64792. shader: string;
  64793. };
  64794. }
  64795. declare module BABYLON {
  64796. /**
  64797. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  64798. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  64799. * As an example, all you have to do is to create the post-process:
  64800. * var mb = new BABYLON.MotionBlurPostProcess(
  64801. * 'mb', // The name of the effect.
  64802. * scene, // The scene containing the objects to blur according to their velocity.
  64803. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  64804. * camera // The camera to apply the render pass to.
  64805. * );
  64806. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  64807. */
  64808. export class MotionBlurPostProcess extends PostProcess {
  64809. /**
  64810. * Defines how much the image is blurred by the movement. Default value is equal to 1
  64811. */
  64812. motionStrength: number;
  64813. /**
  64814. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  64815. */
  64816. get motionBlurSamples(): number;
  64817. /**
  64818. * Sets the number of iterations to be used for motion blur quality
  64819. */
  64820. set motionBlurSamples(samples: number);
  64821. private _motionBlurSamples;
  64822. private _geometryBufferRenderer;
  64823. /**
  64824. * Creates a new instance MotionBlurPostProcess
  64825. * @param name The name of the effect.
  64826. * @param scene The scene containing the objects to blur according to their velocity.
  64827. * @param options The required width/height ratio to downsize to before computing the render pass.
  64828. * @param camera The camera to apply the render pass to.
  64829. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64830. * @param engine The engine which the post process will be applied. (default: current engine)
  64831. * @param reusable If the post process can be reused on the same frame. (default: false)
  64832. * @param textureType Type of textures used when performing the post process. (default: 0)
  64833. * @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)
  64834. */
  64835. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64836. /**
  64837. * Excludes the given skinned mesh from computing bones velocities.
  64838. * 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.
  64839. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  64840. */
  64841. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  64842. /**
  64843. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  64844. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  64845. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  64846. */
  64847. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  64848. /**
  64849. * Disposes the post process.
  64850. * @param camera The camera to dispose the post process on.
  64851. */
  64852. dispose(camera?: Camera): void;
  64853. }
  64854. }
  64855. declare module BABYLON {
  64856. /** @hidden */
  64857. export var refractionPixelShader: {
  64858. name: string;
  64859. shader: string;
  64860. };
  64861. }
  64862. declare module BABYLON {
  64863. /**
  64864. * Post process which applies a refractin texture
  64865. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  64866. */
  64867. export class RefractionPostProcess extends PostProcess {
  64868. /** the base color of the refraction (used to taint the rendering) */
  64869. color: Color3;
  64870. /** simulated refraction depth */
  64871. depth: number;
  64872. /** the coefficient of the base color (0 to remove base color tainting) */
  64873. colorLevel: number;
  64874. private _refTexture;
  64875. private _ownRefractionTexture;
  64876. /**
  64877. * Gets or sets the refraction texture
  64878. * Please note that you are responsible for disposing the texture if you set it manually
  64879. */
  64880. get refractionTexture(): Texture;
  64881. set refractionTexture(value: Texture);
  64882. /**
  64883. * Initializes the RefractionPostProcess
  64884. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  64885. * @param name The name of the effect.
  64886. * @param refractionTextureUrl Url of the refraction texture to use
  64887. * @param color the base color of the refraction (used to taint the rendering)
  64888. * @param depth simulated refraction depth
  64889. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  64890. * @param camera The camera to apply the render pass to.
  64891. * @param options The required width/height ratio to downsize to before computing the render pass.
  64892. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64893. * @param engine The engine which the post process will be applied. (default: current engine)
  64894. * @param reusable If the post process can be reused on the same frame. (default: false)
  64895. */
  64896. constructor(name: string, refractionTextureUrl: string,
  64897. /** the base color of the refraction (used to taint the rendering) */
  64898. color: Color3,
  64899. /** simulated refraction depth */
  64900. depth: number,
  64901. /** the coefficient of the base color (0 to remove base color tainting) */
  64902. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64903. /**
  64904. * Disposes of the post process
  64905. * @param camera Camera to dispose post process on
  64906. */
  64907. dispose(camera: Camera): void;
  64908. }
  64909. }
  64910. declare module BABYLON {
  64911. /** @hidden */
  64912. export var sharpenPixelShader: {
  64913. name: string;
  64914. shader: string;
  64915. };
  64916. }
  64917. declare module BABYLON {
  64918. /**
  64919. * The SharpenPostProcess applies a sharpen kernel to every pixel
  64920. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  64921. */
  64922. export class SharpenPostProcess extends PostProcess {
  64923. /**
  64924. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  64925. */
  64926. colorAmount: number;
  64927. /**
  64928. * How much sharpness should be applied (default: 0.3)
  64929. */
  64930. edgeAmount: number;
  64931. /**
  64932. * Creates a new instance ConvolutionPostProcess
  64933. * @param name The name of the effect.
  64934. * @param options The required width/height ratio to downsize to before computing the render pass.
  64935. * @param camera The camera to apply the render pass to.
  64936. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64937. * @param engine The engine which the post process will be applied. (default: current engine)
  64938. * @param reusable If the post process can be reused on the same frame. (default: false)
  64939. * @param textureType Type of textures used when performing the post process. (default: 0)
  64940. * @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)
  64941. */
  64942. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64943. }
  64944. }
  64945. declare module BABYLON {
  64946. /**
  64947. * PostProcessRenderPipeline
  64948. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64949. */
  64950. export class PostProcessRenderPipeline {
  64951. private engine;
  64952. private _renderEffects;
  64953. private _renderEffectsForIsolatedPass;
  64954. /**
  64955. * List of inspectable custom properties (used by the Inspector)
  64956. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  64957. */
  64958. inspectableCustomProperties: IInspectable[];
  64959. /**
  64960. * @hidden
  64961. */
  64962. protected _cameras: Camera[];
  64963. /** @hidden */
  64964. _name: string;
  64965. /**
  64966. * Gets pipeline name
  64967. */
  64968. get name(): string;
  64969. /** Gets the list of attached cameras */
  64970. get cameras(): Camera[];
  64971. /**
  64972. * Initializes a PostProcessRenderPipeline
  64973. * @param engine engine to add the pipeline to
  64974. * @param name name of the pipeline
  64975. */
  64976. constructor(engine: Engine, name: string);
  64977. /**
  64978. * Gets the class name
  64979. * @returns "PostProcessRenderPipeline"
  64980. */
  64981. getClassName(): string;
  64982. /**
  64983. * If all the render effects in the pipeline are supported
  64984. */
  64985. get isSupported(): boolean;
  64986. /**
  64987. * Adds an effect to the pipeline
  64988. * @param renderEffect the effect to add
  64989. */
  64990. addEffect(renderEffect: PostProcessRenderEffect): void;
  64991. /** @hidden */
  64992. _rebuild(): void;
  64993. /** @hidden */
  64994. _enableEffect(renderEffectName: string, cameras: Camera): void;
  64995. /** @hidden */
  64996. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  64997. /** @hidden */
  64998. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  64999. /** @hidden */
  65000. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  65001. /** @hidden */
  65002. _attachCameras(cameras: Camera, unique: boolean): void;
  65003. /** @hidden */
  65004. _attachCameras(cameras: Camera[], unique: boolean): void;
  65005. /** @hidden */
  65006. _detachCameras(cameras: Camera): void;
  65007. /** @hidden */
  65008. _detachCameras(cameras: Nullable<Camera[]>): void;
  65009. /** @hidden */
  65010. _update(): void;
  65011. /** @hidden */
  65012. _reset(): void;
  65013. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  65014. /**
  65015. * Disposes of the pipeline
  65016. */
  65017. dispose(): void;
  65018. }
  65019. }
  65020. declare module BABYLON {
  65021. /**
  65022. * PostProcessRenderPipelineManager class
  65023. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65024. */
  65025. export class PostProcessRenderPipelineManager {
  65026. private _renderPipelines;
  65027. /**
  65028. * Initializes a PostProcessRenderPipelineManager
  65029. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65030. */
  65031. constructor();
  65032. /**
  65033. * Gets the list of supported render pipelines
  65034. */
  65035. get supportedPipelines(): PostProcessRenderPipeline[];
  65036. /**
  65037. * Adds a pipeline to the manager
  65038. * @param renderPipeline The pipeline to add
  65039. */
  65040. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  65041. /**
  65042. * Attaches a camera to the pipeline
  65043. * @param renderPipelineName The name of the pipeline to attach to
  65044. * @param cameras the camera to attach
  65045. * @param unique if the camera can be attached multiple times to the pipeline
  65046. */
  65047. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  65048. /**
  65049. * Detaches a camera from the pipeline
  65050. * @param renderPipelineName The name of the pipeline to detach from
  65051. * @param cameras the camera to detach
  65052. */
  65053. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  65054. /**
  65055. * Enables an effect by name on a pipeline
  65056. * @param renderPipelineName the name of the pipeline to enable the effect in
  65057. * @param renderEffectName the name of the effect to enable
  65058. * @param cameras the cameras that the effect should be enabled on
  65059. */
  65060. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65061. /**
  65062. * Disables an effect by name on a pipeline
  65063. * @param renderPipelineName the name of the pipeline to disable the effect in
  65064. * @param renderEffectName the name of the effect to disable
  65065. * @param cameras the cameras that the effect should be disabled on
  65066. */
  65067. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65068. /**
  65069. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  65070. */
  65071. update(): void;
  65072. /** @hidden */
  65073. _rebuild(): void;
  65074. /**
  65075. * Disposes of the manager and pipelines
  65076. */
  65077. dispose(): void;
  65078. }
  65079. }
  65080. declare module BABYLON {
  65081. interface Scene {
  65082. /** @hidden (Backing field) */
  65083. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65084. /**
  65085. * Gets the postprocess render pipeline manager
  65086. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65087. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65088. */
  65089. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65090. }
  65091. /**
  65092. * Defines the Render Pipeline scene component responsible to rendering pipelines
  65093. */
  65094. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  65095. /**
  65096. * The component name helpfull to identify the component in the list of scene components.
  65097. */
  65098. readonly name: string;
  65099. /**
  65100. * The scene the component belongs to.
  65101. */
  65102. scene: Scene;
  65103. /**
  65104. * Creates a new instance of the component for the given scene
  65105. * @param scene Defines the scene to register the component in
  65106. */
  65107. constructor(scene: Scene);
  65108. /**
  65109. * Registers the component in a given scene
  65110. */
  65111. register(): void;
  65112. /**
  65113. * Rebuilds the elements related to this component in case of
  65114. * context lost for instance.
  65115. */
  65116. rebuild(): void;
  65117. /**
  65118. * Disposes the component and the associated ressources
  65119. */
  65120. dispose(): void;
  65121. private _gatherRenderTargets;
  65122. }
  65123. }
  65124. declare module BABYLON {
  65125. /**
  65126. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  65127. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65128. */
  65129. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  65130. private _scene;
  65131. private _camerasToBeAttached;
  65132. /**
  65133. * ID of the sharpen post process,
  65134. */
  65135. private readonly SharpenPostProcessId;
  65136. /**
  65137. * @ignore
  65138. * ID of the image processing post process;
  65139. */
  65140. readonly ImageProcessingPostProcessId: string;
  65141. /**
  65142. * @ignore
  65143. * ID of the Fast Approximate Anti-Aliasing post process;
  65144. */
  65145. readonly FxaaPostProcessId: string;
  65146. /**
  65147. * ID of the chromatic aberration post process,
  65148. */
  65149. private readonly ChromaticAberrationPostProcessId;
  65150. /**
  65151. * ID of the grain post process
  65152. */
  65153. private readonly GrainPostProcessId;
  65154. /**
  65155. * Sharpen post process which will apply a sharpen convolution to enhance edges
  65156. */
  65157. sharpen: SharpenPostProcess;
  65158. private _sharpenEffect;
  65159. private bloom;
  65160. /**
  65161. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  65162. */
  65163. depthOfField: DepthOfFieldEffect;
  65164. /**
  65165. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  65166. */
  65167. fxaa: FxaaPostProcess;
  65168. /**
  65169. * Image post processing pass used to perform operations such as tone mapping or color grading.
  65170. */
  65171. imageProcessing: ImageProcessingPostProcess;
  65172. /**
  65173. * Chromatic aberration post process which will shift rgb colors in the image
  65174. */
  65175. chromaticAberration: ChromaticAberrationPostProcess;
  65176. private _chromaticAberrationEffect;
  65177. /**
  65178. * Grain post process which add noise to the image
  65179. */
  65180. grain: GrainPostProcess;
  65181. private _grainEffect;
  65182. /**
  65183. * Glow post process which adds a glow to emissive areas of the image
  65184. */
  65185. private _glowLayer;
  65186. /**
  65187. * Animations which can be used to tweak settings over a period of time
  65188. */
  65189. animations: Animation[];
  65190. private _imageProcessingConfigurationObserver;
  65191. private _sharpenEnabled;
  65192. private _bloomEnabled;
  65193. private _depthOfFieldEnabled;
  65194. private _depthOfFieldBlurLevel;
  65195. private _fxaaEnabled;
  65196. private _imageProcessingEnabled;
  65197. private _defaultPipelineTextureType;
  65198. private _bloomScale;
  65199. private _chromaticAberrationEnabled;
  65200. private _grainEnabled;
  65201. private _buildAllowed;
  65202. /**
  65203. * Gets active scene
  65204. */
  65205. get scene(): Scene;
  65206. /**
  65207. * Enable or disable the sharpen process from the pipeline
  65208. */
  65209. set sharpenEnabled(enabled: boolean);
  65210. get sharpenEnabled(): boolean;
  65211. private _resizeObserver;
  65212. private _hardwareScaleLevel;
  65213. private _bloomKernel;
  65214. /**
  65215. * Specifies the size of the bloom blur kernel, relative to the final output size
  65216. */
  65217. get bloomKernel(): number;
  65218. set bloomKernel(value: number);
  65219. /**
  65220. * Specifies the weight of the bloom in the final rendering
  65221. */
  65222. private _bloomWeight;
  65223. /**
  65224. * Specifies the luma threshold for the area that will be blurred by the bloom
  65225. */
  65226. private _bloomThreshold;
  65227. private _hdr;
  65228. /**
  65229. * The strength of the bloom.
  65230. */
  65231. set bloomWeight(value: number);
  65232. get bloomWeight(): number;
  65233. /**
  65234. * The strength of the bloom.
  65235. */
  65236. set bloomThreshold(value: number);
  65237. get bloomThreshold(): number;
  65238. /**
  65239. * The scale of the bloom, lower value will provide better performance.
  65240. */
  65241. set bloomScale(value: number);
  65242. get bloomScale(): number;
  65243. /**
  65244. * Enable or disable the bloom from the pipeline
  65245. */
  65246. set bloomEnabled(enabled: boolean);
  65247. get bloomEnabled(): boolean;
  65248. private _rebuildBloom;
  65249. /**
  65250. * If the depth of field is enabled.
  65251. */
  65252. get depthOfFieldEnabled(): boolean;
  65253. set depthOfFieldEnabled(enabled: boolean);
  65254. /**
  65255. * Blur level of the depth of field effect. (Higher blur will effect performance)
  65256. */
  65257. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  65258. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  65259. /**
  65260. * If the anti aliasing is enabled.
  65261. */
  65262. set fxaaEnabled(enabled: boolean);
  65263. get fxaaEnabled(): boolean;
  65264. private _samples;
  65265. /**
  65266. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  65267. */
  65268. set samples(sampleCount: number);
  65269. get samples(): number;
  65270. /**
  65271. * If image processing is enabled.
  65272. */
  65273. set imageProcessingEnabled(enabled: boolean);
  65274. get imageProcessingEnabled(): boolean;
  65275. /**
  65276. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  65277. */
  65278. set glowLayerEnabled(enabled: boolean);
  65279. get glowLayerEnabled(): boolean;
  65280. /**
  65281. * Gets the glow layer (or null if not defined)
  65282. */
  65283. get glowLayer(): Nullable<GlowLayer>;
  65284. /**
  65285. * Enable or disable the chromaticAberration process from the pipeline
  65286. */
  65287. set chromaticAberrationEnabled(enabled: boolean);
  65288. get chromaticAberrationEnabled(): boolean;
  65289. /**
  65290. * Enable or disable the grain process from the pipeline
  65291. */
  65292. set grainEnabled(enabled: boolean);
  65293. get grainEnabled(): boolean;
  65294. /**
  65295. * @constructor
  65296. * @param name - The rendering pipeline name (default: "")
  65297. * @param hdr - If high dynamic range textures should be used (default: true)
  65298. * @param scene - The scene linked to this pipeline (default: the last created scene)
  65299. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  65300. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  65301. */
  65302. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  65303. /**
  65304. * Get the class name
  65305. * @returns "DefaultRenderingPipeline"
  65306. */
  65307. getClassName(): string;
  65308. /**
  65309. * Force the compilation of the entire pipeline.
  65310. */
  65311. prepare(): void;
  65312. private _hasCleared;
  65313. private _prevPostProcess;
  65314. private _prevPrevPostProcess;
  65315. private _setAutoClearAndTextureSharing;
  65316. private _depthOfFieldSceneObserver;
  65317. private _buildPipeline;
  65318. private _disposePostProcesses;
  65319. /**
  65320. * Adds a camera to the pipeline
  65321. * @param camera the camera to be added
  65322. */
  65323. addCamera(camera: Camera): void;
  65324. /**
  65325. * Removes a camera from the pipeline
  65326. * @param camera the camera to remove
  65327. */
  65328. removeCamera(camera: Camera): void;
  65329. /**
  65330. * Dispose of the pipeline and stop all post processes
  65331. */
  65332. dispose(): void;
  65333. /**
  65334. * Serialize the rendering pipeline (Used when exporting)
  65335. * @returns the serialized object
  65336. */
  65337. serialize(): any;
  65338. /**
  65339. * Parse the serialized pipeline
  65340. * @param source Source pipeline.
  65341. * @param scene The scene to load the pipeline to.
  65342. * @param rootUrl The URL of the serialized pipeline.
  65343. * @returns An instantiated pipeline from the serialized object.
  65344. */
  65345. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  65346. }
  65347. }
  65348. declare module BABYLON {
  65349. /** @hidden */
  65350. export var lensHighlightsPixelShader: {
  65351. name: string;
  65352. shader: string;
  65353. };
  65354. }
  65355. declare module BABYLON {
  65356. /** @hidden */
  65357. export var depthOfFieldPixelShader: {
  65358. name: string;
  65359. shader: string;
  65360. };
  65361. }
  65362. declare module BABYLON {
  65363. /**
  65364. * BABYLON.JS Chromatic Aberration GLSL Shader
  65365. * Author: Olivier Guyot
  65366. * Separates very slightly R, G and B colors on the edges of the screen
  65367. * Inspired by Francois Tarlier & Martins Upitis
  65368. */
  65369. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  65370. /**
  65371. * @ignore
  65372. * The chromatic aberration PostProcess id in the pipeline
  65373. */
  65374. LensChromaticAberrationEffect: string;
  65375. /**
  65376. * @ignore
  65377. * The highlights enhancing PostProcess id in the pipeline
  65378. */
  65379. HighlightsEnhancingEffect: string;
  65380. /**
  65381. * @ignore
  65382. * The depth-of-field PostProcess id in the pipeline
  65383. */
  65384. LensDepthOfFieldEffect: string;
  65385. private _scene;
  65386. private _depthTexture;
  65387. private _grainTexture;
  65388. private _chromaticAberrationPostProcess;
  65389. private _highlightsPostProcess;
  65390. private _depthOfFieldPostProcess;
  65391. private _edgeBlur;
  65392. private _grainAmount;
  65393. private _chromaticAberration;
  65394. private _distortion;
  65395. private _highlightsGain;
  65396. private _highlightsThreshold;
  65397. private _dofDistance;
  65398. private _dofAperture;
  65399. private _dofDarken;
  65400. private _dofPentagon;
  65401. private _blurNoise;
  65402. /**
  65403. * @constructor
  65404. *
  65405. * Effect parameters are as follow:
  65406. * {
  65407. * chromatic_aberration: number; // from 0 to x (1 for realism)
  65408. * edge_blur: number; // from 0 to x (1 for realism)
  65409. * distortion: number; // from 0 to x (1 for realism)
  65410. * grain_amount: number; // from 0 to 1
  65411. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  65412. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  65413. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  65414. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  65415. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  65416. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  65417. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  65418. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  65419. * }
  65420. * Note: if an effect parameter is unset, effect is disabled
  65421. *
  65422. * @param name The rendering pipeline name
  65423. * @param parameters - An object containing all parameters (see above)
  65424. * @param scene The scene linked to this pipeline
  65425. * @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)
  65426. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65427. */
  65428. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  65429. /**
  65430. * Get the class name
  65431. * @returns "LensRenderingPipeline"
  65432. */
  65433. getClassName(): string;
  65434. /**
  65435. * Gets associated scene
  65436. */
  65437. get scene(): Scene;
  65438. /**
  65439. * Gets or sets the edge blur
  65440. */
  65441. get edgeBlur(): number;
  65442. set edgeBlur(value: number);
  65443. /**
  65444. * Gets or sets the grain amount
  65445. */
  65446. get grainAmount(): number;
  65447. set grainAmount(value: number);
  65448. /**
  65449. * Gets or sets the chromatic aberration amount
  65450. */
  65451. get chromaticAberration(): number;
  65452. set chromaticAberration(value: number);
  65453. /**
  65454. * Gets or sets the depth of field aperture
  65455. */
  65456. get dofAperture(): number;
  65457. set dofAperture(value: number);
  65458. /**
  65459. * Gets or sets the edge distortion
  65460. */
  65461. get edgeDistortion(): number;
  65462. set edgeDistortion(value: number);
  65463. /**
  65464. * Gets or sets the depth of field distortion
  65465. */
  65466. get dofDistortion(): number;
  65467. set dofDistortion(value: number);
  65468. /**
  65469. * Gets or sets the darken out of focus amount
  65470. */
  65471. get darkenOutOfFocus(): number;
  65472. set darkenOutOfFocus(value: number);
  65473. /**
  65474. * Gets or sets a boolean indicating if blur noise is enabled
  65475. */
  65476. get blurNoise(): boolean;
  65477. set blurNoise(value: boolean);
  65478. /**
  65479. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  65480. */
  65481. get pentagonBokeh(): boolean;
  65482. set pentagonBokeh(value: boolean);
  65483. /**
  65484. * Gets or sets the highlight grain amount
  65485. */
  65486. get highlightsGain(): number;
  65487. set highlightsGain(value: number);
  65488. /**
  65489. * Gets or sets the highlight threshold
  65490. */
  65491. get highlightsThreshold(): number;
  65492. set highlightsThreshold(value: number);
  65493. /**
  65494. * Sets the amount of blur at the edges
  65495. * @param amount blur amount
  65496. */
  65497. setEdgeBlur(amount: number): void;
  65498. /**
  65499. * Sets edge blur to 0
  65500. */
  65501. disableEdgeBlur(): void;
  65502. /**
  65503. * Sets the amout of grain
  65504. * @param amount Amount of grain
  65505. */
  65506. setGrainAmount(amount: number): void;
  65507. /**
  65508. * Set grain amount to 0
  65509. */
  65510. disableGrain(): void;
  65511. /**
  65512. * Sets the chromatic aberration amount
  65513. * @param amount amount of chromatic aberration
  65514. */
  65515. setChromaticAberration(amount: number): void;
  65516. /**
  65517. * Sets chromatic aberration amount to 0
  65518. */
  65519. disableChromaticAberration(): void;
  65520. /**
  65521. * Sets the EdgeDistortion amount
  65522. * @param amount amount of EdgeDistortion
  65523. */
  65524. setEdgeDistortion(amount: number): void;
  65525. /**
  65526. * Sets edge distortion to 0
  65527. */
  65528. disableEdgeDistortion(): void;
  65529. /**
  65530. * Sets the FocusDistance amount
  65531. * @param amount amount of FocusDistance
  65532. */
  65533. setFocusDistance(amount: number): void;
  65534. /**
  65535. * Disables depth of field
  65536. */
  65537. disableDepthOfField(): void;
  65538. /**
  65539. * Sets the Aperture amount
  65540. * @param amount amount of Aperture
  65541. */
  65542. setAperture(amount: number): void;
  65543. /**
  65544. * Sets the DarkenOutOfFocus amount
  65545. * @param amount amount of DarkenOutOfFocus
  65546. */
  65547. setDarkenOutOfFocus(amount: number): void;
  65548. private _pentagonBokehIsEnabled;
  65549. /**
  65550. * Creates a pentagon bokeh effect
  65551. */
  65552. enablePentagonBokeh(): void;
  65553. /**
  65554. * Disables the pentagon bokeh effect
  65555. */
  65556. disablePentagonBokeh(): void;
  65557. /**
  65558. * Enables noise blur
  65559. */
  65560. enableNoiseBlur(): void;
  65561. /**
  65562. * Disables noise blur
  65563. */
  65564. disableNoiseBlur(): void;
  65565. /**
  65566. * Sets the HighlightsGain amount
  65567. * @param amount amount of HighlightsGain
  65568. */
  65569. setHighlightsGain(amount: number): void;
  65570. /**
  65571. * Sets the HighlightsThreshold amount
  65572. * @param amount amount of HighlightsThreshold
  65573. */
  65574. setHighlightsThreshold(amount: number): void;
  65575. /**
  65576. * Disables highlights
  65577. */
  65578. disableHighlights(): void;
  65579. /**
  65580. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  65581. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  65582. */
  65583. dispose(disableDepthRender?: boolean): void;
  65584. private _createChromaticAberrationPostProcess;
  65585. private _createHighlightsPostProcess;
  65586. private _createDepthOfFieldPostProcess;
  65587. private _createGrainTexture;
  65588. }
  65589. }
  65590. declare module BABYLON {
  65591. /** @hidden */
  65592. export var ssao2PixelShader: {
  65593. name: string;
  65594. shader: string;
  65595. };
  65596. }
  65597. declare module BABYLON {
  65598. /** @hidden */
  65599. export var ssaoCombinePixelShader: {
  65600. name: string;
  65601. shader: string;
  65602. };
  65603. }
  65604. declare module BABYLON {
  65605. /**
  65606. * Render pipeline to produce ssao effect
  65607. */
  65608. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  65609. /**
  65610. * @ignore
  65611. * The PassPostProcess id in the pipeline that contains the original scene color
  65612. */
  65613. SSAOOriginalSceneColorEffect: string;
  65614. /**
  65615. * @ignore
  65616. * The SSAO PostProcess id in the pipeline
  65617. */
  65618. SSAORenderEffect: string;
  65619. /**
  65620. * @ignore
  65621. * The horizontal blur PostProcess id in the pipeline
  65622. */
  65623. SSAOBlurHRenderEffect: string;
  65624. /**
  65625. * @ignore
  65626. * The vertical blur PostProcess id in the pipeline
  65627. */
  65628. SSAOBlurVRenderEffect: string;
  65629. /**
  65630. * @ignore
  65631. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65632. */
  65633. SSAOCombineRenderEffect: string;
  65634. /**
  65635. * The output strength of the SSAO post-process. Default value is 1.0.
  65636. */
  65637. totalStrength: number;
  65638. /**
  65639. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  65640. */
  65641. maxZ: number;
  65642. /**
  65643. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  65644. */
  65645. minZAspect: number;
  65646. private _samples;
  65647. /**
  65648. * Number of samples used for the SSAO calculations. Default value is 8
  65649. */
  65650. set samples(n: number);
  65651. get samples(): number;
  65652. private _textureSamples;
  65653. /**
  65654. * Number of samples to use for antialiasing
  65655. */
  65656. set textureSamples(n: number);
  65657. get textureSamples(): number;
  65658. /**
  65659. * Ratio object used for SSAO ratio and blur ratio
  65660. */
  65661. private _ratio;
  65662. /**
  65663. * Dynamically generated sphere sampler.
  65664. */
  65665. private _sampleSphere;
  65666. /**
  65667. * Blur filter offsets
  65668. */
  65669. private _samplerOffsets;
  65670. private _expensiveBlur;
  65671. /**
  65672. * If bilateral blur should be used
  65673. */
  65674. set expensiveBlur(b: boolean);
  65675. get expensiveBlur(): boolean;
  65676. /**
  65677. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  65678. */
  65679. radius: number;
  65680. /**
  65681. * The base color of the SSAO post-process
  65682. * The final result is "base + ssao" between [0, 1]
  65683. */
  65684. base: number;
  65685. /**
  65686. * Support test.
  65687. */
  65688. static get IsSupported(): boolean;
  65689. private _scene;
  65690. private _depthTexture;
  65691. private _normalTexture;
  65692. private _randomTexture;
  65693. private _originalColorPostProcess;
  65694. private _ssaoPostProcess;
  65695. private _blurHPostProcess;
  65696. private _blurVPostProcess;
  65697. private _ssaoCombinePostProcess;
  65698. /**
  65699. * Gets active scene
  65700. */
  65701. get scene(): Scene;
  65702. /**
  65703. * @constructor
  65704. * @param name The rendering pipeline name
  65705. * @param scene The scene linked to this pipeline
  65706. * @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 }
  65707. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65708. */
  65709. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  65710. /**
  65711. * Get the class name
  65712. * @returns "SSAO2RenderingPipeline"
  65713. */
  65714. getClassName(): string;
  65715. /**
  65716. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  65717. */
  65718. dispose(disableGeometryBufferRenderer?: boolean): void;
  65719. private _createBlurPostProcess;
  65720. /** @hidden */
  65721. _rebuild(): void;
  65722. private _bits;
  65723. private _radicalInverse_VdC;
  65724. private _hammersley;
  65725. private _hemisphereSample_uniform;
  65726. private _generateHemisphere;
  65727. private _createSSAOPostProcess;
  65728. private _createSSAOCombinePostProcess;
  65729. private _createRandomTexture;
  65730. /**
  65731. * Serialize the rendering pipeline (Used when exporting)
  65732. * @returns the serialized object
  65733. */
  65734. serialize(): any;
  65735. /**
  65736. * Parse the serialized pipeline
  65737. * @param source Source pipeline.
  65738. * @param scene The scene to load the pipeline to.
  65739. * @param rootUrl The URL of the serialized pipeline.
  65740. * @returns An instantiated pipeline from the serialized object.
  65741. */
  65742. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  65743. }
  65744. }
  65745. declare module BABYLON {
  65746. /** @hidden */
  65747. export var ssaoPixelShader: {
  65748. name: string;
  65749. shader: string;
  65750. };
  65751. }
  65752. declare module BABYLON {
  65753. /**
  65754. * Render pipeline to produce ssao effect
  65755. */
  65756. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  65757. /**
  65758. * @ignore
  65759. * The PassPostProcess id in the pipeline that contains the original scene color
  65760. */
  65761. SSAOOriginalSceneColorEffect: string;
  65762. /**
  65763. * @ignore
  65764. * The SSAO PostProcess id in the pipeline
  65765. */
  65766. SSAORenderEffect: string;
  65767. /**
  65768. * @ignore
  65769. * The horizontal blur PostProcess id in the pipeline
  65770. */
  65771. SSAOBlurHRenderEffect: string;
  65772. /**
  65773. * @ignore
  65774. * The vertical blur PostProcess id in the pipeline
  65775. */
  65776. SSAOBlurVRenderEffect: string;
  65777. /**
  65778. * @ignore
  65779. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65780. */
  65781. SSAOCombineRenderEffect: string;
  65782. /**
  65783. * The output strength of the SSAO post-process. Default value is 1.0.
  65784. */
  65785. totalStrength: number;
  65786. /**
  65787. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  65788. */
  65789. radius: number;
  65790. /**
  65791. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  65792. * Must not be equal to fallOff and superior to fallOff.
  65793. * Default value is 0.0075
  65794. */
  65795. area: number;
  65796. /**
  65797. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  65798. * Must not be equal to area and inferior to area.
  65799. * Default value is 0.000001
  65800. */
  65801. fallOff: number;
  65802. /**
  65803. * The base color of the SSAO post-process
  65804. * The final result is "base + ssao" between [0, 1]
  65805. */
  65806. base: number;
  65807. private _scene;
  65808. private _depthTexture;
  65809. private _randomTexture;
  65810. private _originalColorPostProcess;
  65811. private _ssaoPostProcess;
  65812. private _blurHPostProcess;
  65813. private _blurVPostProcess;
  65814. private _ssaoCombinePostProcess;
  65815. private _firstUpdate;
  65816. /**
  65817. * Gets active scene
  65818. */
  65819. get scene(): Scene;
  65820. /**
  65821. * @constructor
  65822. * @param name - The rendering pipeline name
  65823. * @param scene - The scene linked to this pipeline
  65824. * @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 }
  65825. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  65826. */
  65827. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  65828. /**
  65829. * Get the class name
  65830. * @returns "SSAORenderingPipeline"
  65831. */
  65832. getClassName(): string;
  65833. /**
  65834. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  65835. */
  65836. dispose(disableDepthRender?: boolean): void;
  65837. private _createBlurPostProcess;
  65838. /** @hidden */
  65839. _rebuild(): void;
  65840. private _createSSAOPostProcess;
  65841. private _createSSAOCombinePostProcess;
  65842. private _createRandomTexture;
  65843. }
  65844. }
  65845. declare module BABYLON {
  65846. /** @hidden */
  65847. export var standardPixelShader: {
  65848. name: string;
  65849. shader: string;
  65850. };
  65851. }
  65852. declare module BABYLON {
  65853. /**
  65854. * Standard rendering pipeline
  65855. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  65856. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  65857. */
  65858. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  65859. /**
  65860. * Public members
  65861. */
  65862. /**
  65863. * Post-process which contains the original scene color before the pipeline applies all the effects
  65864. */
  65865. originalPostProcess: Nullable<PostProcess>;
  65866. /**
  65867. * Post-process used to down scale an image x4
  65868. */
  65869. downSampleX4PostProcess: Nullable<PostProcess>;
  65870. /**
  65871. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  65872. */
  65873. brightPassPostProcess: Nullable<PostProcess>;
  65874. /**
  65875. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  65876. */
  65877. blurHPostProcesses: PostProcess[];
  65878. /**
  65879. * Post-process array storing all the vertical blur post-processes used by the pipeline
  65880. */
  65881. blurVPostProcesses: PostProcess[];
  65882. /**
  65883. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  65884. */
  65885. textureAdderPostProcess: Nullable<PostProcess>;
  65886. /**
  65887. * Post-process used to create volumetric lighting effect
  65888. */
  65889. volumetricLightPostProcess: Nullable<PostProcess>;
  65890. /**
  65891. * Post-process used to smooth the previous volumetric light post-process on the X axis
  65892. */
  65893. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  65894. /**
  65895. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  65896. */
  65897. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  65898. /**
  65899. * Post-process used to merge the volumetric light effect and the real scene color
  65900. */
  65901. volumetricLightMergePostProces: Nullable<PostProcess>;
  65902. /**
  65903. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  65904. */
  65905. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  65906. /**
  65907. * Base post-process used to calculate the average luminance of the final image for HDR
  65908. */
  65909. luminancePostProcess: Nullable<PostProcess>;
  65910. /**
  65911. * Post-processes used to create down sample post-processes in order to get
  65912. * the average luminance of the final image for HDR
  65913. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  65914. */
  65915. luminanceDownSamplePostProcesses: PostProcess[];
  65916. /**
  65917. * Post-process used to create a HDR effect (light adaptation)
  65918. */
  65919. hdrPostProcess: Nullable<PostProcess>;
  65920. /**
  65921. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  65922. */
  65923. textureAdderFinalPostProcess: Nullable<PostProcess>;
  65924. /**
  65925. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  65926. */
  65927. lensFlareFinalPostProcess: Nullable<PostProcess>;
  65928. /**
  65929. * Post-process used to merge the final HDR post-process and the real scene color
  65930. */
  65931. hdrFinalPostProcess: Nullable<PostProcess>;
  65932. /**
  65933. * Post-process used to create a lens flare effect
  65934. */
  65935. lensFlarePostProcess: Nullable<PostProcess>;
  65936. /**
  65937. * Post-process that merges the result of the lens flare post-process and the real scene color
  65938. */
  65939. lensFlareComposePostProcess: Nullable<PostProcess>;
  65940. /**
  65941. * Post-process used to create a motion blur effect
  65942. */
  65943. motionBlurPostProcess: Nullable<PostProcess>;
  65944. /**
  65945. * Post-process used to create a depth of field effect
  65946. */
  65947. depthOfFieldPostProcess: Nullable<PostProcess>;
  65948. /**
  65949. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  65950. */
  65951. fxaaPostProcess: Nullable<FxaaPostProcess>;
  65952. /**
  65953. * Represents the brightness threshold in order to configure the illuminated surfaces
  65954. */
  65955. brightThreshold: number;
  65956. /**
  65957. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  65958. */
  65959. blurWidth: number;
  65960. /**
  65961. * Sets if the blur for highlighted surfaces must be only horizontal
  65962. */
  65963. horizontalBlur: boolean;
  65964. /**
  65965. * Gets the overall exposure used by the pipeline
  65966. */
  65967. get exposure(): number;
  65968. /**
  65969. * Sets the overall exposure used by the pipeline
  65970. */
  65971. set exposure(value: number);
  65972. /**
  65973. * Texture used typically to simulate "dirty" on camera lens
  65974. */
  65975. lensTexture: Nullable<Texture>;
  65976. /**
  65977. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  65978. */
  65979. volumetricLightCoefficient: number;
  65980. /**
  65981. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  65982. */
  65983. volumetricLightPower: number;
  65984. /**
  65985. * Used the set the blur intensity to smooth the volumetric lights
  65986. */
  65987. volumetricLightBlurScale: number;
  65988. /**
  65989. * Light (spot or directional) used to generate the volumetric lights rays
  65990. * The source light must have a shadow generate so the pipeline can get its
  65991. * depth map
  65992. */
  65993. sourceLight: Nullable<SpotLight | DirectionalLight>;
  65994. /**
  65995. * For eye adaptation, represents the minimum luminance the eye can see
  65996. */
  65997. hdrMinimumLuminance: number;
  65998. /**
  65999. * For eye adaptation, represents the decrease luminance speed
  66000. */
  66001. hdrDecreaseRate: number;
  66002. /**
  66003. * For eye adaptation, represents the increase luminance speed
  66004. */
  66005. hdrIncreaseRate: number;
  66006. /**
  66007. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66008. */
  66009. get hdrAutoExposure(): boolean;
  66010. /**
  66011. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66012. */
  66013. set hdrAutoExposure(value: boolean);
  66014. /**
  66015. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  66016. */
  66017. lensColorTexture: Nullable<Texture>;
  66018. /**
  66019. * The overall strengh for the lens flare effect
  66020. */
  66021. lensFlareStrength: number;
  66022. /**
  66023. * Dispersion coefficient for lens flare ghosts
  66024. */
  66025. lensFlareGhostDispersal: number;
  66026. /**
  66027. * Main lens flare halo width
  66028. */
  66029. lensFlareHaloWidth: number;
  66030. /**
  66031. * Based on the lens distortion effect, defines how much the lens flare result
  66032. * is distorted
  66033. */
  66034. lensFlareDistortionStrength: number;
  66035. /**
  66036. * Configures the blur intensity used for for lens flare (halo)
  66037. */
  66038. lensFlareBlurWidth: number;
  66039. /**
  66040. * Lens star texture must be used to simulate rays on the flares and is available
  66041. * in the documentation
  66042. */
  66043. lensStarTexture: Nullable<Texture>;
  66044. /**
  66045. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  66046. * flare effect by taking account of the dirt texture
  66047. */
  66048. lensFlareDirtTexture: Nullable<Texture>;
  66049. /**
  66050. * Represents the focal length for the depth of field effect
  66051. */
  66052. depthOfFieldDistance: number;
  66053. /**
  66054. * Represents the blur intensity for the blurred part of the depth of field effect
  66055. */
  66056. depthOfFieldBlurWidth: number;
  66057. /**
  66058. * Gets how much the image is blurred by the movement while using the motion blur post-process
  66059. */
  66060. get motionStrength(): number;
  66061. /**
  66062. * Sets how much the image is blurred by the movement while using the motion blur post-process
  66063. */
  66064. set motionStrength(strength: number);
  66065. /**
  66066. * Gets wether or not the motion blur post-process is object based or screen based.
  66067. */
  66068. get objectBasedMotionBlur(): boolean;
  66069. /**
  66070. * Sets wether or not the motion blur post-process should be object based or screen based
  66071. */
  66072. set objectBasedMotionBlur(value: boolean);
  66073. /**
  66074. * List of animations for the pipeline (IAnimatable implementation)
  66075. */
  66076. animations: Animation[];
  66077. /**
  66078. * Private members
  66079. */
  66080. private _scene;
  66081. private _currentDepthOfFieldSource;
  66082. private _basePostProcess;
  66083. private _fixedExposure;
  66084. private _currentExposure;
  66085. private _hdrAutoExposure;
  66086. private _hdrCurrentLuminance;
  66087. private _motionStrength;
  66088. private _isObjectBasedMotionBlur;
  66089. private _floatTextureType;
  66090. private _camerasToBeAttached;
  66091. private _ratio;
  66092. private _bloomEnabled;
  66093. private _depthOfFieldEnabled;
  66094. private _vlsEnabled;
  66095. private _lensFlareEnabled;
  66096. private _hdrEnabled;
  66097. private _motionBlurEnabled;
  66098. private _fxaaEnabled;
  66099. private _motionBlurSamples;
  66100. private _volumetricLightStepsCount;
  66101. private _samples;
  66102. /**
  66103. * @ignore
  66104. * Specifies if the bloom pipeline is enabled
  66105. */
  66106. get BloomEnabled(): boolean;
  66107. set BloomEnabled(enabled: boolean);
  66108. /**
  66109. * @ignore
  66110. * Specifies if the depth of field pipeline is enabed
  66111. */
  66112. get DepthOfFieldEnabled(): boolean;
  66113. set DepthOfFieldEnabled(enabled: boolean);
  66114. /**
  66115. * @ignore
  66116. * Specifies if the lens flare pipeline is enabed
  66117. */
  66118. get LensFlareEnabled(): boolean;
  66119. set LensFlareEnabled(enabled: boolean);
  66120. /**
  66121. * @ignore
  66122. * Specifies if the HDR pipeline is enabled
  66123. */
  66124. get HDREnabled(): boolean;
  66125. set HDREnabled(enabled: boolean);
  66126. /**
  66127. * @ignore
  66128. * Specifies if the volumetric lights scattering effect is enabled
  66129. */
  66130. get VLSEnabled(): boolean;
  66131. set VLSEnabled(enabled: boolean);
  66132. /**
  66133. * @ignore
  66134. * Specifies if the motion blur effect is enabled
  66135. */
  66136. get MotionBlurEnabled(): boolean;
  66137. set MotionBlurEnabled(enabled: boolean);
  66138. /**
  66139. * Specifies if anti-aliasing is enabled
  66140. */
  66141. get fxaaEnabled(): boolean;
  66142. set fxaaEnabled(enabled: boolean);
  66143. /**
  66144. * Specifies the number of steps used to calculate the volumetric lights
  66145. * Typically in interval [50, 200]
  66146. */
  66147. get volumetricLightStepsCount(): number;
  66148. set volumetricLightStepsCount(count: number);
  66149. /**
  66150. * Specifies the number of samples used for the motion blur effect
  66151. * Typically in interval [16, 64]
  66152. */
  66153. get motionBlurSamples(): number;
  66154. set motionBlurSamples(samples: number);
  66155. /**
  66156. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  66157. */
  66158. get samples(): number;
  66159. set samples(sampleCount: number);
  66160. /**
  66161. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  66162. * @constructor
  66163. * @param name The rendering pipeline name
  66164. * @param scene The scene linked to this pipeline
  66165. * @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)
  66166. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  66167. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66168. */
  66169. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  66170. private _buildPipeline;
  66171. private _createDownSampleX4PostProcess;
  66172. private _createBrightPassPostProcess;
  66173. private _createBlurPostProcesses;
  66174. private _createTextureAdderPostProcess;
  66175. private _createVolumetricLightPostProcess;
  66176. private _createLuminancePostProcesses;
  66177. private _createHdrPostProcess;
  66178. private _createLensFlarePostProcess;
  66179. private _createDepthOfFieldPostProcess;
  66180. private _createMotionBlurPostProcess;
  66181. private _getDepthTexture;
  66182. private _disposePostProcesses;
  66183. /**
  66184. * Dispose of the pipeline and stop all post processes
  66185. */
  66186. dispose(): void;
  66187. /**
  66188. * Serialize the rendering pipeline (Used when exporting)
  66189. * @returns the serialized object
  66190. */
  66191. serialize(): any;
  66192. /**
  66193. * Parse the serialized pipeline
  66194. * @param source Source pipeline.
  66195. * @param scene The scene to load the pipeline to.
  66196. * @param rootUrl The URL of the serialized pipeline.
  66197. * @returns An instantiated pipeline from the serialized object.
  66198. */
  66199. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  66200. /**
  66201. * Luminance steps
  66202. */
  66203. static LuminanceSteps: number;
  66204. }
  66205. }
  66206. declare module BABYLON {
  66207. /** @hidden */
  66208. export var tonemapPixelShader: {
  66209. name: string;
  66210. shader: string;
  66211. };
  66212. }
  66213. declare module BABYLON {
  66214. /** Defines operator used for tonemapping */
  66215. export enum TonemappingOperator {
  66216. /** Hable */
  66217. Hable = 0,
  66218. /** Reinhard */
  66219. Reinhard = 1,
  66220. /** HejiDawson */
  66221. HejiDawson = 2,
  66222. /** Photographic */
  66223. Photographic = 3
  66224. }
  66225. /**
  66226. * Defines a post process to apply tone mapping
  66227. */
  66228. export class TonemapPostProcess extends PostProcess {
  66229. private _operator;
  66230. /** Defines the required exposure adjustement */
  66231. exposureAdjustment: number;
  66232. /**
  66233. * Creates a new TonemapPostProcess
  66234. * @param name defines the name of the postprocess
  66235. * @param _operator defines the operator to use
  66236. * @param exposureAdjustment defines the required exposure adjustement
  66237. * @param camera defines the camera to use (can be null)
  66238. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  66239. * @param engine defines the hosting engine (can be ignore if camera is set)
  66240. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  66241. */
  66242. constructor(name: string, _operator: TonemappingOperator,
  66243. /** Defines the required exposure adjustement */
  66244. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  66245. }
  66246. }
  66247. declare module BABYLON {
  66248. /** @hidden */
  66249. export var volumetricLightScatteringPixelShader: {
  66250. name: string;
  66251. shader: string;
  66252. };
  66253. }
  66254. declare module BABYLON {
  66255. /** @hidden */
  66256. export var volumetricLightScatteringPassVertexShader: {
  66257. name: string;
  66258. shader: string;
  66259. };
  66260. }
  66261. declare module BABYLON {
  66262. /** @hidden */
  66263. export var volumetricLightScatteringPassPixelShader: {
  66264. name: string;
  66265. shader: string;
  66266. };
  66267. }
  66268. declare module BABYLON {
  66269. /**
  66270. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  66271. */
  66272. export class VolumetricLightScatteringPostProcess extends PostProcess {
  66273. private _volumetricLightScatteringPass;
  66274. private _volumetricLightScatteringRTT;
  66275. private _viewPort;
  66276. private _screenCoordinates;
  66277. private _cachedDefines;
  66278. /**
  66279. * If not undefined, the mesh position is computed from the attached node position
  66280. */
  66281. attachedNode: {
  66282. position: Vector3;
  66283. };
  66284. /**
  66285. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  66286. */
  66287. customMeshPosition: Vector3;
  66288. /**
  66289. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  66290. */
  66291. useCustomMeshPosition: boolean;
  66292. /**
  66293. * If the post-process should inverse the light scattering direction
  66294. */
  66295. invert: boolean;
  66296. /**
  66297. * The internal mesh used by the post-process
  66298. */
  66299. mesh: Mesh;
  66300. /**
  66301. * @hidden
  66302. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  66303. */
  66304. get useDiffuseColor(): boolean;
  66305. set useDiffuseColor(useDiffuseColor: boolean);
  66306. /**
  66307. * Array containing the excluded meshes not rendered in the internal pass
  66308. */
  66309. excludedMeshes: AbstractMesh[];
  66310. /**
  66311. * Controls the overall intensity of the post-process
  66312. */
  66313. exposure: number;
  66314. /**
  66315. * Dissipates each sample's contribution in range [0, 1]
  66316. */
  66317. decay: number;
  66318. /**
  66319. * Controls the overall intensity of each sample
  66320. */
  66321. weight: number;
  66322. /**
  66323. * Controls the density of each sample
  66324. */
  66325. density: number;
  66326. /**
  66327. * @constructor
  66328. * @param name The post-process name
  66329. * @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)
  66330. * @param camera The camera that the post-process will be attached to
  66331. * @param mesh The mesh used to create the light scattering
  66332. * @param samples The post-process quality, default 100
  66333. * @param samplingModeThe post-process filtering mode
  66334. * @param engine The babylon engine
  66335. * @param reusable If the post-process is reusable
  66336. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  66337. */
  66338. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  66339. /**
  66340. * Returns the string "VolumetricLightScatteringPostProcess"
  66341. * @returns "VolumetricLightScatteringPostProcess"
  66342. */
  66343. getClassName(): string;
  66344. private _isReady;
  66345. /**
  66346. * Sets the new light position for light scattering effect
  66347. * @param position The new custom light position
  66348. */
  66349. setCustomMeshPosition(position: Vector3): void;
  66350. /**
  66351. * Returns the light position for light scattering effect
  66352. * @return Vector3 The custom light position
  66353. */
  66354. getCustomMeshPosition(): Vector3;
  66355. /**
  66356. * Disposes the internal assets and detaches the post-process from the camera
  66357. */
  66358. dispose(camera: Camera): void;
  66359. /**
  66360. * Returns the render target texture used by the post-process
  66361. * @return the render target texture used by the post-process
  66362. */
  66363. getPass(): RenderTargetTexture;
  66364. private _meshExcluded;
  66365. private _createPass;
  66366. private _updateMeshScreenCoordinates;
  66367. /**
  66368. * Creates a default mesh for the Volumeric Light Scattering post-process
  66369. * @param name The mesh name
  66370. * @param scene The scene where to create the mesh
  66371. * @return the default mesh
  66372. */
  66373. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  66374. }
  66375. }
  66376. declare module BABYLON {
  66377. interface Scene {
  66378. /** @hidden (Backing field) */
  66379. _boundingBoxRenderer: BoundingBoxRenderer;
  66380. /** @hidden (Backing field) */
  66381. _forceShowBoundingBoxes: boolean;
  66382. /**
  66383. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  66384. */
  66385. forceShowBoundingBoxes: boolean;
  66386. /**
  66387. * Gets the bounding box renderer associated with the scene
  66388. * @returns a BoundingBoxRenderer
  66389. */
  66390. getBoundingBoxRenderer(): BoundingBoxRenderer;
  66391. }
  66392. interface AbstractMesh {
  66393. /** @hidden (Backing field) */
  66394. _showBoundingBox: boolean;
  66395. /**
  66396. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  66397. */
  66398. showBoundingBox: boolean;
  66399. }
  66400. /**
  66401. * Component responsible of rendering the bounding box of the meshes in a scene.
  66402. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  66403. */
  66404. export class BoundingBoxRenderer implements ISceneComponent {
  66405. /**
  66406. * The component name helpfull to identify the component in the list of scene components.
  66407. */
  66408. readonly name: string;
  66409. /**
  66410. * The scene the component belongs to.
  66411. */
  66412. scene: Scene;
  66413. /**
  66414. * Color of the bounding box lines placed in front of an object
  66415. */
  66416. frontColor: Color3;
  66417. /**
  66418. * Color of the bounding box lines placed behind an object
  66419. */
  66420. backColor: Color3;
  66421. /**
  66422. * Defines if the renderer should show the back lines or not
  66423. */
  66424. showBackLines: boolean;
  66425. /**
  66426. * @hidden
  66427. */
  66428. renderList: SmartArray<BoundingBox>;
  66429. private _colorShader;
  66430. private _vertexBuffers;
  66431. private _indexBuffer;
  66432. private _fillIndexBuffer;
  66433. private _fillIndexData;
  66434. /**
  66435. * Instantiates a new bounding box renderer in a scene.
  66436. * @param scene the scene the renderer renders in
  66437. */
  66438. constructor(scene: Scene);
  66439. /**
  66440. * Registers the component in a given scene
  66441. */
  66442. register(): void;
  66443. private _evaluateSubMesh;
  66444. private _activeMesh;
  66445. private _prepareRessources;
  66446. private _createIndexBuffer;
  66447. /**
  66448. * Rebuilds the elements related to this component in case of
  66449. * context lost for instance.
  66450. */
  66451. rebuild(): void;
  66452. /**
  66453. * @hidden
  66454. */
  66455. reset(): void;
  66456. /**
  66457. * Render the bounding boxes of a specific rendering group
  66458. * @param renderingGroupId defines the rendering group to render
  66459. */
  66460. render(renderingGroupId: number): void;
  66461. /**
  66462. * In case of occlusion queries, we can render the occlusion bounding box through this method
  66463. * @param mesh Define the mesh to render the occlusion bounding box for
  66464. */
  66465. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  66466. /**
  66467. * Dispose and release the resources attached to this renderer.
  66468. */
  66469. dispose(): void;
  66470. }
  66471. }
  66472. declare module BABYLON {
  66473. interface Scene {
  66474. /** @hidden (Backing field) */
  66475. _depthRenderer: {
  66476. [id: string]: DepthRenderer;
  66477. };
  66478. /**
  66479. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  66480. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  66481. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  66482. * @returns the created depth renderer
  66483. */
  66484. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  66485. /**
  66486. * Disables a depth renderer for a given camera
  66487. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  66488. */
  66489. disableDepthRenderer(camera?: Nullable<Camera>): void;
  66490. }
  66491. /**
  66492. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  66493. * in several rendering techniques.
  66494. */
  66495. export class DepthRendererSceneComponent implements ISceneComponent {
  66496. /**
  66497. * The component name helpfull to identify the component in the list of scene components.
  66498. */
  66499. readonly name: string;
  66500. /**
  66501. * The scene the component belongs to.
  66502. */
  66503. scene: Scene;
  66504. /**
  66505. * Creates a new instance of the component for the given scene
  66506. * @param scene Defines the scene to register the component in
  66507. */
  66508. constructor(scene: Scene);
  66509. /**
  66510. * Registers the component in a given scene
  66511. */
  66512. register(): void;
  66513. /**
  66514. * Rebuilds the elements related to this component in case of
  66515. * context lost for instance.
  66516. */
  66517. rebuild(): void;
  66518. /**
  66519. * Disposes the component and the associated ressources
  66520. */
  66521. dispose(): void;
  66522. private _gatherRenderTargets;
  66523. private _gatherActiveCameraRenderTargets;
  66524. }
  66525. }
  66526. declare module BABYLON {
  66527. /** @hidden */
  66528. export var outlinePixelShader: {
  66529. name: string;
  66530. shader: string;
  66531. };
  66532. }
  66533. declare module BABYLON {
  66534. /** @hidden */
  66535. export var outlineVertexShader: {
  66536. name: string;
  66537. shader: string;
  66538. };
  66539. }
  66540. declare module BABYLON {
  66541. interface Scene {
  66542. /** @hidden */
  66543. _outlineRenderer: OutlineRenderer;
  66544. /**
  66545. * Gets the outline renderer associated with the scene
  66546. * @returns a OutlineRenderer
  66547. */
  66548. getOutlineRenderer(): OutlineRenderer;
  66549. }
  66550. interface AbstractMesh {
  66551. /** @hidden (Backing field) */
  66552. _renderOutline: boolean;
  66553. /**
  66554. * Gets or sets a boolean indicating if the outline must be rendered as well
  66555. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  66556. */
  66557. renderOutline: boolean;
  66558. /** @hidden (Backing field) */
  66559. _renderOverlay: boolean;
  66560. /**
  66561. * Gets or sets a boolean indicating if the overlay must be rendered as well
  66562. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  66563. */
  66564. renderOverlay: boolean;
  66565. }
  66566. /**
  66567. * This class is responsible to draw bothe outline/overlay of meshes.
  66568. * It should not be used directly but through the available method on mesh.
  66569. */
  66570. export class OutlineRenderer implements ISceneComponent {
  66571. /**
  66572. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  66573. */
  66574. private static _StencilReference;
  66575. /**
  66576. * The name of the component. Each component must have a unique name.
  66577. */
  66578. name: string;
  66579. /**
  66580. * The scene the component belongs to.
  66581. */
  66582. scene: Scene;
  66583. /**
  66584. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  66585. */
  66586. zOffset: number;
  66587. private _engine;
  66588. private _effect;
  66589. private _cachedDefines;
  66590. private _savedDepthWrite;
  66591. /**
  66592. * Instantiates a new outline renderer. (There could be only one per scene).
  66593. * @param scene Defines the scene it belongs to
  66594. */
  66595. constructor(scene: Scene);
  66596. /**
  66597. * Register the component to one instance of a scene.
  66598. */
  66599. register(): void;
  66600. /**
  66601. * Rebuilds the elements related to this component in case of
  66602. * context lost for instance.
  66603. */
  66604. rebuild(): void;
  66605. /**
  66606. * Disposes the component and the associated ressources.
  66607. */
  66608. dispose(): void;
  66609. /**
  66610. * Renders the outline in the canvas.
  66611. * @param subMesh Defines the sumesh to render
  66612. * @param batch Defines the batch of meshes in case of instances
  66613. * @param useOverlay Defines if the rendering is for the overlay or the outline
  66614. */
  66615. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  66616. /**
  66617. * Returns whether or not the outline renderer is ready for a given submesh.
  66618. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  66619. * @param subMesh Defines the submesh to check readyness for
  66620. * @param useInstances Defines wheter wee are trying to render instances or not
  66621. * @returns true if ready otherwise false
  66622. */
  66623. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66624. private _beforeRenderingMesh;
  66625. private _afterRenderingMesh;
  66626. }
  66627. }
  66628. declare module BABYLON {
  66629. /**
  66630. * Defines the basic options interface of a Sprite Frame Source Size.
  66631. */
  66632. export interface ISpriteJSONSpriteSourceSize {
  66633. /**
  66634. * number of the original width of the Frame
  66635. */
  66636. w: number;
  66637. /**
  66638. * number of the original height of the Frame
  66639. */
  66640. h: number;
  66641. }
  66642. /**
  66643. * Defines the basic options interface of a Sprite Frame Data.
  66644. */
  66645. export interface ISpriteJSONSpriteFrameData {
  66646. /**
  66647. * number of the x offset of the Frame
  66648. */
  66649. x: number;
  66650. /**
  66651. * number of the y offset of the Frame
  66652. */
  66653. y: number;
  66654. /**
  66655. * number of the width of the Frame
  66656. */
  66657. w: number;
  66658. /**
  66659. * number of the height of the Frame
  66660. */
  66661. h: number;
  66662. }
  66663. /**
  66664. * Defines the basic options interface of a JSON Sprite.
  66665. */
  66666. export interface ISpriteJSONSprite {
  66667. /**
  66668. * string name of the Frame
  66669. */
  66670. filename: string;
  66671. /**
  66672. * ISpriteJSONSpriteFrame basic object of the frame data
  66673. */
  66674. frame: ISpriteJSONSpriteFrameData;
  66675. /**
  66676. * boolean to flag is the frame was rotated.
  66677. */
  66678. rotated: boolean;
  66679. /**
  66680. * boolean to flag is the frame was trimmed.
  66681. */
  66682. trimmed: boolean;
  66683. /**
  66684. * ISpriteJSONSpriteFrame basic object of the source data
  66685. */
  66686. spriteSourceSize: ISpriteJSONSpriteFrameData;
  66687. /**
  66688. * ISpriteJSONSpriteFrame basic object of the source data
  66689. */
  66690. sourceSize: ISpriteJSONSpriteSourceSize;
  66691. }
  66692. /**
  66693. * Defines the basic options interface of a JSON atlas.
  66694. */
  66695. export interface ISpriteJSONAtlas {
  66696. /**
  66697. * Array of objects that contain the frame data.
  66698. */
  66699. frames: Array<ISpriteJSONSprite>;
  66700. /**
  66701. * object basic object containing the sprite meta data.
  66702. */
  66703. meta?: object;
  66704. }
  66705. }
  66706. declare module BABYLON {
  66707. /** @hidden */
  66708. export var spriteMapPixelShader: {
  66709. name: string;
  66710. shader: string;
  66711. };
  66712. }
  66713. declare module BABYLON {
  66714. /** @hidden */
  66715. export var spriteMapVertexShader: {
  66716. name: string;
  66717. shader: string;
  66718. };
  66719. }
  66720. declare module BABYLON {
  66721. /**
  66722. * Defines the basic options interface of a SpriteMap
  66723. */
  66724. export interface ISpriteMapOptions {
  66725. /**
  66726. * Vector2 of the number of cells in the grid.
  66727. */
  66728. stageSize?: Vector2;
  66729. /**
  66730. * Vector2 of the size of the output plane in World Units.
  66731. */
  66732. outputSize?: Vector2;
  66733. /**
  66734. * Vector3 of the position of the output plane in World Units.
  66735. */
  66736. outputPosition?: Vector3;
  66737. /**
  66738. * Vector3 of the rotation of the output plane.
  66739. */
  66740. outputRotation?: Vector3;
  66741. /**
  66742. * number of layers that the system will reserve in resources.
  66743. */
  66744. layerCount?: number;
  66745. /**
  66746. * number of max animation frames a single cell will reserve in resources.
  66747. */
  66748. maxAnimationFrames?: number;
  66749. /**
  66750. * number cell index of the base tile when the system compiles.
  66751. */
  66752. baseTile?: number;
  66753. /**
  66754. * boolean flip the sprite after its been repositioned by the framing data.
  66755. */
  66756. flipU?: boolean;
  66757. /**
  66758. * Vector3 scalar of the global RGB values of the SpriteMap.
  66759. */
  66760. colorMultiply?: Vector3;
  66761. }
  66762. /**
  66763. * Defines the IDisposable interface in order to be cleanable from resources.
  66764. */
  66765. export interface ISpriteMap extends IDisposable {
  66766. /**
  66767. * String name of the SpriteMap.
  66768. */
  66769. name: string;
  66770. /**
  66771. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  66772. */
  66773. atlasJSON: ISpriteJSONAtlas;
  66774. /**
  66775. * Texture of the SpriteMap.
  66776. */
  66777. spriteSheet: Texture;
  66778. /**
  66779. * The parameters to initialize the SpriteMap with.
  66780. */
  66781. options: ISpriteMapOptions;
  66782. }
  66783. /**
  66784. * Class used to manage a grid restricted sprite deployment on an Output plane.
  66785. */
  66786. export class SpriteMap implements ISpriteMap {
  66787. /** The Name of the spriteMap */
  66788. name: string;
  66789. /** The JSON file with the frame and meta data */
  66790. atlasJSON: ISpriteJSONAtlas;
  66791. /** The systems Sprite Sheet Texture */
  66792. spriteSheet: Texture;
  66793. /** Arguments passed with the Constructor */
  66794. options: ISpriteMapOptions;
  66795. /** Public Sprite Storage array, parsed from atlasJSON */
  66796. sprites: Array<ISpriteJSONSprite>;
  66797. /** Returns the Number of Sprites in the System */
  66798. get spriteCount(): number;
  66799. /** Returns the Position of Output Plane*/
  66800. get position(): Vector3;
  66801. /** Returns the Position of Output Plane*/
  66802. set position(v: Vector3);
  66803. /** Returns the Rotation of Output Plane*/
  66804. get rotation(): Vector3;
  66805. /** Returns the Rotation of Output Plane*/
  66806. set rotation(v: Vector3);
  66807. /** Sets the AnimationMap*/
  66808. get animationMap(): RawTexture;
  66809. /** Sets the AnimationMap*/
  66810. set animationMap(v: RawTexture);
  66811. /** Scene that the SpriteMap was created in */
  66812. private _scene;
  66813. /** Texture Buffer of Float32 that holds tile frame data*/
  66814. private _frameMap;
  66815. /** Texture Buffers of Float32 that holds tileMap data*/
  66816. private _tileMaps;
  66817. /** Texture Buffer of Float32 that holds Animation Data*/
  66818. private _animationMap;
  66819. /** Custom ShaderMaterial Central to the System*/
  66820. private _material;
  66821. /** Custom ShaderMaterial Central to the System*/
  66822. private _output;
  66823. /** Systems Time Ticker*/
  66824. private _time;
  66825. /**
  66826. * Creates a new SpriteMap
  66827. * @param name defines the SpriteMaps Name
  66828. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  66829. * @param spriteSheet is the Texture that the Sprites are on.
  66830. * @param options a basic deployment configuration
  66831. * @param scene The Scene that the map is deployed on
  66832. */
  66833. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  66834. /**
  66835. * Returns tileID location
  66836. * @returns Vector2 the cell position ID
  66837. */
  66838. getTileID(): Vector2;
  66839. /**
  66840. * Gets the UV location of the mouse over the SpriteMap.
  66841. * @returns Vector2 the UV position of the mouse interaction
  66842. */
  66843. getMousePosition(): Vector2;
  66844. /**
  66845. * Creates the "frame" texture Buffer
  66846. * -------------------------------------
  66847. * Structure of frames
  66848. * "filename": "Falling-Water-2.png",
  66849. * "frame": {"x":69,"y":103,"w":24,"h":32},
  66850. * "rotated": true,
  66851. * "trimmed": true,
  66852. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  66853. * "sourceSize": {"w":32,"h":32}
  66854. * @returns RawTexture of the frameMap
  66855. */
  66856. private _createFrameBuffer;
  66857. /**
  66858. * Creates the tileMap texture Buffer
  66859. * @param buffer normally and array of numbers, or a false to generate from scratch
  66860. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  66861. * @returns RawTexture of the tileMap
  66862. */
  66863. private _createTileBuffer;
  66864. /**
  66865. * Modifies the data of the tileMaps
  66866. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  66867. * @param pos is the iVector2 Coordinates of the Tile
  66868. * @param tile The SpriteIndex of the new Tile
  66869. */
  66870. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  66871. /**
  66872. * Creates the animationMap texture Buffer
  66873. * @param buffer normally and array of numbers, or a false to generate from scratch
  66874. * @returns RawTexture of the animationMap
  66875. */
  66876. private _createTileAnimationBuffer;
  66877. /**
  66878. * Modifies the data of the animationMap
  66879. * @param cellID is the Index of the Sprite
  66880. * @param _frame is the target Animation frame
  66881. * @param toCell is the Target Index of the next frame of the animation
  66882. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  66883. * @param speed is a global scalar of the time variable on the map.
  66884. */
  66885. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  66886. /**
  66887. * Exports the .tilemaps file
  66888. */
  66889. saveTileMaps(): void;
  66890. /**
  66891. * Imports the .tilemaps file
  66892. * @param url of the .tilemaps file
  66893. */
  66894. loadTileMaps(url: string): void;
  66895. /**
  66896. * Release associated resources
  66897. */
  66898. dispose(): void;
  66899. }
  66900. }
  66901. declare module BABYLON {
  66902. /**
  66903. * Class used to manage multiple sprites of different sizes on the same spritesheet
  66904. * @see http://doc.babylonjs.com/babylon101/sprites
  66905. */
  66906. export class SpritePackedManager extends SpriteManager {
  66907. /** defines the packed manager's name */
  66908. name: string;
  66909. /**
  66910. * Creates a new sprite manager from a packed sprite sheet
  66911. * @param name defines the manager's name
  66912. * @param imgUrl defines the sprite sheet url
  66913. * @param capacity defines the maximum allowed number of sprites
  66914. * @param scene defines the hosting scene
  66915. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  66916. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  66917. * @param samplingMode defines the smapling mode to use with spritesheet
  66918. * @param fromPacked set to true; do not alter
  66919. */
  66920. constructor(
  66921. /** defines the packed manager's name */
  66922. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  66923. }
  66924. }
  66925. declare module BABYLON {
  66926. /**
  66927. * Defines the list of states available for a task inside a AssetsManager
  66928. */
  66929. export enum AssetTaskState {
  66930. /**
  66931. * Initialization
  66932. */
  66933. INIT = 0,
  66934. /**
  66935. * Running
  66936. */
  66937. RUNNING = 1,
  66938. /**
  66939. * Done
  66940. */
  66941. DONE = 2,
  66942. /**
  66943. * Error
  66944. */
  66945. ERROR = 3
  66946. }
  66947. /**
  66948. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  66949. */
  66950. export abstract class AbstractAssetTask {
  66951. /**
  66952. * Task name
  66953. */ name: string;
  66954. /**
  66955. * Callback called when the task is successful
  66956. */
  66957. onSuccess: (task: any) => void;
  66958. /**
  66959. * Callback called when the task is not successful
  66960. */
  66961. onError: (task: any, message?: string, exception?: any) => void;
  66962. /**
  66963. * Creates a new AssetsManager
  66964. * @param name defines the name of the task
  66965. */
  66966. constructor(
  66967. /**
  66968. * Task name
  66969. */ name: string);
  66970. private _isCompleted;
  66971. private _taskState;
  66972. private _errorObject;
  66973. /**
  66974. * Get if the task is completed
  66975. */
  66976. get isCompleted(): boolean;
  66977. /**
  66978. * Gets the current state of the task
  66979. */
  66980. get taskState(): AssetTaskState;
  66981. /**
  66982. * Gets the current error object (if task is in error)
  66983. */
  66984. get errorObject(): {
  66985. message?: string;
  66986. exception?: any;
  66987. };
  66988. /**
  66989. * Internal only
  66990. * @hidden
  66991. */
  66992. _setErrorObject(message?: string, exception?: any): void;
  66993. /**
  66994. * Execute the current task
  66995. * @param scene defines the scene where you want your assets to be loaded
  66996. * @param onSuccess is a callback called when the task is successfully executed
  66997. * @param onError is a callback called if an error occurs
  66998. */
  66999. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67000. /**
  67001. * Execute the current task
  67002. * @param scene defines the scene where you want your assets to be loaded
  67003. * @param onSuccess is a callback called when the task is successfully executed
  67004. * @param onError is a callback called if an error occurs
  67005. */
  67006. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67007. /**
  67008. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  67009. * This can be used with failed tasks that have the reason for failure fixed.
  67010. */
  67011. reset(): void;
  67012. private onErrorCallback;
  67013. private onDoneCallback;
  67014. }
  67015. /**
  67016. * Define the interface used by progress events raised during assets loading
  67017. */
  67018. export interface IAssetsProgressEvent {
  67019. /**
  67020. * Defines the number of remaining tasks to process
  67021. */
  67022. remainingCount: number;
  67023. /**
  67024. * Defines the total number of tasks
  67025. */
  67026. totalCount: number;
  67027. /**
  67028. * Defines the task that was just processed
  67029. */
  67030. task: AbstractAssetTask;
  67031. }
  67032. /**
  67033. * Class used to share progress information about assets loading
  67034. */
  67035. export class AssetsProgressEvent implements IAssetsProgressEvent {
  67036. /**
  67037. * Defines the number of remaining tasks to process
  67038. */
  67039. remainingCount: number;
  67040. /**
  67041. * Defines the total number of tasks
  67042. */
  67043. totalCount: number;
  67044. /**
  67045. * Defines the task that was just processed
  67046. */
  67047. task: AbstractAssetTask;
  67048. /**
  67049. * Creates a AssetsProgressEvent
  67050. * @param remainingCount defines the number of remaining tasks to process
  67051. * @param totalCount defines the total number of tasks
  67052. * @param task defines the task that was just processed
  67053. */
  67054. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  67055. }
  67056. /**
  67057. * Define a task used by AssetsManager to load meshes
  67058. */
  67059. export class MeshAssetTask extends AbstractAssetTask {
  67060. /**
  67061. * Defines the name of the task
  67062. */
  67063. name: string;
  67064. /**
  67065. * Defines the list of mesh's names you want to load
  67066. */
  67067. meshesNames: any;
  67068. /**
  67069. * Defines the root url to use as a base to load your meshes and associated resources
  67070. */
  67071. rootUrl: string;
  67072. /**
  67073. * Defines the filename of the scene to load from
  67074. */
  67075. sceneFilename: string;
  67076. /**
  67077. * Gets the list of loaded meshes
  67078. */
  67079. loadedMeshes: Array<AbstractMesh>;
  67080. /**
  67081. * Gets the list of loaded particle systems
  67082. */
  67083. loadedParticleSystems: Array<IParticleSystem>;
  67084. /**
  67085. * Gets the list of loaded skeletons
  67086. */
  67087. loadedSkeletons: Array<Skeleton>;
  67088. /**
  67089. * Gets the list of loaded animation groups
  67090. */
  67091. loadedAnimationGroups: Array<AnimationGroup>;
  67092. /**
  67093. * Callback called when the task is successful
  67094. */
  67095. onSuccess: (task: MeshAssetTask) => void;
  67096. /**
  67097. * Callback called when the task is successful
  67098. */
  67099. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  67100. /**
  67101. * Creates a new MeshAssetTask
  67102. * @param name defines the name of the task
  67103. * @param meshesNames defines the list of mesh's names you want to load
  67104. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  67105. * @param sceneFilename defines the filename of the scene to load from
  67106. */
  67107. constructor(
  67108. /**
  67109. * Defines the name of the task
  67110. */
  67111. name: string,
  67112. /**
  67113. * Defines the list of mesh's names you want to load
  67114. */
  67115. meshesNames: any,
  67116. /**
  67117. * Defines the root url to use as a base to load your meshes and associated resources
  67118. */
  67119. rootUrl: string,
  67120. /**
  67121. * Defines the filename of the scene to load from
  67122. */
  67123. sceneFilename: string);
  67124. /**
  67125. * Execute the current task
  67126. * @param scene defines the scene where you want your assets to be loaded
  67127. * @param onSuccess is a callback called when the task is successfully executed
  67128. * @param onError is a callback called if an error occurs
  67129. */
  67130. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67131. }
  67132. /**
  67133. * Define a task used by AssetsManager to load text content
  67134. */
  67135. export class TextFileAssetTask extends AbstractAssetTask {
  67136. /**
  67137. * Defines the name of the task
  67138. */
  67139. name: string;
  67140. /**
  67141. * Defines the location of the file to load
  67142. */
  67143. url: string;
  67144. /**
  67145. * Gets the loaded text string
  67146. */
  67147. text: string;
  67148. /**
  67149. * Callback called when the task is successful
  67150. */
  67151. onSuccess: (task: TextFileAssetTask) => void;
  67152. /**
  67153. * Callback called when the task is successful
  67154. */
  67155. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  67156. /**
  67157. * Creates a new TextFileAssetTask object
  67158. * @param name defines the name of the task
  67159. * @param url defines the location of the file to load
  67160. */
  67161. constructor(
  67162. /**
  67163. * Defines the name of the task
  67164. */
  67165. name: string,
  67166. /**
  67167. * Defines the location of the file to load
  67168. */
  67169. url: string);
  67170. /**
  67171. * Execute the current task
  67172. * @param scene defines the scene where you want your assets to be loaded
  67173. * @param onSuccess is a callback called when the task is successfully executed
  67174. * @param onError is a callback called if an error occurs
  67175. */
  67176. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67177. }
  67178. /**
  67179. * Define a task used by AssetsManager to load binary data
  67180. */
  67181. export class BinaryFileAssetTask extends AbstractAssetTask {
  67182. /**
  67183. * Defines the name of the task
  67184. */
  67185. name: string;
  67186. /**
  67187. * Defines the location of the file to load
  67188. */
  67189. url: string;
  67190. /**
  67191. * Gets the lodaded data (as an array buffer)
  67192. */
  67193. data: ArrayBuffer;
  67194. /**
  67195. * Callback called when the task is successful
  67196. */
  67197. onSuccess: (task: BinaryFileAssetTask) => void;
  67198. /**
  67199. * Callback called when the task is successful
  67200. */
  67201. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  67202. /**
  67203. * Creates a new BinaryFileAssetTask object
  67204. * @param name defines the name of the new task
  67205. * @param url defines the location of the file to load
  67206. */
  67207. constructor(
  67208. /**
  67209. * Defines the name of the task
  67210. */
  67211. name: string,
  67212. /**
  67213. * Defines the location of the file to load
  67214. */
  67215. url: string);
  67216. /**
  67217. * Execute the current task
  67218. * @param scene defines the scene where you want your assets to be loaded
  67219. * @param onSuccess is a callback called when the task is successfully executed
  67220. * @param onError is a callback called if an error occurs
  67221. */
  67222. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67223. }
  67224. /**
  67225. * Define a task used by AssetsManager to load images
  67226. */
  67227. export class ImageAssetTask extends AbstractAssetTask {
  67228. /**
  67229. * Defines the name of the task
  67230. */
  67231. name: string;
  67232. /**
  67233. * Defines the location of the image to load
  67234. */
  67235. url: string;
  67236. /**
  67237. * Gets the loaded images
  67238. */
  67239. image: HTMLImageElement;
  67240. /**
  67241. * Callback called when the task is successful
  67242. */
  67243. onSuccess: (task: ImageAssetTask) => void;
  67244. /**
  67245. * Callback called when the task is successful
  67246. */
  67247. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  67248. /**
  67249. * Creates a new ImageAssetTask
  67250. * @param name defines the name of the task
  67251. * @param url defines the location of the image to load
  67252. */
  67253. constructor(
  67254. /**
  67255. * Defines the name of the task
  67256. */
  67257. name: string,
  67258. /**
  67259. * Defines the location of the image to load
  67260. */
  67261. url: string);
  67262. /**
  67263. * Execute the current task
  67264. * @param scene defines the scene where you want your assets to be loaded
  67265. * @param onSuccess is a callback called when the task is successfully executed
  67266. * @param onError is a callback called if an error occurs
  67267. */
  67268. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67269. }
  67270. /**
  67271. * Defines the interface used by texture loading tasks
  67272. */
  67273. export interface ITextureAssetTask<TEX extends BaseTexture> {
  67274. /**
  67275. * Gets the loaded texture
  67276. */
  67277. texture: TEX;
  67278. }
  67279. /**
  67280. * Define a task used by AssetsManager to load 2D textures
  67281. */
  67282. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  67283. /**
  67284. * Defines the name of the task
  67285. */
  67286. name: string;
  67287. /**
  67288. * Defines the location of the file to load
  67289. */
  67290. url: string;
  67291. /**
  67292. * Defines if mipmap should not be generated (default is false)
  67293. */
  67294. noMipmap?: boolean | undefined;
  67295. /**
  67296. * Defines if texture must be inverted on Y axis (default is false)
  67297. */
  67298. invertY?: boolean | undefined;
  67299. /**
  67300. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67301. */
  67302. samplingMode: number;
  67303. /**
  67304. * Gets the loaded texture
  67305. */
  67306. texture: Texture;
  67307. /**
  67308. * Callback called when the task is successful
  67309. */
  67310. onSuccess: (task: TextureAssetTask) => void;
  67311. /**
  67312. * Callback called when the task is successful
  67313. */
  67314. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  67315. /**
  67316. * Creates a new TextureAssetTask object
  67317. * @param name defines the name of the task
  67318. * @param url defines the location of the file to load
  67319. * @param noMipmap defines if mipmap should not be generated (default is false)
  67320. * @param invertY defines if texture must be inverted on Y axis (default is false)
  67321. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67322. */
  67323. constructor(
  67324. /**
  67325. * Defines the name of the task
  67326. */
  67327. name: string,
  67328. /**
  67329. * Defines the location of the file to load
  67330. */
  67331. url: string,
  67332. /**
  67333. * Defines if mipmap should not be generated (default is false)
  67334. */
  67335. noMipmap?: boolean | undefined,
  67336. /**
  67337. * Defines if texture must be inverted on Y axis (default is false)
  67338. */
  67339. invertY?: boolean | undefined,
  67340. /**
  67341. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67342. */
  67343. samplingMode?: number);
  67344. /**
  67345. * Execute the current task
  67346. * @param scene defines the scene where you want your assets to be loaded
  67347. * @param onSuccess is a callback called when the task is successfully executed
  67348. * @param onError is a callback called if an error occurs
  67349. */
  67350. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67351. }
  67352. /**
  67353. * Define a task used by AssetsManager to load cube textures
  67354. */
  67355. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  67356. /**
  67357. * Defines the name of the task
  67358. */
  67359. name: string;
  67360. /**
  67361. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67362. */
  67363. url: string;
  67364. /**
  67365. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67366. */
  67367. extensions?: string[] | undefined;
  67368. /**
  67369. * Defines if mipmaps should not be generated (default is false)
  67370. */
  67371. noMipmap?: boolean | undefined;
  67372. /**
  67373. * Defines the explicit list of files (undefined by default)
  67374. */
  67375. files?: string[] | undefined;
  67376. /**
  67377. * Gets the loaded texture
  67378. */
  67379. texture: CubeTexture;
  67380. /**
  67381. * Callback called when the task is successful
  67382. */
  67383. onSuccess: (task: CubeTextureAssetTask) => void;
  67384. /**
  67385. * Callback called when the task is successful
  67386. */
  67387. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  67388. /**
  67389. * Creates a new CubeTextureAssetTask
  67390. * @param name defines the name of the task
  67391. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67392. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67393. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67394. * @param files defines the explicit list of files (undefined by default)
  67395. */
  67396. constructor(
  67397. /**
  67398. * Defines the name of the task
  67399. */
  67400. name: string,
  67401. /**
  67402. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67403. */
  67404. url: string,
  67405. /**
  67406. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67407. */
  67408. extensions?: string[] | undefined,
  67409. /**
  67410. * Defines if mipmaps should not be generated (default is false)
  67411. */
  67412. noMipmap?: boolean | undefined,
  67413. /**
  67414. * Defines the explicit list of files (undefined by default)
  67415. */
  67416. files?: string[] | undefined);
  67417. /**
  67418. * Execute the current task
  67419. * @param scene defines the scene where you want your assets to be loaded
  67420. * @param onSuccess is a callback called when the task is successfully executed
  67421. * @param onError is a callback called if an error occurs
  67422. */
  67423. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67424. }
  67425. /**
  67426. * Define a task used by AssetsManager to load HDR cube textures
  67427. */
  67428. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  67429. /**
  67430. * Defines the name of the task
  67431. */
  67432. name: string;
  67433. /**
  67434. * Defines the location of the file to load
  67435. */
  67436. url: string;
  67437. /**
  67438. * Defines the desired size (the more it increases the longer the generation will be)
  67439. */
  67440. size: number;
  67441. /**
  67442. * Defines if mipmaps should not be generated (default is false)
  67443. */
  67444. noMipmap: boolean;
  67445. /**
  67446. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67447. */
  67448. generateHarmonics: boolean;
  67449. /**
  67450. * 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)
  67451. */
  67452. gammaSpace: boolean;
  67453. /**
  67454. * Internal Use Only
  67455. */
  67456. reserved: boolean;
  67457. /**
  67458. * Gets the loaded texture
  67459. */
  67460. texture: HDRCubeTexture;
  67461. /**
  67462. * Callback called when the task is successful
  67463. */
  67464. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  67465. /**
  67466. * Callback called when the task is successful
  67467. */
  67468. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  67469. /**
  67470. * Creates a new HDRCubeTextureAssetTask object
  67471. * @param name defines the name of the task
  67472. * @param url defines the location of the file to load
  67473. * @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.
  67474. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67475. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67476. * @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)
  67477. * @param reserved Internal use only
  67478. */
  67479. constructor(
  67480. /**
  67481. * Defines the name of the task
  67482. */
  67483. name: string,
  67484. /**
  67485. * Defines the location of the file to load
  67486. */
  67487. url: string,
  67488. /**
  67489. * Defines the desired size (the more it increases the longer the generation will be)
  67490. */
  67491. size: number,
  67492. /**
  67493. * Defines if mipmaps should not be generated (default is false)
  67494. */
  67495. noMipmap?: boolean,
  67496. /**
  67497. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67498. */
  67499. generateHarmonics?: boolean,
  67500. /**
  67501. * 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)
  67502. */
  67503. gammaSpace?: boolean,
  67504. /**
  67505. * Internal Use Only
  67506. */
  67507. reserved?: boolean);
  67508. /**
  67509. * Execute the current task
  67510. * @param scene defines the scene where you want your assets to be loaded
  67511. * @param onSuccess is a callback called when the task is successfully executed
  67512. * @param onError is a callback called if an error occurs
  67513. */
  67514. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67515. }
  67516. /**
  67517. * Define a task used by AssetsManager to load Equirectangular cube textures
  67518. */
  67519. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  67520. /**
  67521. * Defines the name of the task
  67522. */
  67523. name: string;
  67524. /**
  67525. * Defines the location of the file to load
  67526. */
  67527. url: string;
  67528. /**
  67529. * Defines the desired size (the more it increases the longer the generation will be)
  67530. */
  67531. size: number;
  67532. /**
  67533. * Defines if mipmaps should not be generated (default is false)
  67534. */
  67535. noMipmap: boolean;
  67536. /**
  67537. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  67538. * but the standard material would require them in Gamma space) (default is true)
  67539. */
  67540. gammaSpace: boolean;
  67541. /**
  67542. * Gets the loaded texture
  67543. */
  67544. texture: EquiRectangularCubeTexture;
  67545. /**
  67546. * Callback called when the task is successful
  67547. */
  67548. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  67549. /**
  67550. * Callback called when the task is successful
  67551. */
  67552. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  67553. /**
  67554. * Creates a new EquiRectangularCubeTextureAssetTask object
  67555. * @param name defines the name of the task
  67556. * @param url defines the location of the file to load
  67557. * @param size defines the desired size (the more it increases the longer the generation will be)
  67558. * If the size is omitted this implies you are using a preprocessed cubemap.
  67559. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67560. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  67561. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  67562. * (default is true)
  67563. */
  67564. constructor(
  67565. /**
  67566. * Defines the name of the task
  67567. */
  67568. name: string,
  67569. /**
  67570. * Defines the location of the file to load
  67571. */
  67572. url: string,
  67573. /**
  67574. * Defines the desired size (the more it increases the longer the generation will be)
  67575. */
  67576. size: number,
  67577. /**
  67578. * Defines if mipmaps should not be generated (default is false)
  67579. */
  67580. noMipmap?: boolean,
  67581. /**
  67582. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  67583. * but the standard material would require them in Gamma space) (default is true)
  67584. */
  67585. gammaSpace?: boolean);
  67586. /**
  67587. * Execute the current task
  67588. * @param scene defines the scene where you want your assets to be loaded
  67589. * @param onSuccess is a callback called when the task is successfully executed
  67590. * @param onError is a callback called if an error occurs
  67591. */
  67592. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67593. }
  67594. /**
  67595. * This class can be used to easily import assets into a scene
  67596. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  67597. */
  67598. export class AssetsManager {
  67599. private _scene;
  67600. private _isLoading;
  67601. protected _tasks: AbstractAssetTask[];
  67602. protected _waitingTasksCount: number;
  67603. protected _totalTasksCount: number;
  67604. /**
  67605. * Callback called when all tasks are processed
  67606. */
  67607. onFinish: (tasks: AbstractAssetTask[]) => void;
  67608. /**
  67609. * Callback called when a task is successful
  67610. */
  67611. onTaskSuccess: (task: AbstractAssetTask) => void;
  67612. /**
  67613. * Callback called when a task had an error
  67614. */
  67615. onTaskError: (task: AbstractAssetTask) => void;
  67616. /**
  67617. * Callback called when a task is done (whatever the result is)
  67618. */
  67619. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  67620. /**
  67621. * Observable called when all tasks are processed
  67622. */
  67623. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  67624. /**
  67625. * Observable called when a task had an error
  67626. */
  67627. onTaskErrorObservable: Observable<AbstractAssetTask>;
  67628. /**
  67629. * Observable called when all tasks were executed
  67630. */
  67631. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  67632. /**
  67633. * Observable called when a task is done (whatever the result is)
  67634. */
  67635. onProgressObservable: Observable<IAssetsProgressEvent>;
  67636. /**
  67637. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  67638. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  67639. */
  67640. useDefaultLoadingScreen: boolean;
  67641. /**
  67642. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  67643. * when all assets have been downloaded.
  67644. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  67645. */
  67646. autoHideLoadingUI: boolean;
  67647. /**
  67648. * Creates a new AssetsManager
  67649. * @param scene defines the scene to work on
  67650. */
  67651. constructor(scene: Scene);
  67652. /**
  67653. * Add a MeshAssetTask to the list of active tasks
  67654. * @param taskName defines the name of the new task
  67655. * @param meshesNames defines the name of meshes to load
  67656. * @param rootUrl defines the root url to use to locate files
  67657. * @param sceneFilename defines the filename of the scene file
  67658. * @returns a new MeshAssetTask object
  67659. */
  67660. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  67661. /**
  67662. * Add a TextFileAssetTask to the list of active tasks
  67663. * @param taskName defines the name of the new task
  67664. * @param url defines the url of the file to load
  67665. * @returns a new TextFileAssetTask object
  67666. */
  67667. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  67668. /**
  67669. * Add a BinaryFileAssetTask to the list of active tasks
  67670. * @param taskName defines the name of the new task
  67671. * @param url defines the url of the file to load
  67672. * @returns a new BinaryFileAssetTask object
  67673. */
  67674. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  67675. /**
  67676. * Add a ImageAssetTask to the list of active tasks
  67677. * @param taskName defines the name of the new task
  67678. * @param url defines the url of the file to load
  67679. * @returns a new ImageAssetTask object
  67680. */
  67681. addImageTask(taskName: string, url: string): ImageAssetTask;
  67682. /**
  67683. * Add a TextureAssetTask to the list of active tasks
  67684. * @param taskName defines the name of the new task
  67685. * @param url defines the url of the file to load
  67686. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67687. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  67688. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  67689. * @returns a new TextureAssetTask object
  67690. */
  67691. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  67692. /**
  67693. * Add a CubeTextureAssetTask to the list of active tasks
  67694. * @param taskName defines the name of the new task
  67695. * @param url defines the url of the file to load
  67696. * @param extensions defines the extension to use to load the cube map (can be null)
  67697. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67698. * @param files defines the list of files to load (can be null)
  67699. * @returns a new CubeTextureAssetTask object
  67700. */
  67701. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  67702. /**
  67703. *
  67704. * Add a HDRCubeTextureAssetTask to the list of active tasks
  67705. * @param taskName defines the name of the new task
  67706. * @param url defines the url of the file to load
  67707. * @param size defines the size you want for the cubemap (can be null)
  67708. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67709. * @param generateHarmonics defines if you want to automatically generate (true by default)
  67710. * @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)
  67711. * @param reserved Internal use only
  67712. * @returns a new HDRCubeTextureAssetTask object
  67713. */
  67714. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  67715. /**
  67716. *
  67717. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  67718. * @param taskName defines the name of the new task
  67719. * @param url defines the url of the file to load
  67720. * @param size defines the size you want for the cubemap (can be null)
  67721. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67722. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  67723. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  67724. * @returns a new EquiRectangularCubeTextureAssetTask object
  67725. */
  67726. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  67727. /**
  67728. * Remove a task from the assets manager.
  67729. * @param task the task to remove
  67730. */
  67731. removeTask(task: AbstractAssetTask): void;
  67732. private _decreaseWaitingTasksCount;
  67733. private _runTask;
  67734. /**
  67735. * Reset the AssetsManager and remove all tasks
  67736. * @return the current instance of the AssetsManager
  67737. */
  67738. reset(): AssetsManager;
  67739. /**
  67740. * Start the loading process
  67741. * @return the current instance of the AssetsManager
  67742. */
  67743. load(): AssetsManager;
  67744. /**
  67745. * Start the loading process as an async operation
  67746. * @return a promise returning the list of failed tasks
  67747. */
  67748. loadAsync(): Promise<void>;
  67749. }
  67750. }
  67751. declare module BABYLON {
  67752. /**
  67753. * Wrapper class for promise with external resolve and reject.
  67754. */
  67755. export class Deferred<T> {
  67756. /**
  67757. * The promise associated with this deferred object.
  67758. */
  67759. readonly promise: Promise<T>;
  67760. private _resolve;
  67761. private _reject;
  67762. /**
  67763. * The resolve method of the promise associated with this deferred object.
  67764. */
  67765. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  67766. /**
  67767. * The reject method of the promise associated with this deferred object.
  67768. */
  67769. get reject(): (reason?: any) => void;
  67770. /**
  67771. * Constructor for this deferred object.
  67772. */
  67773. constructor();
  67774. }
  67775. }
  67776. declare module BABYLON {
  67777. /**
  67778. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  67779. */
  67780. export class MeshExploder {
  67781. private _centerMesh;
  67782. private _meshes;
  67783. private _meshesOrigins;
  67784. private _toCenterVectors;
  67785. private _scaledDirection;
  67786. private _newPosition;
  67787. private _centerPosition;
  67788. /**
  67789. * Explodes meshes from a center mesh.
  67790. * @param meshes The meshes to explode.
  67791. * @param centerMesh The mesh to be center of explosion.
  67792. */
  67793. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  67794. private _setCenterMesh;
  67795. /**
  67796. * Get class name
  67797. * @returns "MeshExploder"
  67798. */
  67799. getClassName(): string;
  67800. /**
  67801. * "Exploded meshes"
  67802. * @returns Array of meshes with the centerMesh at index 0.
  67803. */
  67804. getMeshes(): Array<Mesh>;
  67805. /**
  67806. * Explodes meshes giving a specific direction
  67807. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  67808. */
  67809. explode(direction?: number): void;
  67810. }
  67811. }
  67812. declare module BABYLON {
  67813. /**
  67814. * Class used to help managing file picking and drag'n'drop
  67815. */
  67816. export class FilesInput {
  67817. /**
  67818. * List of files ready to be loaded
  67819. */
  67820. static get FilesToLoad(): {
  67821. [key: string]: File;
  67822. };
  67823. /**
  67824. * Callback called when a file is processed
  67825. */
  67826. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  67827. private _engine;
  67828. private _currentScene;
  67829. private _sceneLoadedCallback;
  67830. private _progressCallback;
  67831. private _additionalRenderLoopLogicCallback;
  67832. private _textureLoadingCallback;
  67833. private _startingProcessingFilesCallback;
  67834. private _onReloadCallback;
  67835. private _errorCallback;
  67836. private _elementToMonitor;
  67837. private _sceneFileToLoad;
  67838. private _filesToLoad;
  67839. /**
  67840. * Creates a new FilesInput
  67841. * @param engine defines the rendering engine
  67842. * @param scene defines the hosting scene
  67843. * @param sceneLoadedCallback callback called when scene is loaded
  67844. * @param progressCallback callback called to track progress
  67845. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  67846. * @param textureLoadingCallback callback called when a texture is loading
  67847. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  67848. * @param onReloadCallback callback called when a reload is requested
  67849. * @param errorCallback callback call if an error occurs
  67850. */
  67851. 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);
  67852. private _dragEnterHandler;
  67853. private _dragOverHandler;
  67854. private _dropHandler;
  67855. /**
  67856. * Calls this function to listen to drag'n'drop events on a specific DOM element
  67857. * @param elementToMonitor defines the DOM element to track
  67858. */
  67859. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  67860. /**
  67861. * Release all associated resources
  67862. */
  67863. dispose(): void;
  67864. private renderFunction;
  67865. private drag;
  67866. private drop;
  67867. private _traverseFolder;
  67868. private _processFiles;
  67869. /**
  67870. * Load files from a drop event
  67871. * @param event defines the drop event to use as source
  67872. */
  67873. loadFiles(event: any): void;
  67874. private _processReload;
  67875. /**
  67876. * Reload the current scene from the loaded files
  67877. */
  67878. reload(): void;
  67879. }
  67880. }
  67881. declare module BABYLON {
  67882. /**
  67883. * Defines the root class used to create scene optimization to use with SceneOptimizer
  67884. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67885. */
  67886. export class SceneOptimization {
  67887. /**
  67888. * Defines the priority of this optimization (0 by default which means first in the list)
  67889. */
  67890. priority: number;
  67891. /**
  67892. * Gets a string describing the action executed by the current optimization
  67893. * @returns description string
  67894. */
  67895. getDescription(): string;
  67896. /**
  67897. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67898. * @param scene defines the current scene where to apply this optimization
  67899. * @param optimizer defines the current optimizer
  67900. * @returns true if everything that can be done was applied
  67901. */
  67902. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67903. /**
  67904. * Creates the SceneOptimization object
  67905. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67906. * @param desc defines the description associated with the optimization
  67907. */
  67908. constructor(
  67909. /**
  67910. * Defines the priority of this optimization (0 by default which means first in the list)
  67911. */
  67912. priority?: number);
  67913. }
  67914. /**
  67915. * Defines an optimization used to reduce the size of render target textures
  67916. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67917. */
  67918. export class TextureOptimization extends SceneOptimization {
  67919. /**
  67920. * Defines the priority of this optimization (0 by default which means first in the list)
  67921. */
  67922. priority: number;
  67923. /**
  67924. * 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
  67925. */
  67926. maximumSize: number;
  67927. /**
  67928. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  67929. */
  67930. step: number;
  67931. /**
  67932. * Gets a string describing the action executed by the current optimization
  67933. * @returns description string
  67934. */
  67935. getDescription(): string;
  67936. /**
  67937. * Creates the TextureOptimization object
  67938. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67939. * @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
  67940. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  67941. */
  67942. constructor(
  67943. /**
  67944. * Defines the priority of this optimization (0 by default which means first in the list)
  67945. */
  67946. priority?: number,
  67947. /**
  67948. * 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
  67949. */
  67950. maximumSize?: number,
  67951. /**
  67952. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  67953. */
  67954. step?: number);
  67955. /**
  67956. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67957. * @param scene defines the current scene where to apply this optimization
  67958. * @param optimizer defines the current optimizer
  67959. * @returns true if everything that can be done was applied
  67960. */
  67961. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67962. }
  67963. /**
  67964. * Defines an optimization used to increase or decrease the rendering resolution
  67965. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67966. */
  67967. export class HardwareScalingOptimization extends SceneOptimization {
  67968. /**
  67969. * Defines the priority of this optimization (0 by default which means first in the list)
  67970. */
  67971. priority: number;
  67972. /**
  67973. * Defines the maximum scale to use (2 by default)
  67974. */
  67975. maximumScale: number;
  67976. /**
  67977. * Defines the step to use between two passes (0.5 by default)
  67978. */
  67979. step: number;
  67980. private _currentScale;
  67981. private _directionOffset;
  67982. /**
  67983. * Gets a string describing the action executed by the current optimization
  67984. * @return description string
  67985. */
  67986. getDescription(): string;
  67987. /**
  67988. * Creates the HardwareScalingOptimization object
  67989. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67990. * @param maximumScale defines the maximum scale to use (2 by default)
  67991. * @param step defines the step to use between two passes (0.5 by default)
  67992. */
  67993. constructor(
  67994. /**
  67995. * Defines the priority of this optimization (0 by default which means first in the list)
  67996. */
  67997. priority?: number,
  67998. /**
  67999. * Defines the maximum scale to use (2 by default)
  68000. */
  68001. maximumScale?: number,
  68002. /**
  68003. * Defines the step to use between two passes (0.5 by default)
  68004. */
  68005. step?: number);
  68006. /**
  68007. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68008. * @param scene defines the current scene where to apply this optimization
  68009. * @param optimizer defines the current optimizer
  68010. * @returns true if everything that can be done was applied
  68011. */
  68012. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68013. }
  68014. /**
  68015. * Defines an optimization used to remove shadows
  68016. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68017. */
  68018. export class ShadowsOptimization extends SceneOptimization {
  68019. /**
  68020. * Gets a string describing the action executed by the current optimization
  68021. * @return description string
  68022. */
  68023. getDescription(): string;
  68024. /**
  68025. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68026. * @param scene defines the current scene where to apply this optimization
  68027. * @param optimizer defines the current optimizer
  68028. * @returns true if everything that can be done was applied
  68029. */
  68030. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68031. }
  68032. /**
  68033. * Defines an optimization used to turn post-processes off
  68034. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68035. */
  68036. export class PostProcessesOptimization extends SceneOptimization {
  68037. /**
  68038. * Gets a string describing the action executed by the current optimization
  68039. * @return description string
  68040. */
  68041. getDescription(): string;
  68042. /**
  68043. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68044. * @param scene defines the current scene where to apply this optimization
  68045. * @param optimizer defines the current optimizer
  68046. * @returns true if everything that can be done was applied
  68047. */
  68048. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68049. }
  68050. /**
  68051. * Defines an optimization used to turn lens flares off
  68052. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68053. */
  68054. export class LensFlaresOptimization extends SceneOptimization {
  68055. /**
  68056. * Gets a string describing the action executed by the current optimization
  68057. * @return description string
  68058. */
  68059. getDescription(): string;
  68060. /**
  68061. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68062. * @param scene defines the current scene where to apply this optimization
  68063. * @param optimizer defines the current optimizer
  68064. * @returns true if everything that can be done was applied
  68065. */
  68066. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68067. }
  68068. /**
  68069. * Defines an optimization based on user defined callback.
  68070. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68071. */
  68072. export class CustomOptimization extends SceneOptimization {
  68073. /**
  68074. * Callback called to apply the custom optimization.
  68075. */
  68076. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  68077. /**
  68078. * Callback called to get custom description
  68079. */
  68080. onGetDescription: () => string;
  68081. /**
  68082. * Gets a string describing the action executed by the current optimization
  68083. * @returns description string
  68084. */
  68085. getDescription(): string;
  68086. /**
  68087. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68088. * @param scene defines the current scene where to apply this optimization
  68089. * @param optimizer defines the current optimizer
  68090. * @returns true if everything that can be done was applied
  68091. */
  68092. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68093. }
  68094. /**
  68095. * Defines an optimization used to turn particles off
  68096. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68097. */
  68098. export class ParticlesOptimization extends SceneOptimization {
  68099. /**
  68100. * Gets a string describing the action executed by the current optimization
  68101. * @return description string
  68102. */
  68103. getDescription(): string;
  68104. /**
  68105. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68106. * @param scene defines the current scene where to apply this optimization
  68107. * @param optimizer defines the current optimizer
  68108. * @returns true if everything that can be done was applied
  68109. */
  68110. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68111. }
  68112. /**
  68113. * Defines an optimization used to turn render targets off
  68114. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68115. */
  68116. export class RenderTargetsOptimization extends SceneOptimization {
  68117. /**
  68118. * Gets a string describing the action executed by the current optimization
  68119. * @return description string
  68120. */
  68121. getDescription(): string;
  68122. /**
  68123. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68124. * @param scene defines the current scene where to apply this optimization
  68125. * @param optimizer defines the current optimizer
  68126. * @returns true if everything that can be done was applied
  68127. */
  68128. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68129. }
  68130. /**
  68131. * Defines an optimization used to merge meshes with compatible materials
  68132. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68133. */
  68134. export class MergeMeshesOptimization extends SceneOptimization {
  68135. private static _UpdateSelectionTree;
  68136. /**
  68137. * Gets or sets a boolean which defines if optimization octree has to be updated
  68138. */
  68139. static get UpdateSelectionTree(): boolean;
  68140. /**
  68141. * Gets or sets a boolean which defines if optimization octree has to be updated
  68142. */
  68143. static set UpdateSelectionTree(value: boolean);
  68144. /**
  68145. * Gets a string describing the action executed by the current optimization
  68146. * @return description string
  68147. */
  68148. getDescription(): string;
  68149. private _canBeMerged;
  68150. /**
  68151. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68152. * @param scene defines the current scene where to apply this optimization
  68153. * @param optimizer defines the current optimizer
  68154. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  68155. * @returns true if everything that can be done was applied
  68156. */
  68157. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  68158. }
  68159. /**
  68160. * Defines a list of options used by SceneOptimizer
  68161. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68162. */
  68163. export class SceneOptimizerOptions {
  68164. /**
  68165. * Defines the target frame rate to reach (60 by default)
  68166. */
  68167. targetFrameRate: number;
  68168. /**
  68169. * Defines the interval between two checkes (2000ms by default)
  68170. */
  68171. trackerDuration: number;
  68172. /**
  68173. * Gets the list of optimizations to apply
  68174. */
  68175. optimizations: SceneOptimization[];
  68176. /**
  68177. * Creates a new list of options used by SceneOptimizer
  68178. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  68179. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  68180. */
  68181. constructor(
  68182. /**
  68183. * Defines the target frame rate to reach (60 by default)
  68184. */
  68185. targetFrameRate?: number,
  68186. /**
  68187. * Defines the interval between two checkes (2000ms by default)
  68188. */
  68189. trackerDuration?: number);
  68190. /**
  68191. * Add a new optimization
  68192. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  68193. * @returns the current SceneOptimizerOptions
  68194. */
  68195. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  68196. /**
  68197. * Add a new custom optimization
  68198. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  68199. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  68200. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68201. * @returns the current SceneOptimizerOptions
  68202. */
  68203. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  68204. /**
  68205. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  68206. * @param targetFrameRate defines the target frame rate (60 by default)
  68207. * @returns a SceneOptimizerOptions object
  68208. */
  68209. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68210. /**
  68211. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  68212. * @param targetFrameRate defines the target frame rate (60 by default)
  68213. * @returns a SceneOptimizerOptions object
  68214. */
  68215. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68216. /**
  68217. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  68218. * @param targetFrameRate defines the target frame rate (60 by default)
  68219. * @returns a SceneOptimizerOptions object
  68220. */
  68221. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68222. }
  68223. /**
  68224. * Class used to run optimizations in order to reach a target frame rate
  68225. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68226. */
  68227. export class SceneOptimizer implements IDisposable {
  68228. private _isRunning;
  68229. private _options;
  68230. private _scene;
  68231. private _currentPriorityLevel;
  68232. private _targetFrameRate;
  68233. private _trackerDuration;
  68234. private _currentFrameRate;
  68235. private _sceneDisposeObserver;
  68236. private _improvementMode;
  68237. /**
  68238. * Defines an observable called when the optimizer reaches the target frame rate
  68239. */
  68240. onSuccessObservable: Observable<SceneOptimizer>;
  68241. /**
  68242. * Defines an observable called when the optimizer enables an optimization
  68243. */
  68244. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  68245. /**
  68246. * Defines an observable called when the optimizer is not able to reach the target frame rate
  68247. */
  68248. onFailureObservable: Observable<SceneOptimizer>;
  68249. /**
  68250. * Gets a boolean indicating if the optimizer is in improvement mode
  68251. */
  68252. get isInImprovementMode(): boolean;
  68253. /**
  68254. * Gets the current priority level (0 at start)
  68255. */
  68256. get currentPriorityLevel(): number;
  68257. /**
  68258. * Gets the current frame rate checked by the SceneOptimizer
  68259. */
  68260. get currentFrameRate(): number;
  68261. /**
  68262. * Gets or sets the current target frame rate (60 by default)
  68263. */
  68264. get targetFrameRate(): number;
  68265. /**
  68266. * Gets or sets the current target frame rate (60 by default)
  68267. */
  68268. set targetFrameRate(value: number);
  68269. /**
  68270. * Gets or sets the current interval between two checks (every 2000ms by default)
  68271. */
  68272. get trackerDuration(): number;
  68273. /**
  68274. * Gets or sets the current interval between two checks (every 2000ms by default)
  68275. */
  68276. set trackerDuration(value: number);
  68277. /**
  68278. * Gets the list of active optimizations
  68279. */
  68280. get optimizations(): SceneOptimization[];
  68281. /**
  68282. * Creates a new SceneOptimizer
  68283. * @param scene defines the scene to work on
  68284. * @param options defines the options to use with the SceneOptimizer
  68285. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  68286. * @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)
  68287. */
  68288. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  68289. /**
  68290. * Stops the current optimizer
  68291. */
  68292. stop(): void;
  68293. /**
  68294. * Reset the optimizer to initial step (current priority level = 0)
  68295. */
  68296. reset(): void;
  68297. /**
  68298. * Start the optimizer. By default it will try to reach a specific framerate
  68299. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  68300. */
  68301. start(): void;
  68302. private _checkCurrentState;
  68303. /**
  68304. * Release all resources
  68305. */
  68306. dispose(): void;
  68307. /**
  68308. * Helper function to create a SceneOptimizer with one single line of code
  68309. * @param scene defines the scene to work on
  68310. * @param options defines the options to use with the SceneOptimizer
  68311. * @param onSuccess defines a callback to call on success
  68312. * @param onFailure defines a callback to call on failure
  68313. * @returns the new SceneOptimizer object
  68314. */
  68315. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  68316. }
  68317. }
  68318. declare module BABYLON {
  68319. /**
  68320. * Class used to serialize a scene into a string
  68321. */
  68322. export class SceneSerializer {
  68323. /**
  68324. * Clear cache used by a previous serialization
  68325. */
  68326. static ClearCache(): void;
  68327. /**
  68328. * Serialize a scene into a JSON compatible object
  68329. * @param scene defines the scene to serialize
  68330. * @returns a JSON compatible object
  68331. */
  68332. static Serialize(scene: Scene): any;
  68333. /**
  68334. * Serialize a mesh into a JSON compatible object
  68335. * @param toSerialize defines the mesh to serialize
  68336. * @param withParents defines if parents must be serialized as well
  68337. * @param withChildren defines if children must be serialized as well
  68338. * @returns a JSON compatible object
  68339. */
  68340. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  68341. }
  68342. }
  68343. declare module BABYLON {
  68344. /**
  68345. * Class used to host texture specific utilities
  68346. */
  68347. export class TextureTools {
  68348. /**
  68349. * Uses the GPU to create a copy texture rescaled at a given size
  68350. * @param texture Texture to copy from
  68351. * @param width defines the desired width
  68352. * @param height defines the desired height
  68353. * @param useBilinearMode defines if bilinear mode has to be used
  68354. * @return the generated texture
  68355. */
  68356. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  68357. }
  68358. }
  68359. declare module BABYLON {
  68360. /**
  68361. * This represents the different options available for the video capture.
  68362. */
  68363. export interface VideoRecorderOptions {
  68364. /** Defines the mime type of the video. */
  68365. mimeType: string;
  68366. /** Defines the FPS the video should be recorded at. */
  68367. fps: number;
  68368. /** Defines the chunk size for the recording data. */
  68369. recordChunckSize: number;
  68370. /** The audio tracks to attach to the recording. */
  68371. audioTracks?: MediaStreamTrack[];
  68372. }
  68373. /**
  68374. * This can help with recording videos from BabylonJS.
  68375. * This is based on the available WebRTC functionalities of the browser.
  68376. *
  68377. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  68378. */
  68379. export class VideoRecorder {
  68380. private static readonly _defaultOptions;
  68381. /**
  68382. * Returns whether or not the VideoRecorder is available in your browser.
  68383. * @param engine Defines the Babylon Engine.
  68384. * @returns true if supported otherwise false.
  68385. */
  68386. static IsSupported(engine: Engine): boolean;
  68387. private readonly _options;
  68388. private _canvas;
  68389. private _mediaRecorder;
  68390. private _recordedChunks;
  68391. private _fileName;
  68392. private _resolve;
  68393. private _reject;
  68394. /**
  68395. * True when a recording is already in progress.
  68396. */
  68397. get isRecording(): boolean;
  68398. /**
  68399. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  68400. * @param engine Defines the BabylonJS Engine you wish to record.
  68401. * @param options Defines options that can be used to customize the capture.
  68402. */
  68403. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  68404. /**
  68405. * Stops the current recording before the default capture timeout passed in the startRecording function.
  68406. */
  68407. stopRecording(): void;
  68408. /**
  68409. * Starts recording the canvas for a max duration specified in parameters.
  68410. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  68411. * If null no automatic download will start and you can rely on the promise to get the data back.
  68412. * @param maxDuration Defines the maximum recording time in seconds.
  68413. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  68414. * @return A promise callback at the end of the recording with the video data in Blob.
  68415. */
  68416. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  68417. /**
  68418. * Releases internal resources used during the recording.
  68419. */
  68420. dispose(): void;
  68421. private _handleDataAvailable;
  68422. private _handleError;
  68423. private _handleStop;
  68424. }
  68425. }
  68426. declare module BABYLON {
  68427. /**
  68428. * Class containing a set of static utilities functions for screenshots
  68429. */
  68430. export class ScreenshotTools {
  68431. /**
  68432. * Captures a screenshot of the current rendering
  68433. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68434. * @param engine defines the rendering engine
  68435. * @param camera defines the source camera
  68436. * @param size This parameter can be set to a single number or to an object with the
  68437. * following (optional) properties: precision, width, height. If a single number is passed,
  68438. * it will be used for both width and height. If an object is passed, the screenshot size
  68439. * will be derived from the parameters. The precision property is a multiplier allowing
  68440. * rendering at a higher or lower resolution
  68441. * @param successCallback defines the callback receives a single parameter which contains the
  68442. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  68443. * src parameter of an <img> to display it
  68444. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  68445. * Check your browser for supported MIME types
  68446. */
  68447. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  68448. /**
  68449. * Captures a screenshot of the current rendering
  68450. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68451. * @param engine defines the rendering engine
  68452. * @param camera defines the source camera
  68453. * @param size This parameter can be set to a single number or to an object with the
  68454. * following (optional) properties: precision, width, height. If a single number is passed,
  68455. * it will be used for both width and height. If an object is passed, the screenshot size
  68456. * will be derived from the parameters. The precision property is a multiplier allowing
  68457. * rendering at a higher or lower resolution
  68458. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  68459. * Check your browser for supported MIME types
  68460. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  68461. * to the src parameter of an <img> to display it
  68462. */
  68463. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  68464. /**
  68465. * Generates an image screenshot from the specified camera.
  68466. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68467. * @param engine The engine to use for rendering
  68468. * @param camera The camera to use for rendering
  68469. * @param size This parameter can be set to a single number or to an object with the
  68470. * following (optional) properties: precision, width, height. If a single number is passed,
  68471. * it will be used for both width and height. If an object is passed, the screenshot size
  68472. * will be derived from the parameters. The precision property is a multiplier allowing
  68473. * rendering at a higher or lower resolution
  68474. * @param successCallback The callback receives a single parameter which contains the
  68475. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  68476. * src parameter of an <img> to display it
  68477. * @param mimeType The MIME type of the screenshot image (default: image/png).
  68478. * Check your browser for supported MIME types
  68479. * @param samples Texture samples (default: 1)
  68480. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  68481. * @param fileName A name for for the downloaded file.
  68482. */
  68483. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  68484. /**
  68485. * Generates an image screenshot from the specified camera.
  68486. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68487. * @param engine The engine to use for rendering
  68488. * @param camera The camera to use for rendering
  68489. * @param size This parameter can be set to a single number or to an object with the
  68490. * following (optional) properties: precision, width, height. If a single number is passed,
  68491. * it will be used for both width and height. If an object is passed, the screenshot size
  68492. * will be derived from the parameters. The precision property is a multiplier allowing
  68493. * rendering at a higher or lower resolution
  68494. * @param mimeType The MIME type of the screenshot image (default: image/png).
  68495. * Check your browser for supported MIME types
  68496. * @param samples Texture samples (default: 1)
  68497. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  68498. * @param fileName A name for for the downloaded file.
  68499. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  68500. * to the src parameter of an <img> to display it
  68501. */
  68502. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  68503. /**
  68504. * Gets height and width for screenshot size
  68505. * @private
  68506. */
  68507. private static _getScreenshotSize;
  68508. }
  68509. }
  68510. declare module BABYLON {
  68511. /**
  68512. * Interface for a data buffer
  68513. */
  68514. export interface IDataBuffer {
  68515. /**
  68516. * Reads bytes from the data buffer.
  68517. * @param byteOffset The byte offset to read
  68518. * @param byteLength The byte length to read
  68519. * @returns A promise that resolves when the bytes are read
  68520. */
  68521. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  68522. /**
  68523. * The byte length of the buffer.
  68524. */
  68525. readonly byteLength: number;
  68526. }
  68527. /**
  68528. * Utility class for reading from a data buffer
  68529. */
  68530. export class DataReader {
  68531. /**
  68532. * The data buffer associated with this data reader.
  68533. */
  68534. readonly buffer: IDataBuffer;
  68535. /**
  68536. * The current byte offset from the beginning of the data buffer.
  68537. */
  68538. byteOffset: number;
  68539. private _dataView;
  68540. private _dataByteOffset;
  68541. /**
  68542. * Constructor
  68543. * @param buffer The buffer to read
  68544. */
  68545. constructor(buffer: IDataBuffer);
  68546. /**
  68547. * Loads the given byte length.
  68548. * @param byteLength The byte length to load
  68549. * @returns A promise that resolves when the load is complete
  68550. */
  68551. loadAsync(byteLength: number): Promise<void>;
  68552. /**
  68553. * Read a unsigned 32-bit integer from the currently loaded data range.
  68554. * @returns The 32-bit integer read
  68555. */
  68556. readUint32(): number;
  68557. /**
  68558. * Read a byte array from the currently loaded data range.
  68559. * @param byteLength The byte length to read
  68560. * @returns The byte array read
  68561. */
  68562. readUint8Array(byteLength: number): Uint8Array;
  68563. /**
  68564. * Read a string from the currently loaded data range.
  68565. * @param byteLength The byte length to read
  68566. * @returns The string read
  68567. */
  68568. readString(byteLength: number): string;
  68569. /**
  68570. * Skips the given byte length the currently loaded data range.
  68571. * @param byteLength The byte length to skip
  68572. */
  68573. skipBytes(byteLength: number): void;
  68574. }
  68575. }
  68576. declare module BABYLON {
  68577. /**
  68578. * A cursor which tracks a point on a path
  68579. */
  68580. export class PathCursor {
  68581. private path;
  68582. /**
  68583. * Stores path cursor callbacks for when an onchange event is triggered
  68584. */
  68585. private _onchange;
  68586. /**
  68587. * The value of the path cursor
  68588. */
  68589. value: number;
  68590. /**
  68591. * The animation array of the path cursor
  68592. */
  68593. animations: Animation[];
  68594. /**
  68595. * Initializes the path cursor
  68596. * @param path The path to track
  68597. */
  68598. constructor(path: Path2);
  68599. /**
  68600. * Gets the cursor point on the path
  68601. * @returns A point on the path cursor at the cursor location
  68602. */
  68603. getPoint(): Vector3;
  68604. /**
  68605. * Moves the cursor ahead by the step amount
  68606. * @param step The amount to move the cursor forward
  68607. * @returns This path cursor
  68608. */
  68609. moveAhead(step?: number): PathCursor;
  68610. /**
  68611. * Moves the cursor behind by the step amount
  68612. * @param step The amount to move the cursor back
  68613. * @returns This path cursor
  68614. */
  68615. moveBack(step?: number): PathCursor;
  68616. /**
  68617. * Moves the cursor by the step amount
  68618. * If the step amount is greater than one, an exception is thrown
  68619. * @param step The amount to move the cursor
  68620. * @returns This path cursor
  68621. */
  68622. move(step: number): PathCursor;
  68623. /**
  68624. * Ensures that the value is limited between zero and one
  68625. * @returns This path cursor
  68626. */
  68627. private ensureLimits;
  68628. /**
  68629. * Runs onchange callbacks on change (used by the animation engine)
  68630. * @returns This path cursor
  68631. */
  68632. private raiseOnChange;
  68633. /**
  68634. * Executes a function on change
  68635. * @param f A path cursor onchange callback
  68636. * @returns This path cursor
  68637. */
  68638. onchange(f: (cursor: PathCursor) => void): PathCursor;
  68639. }
  68640. }
  68641. declare module BABYLON {
  68642. /** @hidden */
  68643. export var blurPixelShader: {
  68644. name: string;
  68645. shader: string;
  68646. };
  68647. }
  68648. declare module BABYLON {
  68649. /** @hidden */
  68650. export var pointCloudVertexDeclaration: {
  68651. name: string;
  68652. shader: string;
  68653. };
  68654. }
  68655. // Mixins
  68656. interface Window {
  68657. mozIndexedDB: IDBFactory;
  68658. webkitIndexedDB: IDBFactory;
  68659. msIndexedDB: IDBFactory;
  68660. webkitURL: typeof URL;
  68661. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  68662. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  68663. WebGLRenderingContext: WebGLRenderingContext;
  68664. MSGesture: MSGesture;
  68665. CANNON: any;
  68666. AudioContext: AudioContext;
  68667. webkitAudioContext: AudioContext;
  68668. PointerEvent: any;
  68669. Math: Math;
  68670. Uint8Array: Uint8ArrayConstructor;
  68671. Float32Array: Float32ArrayConstructor;
  68672. mozURL: typeof URL;
  68673. msURL: typeof URL;
  68674. VRFrameData: any; // WebVR, from specs 1.1
  68675. DracoDecoderModule: any;
  68676. setImmediate(handler: (...args: any[]) => void): number;
  68677. }
  68678. interface HTMLCanvasElement {
  68679. requestPointerLock(): void;
  68680. msRequestPointerLock?(): void;
  68681. mozRequestPointerLock?(): void;
  68682. webkitRequestPointerLock?(): void;
  68683. /** Track wether a record is in progress */
  68684. isRecording: boolean;
  68685. /** Capture Stream method defined by some browsers */
  68686. captureStream(fps?: number): MediaStream;
  68687. }
  68688. interface CanvasRenderingContext2D {
  68689. msImageSmoothingEnabled: boolean;
  68690. }
  68691. interface MouseEvent {
  68692. mozMovementX: number;
  68693. mozMovementY: number;
  68694. webkitMovementX: number;
  68695. webkitMovementY: number;
  68696. msMovementX: number;
  68697. msMovementY: number;
  68698. }
  68699. interface Navigator {
  68700. mozGetVRDevices: (any: any) => any;
  68701. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  68702. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  68703. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  68704. webkitGetGamepads(): Gamepad[];
  68705. msGetGamepads(): Gamepad[];
  68706. webkitGamepads(): Gamepad[];
  68707. }
  68708. interface HTMLVideoElement {
  68709. mozSrcObject: any;
  68710. }
  68711. interface Math {
  68712. fround(x: number): number;
  68713. imul(a: number, b: number): number;
  68714. }
  68715. interface WebGLRenderingContext {
  68716. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  68717. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  68718. vertexAttribDivisor(index: number, divisor: number): void;
  68719. createVertexArray(): any;
  68720. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  68721. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  68722. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  68723. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  68724. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  68725. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  68726. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  68727. // Queries
  68728. createQuery(): WebGLQuery;
  68729. deleteQuery(query: WebGLQuery): void;
  68730. beginQuery(target: number, query: WebGLQuery): void;
  68731. endQuery(target: number): void;
  68732. getQueryParameter(query: WebGLQuery, pname: number): any;
  68733. getQuery(target: number, pname: number): any;
  68734. MAX_SAMPLES: number;
  68735. RGBA8: number;
  68736. READ_FRAMEBUFFER: number;
  68737. DRAW_FRAMEBUFFER: number;
  68738. UNIFORM_BUFFER: number;
  68739. HALF_FLOAT_OES: number;
  68740. RGBA16F: number;
  68741. RGBA32F: number;
  68742. R32F: number;
  68743. RG32F: number;
  68744. RGB32F: number;
  68745. R16F: number;
  68746. RG16F: number;
  68747. RGB16F: number;
  68748. RED: number;
  68749. RG: number;
  68750. R8: number;
  68751. RG8: number;
  68752. UNSIGNED_INT_24_8: number;
  68753. DEPTH24_STENCIL8: number;
  68754. MIN: number;
  68755. MAX: number;
  68756. /* Multiple Render Targets */
  68757. drawBuffers(buffers: number[]): void;
  68758. readBuffer(src: number): void;
  68759. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  68760. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  68761. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  68762. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  68763. // Occlusion Query
  68764. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  68765. ANY_SAMPLES_PASSED: number;
  68766. QUERY_RESULT_AVAILABLE: number;
  68767. QUERY_RESULT: number;
  68768. }
  68769. interface WebGLProgram {
  68770. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  68771. }
  68772. interface EXT_disjoint_timer_query {
  68773. QUERY_COUNTER_BITS_EXT: number;
  68774. TIME_ELAPSED_EXT: number;
  68775. TIMESTAMP_EXT: number;
  68776. GPU_DISJOINT_EXT: number;
  68777. QUERY_RESULT_EXT: number;
  68778. QUERY_RESULT_AVAILABLE_EXT: number;
  68779. queryCounterEXT(query: WebGLQuery, target: number): void;
  68780. createQueryEXT(): WebGLQuery;
  68781. beginQueryEXT(target: number, query: WebGLQuery): void;
  68782. endQueryEXT(target: number): void;
  68783. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  68784. deleteQueryEXT(query: WebGLQuery): void;
  68785. }
  68786. interface WebGLUniformLocation {
  68787. _currentState: any;
  68788. }
  68789. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  68790. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  68791. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  68792. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  68793. interface WebGLRenderingContext {
  68794. readonly RASTERIZER_DISCARD: number;
  68795. readonly DEPTH_COMPONENT24: number;
  68796. readonly TEXTURE_3D: number;
  68797. readonly TEXTURE_2D_ARRAY: number;
  68798. readonly TEXTURE_COMPARE_FUNC: number;
  68799. readonly TEXTURE_COMPARE_MODE: number;
  68800. readonly COMPARE_REF_TO_TEXTURE: number;
  68801. readonly TEXTURE_WRAP_R: number;
  68802. readonly HALF_FLOAT: number;
  68803. readonly RGB8: number;
  68804. readonly RED_INTEGER: number;
  68805. readonly RG_INTEGER: number;
  68806. readonly RGB_INTEGER: number;
  68807. readonly RGBA_INTEGER: number;
  68808. readonly R8_SNORM: number;
  68809. readonly RG8_SNORM: number;
  68810. readonly RGB8_SNORM: number;
  68811. readonly RGBA8_SNORM: number;
  68812. readonly R8I: number;
  68813. readonly RG8I: number;
  68814. readonly RGB8I: number;
  68815. readonly RGBA8I: number;
  68816. readonly R8UI: number;
  68817. readonly RG8UI: number;
  68818. readonly RGB8UI: number;
  68819. readonly RGBA8UI: number;
  68820. readonly R16I: number;
  68821. readonly RG16I: number;
  68822. readonly RGB16I: number;
  68823. readonly RGBA16I: number;
  68824. readonly R16UI: number;
  68825. readonly RG16UI: number;
  68826. readonly RGB16UI: number;
  68827. readonly RGBA16UI: number;
  68828. readonly R32I: number;
  68829. readonly RG32I: number;
  68830. readonly RGB32I: number;
  68831. readonly RGBA32I: number;
  68832. readonly R32UI: number;
  68833. readonly RG32UI: number;
  68834. readonly RGB32UI: number;
  68835. readonly RGBA32UI: number;
  68836. readonly RGB10_A2UI: number;
  68837. readonly R11F_G11F_B10F: number;
  68838. readonly RGB9_E5: number;
  68839. readonly RGB10_A2: number;
  68840. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  68841. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  68842. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  68843. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  68844. readonly DEPTH_COMPONENT32F: number;
  68845. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  68846. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  68847. 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;
  68848. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  68849. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  68850. readonly TRANSFORM_FEEDBACK: number;
  68851. readonly INTERLEAVED_ATTRIBS: number;
  68852. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  68853. createTransformFeedback(): WebGLTransformFeedback;
  68854. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  68855. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  68856. beginTransformFeedback(primitiveMode: number): void;
  68857. endTransformFeedback(): void;
  68858. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  68859. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  68860. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  68861. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  68862. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  68863. }
  68864. interface ImageBitmap {
  68865. readonly width: number;
  68866. readonly height: number;
  68867. close(): void;
  68868. }
  68869. interface WebGLQuery extends WebGLObject {
  68870. }
  68871. declare var WebGLQuery: {
  68872. prototype: WebGLQuery;
  68873. new(): WebGLQuery;
  68874. };
  68875. interface WebGLSampler extends WebGLObject {
  68876. }
  68877. declare var WebGLSampler: {
  68878. prototype: WebGLSampler;
  68879. new(): WebGLSampler;
  68880. };
  68881. interface WebGLSync extends WebGLObject {
  68882. }
  68883. declare var WebGLSync: {
  68884. prototype: WebGLSync;
  68885. new(): WebGLSync;
  68886. };
  68887. interface WebGLTransformFeedback extends WebGLObject {
  68888. }
  68889. declare var WebGLTransformFeedback: {
  68890. prototype: WebGLTransformFeedback;
  68891. new(): WebGLTransformFeedback;
  68892. };
  68893. interface WebGLVertexArrayObject extends WebGLObject {
  68894. }
  68895. declare var WebGLVertexArrayObject: {
  68896. prototype: WebGLVertexArrayObject;
  68897. new(): WebGLVertexArrayObject;
  68898. };
  68899. // Type definitions for WebVR API
  68900. // Project: https://w3c.github.io/webvr/
  68901. // Definitions by: six a <https://github.com/lostfictions>
  68902. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  68903. interface VRDisplay extends EventTarget {
  68904. /**
  68905. * Dictionary of capabilities describing the VRDisplay.
  68906. */
  68907. readonly capabilities: VRDisplayCapabilities;
  68908. /**
  68909. * z-depth defining the far plane of the eye view frustum
  68910. * enables mapping of values in the render target depth
  68911. * attachment to scene coordinates. Initially set to 10000.0.
  68912. */
  68913. depthFar: number;
  68914. /**
  68915. * z-depth defining the near plane of the eye view frustum
  68916. * enables mapping of values in the render target depth
  68917. * attachment to scene coordinates. Initially set to 0.01.
  68918. */
  68919. depthNear: number;
  68920. /**
  68921. * An identifier for this distinct VRDisplay. Used as an
  68922. * association point in the Gamepad API.
  68923. */
  68924. readonly displayId: number;
  68925. /**
  68926. * A display name, a user-readable name identifying it.
  68927. */
  68928. readonly displayName: string;
  68929. readonly isConnected: boolean;
  68930. readonly isPresenting: boolean;
  68931. /**
  68932. * If this VRDisplay supports room-scale experiences, the optional
  68933. * stage attribute contains details on the room-scale parameters.
  68934. */
  68935. readonly stageParameters: VRStageParameters | null;
  68936. /**
  68937. * Passing the value returned by `requestAnimationFrame` to
  68938. * `cancelAnimationFrame` will unregister the callback.
  68939. * @param handle Define the hanle of the request to cancel
  68940. */
  68941. cancelAnimationFrame(handle: number): void;
  68942. /**
  68943. * Stops presenting to the VRDisplay.
  68944. * @returns a promise to know when it stopped
  68945. */
  68946. exitPresent(): Promise<void>;
  68947. /**
  68948. * Return the current VREyeParameters for the given eye.
  68949. * @param whichEye Define the eye we want the parameter for
  68950. * @returns the eye parameters
  68951. */
  68952. getEyeParameters(whichEye: string): VREyeParameters;
  68953. /**
  68954. * Populates the passed VRFrameData with the information required to render
  68955. * the current frame.
  68956. * @param frameData Define the data structure to populate
  68957. * @returns true if ok otherwise false
  68958. */
  68959. getFrameData(frameData: VRFrameData): boolean;
  68960. /**
  68961. * Get the layers currently being presented.
  68962. * @returns the list of VR layers
  68963. */
  68964. getLayers(): VRLayer[];
  68965. /**
  68966. * Return a VRPose containing the future predicted pose of the VRDisplay
  68967. * when the current frame will be presented. The value returned will not
  68968. * change until JavaScript has returned control to the browser.
  68969. *
  68970. * The VRPose will contain the position, orientation, velocity,
  68971. * and acceleration of each of these properties.
  68972. * @returns the pose object
  68973. */
  68974. getPose(): VRPose;
  68975. /**
  68976. * Return the current instantaneous pose of the VRDisplay, with no
  68977. * prediction applied.
  68978. * @returns the current instantaneous pose
  68979. */
  68980. getImmediatePose(): VRPose;
  68981. /**
  68982. * The callback passed to `requestAnimationFrame` will be called
  68983. * any time a new frame should be rendered. When the VRDisplay is
  68984. * presenting the callback will be called at the native refresh
  68985. * rate of the HMD. When not presenting this function acts
  68986. * identically to how window.requestAnimationFrame acts. Content should
  68987. * make no assumptions of frame rate or vsync behavior as the HMD runs
  68988. * asynchronously from other displays and at differing refresh rates.
  68989. * @param callback Define the eaction to run next frame
  68990. * @returns the request handle it
  68991. */
  68992. requestAnimationFrame(callback: FrameRequestCallback): number;
  68993. /**
  68994. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  68995. * Repeat calls while already presenting will update the VRLayers being displayed.
  68996. * @param layers Define the list of layer to present
  68997. * @returns a promise to know when the request has been fulfilled
  68998. */
  68999. requestPresent(layers: VRLayer[]): Promise<void>;
  69000. /**
  69001. * Reset the pose for this display, treating its current position and
  69002. * orientation as the "origin/zero" values. VRPose.position,
  69003. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  69004. * updated when calling resetPose(). This should be called in only
  69005. * sitting-space experiences.
  69006. */
  69007. resetPose(): void;
  69008. /**
  69009. * The VRLayer provided to the VRDisplay will be captured and presented
  69010. * in the HMD. Calling this function has the same effect on the source
  69011. * canvas as any other operation that uses its source image, and canvases
  69012. * created without preserveDrawingBuffer set to true will be cleared.
  69013. * @param pose Define the pose to submit
  69014. */
  69015. submitFrame(pose?: VRPose): void;
  69016. }
  69017. declare var VRDisplay: {
  69018. prototype: VRDisplay;
  69019. new(): VRDisplay;
  69020. };
  69021. interface VRLayer {
  69022. leftBounds?: number[] | Float32Array | null;
  69023. rightBounds?: number[] | Float32Array | null;
  69024. source?: HTMLCanvasElement | null;
  69025. }
  69026. interface VRDisplayCapabilities {
  69027. readonly canPresent: boolean;
  69028. readonly hasExternalDisplay: boolean;
  69029. readonly hasOrientation: boolean;
  69030. readonly hasPosition: boolean;
  69031. readonly maxLayers: number;
  69032. }
  69033. interface VREyeParameters {
  69034. /** @deprecated */
  69035. readonly fieldOfView: VRFieldOfView;
  69036. readonly offset: Float32Array;
  69037. readonly renderHeight: number;
  69038. readonly renderWidth: number;
  69039. }
  69040. interface VRFieldOfView {
  69041. readonly downDegrees: number;
  69042. readonly leftDegrees: number;
  69043. readonly rightDegrees: number;
  69044. readonly upDegrees: number;
  69045. }
  69046. interface VRFrameData {
  69047. readonly leftProjectionMatrix: Float32Array;
  69048. readonly leftViewMatrix: Float32Array;
  69049. readonly pose: VRPose;
  69050. readonly rightProjectionMatrix: Float32Array;
  69051. readonly rightViewMatrix: Float32Array;
  69052. readonly timestamp: number;
  69053. }
  69054. interface VRPose {
  69055. readonly angularAcceleration: Float32Array | null;
  69056. readonly angularVelocity: Float32Array | null;
  69057. readonly linearAcceleration: Float32Array | null;
  69058. readonly linearVelocity: Float32Array | null;
  69059. readonly orientation: Float32Array | null;
  69060. readonly position: Float32Array | null;
  69061. readonly timestamp: number;
  69062. }
  69063. interface VRStageParameters {
  69064. sittingToStandingTransform?: Float32Array;
  69065. sizeX?: number;
  69066. sizeY?: number;
  69067. }
  69068. interface Navigator {
  69069. getVRDisplays(): Promise<VRDisplay[]>;
  69070. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  69071. }
  69072. interface Window {
  69073. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  69074. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  69075. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  69076. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  69077. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  69078. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  69079. }
  69080. interface Gamepad {
  69081. readonly displayId: number;
  69082. }
  69083. type XRSessionMode =
  69084. | "inline"
  69085. | "immersive-vr"
  69086. | "immersive-ar";
  69087. type XRReferenceSpaceType =
  69088. | "viewer"
  69089. | "local"
  69090. | "local-floor"
  69091. | "bounded-floor"
  69092. | "unbounded";
  69093. type XREnvironmentBlendMode =
  69094. | "opaque"
  69095. | "additive"
  69096. | "alpha-blend";
  69097. type XRVisibilityState =
  69098. | "visible"
  69099. | "visible-blurred"
  69100. | "hidden";
  69101. type XRHandedness =
  69102. | "none"
  69103. | "left"
  69104. | "right";
  69105. type XRTargetRayMode =
  69106. | "gaze"
  69107. | "tracked-pointer"
  69108. | "screen";
  69109. type XREye =
  69110. | "none"
  69111. | "left"
  69112. | "right";
  69113. interface XRSpace extends EventTarget {
  69114. }
  69115. interface XRRenderState {
  69116. depthNear?: number;
  69117. depthFar?: number;
  69118. inlineVerticalFieldOfView?: number;
  69119. baseLayer?: XRWebGLLayer;
  69120. }
  69121. interface XRInputSource {
  69122. handedness: XRHandedness;
  69123. targetRayMode: XRTargetRayMode;
  69124. targetRaySpace: XRSpace;
  69125. gripSpace: XRSpace | undefined;
  69126. gamepad: Gamepad | undefined;
  69127. profiles: Array<string>;
  69128. }
  69129. interface XRSession extends XRAnchorCreator {
  69130. addEventListener: Function;
  69131. removeEventListener: Function;
  69132. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  69133. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  69134. requestAnimationFrame: Function;
  69135. end(): Promise<void>;
  69136. renderState: XRRenderState;
  69137. inputSources: Array<XRInputSource>;
  69138. // AR hit test
  69139. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  69140. updateWorldTrackingState(options: {
  69141. planeDetectionState?: { enabled: boolean; }
  69142. }): void;
  69143. }
  69144. interface XRReferenceSpace extends XRSpace {
  69145. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  69146. onreset: any;
  69147. }
  69148. type XRPlaneSet = Set<XRPlane>;
  69149. type XRAnchorSet = Set<XRAnchor>;
  69150. interface XRFrame {
  69151. session: XRSession;
  69152. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  69153. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  69154. // Anchors
  69155. trackedAnchors?: XRAnchorSet;
  69156. // Planes
  69157. worldInformation: {
  69158. detectedPlanes?: XRPlaneSet;
  69159. };
  69160. }
  69161. interface XRViewerPose extends XRPose {
  69162. views: Array<XRView>;
  69163. }
  69164. interface XRPose {
  69165. transform: XRRigidTransform;
  69166. emulatedPosition: boolean;
  69167. }
  69168. interface XRWebGLLayerOptions {
  69169. antialias?: boolean;
  69170. depth?: boolean;
  69171. stencil?: boolean;
  69172. alpha?: boolean;
  69173. multiview?: boolean;
  69174. framebufferScaleFactor?: number;
  69175. }
  69176. declare var XRWebGLLayer: {
  69177. prototype: XRWebGLLayer;
  69178. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  69179. };
  69180. interface XRWebGLLayer {
  69181. framebuffer: WebGLFramebuffer;
  69182. framebufferWidth: number;
  69183. framebufferHeight: number;
  69184. getViewport: Function;
  69185. }
  69186. declare class XRRigidTransform {
  69187. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  69188. position: DOMPointReadOnly;
  69189. orientation: DOMPointReadOnly;
  69190. matrix: Float32Array;
  69191. inverse: XRRigidTransform;
  69192. }
  69193. interface XRView {
  69194. eye: XREye;
  69195. projectionMatrix: Float32Array;
  69196. transform: XRRigidTransform;
  69197. }
  69198. interface XRInputSourceChangeEvent {
  69199. session: XRSession;
  69200. removed: Array<XRInputSource>;
  69201. added: Array<XRInputSource>;
  69202. }
  69203. interface XRInputSourceEvent extends Event {
  69204. readonly frame: XRFrame;
  69205. readonly inputSource: XRInputSource;
  69206. }
  69207. // Experimental(er) features
  69208. declare class XRRay {
  69209. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  69210. origin: DOMPointReadOnly;
  69211. direction: DOMPointReadOnly;
  69212. matrix: Float32Array;
  69213. }
  69214. interface XRHitResult {
  69215. hitMatrix: Float32Array;
  69216. }
  69217. interface XRAnchor {
  69218. // remove?
  69219. id?: string;
  69220. anchorSpace: XRSpace;
  69221. lastChangedTime: number;
  69222. detach(): void;
  69223. }
  69224. interface XRPlane extends XRAnchorCreator {
  69225. orientation: "Horizontal" | "Vertical";
  69226. planeSpace: XRSpace;
  69227. polygon: Array<DOMPointReadOnly>;
  69228. lastChangedTime: number;
  69229. }
  69230. interface XRAnchorCreator {
  69231. // AR Anchors
  69232. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  69233. }
  69234. /**
  69235. * @ignore
  69236. */
  69237. declare module BABYLON.GLTF2.Exporter {
  69238. }
  69239. /**
  69240. * @ignore
  69241. */
  69242. declare module BABYLON.GLTF1 {
  69243. }
  69244. declare module BABYLON.GUI {
  69245. /**
  69246. * Class used to specific a value and its associated unit
  69247. */
  69248. export class ValueAndUnit {
  69249. /** defines the unit to store */
  69250. unit: number;
  69251. /** defines a boolean indicating if the value can be negative */
  69252. negativeValueAllowed: boolean;
  69253. private _value;
  69254. private _originalUnit;
  69255. /**
  69256. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  69257. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  69258. */
  69259. ignoreAdaptiveScaling: boolean;
  69260. /**
  69261. * Creates a new ValueAndUnit
  69262. * @param value defines the value to store
  69263. * @param unit defines the unit to store
  69264. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  69265. */
  69266. constructor(value: number,
  69267. /** defines the unit to store */
  69268. unit?: number,
  69269. /** defines a boolean indicating if the value can be negative */
  69270. negativeValueAllowed?: boolean);
  69271. /** Gets a boolean indicating if the value is a percentage */
  69272. get isPercentage(): boolean;
  69273. /** Gets a boolean indicating if the value is store as pixel */
  69274. get isPixel(): boolean;
  69275. /** Gets direct internal value */
  69276. get internalValue(): number;
  69277. /**
  69278. * Gets value as pixel
  69279. * @param host defines the root host
  69280. * @param refValue defines the reference value for percentages
  69281. * @returns the value as pixel
  69282. */
  69283. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  69284. /**
  69285. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  69286. * @param value defines the value to store
  69287. * @param unit defines the unit to store
  69288. * @returns the current ValueAndUnit
  69289. */
  69290. updateInPlace(value: number, unit?: number): ValueAndUnit;
  69291. /**
  69292. * Gets the value accordingly to its unit
  69293. * @param host defines the root host
  69294. * @returns the value
  69295. */
  69296. getValue(host: AdvancedDynamicTexture): number;
  69297. /**
  69298. * Gets a string representation of the value
  69299. * @param host defines the root host
  69300. * @param decimals defines an optional number of decimals to display
  69301. * @returns a string
  69302. */
  69303. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  69304. /**
  69305. * Store a value parsed from a string
  69306. * @param source defines the source string
  69307. * @returns true if the value was successfully parsed
  69308. */
  69309. fromString(source: string | number): boolean;
  69310. private static _Regex;
  69311. private static _UNITMODE_PERCENTAGE;
  69312. private static _UNITMODE_PIXEL;
  69313. /** UNITMODE_PERCENTAGE */
  69314. static get UNITMODE_PERCENTAGE(): number;
  69315. /** UNITMODE_PIXEL */
  69316. static get UNITMODE_PIXEL(): number;
  69317. }
  69318. }
  69319. declare module BABYLON.GUI {
  69320. /**
  69321. * Define a style used by control to automatically setup properties based on a template.
  69322. * Only support font related properties so far
  69323. */
  69324. export class Style implements BABYLON.IDisposable {
  69325. private _fontFamily;
  69326. private _fontStyle;
  69327. private _fontWeight;
  69328. /** @hidden */
  69329. _host: AdvancedDynamicTexture;
  69330. /** @hidden */
  69331. _fontSize: ValueAndUnit;
  69332. /**
  69333. * BABYLON.Observable raised when the style values are changed
  69334. */
  69335. onChangedObservable: BABYLON.Observable<Style>;
  69336. /**
  69337. * Creates a new style object
  69338. * @param host defines the AdvancedDynamicTexture which hosts this style
  69339. */
  69340. constructor(host: AdvancedDynamicTexture);
  69341. /**
  69342. * Gets or sets the font size
  69343. */
  69344. get fontSize(): string | number;
  69345. set fontSize(value: string | number);
  69346. /**
  69347. * Gets or sets the font family
  69348. */
  69349. get fontFamily(): string;
  69350. set fontFamily(value: string);
  69351. /**
  69352. * Gets or sets the font style
  69353. */
  69354. get fontStyle(): string;
  69355. set fontStyle(value: string);
  69356. /** Gets or sets font weight */
  69357. get fontWeight(): string;
  69358. set fontWeight(value: string);
  69359. /** Dispose all associated resources */
  69360. dispose(): void;
  69361. }
  69362. }
  69363. declare module BABYLON.GUI {
  69364. /**
  69365. * Class used to transport BABYLON.Vector2 information for pointer events
  69366. */
  69367. export class Vector2WithInfo extends BABYLON.Vector2 {
  69368. /** defines the current mouse button index */
  69369. buttonIndex: number;
  69370. /**
  69371. * Creates a new Vector2WithInfo
  69372. * @param source defines the vector2 data to transport
  69373. * @param buttonIndex defines the current mouse button index
  69374. */
  69375. constructor(source: BABYLON.Vector2,
  69376. /** defines the current mouse button index */
  69377. buttonIndex?: number);
  69378. }
  69379. /** Class used to provide 2D matrix features */
  69380. export class Matrix2D {
  69381. /** Gets the internal array of 6 floats used to store matrix data */
  69382. m: Float32Array;
  69383. /**
  69384. * Creates a new matrix
  69385. * @param m00 defines value for (0, 0)
  69386. * @param m01 defines value for (0, 1)
  69387. * @param m10 defines value for (1, 0)
  69388. * @param m11 defines value for (1, 1)
  69389. * @param m20 defines value for (2, 0)
  69390. * @param m21 defines value for (2, 1)
  69391. */
  69392. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  69393. /**
  69394. * Fills the matrix from direct values
  69395. * @param m00 defines value for (0, 0)
  69396. * @param m01 defines value for (0, 1)
  69397. * @param m10 defines value for (1, 0)
  69398. * @param m11 defines value for (1, 1)
  69399. * @param m20 defines value for (2, 0)
  69400. * @param m21 defines value for (2, 1)
  69401. * @returns the current modified matrix
  69402. */
  69403. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  69404. /**
  69405. * Gets matrix determinant
  69406. * @returns the determinant
  69407. */
  69408. determinant(): number;
  69409. /**
  69410. * Inverses the matrix and stores it in a target matrix
  69411. * @param result defines the target matrix
  69412. * @returns the current matrix
  69413. */
  69414. invertToRef(result: Matrix2D): Matrix2D;
  69415. /**
  69416. * Multiplies the current matrix with another one
  69417. * @param other defines the second operand
  69418. * @param result defines the target matrix
  69419. * @returns the current matrix
  69420. */
  69421. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  69422. /**
  69423. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  69424. * @param x defines the x coordinate to transform
  69425. * @param y defines the x coordinate to transform
  69426. * @param result defines the target vector2
  69427. * @returns the current matrix
  69428. */
  69429. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  69430. /**
  69431. * Creates an identity matrix
  69432. * @returns a new matrix
  69433. */
  69434. static Identity(): Matrix2D;
  69435. /**
  69436. * Creates a translation matrix and stores it in a target matrix
  69437. * @param x defines the x coordinate of the translation
  69438. * @param y defines the y coordinate of the translation
  69439. * @param result defines the target matrix
  69440. */
  69441. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  69442. /**
  69443. * Creates a scaling matrix and stores it in a target matrix
  69444. * @param x defines the x coordinate of the scaling
  69445. * @param y defines the y coordinate of the scaling
  69446. * @param result defines the target matrix
  69447. */
  69448. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  69449. /**
  69450. * Creates a rotation matrix and stores it in a target matrix
  69451. * @param angle defines the rotation angle
  69452. * @param result defines the target matrix
  69453. */
  69454. static RotationToRef(angle: number, result: Matrix2D): void;
  69455. private static _TempPreTranslationMatrix;
  69456. private static _TempPostTranslationMatrix;
  69457. private static _TempRotationMatrix;
  69458. private static _TempScalingMatrix;
  69459. private static _TempCompose0;
  69460. private static _TempCompose1;
  69461. private static _TempCompose2;
  69462. /**
  69463. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  69464. * @param tx defines the x coordinate of the translation
  69465. * @param ty defines the y coordinate of the translation
  69466. * @param angle defines the rotation angle
  69467. * @param scaleX defines the x coordinate of the scaling
  69468. * @param scaleY defines the y coordinate of the scaling
  69469. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  69470. * @param result defines the target matrix
  69471. */
  69472. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  69473. }
  69474. }
  69475. declare module BABYLON.GUI {
  69476. /**
  69477. * Class used to store 2D control sizes
  69478. */
  69479. export class Measure {
  69480. /** defines left coordinate */
  69481. left: number;
  69482. /** defines top coordinate */
  69483. top: number;
  69484. /** defines width dimension */
  69485. width: number;
  69486. /** defines height dimension */
  69487. height: number;
  69488. /**
  69489. * Creates a new measure
  69490. * @param left defines left coordinate
  69491. * @param top defines top coordinate
  69492. * @param width defines width dimension
  69493. * @param height defines height dimension
  69494. */
  69495. constructor(
  69496. /** defines left coordinate */
  69497. left: number,
  69498. /** defines top coordinate */
  69499. top: number,
  69500. /** defines width dimension */
  69501. width: number,
  69502. /** defines height dimension */
  69503. height: number);
  69504. /**
  69505. * Copy from another measure
  69506. * @param other defines the other measure to copy from
  69507. */
  69508. copyFrom(other: Measure): void;
  69509. /**
  69510. * Copy from a group of 4 floats
  69511. * @param left defines left coordinate
  69512. * @param top defines top coordinate
  69513. * @param width defines width dimension
  69514. * @param height defines height dimension
  69515. */
  69516. copyFromFloats(left: number, top: number, width: number, height: number): void;
  69517. /**
  69518. * Computes the axis aligned bounding box measure for two given measures
  69519. * @param a Input measure
  69520. * @param b Input measure
  69521. * @param result the resulting bounding measure
  69522. */
  69523. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  69524. /**
  69525. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  69526. * @param transform the matrix to transform the measure before computing the AABB
  69527. * @param result the resulting AABB
  69528. */
  69529. transformToRef(transform: Matrix2D, result: Measure): void;
  69530. /**
  69531. * Check equality between this measure and another one
  69532. * @param other defines the other measures
  69533. * @returns true if both measures are equals
  69534. */
  69535. isEqualsTo(other: Measure): boolean;
  69536. /**
  69537. * Creates an empty measure
  69538. * @returns a new measure
  69539. */
  69540. static Empty(): Measure;
  69541. }
  69542. }
  69543. declare module BABYLON.GUI {
  69544. /**
  69545. * Interface used to define a control that can receive focus
  69546. */
  69547. export interface IFocusableControl {
  69548. /**
  69549. * Function called when the control receives the focus
  69550. */
  69551. onFocus(): void;
  69552. /**
  69553. * Function called when the control loses the focus
  69554. */
  69555. onBlur(): void;
  69556. /**
  69557. * Function called to let the control handle keyboard events
  69558. * @param evt defines the current keyboard event
  69559. */
  69560. processKeyboard(evt: KeyboardEvent): void;
  69561. /**
  69562. * Function called to get the list of controls that should not steal the focus from this control
  69563. * @returns an array of controls
  69564. */
  69565. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  69566. }
  69567. /**
  69568. * Class used to create texture to support 2D GUI elements
  69569. * @see http://doc.babylonjs.com/how_to/gui
  69570. */
  69571. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  69572. private _isDirty;
  69573. private _renderObserver;
  69574. private _resizeObserver;
  69575. private _preKeyboardObserver;
  69576. private _pointerMoveObserver;
  69577. private _pointerObserver;
  69578. private _canvasPointerOutObserver;
  69579. private _background;
  69580. /** @hidden */
  69581. _rootContainer: Container;
  69582. /** @hidden */
  69583. _lastPickedControl: Control;
  69584. /** @hidden */
  69585. _lastControlOver: {
  69586. [pointerId: number]: Control;
  69587. };
  69588. /** @hidden */
  69589. _lastControlDown: {
  69590. [pointerId: number]: Control;
  69591. };
  69592. /** @hidden */
  69593. _capturingControl: {
  69594. [pointerId: number]: Control;
  69595. };
  69596. /** @hidden */
  69597. _shouldBlockPointer: boolean;
  69598. /** @hidden */
  69599. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  69600. /** @hidden */
  69601. _linkedControls: Control[];
  69602. private _isFullscreen;
  69603. private _fullscreenViewport;
  69604. private _idealWidth;
  69605. private _idealHeight;
  69606. private _useSmallestIdeal;
  69607. private _renderAtIdealSize;
  69608. private _focusedControl;
  69609. private _blockNextFocusCheck;
  69610. private _renderScale;
  69611. private _rootElement;
  69612. private _cursorChanged;
  69613. /**
  69614. * Define type to string to ensure compatibility across browsers
  69615. * Safari doesn't support DataTransfer constructor
  69616. */
  69617. private _clipboardData;
  69618. /**
  69619. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  69620. */
  69621. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  69622. /**
  69623. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  69624. */
  69625. onControlPickedObservable: BABYLON.Observable<Control>;
  69626. /**
  69627. * BABYLON.Observable event triggered before layout is evaluated
  69628. */
  69629. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  69630. /**
  69631. * BABYLON.Observable event triggered after the layout was evaluated
  69632. */
  69633. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  69634. /**
  69635. * BABYLON.Observable event triggered before the texture is rendered
  69636. */
  69637. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  69638. /**
  69639. * BABYLON.Observable event triggered after the texture was rendered
  69640. */
  69641. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  69642. /**
  69643. * Gets or sets a boolean defining if alpha is stored as premultiplied
  69644. */
  69645. premulAlpha: boolean;
  69646. /**
  69647. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  69648. * Useful when you want more antialiasing
  69649. */
  69650. get renderScale(): number;
  69651. set renderScale(value: number);
  69652. /** Gets or sets the background color */
  69653. get background(): string;
  69654. set background(value: string);
  69655. /**
  69656. * Gets or sets the ideal width used to design controls.
  69657. * The GUI will then rescale everything accordingly
  69658. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  69659. */
  69660. get idealWidth(): number;
  69661. set idealWidth(value: number);
  69662. /**
  69663. * Gets or sets the ideal height used to design controls.
  69664. * The GUI will then rescale everything accordingly
  69665. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  69666. */
  69667. get idealHeight(): number;
  69668. set idealHeight(value: number);
  69669. /**
  69670. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  69671. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  69672. */
  69673. get useSmallestIdeal(): boolean;
  69674. set useSmallestIdeal(value: boolean);
  69675. /**
  69676. * Gets or sets a boolean indicating if adaptive scaling must be used
  69677. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  69678. */
  69679. get renderAtIdealSize(): boolean;
  69680. set renderAtIdealSize(value: boolean);
  69681. /**
  69682. * Gets the underlying layer used to render the texture when in fullscreen mode
  69683. */
  69684. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  69685. /**
  69686. * Gets the root container control
  69687. */
  69688. get rootContainer(): Container;
  69689. /**
  69690. * Returns an array containing the root container.
  69691. * This is mostly used to let the Inspector introspects the ADT
  69692. * @returns an array containing the rootContainer
  69693. */
  69694. getChildren(): Array<Container>;
  69695. /**
  69696. * Will return all controls that are inside this texture
  69697. * @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
  69698. * @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
  69699. * @return all child controls
  69700. */
  69701. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  69702. /**
  69703. * Gets or sets the current focused control
  69704. */
  69705. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  69706. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  69707. /**
  69708. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  69709. */
  69710. get isForeground(): boolean;
  69711. set isForeground(value: boolean);
  69712. /**
  69713. * Gets or set information about clipboardData
  69714. */
  69715. get clipboardData(): string;
  69716. set clipboardData(value: string);
  69717. /**
  69718. * Creates a new AdvancedDynamicTexture
  69719. * @param name defines the name of the texture
  69720. * @param width defines the width of the texture
  69721. * @param height defines the height of the texture
  69722. * @param scene defines the hosting scene
  69723. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  69724. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  69725. */
  69726. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  69727. /**
  69728. * Get the current class name of the texture useful for serialization or dynamic coding.
  69729. * @returns "AdvancedDynamicTexture"
  69730. */
  69731. getClassName(): string;
  69732. /**
  69733. * Function used to execute a function on all controls
  69734. * @param func defines the function to execute
  69735. * @param container defines the container where controls belong. If null the root container will be used
  69736. */
  69737. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  69738. private _useInvalidateRectOptimization;
  69739. /**
  69740. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  69741. */
  69742. get useInvalidateRectOptimization(): boolean;
  69743. set useInvalidateRectOptimization(value: boolean);
  69744. private _invalidatedRectangle;
  69745. /**
  69746. * Invalidates a rectangle area on the gui texture
  69747. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  69748. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  69749. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  69750. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  69751. */
  69752. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  69753. /**
  69754. * Marks the texture as dirty forcing a complete update
  69755. */
  69756. markAsDirty(): void;
  69757. /**
  69758. * Helper function used to create a new style
  69759. * @returns a new style
  69760. * @see http://doc.babylonjs.com/how_to/gui#styles
  69761. */
  69762. createStyle(): Style;
  69763. /**
  69764. * Adds a new control to the root container
  69765. * @param control defines the control to add
  69766. * @returns the current texture
  69767. */
  69768. addControl(control: Control): AdvancedDynamicTexture;
  69769. /**
  69770. * Removes a control from the root container
  69771. * @param control defines the control to remove
  69772. * @returns the current texture
  69773. */
  69774. removeControl(control: Control): AdvancedDynamicTexture;
  69775. /**
  69776. * Release all resources
  69777. */
  69778. dispose(): void;
  69779. private _onResize;
  69780. /** @hidden */
  69781. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  69782. /**
  69783. * Get screen coordinates for a vector3
  69784. * @param position defines the position to project
  69785. * @param worldMatrix defines the world matrix to use
  69786. * @returns the projected position
  69787. */
  69788. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  69789. private _checkUpdate;
  69790. private _clearMeasure;
  69791. private _render;
  69792. /** @hidden */
  69793. _changeCursor(cursor: string): void;
  69794. /** @hidden */
  69795. _registerLastControlDown(control: Control, pointerId: number): void;
  69796. private _doPicking;
  69797. /** @hidden */
  69798. _cleanControlAfterRemovalFromList(list: {
  69799. [pointerId: number]: Control;
  69800. }, control: Control): void;
  69801. /** @hidden */
  69802. _cleanControlAfterRemoval(control: Control): void;
  69803. /** Attach to all scene events required to support pointer events */
  69804. attach(): void;
  69805. /** @hidden */
  69806. private onClipboardCopy;
  69807. /** @hidden */
  69808. private onClipboardCut;
  69809. /** @hidden */
  69810. private onClipboardPaste;
  69811. /**
  69812. * Register the clipboard Events onto the canvas
  69813. */
  69814. registerClipboardEvents(): void;
  69815. /**
  69816. * Unregister the clipboard Events from the canvas
  69817. */
  69818. unRegisterClipboardEvents(): void;
  69819. /**
  69820. * Connect the texture to a hosting mesh to enable interactions
  69821. * @param mesh defines the mesh to attach to
  69822. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  69823. */
  69824. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  69825. /**
  69826. * Move the focus to a specific control
  69827. * @param control defines the control which will receive the focus
  69828. */
  69829. moveFocusToControl(control: IFocusableControl): void;
  69830. private _manageFocus;
  69831. private _attachToOnPointerOut;
  69832. /**
  69833. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  69834. * @param mesh defines the mesh which will receive the texture
  69835. * @param width defines the texture width (1024 by default)
  69836. * @param height defines the texture height (1024 by default)
  69837. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  69838. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  69839. * @returns a new AdvancedDynamicTexture
  69840. */
  69841. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  69842. /**
  69843. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  69844. * In this mode the texture will rely on a layer for its rendering.
  69845. * This allows it to be treated like any other layer.
  69846. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  69847. * LayerMask is set through advancedTexture.layer.layerMask
  69848. * @param name defines name for the texture
  69849. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  69850. * @param scene defines the hsoting scene
  69851. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  69852. * @returns a new AdvancedDynamicTexture
  69853. */
  69854. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  69855. }
  69856. }
  69857. declare module BABYLON.GUI {
  69858. /**
  69859. * Root class used for all 2D controls
  69860. * @see http://doc.babylonjs.com/how_to/gui#controls
  69861. */
  69862. export class Control {
  69863. /** defines the name of the control */
  69864. name?: string | undefined;
  69865. /**
  69866. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  69867. */
  69868. static AllowAlphaInheritance: boolean;
  69869. private _alpha;
  69870. private _alphaSet;
  69871. private _zIndex;
  69872. /** @hidden */
  69873. _host: AdvancedDynamicTexture;
  69874. /** Gets or sets the control parent */
  69875. parent: BABYLON.Nullable<Container>;
  69876. /** @hidden */
  69877. _currentMeasure: Measure;
  69878. private _fontFamily;
  69879. private _fontStyle;
  69880. private _fontWeight;
  69881. private _fontSize;
  69882. private _font;
  69883. /** @hidden */
  69884. _width: ValueAndUnit;
  69885. /** @hidden */
  69886. _height: ValueAndUnit;
  69887. /** @hidden */
  69888. protected _fontOffset: {
  69889. ascent: number;
  69890. height: number;
  69891. descent: number;
  69892. };
  69893. private _color;
  69894. private _style;
  69895. private _styleObserver;
  69896. /** @hidden */
  69897. protected _horizontalAlignment: number;
  69898. /** @hidden */
  69899. protected _verticalAlignment: number;
  69900. /** @hidden */
  69901. protected _isDirty: boolean;
  69902. /** @hidden */
  69903. protected _wasDirty: boolean;
  69904. /** @hidden */
  69905. _tempParentMeasure: Measure;
  69906. /** @hidden */
  69907. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  69908. /** @hidden */
  69909. protected _cachedParentMeasure: Measure;
  69910. private _paddingLeft;
  69911. private _paddingRight;
  69912. private _paddingTop;
  69913. private _paddingBottom;
  69914. /** @hidden */
  69915. _left: ValueAndUnit;
  69916. /** @hidden */
  69917. _top: ValueAndUnit;
  69918. private _scaleX;
  69919. private _scaleY;
  69920. private _rotation;
  69921. private _transformCenterX;
  69922. private _transformCenterY;
  69923. /** @hidden */
  69924. _transformMatrix: Matrix2D;
  69925. /** @hidden */
  69926. protected _invertTransformMatrix: Matrix2D;
  69927. /** @hidden */
  69928. protected _transformedPosition: BABYLON.Vector2;
  69929. private _isMatrixDirty;
  69930. private _cachedOffsetX;
  69931. private _cachedOffsetY;
  69932. private _isVisible;
  69933. private _isHighlighted;
  69934. /** @hidden */
  69935. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  69936. private _fontSet;
  69937. private _dummyVector2;
  69938. private _downCount;
  69939. private _enterCount;
  69940. private _doNotRender;
  69941. private _downPointerIds;
  69942. protected _isEnabled: boolean;
  69943. protected _disabledColor: string;
  69944. /** @hidden */
  69945. protected _rebuildLayout: boolean;
  69946. /** @hidden */
  69947. _isClipped: boolean;
  69948. /** @hidden */
  69949. _automaticSize: boolean;
  69950. /** @hidden */
  69951. _tag: any;
  69952. /**
  69953. * 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
  69954. */
  69955. uniqueId: number;
  69956. /**
  69957. * Gets or sets an object used to store user defined information for the node
  69958. */
  69959. metadata: any;
  69960. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  69961. isHitTestVisible: boolean;
  69962. /** Gets or sets a boolean indicating if the control can block pointer events */
  69963. isPointerBlocker: boolean;
  69964. /** Gets or sets a boolean indicating if the control can be focusable */
  69965. isFocusInvisible: boolean;
  69966. /**
  69967. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  69968. * 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
  69969. */
  69970. clipChildren: boolean;
  69971. /**
  69972. * Gets or sets a boolean indicating that control content must be clipped
  69973. * 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
  69974. */
  69975. clipContent: boolean;
  69976. /**
  69977. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  69978. */
  69979. useBitmapCache: boolean;
  69980. private _cacheData;
  69981. private _shadowOffsetX;
  69982. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  69983. get shadowOffsetX(): number;
  69984. set shadowOffsetX(value: number);
  69985. private _shadowOffsetY;
  69986. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  69987. get shadowOffsetY(): number;
  69988. set shadowOffsetY(value: number);
  69989. private _shadowBlur;
  69990. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  69991. get shadowBlur(): number;
  69992. set shadowBlur(value: number);
  69993. private _shadowColor;
  69994. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  69995. get shadowColor(): string;
  69996. set shadowColor(value: string);
  69997. /** Gets or sets the cursor to use when the control is hovered */
  69998. hoverCursor: string;
  69999. /** @hidden */
  70000. protected _linkOffsetX: ValueAndUnit;
  70001. /** @hidden */
  70002. protected _linkOffsetY: ValueAndUnit;
  70003. /** Gets the control type name */
  70004. get typeName(): string;
  70005. /**
  70006. * Get the current class name of the control.
  70007. * @returns current class name
  70008. */
  70009. getClassName(): string;
  70010. /**
  70011. * An event triggered when the pointer move over the control.
  70012. */
  70013. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  70014. /**
  70015. * An event triggered when the pointer move out of the control.
  70016. */
  70017. onPointerOutObservable: BABYLON.Observable<Control>;
  70018. /**
  70019. * An event triggered when the pointer taps the control
  70020. */
  70021. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  70022. /**
  70023. * An event triggered when pointer up
  70024. */
  70025. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  70026. /**
  70027. * An event triggered when a control is clicked on
  70028. */
  70029. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  70030. /**
  70031. * An event triggered when pointer enters the control
  70032. */
  70033. onPointerEnterObservable: BABYLON.Observable<Control>;
  70034. /**
  70035. * An event triggered when the control is marked as dirty
  70036. */
  70037. onDirtyObservable: BABYLON.Observable<Control>;
  70038. /**
  70039. * An event triggered before drawing the control
  70040. */
  70041. onBeforeDrawObservable: BABYLON.Observable<Control>;
  70042. /**
  70043. * An event triggered after the control was drawn
  70044. */
  70045. onAfterDrawObservable: BABYLON.Observable<Control>;
  70046. /**
  70047. * Get the hosting AdvancedDynamicTexture
  70048. */
  70049. get host(): AdvancedDynamicTexture;
  70050. /** Gets or set information about font offsets (used to render and align text) */
  70051. get fontOffset(): {
  70052. ascent: number;
  70053. height: number;
  70054. descent: number;
  70055. };
  70056. set fontOffset(offset: {
  70057. ascent: number;
  70058. height: number;
  70059. descent: number;
  70060. });
  70061. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  70062. get alpha(): number;
  70063. set alpha(value: number);
  70064. /**
  70065. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  70066. */
  70067. get isHighlighted(): boolean;
  70068. set isHighlighted(value: boolean);
  70069. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  70070. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70071. */
  70072. get scaleX(): number;
  70073. set scaleX(value: number);
  70074. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  70075. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70076. */
  70077. get scaleY(): number;
  70078. set scaleY(value: number);
  70079. /** Gets or sets the rotation angle (0 by default)
  70080. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70081. */
  70082. get rotation(): number;
  70083. set rotation(value: number);
  70084. /** Gets or sets the transformation center on Y axis (0 by default)
  70085. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70086. */
  70087. get transformCenterY(): number;
  70088. set transformCenterY(value: number);
  70089. /** Gets or sets the transformation center on X axis (0 by default)
  70090. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70091. */
  70092. get transformCenterX(): number;
  70093. set transformCenterX(value: number);
  70094. /**
  70095. * Gets or sets the horizontal alignment
  70096. * @see http://doc.babylonjs.com/how_to/gui#alignments
  70097. */
  70098. get horizontalAlignment(): number;
  70099. set horizontalAlignment(value: number);
  70100. /**
  70101. * Gets or sets the vertical alignment
  70102. * @see http://doc.babylonjs.com/how_to/gui#alignments
  70103. */
  70104. get verticalAlignment(): number;
  70105. set verticalAlignment(value: number);
  70106. /**
  70107. * Gets or sets control width
  70108. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70109. */
  70110. get width(): string | number;
  70111. set width(value: string | number);
  70112. /**
  70113. * Gets or sets the control width in pixel
  70114. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70115. */
  70116. get widthInPixels(): number;
  70117. set widthInPixels(value: number);
  70118. /**
  70119. * Gets or sets control height
  70120. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70121. */
  70122. get height(): string | number;
  70123. set height(value: string | number);
  70124. /**
  70125. * Gets or sets control height in pixel
  70126. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70127. */
  70128. get heightInPixels(): number;
  70129. set heightInPixels(value: number);
  70130. /** Gets or set font family */
  70131. get fontFamily(): string;
  70132. set fontFamily(value: string);
  70133. /** Gets or sets font style */
  70134. get fontStyle(): string;
  70135. set fontStyle(value: string);
  70136. /** Gets or sets font weight */
  70137. get fontWeight(): string;
  70138. set fontWeight(value: string);
  70139. /**
  70140. * Gets or sets style
  70141. * @see http://doc.babylonjs.com/how_to/gui#styles
  70142. */
  70143. get style(): BABYLON.Nullable<Style>;
  70144. set style(value: BABYLON.Nullable<Style>);
  70145. /** @hidden */
  70146. get _isFontSizeInPercentage(): boolean;
  70147. /** Gets or sets font size in pixels */
  70148. get fontSizeInPixels(): number;
  70149. set fontSizeInPixels(value: number);
  70150. /** Gets or sets font size */
  70151. get fontSize(): string | number;
  70152. set fontSize(value: string | number);
  70153. /** Gets or sets foreground color */
  70154. get color(): string;
  70155. set color(value: string);
  70156. /** Gets or sets z index which is used to reorder controls on the z axis */
  70157. get zIndex(): number;
  70158. set zIndex(value: number);
  70159. /** Gets or sets a boolean indicating if the control can be rendered */
  70160. get notRenderable(): boolean;
  70161. set notRenderable(value: boolean);
  70162. /** Gets or sets a boolean indicating if the control is visible */
  70163. get isVisible(): boolean;
  70164. set isVisible(value: boolean);
  70165. /** Gets a boolean indicating that the control needs to update its rendering */
  70166. get isDirty(): boolean;
  70167. /**
  70168. * Gets the current linked mesh (or null if none)
  70169. */
  70170. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  70171. /**
  70172. * Gets or sets a value indicating the padding to use on the left of the control
  70173. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70174. */
  70175. get paddingLeft(): string | number;
  70176. set paddingLeft(value: string | number);
  70177. /**
  70178. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  70179. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70180. */
  70181. get paddingLeftInPixels(): number;
  70182. set paddingLeftInPixels(value: number);
  70183. /**
  70184. * Gets or sets a value indicating the padding to use on the right of the control
  70185. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70186. */
  70187. get paddingRight(): string | number;
  70188. set paddingRight(value: string | number);
  70189. /**
  70190. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  70191. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70192. */
  70193. get paddingRightInPixels(): number;
  70194. set paddingRightInPixels(value: number);
  70195. /**
  70196. * Gets or sets a value indicating the padding to use on the top of the control
  70197. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70198. */
  70199. get paddingTop(): string | number;
  70200. set paddingTop(value: string | number);
  70201. /**
  70202. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  70203. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70204. */
  70205. get paddingTopInPixels(): number;
  70206. set paddingTopInPixels(value: number);
  70207. /**
  70208. * Gets or sets a value indicating the padding to use on the bottom of the control
  70209. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70210. */
  70211. get paddingBottom(): string | number;
  70212. set paddingBottom(value: string | number);
  70213. /**
  70214. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  70215. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70216. */
  70217. get paddingBottomInPixels(): number;
  70218. set paddingBottomInPixels(value: number);
  70219. /**
  70220. * Gets or sets a value indicating the left coordinate of the control
  70221. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70222. */
  70223. get left(): string | number;
  70224. set left(value: string | number);
  70225. /**
  70226. * Gets or sets a value indicating the left coordinate in pixels of the control
  70227. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70228. */
  70229. get leftInPixels(): number;
  70230. set leftInPixels(value: number);
  70231. /**
  70232. * Gets or sets a value indicating the top coordinate of the control
  70233. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70234. */
  70235. get top(): string | number;
  70236. set top(value: string | number);
  70237. /**
  70238. * Gets or sets a value indicating the top coordinate in pixels of the control
  70239. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70240. */
  70241. get topInPixels(): number;
  70242. set topInPixels(value: number);
  70243. /**
  70244. * Gets or sets a value indicating the offset on X axis to the linked mesh
  70245. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  70246. */
  70247. get linkOffsetX(): string | number;
  70248. set linkOffsetX(value: string | number);
  70249. /**
  70250. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  70251. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  70252. */
  70253. get linkOffsetXInPixels(): number;
  70254. set linkOffsetXInPixels(value: number);
  70255. /**
  70256. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  70257. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  70258. */
  70259. get linkOffsetY(): string | number;
  70260. set linkOffsetY(value: string | number);
  70261. /**
  70262. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  70263. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  70264. */
  70265. get linkOffsetYInPixels(): number;
  70266. set linkOffsetYInPixels(value: number);
  70267. /** Gets the center coordinate on X axis */
  70268. get centerX(): number;
  70269. /** Gets the center coordinate on Y axis */
  70270. get centerY(): number;
  70271. /** Gets or sets if control is Enabled*/
  70272. get isEnabled(): boolean;
  70273. set isEnabled(value: boolean);
  70274. /** Gets or sets background color of control if it's disabled*/
  70275. get disabledColor(): string;
  70276. set disabledColor(value: string);
  70277. /**
  70278. * Creates a new control
  70279. * @param name defines the name of the control
  70280. */
  70281. constructor(
  70282. /** defines the name of the control */
  70283. name?: string | undefined);
  70284. /** @hidden */
  70285. protected _getTypeName(): string;
  70286. /**
  70287. * Gets the first ascendant in the hierarchy of the given type
  70288. * @param className defines the required type
  70289. * @returns the ascendant or null if not found
  70290. */
  70291. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  70292. /** @hidden */
  70293. _resetFontCache(): void;
  70294. /**
  70295. * Determines if a container is an ascendant of the current control
  70296. * @param container defines the container to look for
  70297. * @returns true if the container is one of the ascendant of the control
  70298. */
  70299. isAscendant(container: Control): boolean;
  70300. /**
  70301. * Gets coordinates in local control space
  70302. * @param globalCoordinates defines the coordinates to transform
  70303. * @returns the new coordinates in local space
  70304. */
  70305. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  70306. /**
  70307. * Gets coordinates in local control space
  70308. * @param globalCoordinates defines the coordinates to transform
  70309. * @param result defines the target vector2 where to store the result
  70310. * @returns the current control
  70311. */
  70312. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  70313. /**
  70314. * Gets coordinates in parent local control space
  70315. * @param globalCoordinates defines the coordinates to transform
  70316. * @returns the new coordinates in parent local space
  70317. */
  70318. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  70319. /**
  70320. * Move the current control to a vector3 position projected onto the screen.
  70321. * @param position defines the target position
  70322. * @param scene defines the hosting scene
  70323. */
  70324. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  70325. /**
  70326. * Will store all controls that have this control as ascendant in a given array
  70327. * @param results defines the array where to store the descendants
  70328. * @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
  70329. * @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
  70330. */
  70331. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  70332. /**
  70333. * Will return all controls that have this control as ascendant
  70334. * @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
  70335. * @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
  70336. * @return all child controls
  70337. */
  70338. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  70339. /**
  70340. * Link current control with a target mesh
  70341. * @param mesh defines the mesh to link with
  70342. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  70343. */
  70344. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  70345. /** @hidden */
  70346. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  70347. /** @hidden */
  70348. _offsetLeft(offset: number): void;
  70349. /** @hidden */
  70350. _offsetTop(offset: number): void;
  70351. /** @hidden */
  70352. _markMatrixAsDirty(): void;
  70353. /** @hidden */
  70354. _flagDescendantsAsMatrixDirty(): void;
  70355. /** @hidden */
  70356. _intersectsRect(rect: Measure): boolean;
  70357. /** @hidden */
  70358. protected invalidateRect(): void;
  70359. /** @hidden */
  70360. _markAsDirty(force?: boolean): void;
  70361. /** @hidden */
  70362. _markAllAsDirty(): void;
  70363. /** @hidden */
  70364. _link(host: AdvancedDynamicTexture): void;
  70365. /** @hidden */
  70366. protected _transform(context?: CanvasRenderingContext2D): void;
  70367. /** @hidden */
  70368. _renderHighlight(context: CanvasRenderingContext2D): void;
  70369. /** @hidden */
  70370. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  70371. /** @hidden */
  70372. protected _applyStates(context: CanvasRenderingContext2D): void;
  70373. /** @hidden */
  70374. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  70375. /** @hidden */
  70376. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70377. protected _evaluateClippingState(parentMeasure: Measure): void;
  70378. /** @hidden */
  70379. _measure(): void;
  70380. /** @hidden */
  70381. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70382. /** @hidden */
  70383. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70384. /** @hidden */
  70385. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70386. /** @hidden */
  70387. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  70388. private static _ClipMeasure;
  70389. private _tmpMeasureA;
  70390. private _clip;
  70391. /** @hidden */
  70392. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  70393. /** @hidden */
  70394. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  70395. /**
  70396. * Tests if a given coordinates belong to the current control
  70397. * @param x defines x coordinate to test
  70398. * @param y defines y coordinate to test
  70399. * @returns true if the coordinates are inside the control
  70400. */
  70401. contains(x: number, y: number): boolean;
  70402. /** @hidden */
  70403. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  70404. /** @hidden */
  70405. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  70406. /** @hidden */
  70407. _onPointerEnter(target: Control): boolean;
  70408. /** @hidden */
  70409. _onPointerOut(target: Control, force?: boolean): void;
  70410. /** @hidden */
  70411. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  70412. /** @hidden */
  70413. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  70414. /** @hidden */
  70415. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  70416. /** @hidden */
  70417. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  70418. private _prepareFont;
  70419. /** Releases associated resources */
  70420. dispose(): void;
  70421. private static _HORIZONTAL_ALIGNMENT_LEFT;
  70422. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  70423. private static _HORIZONTAL_ALIGNMENT_CENTER;
  70424. private static _VERTICAL_ALIGNMENT_TOP;
  70425. private static _VERTICAL_ALIGNMENT_BOTTOM;
  70426. private static _VERTICAL_ALIGNMENT_CENTER;
  70427. /** HORIZONTAL_ALIGNMENT_LEFT */
  70428. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  70429. /** HORIZONTAL_ALIGNMENT_RIGHT */
  70430. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  70431. /** HORIZONTAL_ALIGNMENT_CENTER */
  70432. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  70433. /** VERTICAL_ALIGNMENT_TOP */
  70434. static get VERTICAL_ALIGNMENT_TOP(): number;
  70435. /** VERTICAL_ALIGNMENT_BOTTOM */
  70436. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  70437. /** VERTICAL_ALIGNMENT_CENTER */
  70438. static get VERTICAL_ALIGNMENT_CENTER(): number;
  70439. private static _FontHeightSizes;
  70440. /** @hidden */
  70441. static _GetFontOffset(font: string): {
  70442. ascent: number;
  70443. height: number;
  70444. descent: number;
  70445. };
  70446. /**
  70447. * Creates a stack panel that can be used to render headers
  70448. * @param control defines the control to associate with the header
  70449. * @param text defines the text of the header
  70450. * @param size defines the size of the header
  70451. * @param options defines options used to configure the header
  70452. * @returns a new StackPanel
  70453. * @ignore
  70454. * @hidden
  70455. */
  70456. static AddHeader: (control: Control, text: string, size: string | number, options: {
  70457. isHorizontal: boolean;
  70458. controlFirst: boolean;
  70459. }) => any;
  70460. /** @hidden */
  70461. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  70462. }
  70463. }
  70464. declare module BABYLON.GUI {
  70465. /**
  70466. * Root class for 2D containers
  70467. * @see http://doc.babylonjs.com/how_to/gui#containers
  70468. */
  70469. export class Container extends Control {
  70470. name?: string | undefined;
  70471. /** @hidden */
  70472. protected _children: Control[];
  70473. /** @hidden */
  70474. protected _measureForChildren: Measure;
  70475. /** @hidden */
  70476. protected _background: string;
  70477. /** @hidden */
  70478. protected _adaptWidthToChildren: boolean;
  70479. /** @hidden */
  70480. protected _adaptHeightToChildren: boolean;
  70481. /**
  70482. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  70483. */
  70484. logLayoutCycleErrors: boolean;
  70485. /**
  70486. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  70487. */
  70488. maxLayoutCycle: number;
  70489. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  70490. get adaptHeightToChildren(): boolean;
  70491. set adaptHeightToChildren(value: boolean);
  70492. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  70493. get adaptWidthToChildren(): boolean;
  70494. set adaptWidthToChildren(value: boolean);
  70495. /** Gets or sets background color */
  70496. get background(): string;
  70497. set background(value: string);
  70498. /** Gets the list of children */
  70499. get children(): Control[];
  70500. /**
  70501. * Creates a new Container
  70502. * @param name defines the name of the container
  70503. */
  70504. constructor(name?: string | undefined);
  70505. protected _getTypeName(): string;
  70506. _flagDescendantsAsMatrixDirty(): void;
  70507. /**
  70508. * Gets a child using its name
  70509. * @param name defines the child name to look for
  70510. * @returns the child control if found
  70511. */
  70512. getChildByName(name: string): BABYLON.Nullable<Control>;
  70513. /**
  70514. * Gets a child using its type and its name
  70515. * @param name defines the child name to look for
  70516. * @param type defines the child type to look for
  70517. * @returns the child control if found
  70518. */
  70519. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  70520. /**
  70521. * Search for a specific control in children
  70522. * @param control defines the control to look for
  70523. * @returns true if the control is in child list
  70524. */
  70525. containsControl(control: Control): boolean;
  70526. /**
  70527. * Adds a new control to the current container
  70528. * @param control defines the control to add
  70529. * @returns the current container
  70530. */
  70531. addControl(control: BABYLON.Nullable<Control>): Container;
  70532. /**
  70533. * Removes all controls from the current container
  70534. * @returns the current container
  70535. */
  70536. clearControls(): Container;
  70537. /**
  70538. * Removes a control from the current container
  70539. * @param control defines the control to remove
  70540. * @returns the current container
  70541. */
  70542. removeControl(control: Control): Container;
  70543. /** @hidden */
  70544. _reOrderControl(control: Control): void;
  70545. /** @hidden */
  70546. _offsetLeft(offset: number): void;
  70547. /** @hidden */
  70548. _offsetTop(offset: number): void;
  70549. /** @hidden */
  70550. _markAllAsDirty(): void;
  70551. /** @hidden */
  70552. protected _localDraw(context: CanvasRenderingContext2D): void;
  70553. /** @hidden */
  70554. _link(host: AdvancedDynamicTexture): void;
  70555. /** @hidden */
  70556. protected _beforeLayout(): void;
  70557. /** @hidden */
  70558. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70559. /** @hidden */
  70560. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  70561. protected _postMeasure(): void;
  70562. /** @hidden */
  70563. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  70564. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  70565. /** @hidden */
  70566. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  70567. /** @hidden */
  70568. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70569. /** Releases associated resources */
  70570. dispose(): void;
  70571. }
  70572. }
  70573. declare module BABYLON.GUI {
  70574. /** Class used to create rectangle container */
  70575. export class Rectangle extends Container {
  70576. name?: string | undefined;
  70577. private _thickness;
  70578. private _cornerRadius;
  70579. /** Gets or sets border thickness */
  70580. get thickness(): number;
  70581. set thickness(value: number);
  70582. /** Gets or sets the corner radius angle */
  70583. get cornerRadius(): number;
  70584. set cornerRadius(value: number);
  70585. /**
  70586. * Creates a new Rectangle
  70587. * @param name defines the control name
  70588. */
  70589. constructor(name?: string | undefined);
  70590. protected _getTypeName(): string;
  70591. protected _localDraw(context: CanvasRenderingContext2D): void;
  70592. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70593. private _drawRoundedRect;
  70594. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  70595. }
  70596. }
  70597. declare module BABYLON.GUI {
  70598. /**
  70599. * Enum that determines the text-wrapping mode to use.
  70600. */
  70601. export enum TextWrapping {
  70602. /**
  70603. * Clip the text when it's larger than Control.width; this is the default mode.
  70604. */
  70605. Clip = 0,
  70606. /**
  70607. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  70608. */
  70609. WordWrap = 1,
  70610. /**
  70611. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  70612. */
  70613. Ellipsis = 2
  70614. }
  70615. /**
  70616. * Class used to create text block control
  70617. */
  70618. export class TextBlock extends Control {
  70619. /**
  70620. * Defines the name of the control
  70621. */
  70622. name?: string | undefined;
  70623. private _text;
  70624. private _textWrapping;
  70625. private _textHorizontalAlignment;
  70626. private _textVerticalAlignment;
  70627. private _lines;
  70628. private _resizeToFit;
  70629. private _lineSpacing;
  70630. private _outlineWidth;
  70631. private _outlineColor;
  70632. /**
  70633. * An event triggered after the text is changed
  70634. */
  70635. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  70636. /**
  70637. * An event triggered after the text was broken up into lines
  70638. */
  70639. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  70640. /**
  70641. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  70642. */
  70643. get lines(): any[];
  70644. /**
  70645. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  70646. */
  70647. get resizeToFit(): boolean;
  70648. /**
  70649. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  70650. */
  70651. set resizeToFit(value: boolean);
  70652. /**
  70653. * Gets or sets a boolean indicating if text must be wrapped
  70654. */
  70655. get textWrapping(): TextWrapping | boolean;
  70656. /**
  70657. * Gets or sets a boolean indicating if text must be wrapped
  70658. */
  70659. set textWrapping(value: TextWrapping | boolean);
  70660. /**
  70661. * Gets or sets text to display
  70662. */
  70663. get text(): string;
  70664. /**
  70665. * Gets or sets text to display
  70666. */
  70667. set text(value: string);
  70668. /**
  70669. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  70670. */
  70671. get textHorizontalAlignment(): number;
  70672. /**
  70673. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  70674. */
  70675. set textHorizontalAlignment(value: number);
  70676. /**
  70677. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  70678. */
  70679. get textVerticalAlignment(): number;
  70680. /**
  70681. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  70682. */
  70683. set textVerticalAlignment(value: number);
  70684. /**
  70685. * Gets or sets line spacing value
  70686. */
  70687. set lineSpacing(value: string | number);
  70688. /**
  70689. * Gets or sets line spacing value
  70690. */
  70691. get lineSpacing(): string | number;
  70692. /**
  70693. * Gets or sets outlineWidth of the text to display
  70694. */
  70695. get outlineWidth(): number;
  70696. /**
  70697. * Gets or sets outlineWidth of the text to display
  70698. */
  70699. set outlineWidth(value: number);
  70700. /**
  70701. * Gets or sets outlineColor of the text to display
  70702. */
  70703. get outlineColor(): string;
  70704. /**
  70705. * Gets or sets outlineColor of the text to display
  70706. */
  70707. set outlineColor(value: string);
  70708. /**
  70709. * Creates a new TextBlock object
  70710. * @param name defines the name of the control
  70711. * @param text defines the text to display (emptry string by default)
  70712. */
  70713. constructor(
  70714. /**
  70715. * Defines the name of the control
  70716. */
  70717. name?: string | undefined, text?: string);
  70718. protected _getTypeName(): string;
  70719. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70720. private _drawText;
  70721. /** @hidden */
  70722. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  70723. protected _applyStates(context: CanvasRenderingContext2D): void;
  70724. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  70725. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  70726. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  70727. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  70728. protected _renderLines(context: CanvasRenderingContext2D): void;
  70729. /**
  70730. * Given a width constraint applied on the text block, find the expected height
  70731. * @returns expected height
  70732. */
  70733. computeExpectedHeight(): number;
  70734. dispose(): void;
  70735. }
  70736. }
  70737. declare module BABYLON.GUI {
  70738. /**
  70739. * Class used to create 2D images
  70740. */
  70741. export class Image extends Control {
  70742. name?: string | undefined;
  70743. private _workingCanvas;
  70744. private _domImage;
  70745. private _imageWidth;
  70746. private _imageHeight;
  70747. private _loaded;
  70748. private _stretch;
  70749. private _source;
  70750. private _autoScale;
  70751. private _sourceLeft;
  70752. private _sourceTop;
  70753. private _sourceWidth;
  70754. private _sourceHeight;
  70755. private _cellWidth;
  70756. private _cellHeight;
  70757. private _cellId;
  70758. private _populateNinePatchSlicesFromImage;
  70759. private _sliceLeft;
  70760. private _sliceRight;
  70761. private _sliceTop;
  70762. private _sliceBottom;
  70763. private _detectPointerOnOpaqueOnly;
  70764. /**
  70765. * BABYLON.Observable notified when the content is loaded
  70766. */
  70767. onImageLoadedObservable: BABYLON.Observable<Image>;
  70768. /**
  70769. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  70770. */
  70771. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  70772. /**
  70773. * Gets a boolean indicating that the content is loaded
  70774. */
  70775. get isLoaded(): boolean;
  70776. /**
  70777. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  70778. */
  70779. get populateNinePatchSlicesFromImage(): boolean;
  70780. set populateNinePatchSlicesFromImage(value: boolean);
  70781. /**
  70782. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  70783. * Beware using this as this will comsume more memory as the image has to be stored twice
  70784. */
  70785. get detectPointerOnOpaqueOnly(): boolean;
  70786. set detectPointerOnOpaqueOnly(value: boolean);
  70787. /**
  70788. * Gets or sets the left value for slicing (9-patch)
  70789. */
  70790. get sliceLeft(): number;
  70791. set sliceLeft(value: number);
  70792. /**
  70793. * Gets or sets the right value for slicing (9-patch)
  70794. */
  70795. get sliceRight(): number;
  70796. set sliceRight(value: number);
  70797. /**
  70798. * Gets or sets the top value for slicing (9-patch)
  70799. */
  70800. get sliceTop(): number;
  70801. set sliceTop(value: number);
  70802. /**
  70803. * Gets or sets the bottom value for slicing (9-patch)
  70804. */
  70805. get sliceBottom(): number;
  70806. set sliceBottom(value: number);
  70807. /**
  70808. * Gets or sets the left coordinate in the source image
  70809. */
  70810. get sourceLeft(): number;
  70811. set sourceLeft(value: number);
  70812. /**
  70813. * Gets or sets the top coordinate in the source image
  70814. */
  70815. get sourceTop(): number;
  70816. set sourceTop(value: number);
  70817. /**
  70818. * Gets or sets the width to capture in the source image
  70819. */
  70820. get sourceWidth(): number;
  70821. set sourceWidth(value: number);
  70822. /**
  70823. * Gets or sets the height to capture in the source image
  70824. */
  70825. get sourceHeight(): number;
  70826. set sourceHeight(value: number);
  70827. /**
  70828. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  70829. * @see http://doc.babylonjs.com/how_to/gui#image
  70830. */
  70831. get autoScale(): boolean;
  70832. set autoScale(value: boolean);
  70833. /** Gets or sets the streching mode used by the image */
  70834. get stretch(): number;
  70835. set stretch(value: number);
  70836. /** @hidden */
  70837. _rotate90(n: number): Image;
  70838. /**
  70839. * Gets or sets the internal DOM image used to render the control
  70840. */
  70841. set domImage(value: HTMLImageElement);
  70842. get domImage(): HTMLImageElement;
  70843. private _onImageLoaded;
  70844. private _extractNinePatchSliceDataFromImage;
  70845. /**
  70846. * Gets or sets image source url
  70847. */
  70848. set source(value: BABYLON.Nullable<string>);
  70849. /**
  70850. * Checks for svg document with icon id present
  70851. */
  70852. private _svgCheck;
  70853. /**
  70854. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  70855. * given external svg file and icon id
  70856. */
  70857. private _getSVGAttribs;
  70858. /**
  70859. * Gets or sets the cell width to use when animation sheet is enabled
  70860. * @see http://doc.babylonjs.com/how_to/gui#image
  70861. */
  70862. get cellWidth(): number;
  70863. set cellWidth(value: number);
  70864. /**
  70865. * Gets or sets the cell height to use when animation sheet is enabled
  70866. * @see http://doc.babylonjs.com/how_to/gui#image
  70867. */
  70868. get cellHeight(): number;
  70869. set cellHeight(value: number);
  70870. /**
  70871. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  70872. * @see http://doc.babylonjs.com/how_to/gui#image
  70873. */
  70874. get cellId(): number;
  70875. set cellId(value: number);
  70876. /**
  70877. * Creates a new Image
  70878. * @param name defines the control name
  70879. * @param url defines the image url
  70880. */
  70881. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  70882. /**
  70883. * Tests if a given coordinates belong to the current control
  70884. * @param x defines x coordinate to test
  70885. * @param y defines y coordinate to test
  70886. * @returns true if the coordinates are inside the control
  70887. */
  70888. contains(x: number, y: number): boolean;
  70889. protected _getTypeName(): string;
  70890. /** Force the control to synchronize with its content */
  70891. synchronizeSizeWithContent(): void;
  70892. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  70893. private _prepareWorkingCanvasForOpaqueDetection;
  70894. private _drawImage;
  70895. _draw(context: CanvasRenderingContext2D): void;
  70896. private _renderCornerPatch;
  70897. private _renderNinePatch;
  70898. dispose(): void;
  70899. /** STRETCH_NONE */
  70900. static readonly STRETCH_NONE: number;
  70901. /** STRETCH_FILL */
  70902. static readonly STRETCH_FILL: number;
  70903. /** STRETCH_UNIFORM */
  70904. static readonly STRETCH_UNIFORM: number;
  70905. /** STRETCH_EXTEND */
  70906. static readonly STRETCH_EXTEND: number;
  70907. /** NINE_PATCH */
  70908. static readonly STRETCH_NINE_PATCH: number;
  70909. }
  70910. }
  70911. declare module BABYLON.GUI {
  70912. /**
  70913. * Class used to create 2D buttons
  70914. */
  70915. export class Button extends Rectangle {
  70916. name?: string | undefined;
  70917. /**
  70918. * Function called to generate a pointer enter animation
  70919. */
  70920. pointerEnterAnimation: () => void;
  70921. /**
  70922. * Function called to generate a pointer out animation
  70923. */
  70924. pointerOutAnimation: () => void;
  70925. /**
  70926. * Function called to generate a pointer down animation
  70927. */
  70928. pointerDownAnimation: () => void;
  70929. /**
  70930. * Function called to generate a pointer up animation
  70931. */
  70932. pointerUpAnimation: () => void;
  70933. /**
  70934. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  70935. */
  70936. delegatePickingToChildren: boolean;
  70937. private _image;
  70938. /**
  70939. * Returns the image part of the button (if any)
  70940. */
  70941. get image(): BABYLON.Nullable<Image>;
  70942. private _textBlock;
  70943. /**
  70944. * Returns the image part of the button (if any)
  70945. */
  70946. get textBlock(): BABYLON.Nullable<TextBlock>;
  70947. /**
  70948. * Creates a new Button
  70949. * @param name defines the name of the button
  70950. */
  70951. constructor(name?: string | undefined);
  70952. protected _getTypeName(): string;
  70953. /** @hidden */
  70954. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  70955. /** @hidden */
  70956. _onPointerEnter(target: Control): boolean;
  70957. /** @hidden */
  70958. _onPointerOut(target: Control, force?: boolean): void;
  70959. /** @hidden */
  70960. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  70961. /** @hidden */
  70962. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  70963. /**
  70964. * Creates a new button made with an image and a text
  70965. * @param name defines the name of the button
  70966. * @param text defines the text of the button
  70967. * @param imageUrl defines the url of the image
  70968. * @returns a new Button
  70969. */
  70970. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  70971. /**
  70972. * Creates a new button made with an image
  70973. * @param name defines the name of the button
  70974. * @param imageUrl defines the url of the image
  70975. * @returns a new Button
  70976. */
  70977. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  70978. /**
  70979. * Creates a new button made with a text
  70980. * @param name defines the name of the button
  70981. * @param text defines the text of the button
  70982. * @returns a new Button
  70983. */
  70984. static CreateSimpleButton(name: string, text: string): Button;
  70985. /**
  70986. * Creates a new button made with an image and a centered text
  70987. * @param name defines the name of the button
  70988. * @param text defines the text of the button
  70989. * @param imageUrl defines the url of the image
  70990. * @returns a new Button
  70991. */
  70992. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  70993. }
  70994. }
  70995. declare module BABYLON.GUI {
  70996. /**
  70997. * Class used to create a 2D stack panel container
  70998. */
  70999. export class StackPanel extends Container {
  71000. name?: string | undefined;
  71001. private _isVertical;
  71002. private _manualWidth;
  71003. private _manualHeight;
  71004. private _doNotTrackManualChanges;
  71005. /**
  71006. * Gets or sets a boolean indicating that layou warnings should be ignored
  71007. */
  71008. ignoreLayoutWarnings: boolean;
  71009. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  71010. get isVertical(): boolean;
  71011. set isVertical(value: boolean);
  71012. /**
  71013. * Gets or sets panel width.
  71014. * This value should not be set when in horizontal mode as it will be computed automatically
  71015. */
  71016. set width(value: string | number);
  71017. get width(): string | number;
  71018. /**
  71019. * Gets or sets panel height.
  71020. * This value should not be set when in vertical mode as it will be computed automatically
  71021. */
  71022. set height(value: string | number);
  71023. get height(): string | number;
  71024. /**
  71025. * Creates a new StackPanel
  71026. * @param name defines control name
  71027. */
  71028. constructor(name?: string | undefined);
  71029. protected _getTypeName(): string;
  71030. /** @hidden */
  71031. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71032. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71033. protected _postMeasure(): void;
  71034. }
  71035. }
  71036. declare module BABYLON.GUI {
  71037. /**
  71038. * Class used to represent a 2D checkbox
  71039. */
  71040. export class Checkbox extends Control {
  71041. name?: string | undefined;
  71042. private _isChecked;
  71043. private _background;
  71044. private _checkSizeRatio;
  71045. private _thickness;
  71046. /** Gets or sets border thickness */
  71047. get thickness(): number;
  71048. set thickness(value: number);
  71049. /**
  71050. * BABYLON.Observable raised when isChecked property changes
  71051. */
  71052. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  71053. /** Gets or sets a value indicating the ratio between overall size and check size */
  71054. get checkSizeRatio(): number;
  71055. set checkSizeRatio(value: number);
  71056. /** Gets or sets background color */
  71057. get background(): string;
  71058. set background(value: string);
  71059. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  71060. get isChecked(): boolean;
  71061. set isChecked(value: boolean);
  71062. /**
  71063. * Creates a new CheckBox
  71064. * @param name defines the control name
  71065. */
  71066. constructor(name?: string | undefined);
  71067. protected _getTypeName(): string;
  71068. /** @hidden */
  71069. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  71070. /** @hidden */
  71071. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  71072. /**
  71073. * Utility function to easily create a checkbox with a header
  71074. * @param title defines the label to use for the header
  71075. * @param onValueChanged defines the callback to call when value changes
  71076. * @returns a StackPanel containing the checkbox and a textBlock
  71077. */
  71078. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  71079. }
  71080. }
  71081. declare module BABYLON.GUI {
  71082. /**
  71083. * Class used to store key control properties
  71084. */
  71085. export class KeyPropertySet {
  71086. /** Width */
  71087. width?: string;
  71088. /** Height */
  71089. height?: string;
  71090. /** Left padding */
  71091. paddingLeft?: string;
  71092. /** Right padding */
  71093. paddingRight?: string;
  71094. /** Top padding */
  71095. paddingTop?: string;
  71096. /** Bottom padding */
  71097. paddingBottom?: string;
  71098. /** Foreground color */
  71099. color?: string;
  71100. /** Background color */
  71101. background?: string;
  71102. }
  71103. /**
  71104. * Class used to create virtual keyboard
  71105. */
  71106. export class VirtualKeyboard extends StackPanel {
  71107. /** BABYLON.Observable raised when a key is pressed */
  71108. onKeyPressObservable: BABYLON.Observable<string>;
  71109. /** Gets or sets default key button width */
  71110. defaultButtonWidth: string;
  71111. /** Gets or sets default key button height */
  71112. defaultButtonHeight: string;
  71113. /** Gets or sets default key button left padding */
  71114. defaultButtonPaddingLeft: string;
  71115. /** Gets or sets default key button right padding */
  71116. defaultButtonPaddingRight: string;
  71117. /** Gets or sets default key button top padding */
  71118. defaultButtonPaddingTop: string;
  71119. /** Gets or sets default key button bottom padding */
  71120. defaultButtonPaddingBottom: string;
  71121. /** Gets or sets default key button foreground color */
  71122. defaultButtonColor: string;
  71123. /** Gets or sets default key button background color */
  71124. defaultButtonBackground: string;
  71125. /** Gets or sets shift button foreground color */
  71126. shiftButtonColor: string;
  71127. /** Gets or sets shift button thickness*/
  71128. selectedShiftThickness: number;
  71129. /** Gets shift key state */
  71130. shiftState: number;
  71131. protected _getTypeName(): string;
  71132. private _createKey;
  71133. /**
  71134. * Adds a new row of keys
  71135. * @param keys defines the list of keys to add
  71136. * @param propertySets defines the associated property sets
  71137. */
  71138. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  71139. /**
  71140. * Set the shift key to a specific state
  71141. * @param shiftState defines the new shift state
  71142. */
  71143. applyShiftState(shiftState: number): void;
  71144. private _currentlyConnectedInputText;
  71145. private _connectedInputTexts;
  71146. private _onKeyPressObserver;
  71147. /** Gets the input text control currently attached to the keyboard */
  71148. get connectedInputText(): BABYLON.Nullable<InputText>;
  71149. /**
  71150. * Connects the keyboard with an input text control
  71151. *
  71152. * @param input defines the target control
  71153. */
  71154. connect(input: InputText): void;
  71155. /**
  71156. * Disconnects the keyboard from connected InputText controls
  71157. *
  71158. * @param input optionally defines a target control, otherwise all are disconnected
  71159. */
  71160. disconnect(input?: InputText): void;
  71161. private _removeConnectedInputObservables;
  71162. /**
  71163. * Release all resources
  71164. */
  71165. dispose(): void;
  71166. /**
  71167. * Creates a new keyboard using a default layout
  71168. *
  71169. * @param name defines control name
  71170. * @returns a new VirtualKeyboard
  71171. */
  71172. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  71173. }
  71174. }
  71175. declare module BABYLON.GUI {
  71176. /**
  71177. * Class used to create input text control
  71178. */
  71179. export class InputText extends Control implements IFocusableControl {
  71180. name?: string | undefined;
  71181. private _text;
  71182. private _placeholderText;
  71183. private _background;
  71184. private _focusedBackground;
  71185. private _focusedColor;
  71186. private _placeholderColor;
  71187. private _thickness;
  71188. private _margin;
  71189. private _autoStretchWidth;
  71190. private _maxWidth;
  71191. private _isFocused;
  71192. private _blinkTimeout;
  71193. private _blinkIsEven;
  71194. private _cursorOffset;
  71195. private _scrollLeft;
  71196. private _textWidth;
  71197. private _clickedCoordinate;
  71198. private _deadKey;
  71199. private _addKey;
  71200. private _currentKey;
  71201. private _isTextHighlightOn;
  71202. private _textHighlightColor;
  71203. private _highligherOpacity;
  71204. private _highlightedText;
  71205. private _startHighlightIndex;
  71206. private _endHighlightIndex;
  71207. private _cursorIndex;
  71208. private _onFocusSelectAll;
  71209. private _isPointerDown;
  71210. private _onClipboardObserver;
  71211. private _onPointerDblTapObserver;
  71212. /** @hidden */
  71213. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  71214. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  71215. promptMessage: string;
  71216. /** Force disable prompt on mobile device */
  71217. disableMobilePrompt: boolean;
  71218. /** BABYLON.Observable raised when the text changes */
  71219. onTextChangedObservable: BABYLON.Observable<InputText>;
  71220. /** BABYLON.Observable raised just before an entered character is to be added */
  71221. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  71222. /** BABYLON.Observable raised when the control gets the focus */
  71223. onFocusObservable: BABYLON.Observable<InputText>;
  71224. /** BABYLON.Observable raised when the control loses the focus */
  71225. onBlurObservable: BABYLON.Observable<InputText>;
  71226. /**Observable raised when the text is highlighted */
  71227. onTextHighlightObservable: BABYLON.Observable<InputText>;
  71228. /**Observable raised when copy event is triggered */
  71229. onTextCopyObservable: BABYLON.Observable<InputText>;
  71230. /** BABYLON.Observable raised when cut event is triggered */
  71231. onTextCutObservable: BABYLON.Observable<InputText>;
  71232. /** BABYLON.Observable raised when paste event is triggered */
  71233. onTextPasteObservable: BABYLON.Observable<InputText>;
  71234. /** BABYLON.Observable raised when a key event was processed */
  71235. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  71236. /** Gets or sets the maximum width allowed by the control */
  71237. get maxWidth(): string | number;
  71238. /** Gets the maximum width allowed by the control in pixels */
  71239. get maxWidthInPixels(): number;
  71240. set maxWidth(value: string | number);
  71241. /** Gets or sets the text highlighter transparency; default: 0.4 */
  71242. get highligherOpacity(): number;
  71243. set highligherOpacity(value: number);
  71244. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  71245. get onFocusSelectAll(): boolean;
  71246. set onFocusSelectAll(value: boolean);
  71247. /** Gets or sets the text hightlight color */
  71248. get textHighlightColor(): string;
  71249. set textHighlightColor(value: string);
  71250. /** Gets or sets control margin */
  71251. get margin(): string;
  71252. /** Gets control margin in pixels */
  71253. get marginInPixels(): number;
  71254. set margin(value: string);
  71255. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  71256. get autoStretchWidth(): boolean;
  71257. set autoStretchWidth(value: boolean);
  71258. /** Gets or sets border thickness */
  71259. get thickness(): number;
  71260. set thickness(value: number);
  71261. /** Gets or sets the background color when focused */
  71262. get focusedBackground(): string;
  71263. set focusedBackground(value: string);
  71264. /** Gets or sets the background color when focused */
  71265. get focusedColor(): string;
  71266. set focusedColor(value: string);
  71267. /** Gets or sets the background color */
  71268. get background(): string;
  71269. set background(value: string);
  71270. /** Gets or sets the placeholder color */
  71271. get placeholderColor(): string;
  71272. set placeholderColor(value: string);
  71273. /** Gets or sets the text displayed when the control is empty */
  71274. get placeholderText(): string;
  71275. set placeholderText(value: string);
  71276. /** Gets or sets the dead key flag */
  71277. get deadKey(): boolean;
  71278. set deadKey(flag: boolean);
  71279. /** Gets or sets the highlight text */
  71280. get highlightedText(): string;
  71281. set highlightedText(text: string);
  71282. /** Gets or sets if the current key should be added */
  71283. get addKey(): boolean;
  71284. set addKey(flag: boolean);
  71285. /** Gets or sets the value of the current key being entered */
  71286. get currentKey(): string;
  71287. set currentKey(key: string);
  71288. /** Gets or sets the text displayed in the control */
  71289. get text(): string;
  71290. set text(value: string);
  71291. /** Gets or sets control width */
  71292. get width(): string | number;
  71293. set width(value: string | number);
  71294. /**
  71295. * Creates a new InputText
  71296. * @param name defines the control name
  71297. * @param text defines the text of the control
  71298. */
  71299. constructor(name?: string | undefined, text?: string);
  71300. /** @hidden */
  71301. onBlur(): void;
  71302. /** @hidden */
  71303. onFocus(): void;
  71304. protected _getTypeName(): string;
  71305. /**
  71306. * Function called to get the list of controls that should not steal the focus from this control
  71307. * @returns an array of controls
  71308. */
  71309. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  71310. /** @hidden */
  71311. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  71312. /** @hidden */
  71313. private _updateValueFromCursorIndex;
  71314. /** @hidden */
  71315. private _processDblClick;
  71316. /** @hidden */
  71317. private _selectAllText;
  71318. /**
  71319. * Handles the keyboard event
  71320. * @param evt Defines the KeyboardEvent
  71321. */
  71322. processKeyboard(evt: KeyboardEvent): void;
  71323. /** @hidden */
  71324. private _onCopyText;
  71325. /** @hidden */
  71326. private _onCutText;
  71327. /** @hidden */
  71328. private _onPasteText;
  71329. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  71330. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  71331. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  71332. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  71333. protected _beforeRenderText(text: string): string;
  71334. dispose(): void;
  71335. }
  71336. }
  71337. declare module BABYLON.GUI {
  71338. /**
  71339. * Class used to create a 2D grid container
  71340. */
  71341. export class Grid extends Container {
  71342. name?: string | undefined;
  71343. private _rowDefinitions;
  71344. private _columnDefinitions;
  71345. private _cells;
  71346. private _childControls;
  71347. /**
  71348. * Gets the number of columns
  71349. */
  71350. get columnCount(): number;
  71351. /**
  71352. * Gets the number of rows
  71353. */
  71354. get rowCount(): number;
  71355. /** Gets the list of children */
  71356. get children(): Control[];
  71357. /** Gets the list of cells (e.g. the containers) */
  71358. get cells(): {
  71359. [key: string]: Container;
  71360. };
  71361. /**
  71362. * Gets the definition of a specific row
  71363. * @param index defines the index of the row
  71364. * @returns the row definition
  71365. */
  71366. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  71367. /**
  71368. * Gets the definition of a specific column
  71369. * @param index defines the index of the column
  71370. * @returns the column definition
  71371. */
  71372. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  71373. /**
  71374. * Adds a new row to the grid
  71375. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  71376. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  71377. * @returns the current grid
  71378. */
  71379. addRowDefinition(height: number, isPixel?: boolean): Grid;
  71380. /**
  71381. * Adds a new column to the grid
  71382. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  71383. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  71384. * @returns the current grid
  71385. */
  71386. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  71387. /**
  71388. * Update a row definition
  71389. * @param index defines the index of the row to update
  71390. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  71391. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  71392. * @returns the current grid
  71393. */
  71394. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  71395. /**
  71396. * Update a column definition
  71397. * @param index defines the index of the column to update
  71398. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  71399. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  71400. * @returns the current grid
  71401. */
  71402. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  71403. /**
  71404. * Gets the list of children stored in a specific cell
  71405. * @param row defines the row to check
  71406. * @param column defines the column to check
  71407. * @returns the list of controls
  71408. */
  71409. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  71410. /**
  71411. * Gets a string representing the child cell info (row x column)
  71412. * @param child defines the control to get info from
  71413. * @returns a string containing the child cell info (row x column)
  71414. */
  71415. getChildCellInfo(child: Control): string;
  71416. private _removeCell;
  71417. private _offsetCell;
  71418. /**
  71419. * Remove a column definition at specified index
  71420. * @param index defines the index of the column to remove
  71421. * @returns the current grid
  71422. */
  71423. removeColumnDefinition(index: number): Grid;
  71424. /**
  71425. * Remove a row definition at specified index
  71426. * @param index defines the index of the row to remove
  71427. * @returns the current grid
  71428. */
  71429. removeRowDefinition(index: number): Grid;
  71430. /**
  71431. * Adds a new control to the current grid
  71432. * @param control defines the control to add
  71433. * @param row defines the row where to add the control (0 by default)
  71434. * @param column defines the column where to add the control (0 by default)
  71435. * @returns the current grid
  71436. */
  71437. addControl(control: Control, row?: number, column?: number): Grid;
  71438. /**
  71439. * Removes a control from the current container
  71440. * @param control defines the control to remove
  71441. * @returns the current container
  71442. */
  71443. removeControl(control: Control): Container;
  71444. /**
  71445. * Creates a new Grid
  71446. * @param name defines control name
  71447. */
  71448. constructor(name?: string | undefined);
  71449. protected _getTypeName(): string;
  71450. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  71451. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71452. _flagDescendantsAsMatrixDirty(): void;
  71453. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  71454. /** Releases associated resources */
  71455. dispose(): void;
  71456. }
  71457. }
  71458. declare module BABYLON.GUI {
  71459. /** Class used to create color pickers */
  71460. export class ColorPicker extends Control {
  71461. name?: string | undefined;
  71462. private static _Epsilon;
  71463. private _colorWheelCanvas;
  71464. private _value;
  71465. private _tmpColor;
  71466. private _pointerStartedOnSquare;
  71467. private _pointerStartedOnWheel;
  71468. private _squareLeft;
  71469. private _squareTop;
  71470. private _squareSize;
  71471. private _h;
  71472. private _s;
  71473. private _v;
  71474. private _lastPointerDownID;
  71475. /**
  71476. * BABYLON.Observable raised when the value changes
  71477. */
  71478. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  71479. /** Gets or sets the color of the color picker */
  71480. get value(): BABYLON.Color3;
  71481. set value(value: BABYLON.Color3);
  71482. /**
  71483. * Gets or sets control width
  71484. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71485. */
  71486. get width(): string | number;
  71487. set width(value: string | number);
  71488. /**
  71489. * Gets or sets control height
  71490. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  71491. */
  71492. get height(): string | number;
  71493. /** Gets or sets control height */
  71494. set height(value: string | number);
  71495. /** Gets or sets control size */
  71496. get size(): string | number;
  71497. set size(value: string | number);
  71498. /**
  71499. * Creates a new ColorPicker
  71500. * @param name defines the control name
  71501. */
  71502. constructor(name?: string | undefined);
  71503. protected _getTypeName(): string;
  71504. /** @hidden */
  71505. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71506. private _updateSquareProps;
  71507. private _drawGradientSquare;
  71508. private _drawCircle;
  71509. private _createColorWheelCanvas;
  71510. /** @hidden */
  71511. _draw(context: CanvasRenderingContext2D): void;
  71512. private _pointerIsDown;
  71513. private _updateValueFromPointer;
  71514. private _isPointOnSquare;
  71515. private _isPointOnWheel;
  71516. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  71517. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  71518. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  71519. /**
  71520. * This function expands the color picker by creating a color picker dialog with manual
  71521. * color value input and the ability to save colors into an array to be used later in
  71522. * subsequent launches of the dialogue.
  71523. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  71524. * @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.
  71525. * @returns picked color as a hex string and the saved colors array as hex strings.
  71526. */
  71527. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  71528. pickerWidth?: string;
  71529. pickerHeight?: string;
  71530. headerHeight?: string;
  71531. lastColor?: string;
  71532. swatchLimit?: number;
  71533. numSwatchesPerLine?: number;
  71534. savedColors?: Array<string>;
  71535. }): Promise<{
  71536. savedColors?: string[];
  71537. pickedColor: string;
  71538. }>;
  71539. }
  71540. }
  71541. declare module BABYLON.GUI {
  71542. /** Class used to create 2D ellipse containers */
  71543. export class Ellipse extends Container {
  71544. name?: string | undefined;
  71545. private _thickness;
  71546. /** Gets or sets border thickness */
  71547. get thickness(): number;
  71548. set thickness(value: number);
  71549. /**
  71550. * Creates a new Ellipse
  71551. * @param name defines the control name
  71552. */
  71553. constructor(name?: string | undefined);
  71554. protected _getTypeName(): string;
  71555. protected _localDraw(context: CanvasRenderingContext2D): void;
  71556. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71557. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  71558. }
  71559. }
  71560. declare module BABYLON.GUI {
  71561. /**
  71562. * Class used to create a password control
  71563. */
  71564. export class InputPassword extends InputText {
  71565. protected _beforeRenderText(text: string): string;
  71566. }
  71567. }
  71568. declare module BABYLON.GUI {
  71569. /** Class used to render 2D lines */
  71570. export class Line extends Control {
  71571. name?: string | undefined;
  71572. private _lineWidth;
  71573. private _x1;
  71574. private _y1;
  71575. private _x2;
  71576. private _y2;
  71577. private _dash;
  71578. private _connectedControl;
  71579. private _connectedControlDirtyObserver;
  71580. /** Gets or sets the dash pattern */
  71581. get dash(): Array<number>;
  71582. set dash(value: Array<number>);
  71583. /** Gets or sets the control connected with the line end */
  71584. get connectedControl(): Control;
  71585. set connectedControl(value: Control);
  71586. /** Gets or sets start coordinates on X axis */
  71587. get x1(): string | number;
  71588. set x1(value: string | number);
  71589. /** Gets or sets start coordinates on Y axis */
  71590. get y1(): string | number;
  71591. set y1(value: string | number);
  71592. /** Gets or sets end coordinates on X axis */
  71593. get x2(): string | number;
  71594. set x2(value: string | number);
  71595. /** Gets or sets end coordinates on Y axis */
  71596. get y2(): string | number;
  71597. set y2(value: string | number);
  71598. /** Gets or sets line width */
  71599. get lineWidth(): number;
  71600. set lineWidth(value: number);
  71601. /** Gets or sets horizontal alignment */
  71602. set horizontalAlignment(value: number);
  71603. /** Gets or sets vertical alignment */
  71604. set verticalAlignment(value: number);
  71605. private get _effectiveX2();
  71606. private get _effectiveY2();
  71607. /**
  71608. * Creates a new Line
  71609. * @param name defines the control name
  71610. */
  71611. constructor(name?: string | undefined);
  71612. protected _getTypeName(): string;
  71613. _draw(context: CanvasRenderingContext2D): void;
  71614. _measure(): void;
  71615. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71616. /**
  71617. * Move one end of the line given 3D cartesian coordinates.
  71618. * @param position Targeted world position
  71619. * @param scene BABYLON.Scene
  71620. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  71621. */
  71622. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  71623. /**
  71624. * Move one end of the line to a position in screen absolute space.
  71625. * @param projectedPosition Position in screen absolute space (X, Y)
  71626. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  71627. */
  71628. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  71629. }
  71630. }
  71631. declare module BABYLON.GUI {
  71632. /**
  71633. * Class used to store a point for a MultiLine object.
  71634. * The point can be pure 2D coordinates, a mesh or a control
  71635. */
  71636. export class MultiLinePoint {
  71637. private _multiLine;
  71638. private _x;
  71639. private _y;
  71640. private _control;
  71641. private _mesh;
  71642. private _controlObserver;
  71643. private _meshObserver;
  71644. /** @hidden */
  71645. _point: BABYLON.Vector2;
  71646. /**
  71647. * Creates a new MultiLinePoint
  71648. * @param multiLine defines the source MultiLine object
  71649. */
  71650. constructor(multiLine: MultiLine);
  71651. /** Gets or sets x coordinate */
  71652. get x(): string | number;
  71653. set x(value: string | number);
  71654. /** Gets or sets y coordinate */
  71655. get y(): string | number;
  71656. set y(value: string | number);
  71657. /** Gets or sets the control associated with this point */
  71658. get control(): BABYLON.Nullable<Control>;
  71659. set control(value: BABYLON.Nullable<Control>);
  71660. /** Gets or sets the mesh associated with this point */
  71661. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  71662. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  71663. /** Resets links */
  71664. resetLinks(): void;
  71665. /**
  71666. * Gets a translation vector
  71667. * @returns the translation vector
  71668. */
  71669. translate(): BABYLON.Vector2;
  71670. private _translatePoint;
  71671. /** Release associated resources */
  71672. dispose(): void;
  71673. }
  71674. }
  71675. declare module BABYLON.GUI {
  71676. /**
  71677. * Class used to create multi line control
  71678. */
  71679. export class MultiLine extends Control {
  71680. name?: string | undefined;
  71681. private _lineWidth;
  71682. private _dash;
  71683. private _points;
  71684. private _minX;
  71685. private _minY;
  71686. private _maxX;
  71687. private _maxY;
  71688. /**
  71689. * Creates a new MultiLine
  71690. * @param name defines the control name
  71691. */
  71692. constructor(name?: string | undefined);
  71693. /** Gets or sets dash pattern */
  71694. get dash(): Array<number>;
  71695. set dash(value: Array<number>);
  71696. /**
  71697. * Gets point stored at specified index
  71698. * @param index defines the index to look for
  71699. * @returns the requested point if found
  71700. */
  71701. getAt(index: number): MultiLinePoint;
  71702. /** Function called when a point is updated */
  71703. onPointUpdate: () => void;
  71704. /**
  71705. * Adds new points to the point collection
  71706. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  71707. * @returns the list of created MultiLinePoint
  71708. */
  71709. add(...items: (AbstractMesh | Control | {
  71710. x: string | number;
  71711. y: string | number;
  71712. })[]): MultiLinePoint[];
  71713. /**
  71714. * Adds a new point to the point collection
  71715. * @param item defines the item (mesh, control or 2d coordiantes) to add
  71716. * @returns the created MultiLinePoint
  71717. */
  71718. push(item?: (AbstractMesh | Control | {
  71719. x: string | number;
  71720. y: string | number;
  71721. })): MultiLinePoint;
  71722. /**
  71723. * Remove a specific value or point from the active point collection
  71724. * @param value defines the value or point to remove
  71725. */
  71726. remove(value: number | MultiLinePoint): void;
  71727. /**
  71728. * Resets this object to initial state (no point)
  71729. */
  71730. reset(): void;
  71731. /**
  71732. * Resets all links
  71733. */
  71734. resetLinks(): void;
  71735. /** Gets or sets line width */
  71736. get lineWidth(): number;
  71737. set lineWidth(value: number);
  71738. set horizontalAlignment(value: number);
  71739. set verticalAlignment(value: number);
  71740. protected _getTypeName(): string;
  71741. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  71742. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71743. _measure(): void;
  71744. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71745. dispose(): void;
  71746. }
  71747. }
  71748. declare module BABYLON.GUI {
  71749. /**
  71750. * Class used to create radio button controls
  71751. */
  71752. export class RadioButton extends Control {
  71753. name?: string | undefined;
  71754. private _isChecked;
  71755. private _background;
  71756. private _checkSizeRatio;
  71757. private _thickness;
  71758. /** Gets or sets border thickness */
  71759. get thickness(): number;
  71760. set thickness(value: number);
  71761. /** Gets or sets group name */
  71762. group: string;
  71763. /** BABYLON.Observable raised when isChecked is changed */
  71764. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  71765. /** Gets or sets a value indicating the ratio between overall size and check size */
  71766. get checkSizeRatio(): number;
  71767. set checkSizeRatio(value: number);
  71768. /** Gets or sets background color */
  71769. get background(): string;
  71770. set background(value: string);
  71771. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  71772. get isChecked(): boolean;
  71773. set isChecked(value: boolean);
  71774. /**
  71775. * Creates a new RadioButton
  71776. * @param name defines the control name
  71777. */
  71778. constructor(name?: string | undefined);
  71779. protected _getTypeName(): string;
  71780. _draw(context: CanvasRenderingContext2D): void;
  71781. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  71782. /**
  71783. * Utility function to easily create a radio button with a header
  71784. * @param title defines the label to use for the header
  71785. * @param group defines the group to use for the radio button
  71786. * @param isChecked defines the initial state of the radio button
  71787. * @param onValueChanged defines the callback to call when value changes
  71788. * @returns a StackPanel containing the radio button and a textBlock
  71789. */
  71790. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  71791. }
  71792. }
  71793. declare module BABYLON.GUI {
  71794. /**
  71795. * Class used to create slider controls
  71796. */
  71797. export class BaseSlider extends Control {
  71798. name?: string | undefined;
  71799. protected _thumbWidth: ValueAndUnit;
  71800. private _minimum;
  71801. private _maximum;
  71802. private _value;
  71803. private _isVertical;
  71804. protected _barOffset: ValueAndUnit;
  71805. private _isThumbClamped;
  71806. protected _displayThumb: boolean;
  71807. private _step;
  71808. private _lastPointerDownID;
  71809. protected _effectiveBarOffset: number;
  71810. protected _renderLeft: number;
  71811. protected _renderTop: number;
  71812. protected _renderWidth: number;
  71813. protected _renderHeight: number;
  71814. protected _backgroundBoxLength: number;
  71815. protected _backgroundBoxThickness: number;
  71816. protected _effectiveThumbThickness: number;
  71817. /** BABYLON.Observable raised when the sldier value changes */
  71818. onValueChangedObservable: BABYLON.Observable<number>;
  71819. /** Gets or sets a boolean indicating if the thumb must be rendered */
  71820. get displayThumb(): boolean;
  71821. set displayThumb(value: boolean);
  71822. /** Gets or sets a step to apply to values (0 by default) */
  71823. get step(): number;
  71824. set step(value: number);
  71825. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  71826. get barOffset(): string | number;
  71827. /** Gets main bar offset in pixels*/
  71828. get barOffsetInPixels(): number;
  71829. set barOffset(value: string | number);
  71830. /** Gets or sets thumb width */
  71831. get thumbWidth(): string | number;
  71832. /** Gets thumb width in pixels */
  71833. get thumbWidthInPixels(): number;
  71834. set thumbWidth(value: string | number);
  71835. /** Gets or sets minimum value */
  71836. get minimum(): number;
  71837. set minimum(value: number);
  71838. /** Gets or sets maximum value */
  71839. get maximum(): number;
  71840. set maximum(value: number);
  71841. /** Gets or sets current value */
  71842. get value(): number;
  71843. set value(value: number);
  71844. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  71845. get isVertical(): boolean;
  71846. set isVertical(value: boolean);
  71847. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  71848. get isThumbClamped(): boolean;
  71849. set isThumbClamped(value: boolean);
  71850. /**
  71851. * Creates a new BaseSlider
  71852. * @param name defines the control name
  71853. */
  71854. constructor(name?: string | undefined);
  71855. protected _getTypeName(): string;
  71856. protected _getThumbPosition(): number;
  71857. protected _getThumbThickness(type: string): number;
  71858. protected _prepareRenderingData(type: string): void;
  71859. private _pointerIsDown;
  71860. /** @hidden */
  71861. protected _updateValueFromPointer(x: number, y: number): void;
  71862. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  71863. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  71864. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  71865. }
  71866. }
  71867. declare module BABYLON.GUI {
  71868. /**
  71869. * Class used to create slider controls
  71870. */
  71871. export class Slider extends BaseSlider {
  71872. name?: string | undefined;
  71873. private _background;
  71874. private _borderColor;
  71875. private _isThumbCircle;
  71876. protected _displayValueBar: boolean;
  71877. /** Gets or sets a boolean indicating if the value bar must be rendered */
  71878. get displayValueBar(): boolean;
  71879. set displayValueBar(value: boolean);
  71880. /** Gets or sets border color */
  71881. get borderColor(): string;
  71882. set borderColor(value: string);
  71883. /** Gets or sets background color */
  71884. get background(): string;
  71885. set background(value: string);
  71886. /** Gets or sets a boolean indicating if the thumb should be round or square */
  71887. get isThumbCircle(): boolean;
  71888. set isThumbCircle(value: boolean);
  71889. /**
  71890. * Creates a new Slider
  71891. * @param name defines the control name
  71892. */
  71893. constructor(name?: string | undefined);
  71894. protected _getTypeName(): string;
  71895. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  71896. }
  71897. }
  71898. declare module BABYLON.GUI {
  71899. /** Class used to create a RadioGroup
  71900. * which contains groups of radio buttons
  71901. */
  71902. export class SelectorGroup {
  71903. /** name of SelectorGroup */
  71904. name: string;
  71905. private _groupPanel;
  71906. private _selectors;
  71907. private _groupHeader;
  71908. /**
  71909. * Creates a new SelectorGroup
  71910. * @param name of group, used as a group heading
  71911. */
  71912. constructor(
  71913. /** name of SelectorGroup */
  71914. name: string);
  71915. /** Gets the groupPanel of the SelectorGroup */
  71916. get groupPanel(): StackPanel;
  71917. /** Gets the selectors array */
  71918. get selectors(): StackPanel[];
  71919. /** Gets and sets the group header */
  71920. get header(): string;
  71921. set header(label: string);
  71922. /** @hidden */
  71923. private _addGroupHeader;
  71924. /** @hidden*/
  71925. _getSelector(selectorNb: number): StackPanel | undefined;
  71926. /** Removes the selector at the given position
  71927. * @param selectorNb the position of the selector within the group
  71928. */
  71929. removeSelector(selectorNb: number): void;
  71930. }
  71931. /** Class used to create a CheckboxGroup
  71932. * which contains groups of checkbox buttons
  71933. */
  71934. export class CheckboxGroup extends SelectorGroup {
  71935. /** Adds a checkbox as a control
  71936. * @param text is the label for the selector
  71937. * @param func is the function called when the Selector is checked
  71938. * @param checked is true when Selector is checked
  71939. */
  71940. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  71941. /** @hidden */
  71942. _setSelectorLabel(selectorNb: number, label: string): void;
  71943. /** @hidden */
  71944. _setSelectorLabelColor(selectorNb: number, color: string): void;
  71945. /** @hidden */
  71946. _setSelectorButtonColor(selectorNb: number, color: string): void;
  71947. /** @hidden */
  71948. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  71949. }
  71950. /** Class used to create a RadioGroup
  71951. * which contains groups of radio buttons
  71952. */
  71953. export class RadioGroup extends SelectorGroup {
  71954. private _selectNb;
  71955. /** Adds a radio button as a control
  71956. * @param label is the label for the selector
  71957. * @param func is the function called when the Selector is checked
  71958. * @param checked is true when Selector is checked
  71959. */
  71960. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  71961. /** @hidden */
  71962. _setSelectorLabel(selectorNb: number, label: string): void;
  71963. /** @hidden */
  71964. _setSelectorLabelColor(selectorNb: number, color: string): void;
  71965. /** @hidden */
  71966. _setSelectorButtonColor(selectorNb: number, color: string): void;
  71967. /** @hidden */
  71968. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  71969. }
  71970. /** Class used to create a SliderGroup
  71971. * which contains groups of slider buttons
  71972. */
  71973. export class SliderGroup extends SelectorGroup {
  71974. /**
  71975. * Adds a slider to the SelectorGroup
  71976. * @param label is the label for the SliderBar
  71977. * @param func is the function called when the Slider moves
  71978. * @param unit is a string describing the units used, eg degrees or metres
  71979. * @param min is the minimum value for the Slider
  71980. * @param max is the maximum value for the Slider
  71981. * @param value is the start value for the Slider between min and max
  71982. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  71983. */
  71984. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  71985. /** @hidden */
  71986. _setSelectorLabel(selectorNb: number, label: string): void;
  71987. /** @hidden */
  71988. _setSelectorLabelColor(selectorNb: number, color: string): void;
  71989. /** @hidden */
  71990. _setSelectorButtonColor(selectorNb: number, color: string): void;
  71991. /** @hidden */
  71992. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  71993. }
  71994. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  71995. * @see http://doc.babylonjs.com/how_to/selector
  71996. */
  71997. export class SelectionPanel extends Rectangle {
  71998. /** name of SelectionPanel */
  71999. name: string;
  72000. /** an array of SelectionGroups */
  72001. groups: SelectorGroup[];
  72002. private _panel;
  72003. private _buttonColor;
  72004. private _buttonBackground;
  72005. private _headerColor;
  72006. private _barColor;
  72007. private _barHeight;
  72008. private _spacerHeight;
  72009. private _labelColor;
  72010. private _groups;
  72011. private _bars;
  72012. /**
  72013. * Creates a new SelectionPanel
  72014. * @param name of SelectionPanel
  72015. * @param groups is an array of SelectionGroups
  72016. */
  72017. constructor(
  72018. /** name of SelectionPanel */
  72019. name: string,
  72020. /** an array of SelectionGroups */
  72021. groups?: SelectorGroup[]);
  72022. protected _getTypeName(): string;
  72023. /** Gets or sets the headerColor */
  72024. get headerColor(): string;
  72025. set headerColor(color: string);
  72026. private _setHeaderColor;
  72027. /** Gets or sets the button color */
  72028. get buttonColor(): string;
  72029. set buttonColor(color: string);
  72030. private _setbuttonColor;
  72031. /** Gets or sets the label color */
  72032. get labelColor(): string;
  72033. set labelColor(color: string);
  72034. private _setLabelColor;
  72035. /** Gets or sets the button background */
  72036. get buttonBackground(): string;
  72037. set buttonBackground(color: string);
  72038. private _setButtonBackground;
  72039. /** Gets or sets the color of separator bar */
  72040. get barColor(): string;
  72041. set barColor(color: string);
  72042. private _setBarColor;
  72043. /** Gets or sets the height of separator bar */
  72044. get barHeight(): string;
  72045. set barHeight(value: string);
  72046. private _setBarHeight;
  72047. /** Gets or sets the height of spacers*/
  72048. get spacerHeight(): string;
  72049. set spacerHeight(value: string);
  72050. private _setSpacerHeight;
  72051. /** Adds a bar between groups */
  72052. private _addSpacer;
  72053. /** Add a group to the selection panel
  72054. * @param group is the selector group to add
  72055. */
  72056. addGroup(group: SelectorGroup): void;
  72057. /** Remove the group from the given position
  72058. * @param groupNb is the position of the group in the list
  72059. */
  72060. removeGroup(groupNb: number): void;
  72061. /** Change a group header label
  72062. * @param label is the new group header label
  72063. * @param groupNb is the number of the group to relabel
  72064. * */
  72065. setHeaderName(label: string, groupNb: number): void;
  72066. /** Change selector label to the one given
  72067. * @param label is the new selector label
  72068. * @param groupNb is the number of the groupcontaining the selector
  72069. * @param selectorNb is the number of the selector within a group to relabel
  72070. * */
  72071. relabel(label: string, groupNb: number, selectorNb: number): void;
  72072. /** For a given group position remove the selector at the given position
  72073. * @param groupNb is the number of the group to remove the selector from
  72074. * @param selectorNb is the number of the selector within the group
  72075. */
  72076. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  72077. /** For a given group position of correct type add a checkbox button
  72078. * @param groupNb is the number of the group to remove the selector from
  72079. * @param label is the label for the selector
  72080. * @param func is the function called when the Selector is checked
  72081. * @param checked is true when Selector is checked
  72082. */
  72083. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  72084. /** For a given group position of correct type add a radio button
  72085. * @param groupNb is the number of the group to remove the selector from
  72086. * @param label is the label for the selector
  72087. * @param func is the function called when the Selector is checked
  72088. * @param checked is true when Selector is checked
  72089. */
  72090. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  72091. /**
  72092. * For a given slider group add a slider
  72093. * @param groupNb is the number of the group to add the slider to
  72094. * @param label is the label for the Slider
  72095. * @param func is the function called when the Slider moves
  72096. * @param unit is a string describing the units used, eg degrees or metres
  72097. * @param min is the minimum value for the Slider
  72098. * @param max is the maximum value for the Slider
  72099. * @param value is the start value for the Slider between min and max
  72100. * @param onVal is the function used to format the value displayed, eg radians to degrees
  72101. */
  72102. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  72103. }
  72104. }
  72105. declare module BABYLON.GUI {
  72106. /**
  72107. * Class used to hold a the container for ScrollViewer
  72108. * @hidden
  72109. */
  72110. export class _ScrollViewerWindow extends Container {
  72111. parentClientWidth: number;
  72112. parentClientHeight: number;
  72113. /**
  72114. * Creates a new ScrollViewerWindow
  72115. * @param name of ScrollViewerWindow
  72116. */
  72117. constructor(name?: string);
  72118. protected _getTypeName(): string;
  72119. /** @hidden */
  72120. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72121. protected _postMeasure(): void;
  72122. }
  72123. }
  72124. declare module BABYLON.GUI {
  72125. /**
  72126. * Class used to create slider controls
  72127. */
  72128. export class ScrollBar extends BaseSlider {
  72129. name?: string | undefined;
  72130. private _background;
  72131. private _borderColor;
  72132. private _tempMeasure;
  72133. /** Gets or sets border color */
  72134. get borderColor(): string;
  72135. set borderColor(value: string);
  72136. /** Gets or sets background color */
  72137. get background(): string;
  72138. set background(value: string);
  72139. /**
  72140. * Creates a new Slider
  72141. * @param name defines the control name
  72142. */
  72143. constructor(name?: string | undefined);
  72144. protected _getTypeName(): string;
  72145. protected _getThumbThickness(): number;
  72146. _draw(context: CanvasRenderingContext2D): void;
  72147. private _first;
  72148. private _originX;
  72149. private _originY;
  72150. /** @hidden */
  72151. protected _updateValueFromPointer(x: number, y: number): void;
  72152. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72153. }
  72154. }
  72155. declare module BABYLON.GUI {
  72156. /**
  72157. * Class used to create slider controls
  72158. */
  72159. export class ImageScrollBar extends BaseSlider {
  72160. name?: string | undefined;
  72161. private _backgroundBaseImage;
  72162. private _backgroundImage;
  72163. private _thumbImage;
  72164. private _thumbBaseImage;
  72165. private _thumbLength;
  72166. private _thumbHeight;
  72167. private _barImageHeight;
  72168. private _tempMeasure;
  72169. /**
  72170. * Gets or sets the image used to render the background for horizontal bar
  72171. */
  72172. get backgroundImage(): Image;
  72173. set backgroundImage(value: Image);
  72174. /**
  72175. * Gets or sets the image used to render the thumb
  72176. */
  72177. get thumbImage(): Image;
  72178. set thumbImage(value: Image);
  72179. /**
  72180. * Gets or sets the length of the thumb
  72181. */
  72182. get thumbLength(): number;
  72183. set thumbLength(value: number);
  72184. /**
  72185. * Gets or sets the height of the thumb
  72186. */
  72187. get thumbHeight(): number;
  72188. set thumbHeight(value: number);
  72189. /**
  72190. * Gets or sets the height of the bar image
  72191. */
  72192. get barImageHeight(): number;
  72193. set barImageHeight(value: number);
  72194. /**
  72195. * Creates a new ImageScrollBar
  72196. * @param name defines the control name
  72197. */
  72198. constructor(name?: string | undefined);
  72199. protected _getTypeName(): string;
  72200. protected _getThumbThickness(): number;
  72201. _draw(context: CanvasRenderingContext2D): void;
  72202. private _first;
  72203. private _originX;
  72204. private _originY;
  72205. /** @hidden */
  72206. protected _updateValueFromPointer(x: number, y: number): void;
  72207. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72208. }
  72209. }
  72210. declare module BABYLON.GUI {
  72211. /**
  72212. * Class used to hold a viewer window and sliders in a grid
  72213. */
  72214. export class ScrollViewer extends Rectangle {
  72215. private _grid;
  72216. private _horizontalBarSpace;
  72217. private _verticalBarSpace;
  72218. private _dragSpace;
  72219. private _horizontalBar;
  72220. private _verticalBar;
  72221. private _barColor;
  72222. private _barBackground;
  72223. private _barImage;
  72224. private _barBackgroundImage;
  72225. private _barSize;
  72226. private _endLeft;
  72227. private _endTop;
  72228. private _window;
  72229. private _pointerIsOver;
  72230. private _wheelPrecision;
  72231. private _onPointerObserver;
  72232. private _clientWidth;
  72233. private _clientHeight;
  72234. private _useImageBar;
  72235. private _thumbLength;
  72236. private _thumbHeight;
  72237. private _barImageHeight;
  72238. /**
  72239. * Gets the horizontal scrollbar
  72240. */
  72241. get horizontalBar(): ScrollBar | ImageScrollBar;
  72242. /**
  72243. * Gets the vertical scrollbar
  72244. */
  72245. get verticalBar(): ScrollBar | ImageScrollBar;
  72246. /**
  72247. * Adds a new control to the current container
  72248. * @param control defines the control to add
  72249. * @returns the current container
  72250. */
  72251. addControl(control: BABYLON.Nullable<Control>): Container;
  72252. /**
  72253. * Removes a control from the current container
  72254. * @param control defines the control to remove
  72255. * @returns the current container
  72256. */
  72257. removeControl(control: Control): Container;
  72258. /** Gets the list of children */
  72259. get children(): Control[];
  72260. _flagDescendantsAsMatrixDirty(): void;
  72261. /**
  72262. * Creates a new ScrollViewer
  72263. * @param name of ScrollViewer
  72264. */
  72265. constructor(name?: string, isImageBased?: boolean);
  72266. /** Reset the scroll viewer window to initial size */
  72267. resetWindow(): void;
  72268. protected _getTypeName(): string;
  72269. private _buildClientSizes;
  72270. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72271. protected _postMeasure(): void;
  72272. /**
  72273. * Gets or sets the mouse wheel precision
  72274. * from 0 to 1 with a default value of 0.05
  72275. * */
  72276. get wheelPrecision(): number;
  72277. set wheelPrecision(value: number);
  72278. /** Gets or sets the scroll bar container background color */
  72279. get scrollBackground(): string;
  72280. set scrollBackground(color: string);
  72281. /** Gets or sets the bar color */
  72282. get barColor(): string;
  72283. set barColor(color: string);
  72284. /** Gets or sets the bar image */
  72285. get thumbImage(): Image;
  72286. set thumbImage(value: Image);
  72287. /** Gets or sets the size of the bar */
  72288. get barSize(): number;
  72289. set barSize(value: number);
  72290. /** Gets or sets the length of the thumb */
  72291. get thumbLength(): number;
  72292. set thumbLength(value: number);
  72293. /** Gets or sets the height of the thumb */
  72294. get thumbHeight(): number;
  72295. set thumbHeight(value: number);
  72296. /** Gets or sets the height of the bar image */
  72297. get barImageHeight(): number;
  72298. set barImageHeight(value: number);
  72299. /** Gets or sets the bar background */
  72300. get barBackground(): string;
  72301. set barBackground(color: string);
  72302. /** Gets or sets the bar background image */
  72303. get barImage(): Image;
  72304. set barImage(value: Image);
  72305. /** @hidden */
  72306. private _updateScroller;
  72307. _link(host: AdvancedDynamicTexture): void;
  72308. /** @hidden */
  72309. private _addBar;
  72310. /** @hidden */
  72311. private _attachWheel;
  72312. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  72313. /** Releases associated resources */
  72314. dispose(): void;
  72315. }
  72316. }
  72317. declare module BABYLON.GUI {
  72318. /** Class used to render a grid */
  72319. export class DisplayGrid extends Control {
  72320. name?: string | undefined;
  72321. private _cellWidth;
  72322. private _cellHeight;
  72323. private _minorLineTickness;
  72324. private _minorLineColor;
  72325. private _majorLineTickness;
  72326. private _majorLineColor;
  72327. private _majorLineFrequency;
  72328. private _background;
  72329. private _displayMajorLines;
  72330. private _displayMinorLines;
  72331. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  72332. get displayMinorLines(): boolean;
  72333. set displayMinorLines(value: boolean);
  72334. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  72335. get displayMajorLines(): boolean;
  72336. set displayMajorLines(value: boolean);
  72337. /** Gets or sets background color (Black by default) */
  72338. get background(): string;
  72339. set background(value: string);
  72340. /** Gets or sets the width of each cell (20 by default) */
  72341. get cellWidth(): number;
  72342. set cellWidth(value: number);
  72343. /** Gets or sets the height of each cell (20 by default) */
  72344. get cellHeight(): number;
  72345. set cellHeight(value: number);
  72346. /** Gets or sets the tickness of minor lines (1 by default) */
  72347. get minorLineTickness(): number;
  72348. set minorLineTickness(value: number);
  72349. /** Gets or sets the color of minor lines (DarkGray by default) */
  72350. get minorLineColor(): string;
  72351. set minorLineColor(value: string);
  72352. /** Gets or sets the tickness of major lines (2 by default) */
  72353. get majorLineTickness(): number;
  72354. set majorLineTickness(value: number);
  72355. /** Gets or sets the color of major lines (White by default) */
  72356. get majorLineColor(): string;
  72357. set majorLineColor(value: string);
  72358. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  72359. get majorLineFrequency(): number;
  72360. set majorLineFrequency(value: number);
  72361. /**
  72362. * Creates a new GridDisplayRectangle
  72363. * @param name defines the control name
  72364. */
  72365. constructor(name?: string | undefined);
  72366. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72367. protected _getTypeName(): string;
  72368. }
  72369. }
  72370. declare module BABYLON.GUI {
  72371. /**
  72372. * Class used to create slider controls based on images
  72373. */
  72374. export class ImageBasedSlider extends BaseSlider {
  72375. name?: string | undefined;
  72376. private _backgroundImage;
  72377. private _thumbImage;
  72378. private _valueBarImage;
  72379. private _tempMeasure;
  72380. get displayThumb(): boolean;
  72381. set displayThumb(value: boolean);
  72382. /**
  72383. * Gets or sets the image used to render the background
  72384. */
  72385. get backgroundImage(): Image;
  72386. set backgroundImage(value: Image);
  72387. /**
  72388. * Gets or sets the image used to render the value bar
  72389. */
  72390. get valueBarImage(): Image;
  72391. set valueBarImage(value: Image);
  72392. /**
  72393. * Gets or sets the image used to render the thumb
  72394. */
  72395. get thumbImage(): Image;
  72396. set thumbImage(value: Image);
  72397. /**
  72398. * Creates a new ImageBasedSlider
  72399. * @param name defines the control name
  72400. */
  72401. constructor(name?: string | undefined);
  72402. protected _getTypeName(): string;
  72403. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72404. }
  72405. }
  72406. declare module BABYLON.GUI {
  72407. /**
  72408. * Forcing an export so that this code will execute
  72409. * @hidden
  72410. */
  72411. const name = "Statics";
  72412. }
  72413. declare module BABYLON.GUI {
  72414. /**
  72415. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  72416. */
  72417. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  72418. /**
  72419. * Define the instrumented AdvancedDynamicTexture.
  72420. */
  72421. texture: AdvancedDynamicTexture;
  72422. private _captureRenderTime;
  72423. private _renderTime;
  72424. private _captureLayoutTime;
  72425. private _layoutTime;
  72426. private _onBeginRenderObserver;
  72427. private _onEndRenderObserver;
  72428. private _onBeginLayoutObserver;
  72429. private _onEndLayoutObserver;
  72430. /**
  72431. * Gets the perf counter used to capture render time
  72432. */
  72433. get renderTimeCounter(): BABYLON.PerfCounter;
  72434. /**
  72435. * Gets the perf counter used to capture layout time
  72436. */
  72437. get layoutTimeCounter(): BABYLON.PerfCounter;
  72438. /**
  72439. * Enable or disable the render time capture
  72440. */
  72441. get captureRenderTime(): boolean;
  72442. set captureRenderTime(value: boolean);
  72443. /**
  72444. * Enable or disable the layout time capture
  72445. */
  72446. get captureLayoutTime(): boolean;
  72447. set captureLayoutTime(value: boolean);
  72448. /**
  72449. * Instantiates a new advanced dynamic texture instrumentation.
  72450. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  72451. * @param texture Defines the AdvancedDynamicTexture to instrument
  72452. */
  72453. constructor(
  72454. /**
  72455. * Define the instrumented AdvancedDynamicTexture.
  72456. */
  72457. texture: AdvancedDynamicTexture);
  72458. /**
  72459. * Dispose and release associated resources.
  72460. */
  72461. dispose(): void;
  72462. }
  72463. }
  72464. declare module BABYLON.GUI {
  72465. /**
  72466. * Class used to load GUI via XML.
  72467. */
  72468. export class XmlLoader {
  72469. private _nodes;
  72470. private _nodeTypes;
  72471. private _isLoaded;
  72472. private _objectAttributes;
  72473. private _parentClass;
  72474. /**
  72475. * Create a new xml loader
  72476. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  72477. */
  72478. constructor(parentClass?: null);
  72479. private _getChainElement;
  72480. private _getClassAttribute;
  72481. private _createGuiElement;
  72482. private _parseGrid;
  72483. private _parseElement;
  72484. private _prepareSourceElement;
  72485. private _parseElementsFromSource;
  72486. private _parseXml;
  72487. /**
  72488. * Gets if the loading has finished.
  72489. * @returns whether the loading has finished or not
  72490. */
  72491. isLoaded(): boolean;
  72492. /**
  72493. * Gets a loaded node / control by id.
  72494. * @param id the Controls id set in the xml
  72495. * @returns element of type Control
  72496. */
  72497. getNodeById(id: string): any;
  72498. /**
  72499. * Gets all loaded nodes / controls
  72500. * @returns Array of controls
  72501. */
  72502. getNodes(): any;
  72503. /**
  72504. * Initiates the xml layout loading
  72505. * @param xmlFile defines the xml layout to load
  72506. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  72507. * @param callback defines the callback called on layout load.
  72508. */
  72509. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  72510. }
  72511. }
  72512. declare module BABYLON.GUI {
  72513. /**
  72514. * Class used to create containers for controls
  72515. */
  72516. export class Container3D extends Control3D {
  72517. private _blockLayout;
  72518. /**
  72519. * Gets the list of child controls
  72520. */
  72521. protected _children: Control3D[];
  72522. /**
  72523. * Gets the list of child controls
  72524. */
  72525. get children(): Array<Control3D>;
  72526. /**
  72527. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  72528. * This is helpful to optimize layout operation when adding multiple children in a row
  72529. */
  72530. get blockLayout(): boolean;
  72531. set blockLayout(value: boolean);
  72532. /**
  72533. * Creates a new container
  72534. * @param name defines the container name
  72535. */
  72536. constructor(name?: string);
  72537. /**
  72538. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  72539. * @returns the current container
  72540. */
  72541. updateLayout(): Container3D;
  72542. /**
  72543. * Gets a boolean indicating if the given control is in the children of this control
  72544. * @param control defines the control to check
  72545. * @returns true if the control is in the child list
  72546. */
  72547. containsControl(control: Control3D): boolean;
  72548. /**
  72549. * Adds a control to the children of this control
  72550. * @param control defines the control to add
  72551. * @returns the current container
  72552. */
  72553. addControl(control: Control3D): Container3D;
  72554. /**
  72555. * This function will be called everytime a new control is added
  72556. */
  72557. protected _arrangeChildren(): void;
  72558. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  72559. /**
  72560. * Removes a control from the children of this control
  72561. * @param control defines the control to remove
  72562. * @returns the current container
  72563. */
  72564. removeControl(control: Control3D): Container3D;
  72565. protected _getTypeName(): string;
  72566. /**
  72567. * Releases all associated resources
  72568. */
  72569. dispose(): void;
  72570. /** Control rotation will remain unchanged */
  72571. static readonly UNSET_ORIENTATION: number;
  72572. /** Control will rotate to make it look at sphere central axis */
  72573. static readonly FACEORIGIN_ORIENTATION: number;
  72574. /** Control will rotate to make it look back at sphere central axis */
  72575. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  72576. /** Control will rotate to look at z axis (0, 0, 1) */
  72577. static readonly FACEFORWARD_ORIENTATION: number;
  72578. /** Control will rotate to look at negative z axis (0, 0, -1) */
  72579. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  72580. }
  72581. }
  72582. declare module BABYLON.GUI {
  72583. /**
  72584. * Class used to manage 3D user interface
  72585. * @see http://doc.babylonjs.com/how_to/gui3d
  72586. */
  72587. export class GUI3DManager implements BABYLON.IDisposable {
  72588. private _scene;
  72589. private _sceneDisposeObserver;
  72590. private _utilityLayer;
  72591. private _rootContainer;
  72592. private _pointerObserver;
  72593. private _pointerOutObserver;
  72594. /** @hidden */
  72595. _lastPickedControl: Control3D;
  72596. /** @hidden */
  72597. _lastControlOver: {
  72598. [pointerId: number]: Control3D;
  72599. };
  72600. /** @hidden */
  72601. _lastControlDown: {
  72602. [pointerId: number]: Control3D;
  72603. };
  72604. /**
  72605. * BABYLON.Observable raised when the point picked by the pointer events changed
  72606. */
  72607. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  72608. /** @hidden */
  72609. _sharedMaterials: {
  72610. [key: string]: BABYLON.Material;
  72611. };
  72612. /** Gets the hosting scene */
  72613. get scene(): BABYLON.Scene;
  72614. /** Gets associated utility layer */
  72615. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  72616. /**
  72617. * Creates a new GUI3DManager
  72618. * @param scene
  72619. */
  72620. constructor(scene?: BABYLON.Scene);
  72621. private _handlePointerOut;
  72622. private _doPicking;
  72623. /**
  72624. * Gets the root container
  72625. */
  72626. get rootContainer(): Container3D;
  72627. /**
  72628. * Gets a boolean indicating if the given control is in the root child list
  72629. * @param control defines the control to check
  72630. * @returns true if the control is in the root child list
  72631. */
  72632. containsControl(control: Control3D): boolean;
  72633. /**
  72634. * Adds a control to the root child list
  72635. * @param control defines the control to add
  72636. * @returns the current manager
  72637. */
  72638. addControl(control: Control3D): GUI3DManager;
  72639. /**
  72640. * Removes a control from the root child list
  72641. * @param control defines the control to remove
  72642. * @returns the current container
  72643. */
  72644. removeControl(control: Control3D): GUI3DManager;
  72645. /**
  72646. * Releases all associated resources
  72647. */
  72648. dispose(): void;
  72649. }
  72650. }
  72651. declare module BABYLON.GUI {
  72652. /**
  72653. * Class used to transport BABYLON.Vector3 information for pointer events
  72654. */
  72655. export class Vector3WithInfo extends BABYLON.Vector3 {
  72656. /** defines the current mouse button index */
  72657. buttonIndex: number;
  72658. /**
  72659. * Creates a new Vector3WithInfo
  72660. * @param source defines the vector3 data to transport
  72661. * @param buttonIndex defines the current mouse button index
  72662. */
  72663. constructor(source: BABYLON.Vector3,
  72664. /** defines the current mouse button index */
  72665. buttonIndex?: number);
  72666. }
  72667. }
  72668. declare module BABYLON.GUI {
  72669. /**
  72670. * Class used as base class for controls
  72671. */
  72672. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  72673. /** Defines the control name */
  72674. name?: string | undefined;
  72675. /** @hidden */
  72676. _host: GUI3DManager;
  72677. private _node;
  72678. private _downCount;
  72679. private _enterCount;
  72680. private _downPointerIds;
  72681. private _isVisible;
  72682. /** Gets or sets the control position in world space */
  72683. get position(): BABYLON.Vector3;
  72684. set position(value: BABYLON.Vector3);
  72685. /** Gets or sets the control scaling in world space */
  72686. get scaling(): BABYLON.Vector3;
  72687. set scaling(value: BABYLON.Vector3);
  72688. /** Callback used to start pointer enter animation */
  72689. pointerEnterAnimation: () => void;
  72690. /** Callback used to start pointer out animation */
  72691. pointerOutAnimation: () => void;
  72692. /** Callback used to start pointer down animation */
  72693. pointerDownAnimation: () => void;
  72694. /** Callback used to start pointer up animation */
  72695. pointerUpAnimation: () => void;
  72696. /**
  72697. * An event triggered when the pointer move over the control
  72698. */
  72699. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  72700. /**
  72701. * An event triggered when the pointer move out of the control
  72702. */
  72703. onPointerOutObservable: BABYLON.Observable<Control3D>;
  72704. /**
  72705. * An event triggered when the pointer taps the control
  72706. */
  72707. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  72708. /**
  72709. * An event triggered when pointer is up
  72710. */
  72711. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  72712. /**
  72713. * An event triggered when a control is clicked on (with a mouse)
  72714. */
  72715. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  72716. /**
  72717. * An event triggered when pointer enters the control
  72718. */
  72719. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  72720. /**
  72721. * Gets or sets the parent container
  72722. */
  72723. parent: BABYLON.Nullable<Container3D>;
  72724. private _behaviors;
  72725. /**
  72726. * Gets the list of attached behaviors
  72727. * @see http://doc.babylonjs.com/features/behaviour
  72728. */
  72729. get behaviors(): BABYLON.Behavior<Control3D>[];
  72730. /**
  72731. * Attach a behavior to the control
  72732. * @see http://doc.babylonjs.com/features/behaviour
  72733. * @param behavior defines the behavior to attach
  72734. * @returns the current control
  72735. */
  72736. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  72737. /**
  72738. * Remove an attached behavior
  72739. * @see http://doc.babylonjs.com/features/behaviour
  72740. * @param behavior defines the behavior to attach
  72741. * @returns the current control
  72742. */
  72743. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  72744. /**
  72745. * Gets an attached behavior by name
  72746. * @param name defines the name of the behavior to look for
  72747. * @see http://doc.babylonjs.com/features/behaviour
  72748. * @returns null if behavior was not found else the requested behavior
  72749. */
  72750. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  72751. /** Gets or sets a boolean indicating if the control is visible */
  72752. get isVisible(): boolean;
  72753. set isVisible(value: boolean);
  72754. /**
  72755. * Creates a new control
  72756. * @param name defines the control name
  72757. */
  72758. constructor(
  72759. /** Defines the control name */
  72760. name?: string | undefined);
  72761. /**
  72762. * Gets a string representing the class name
  72763. */
  72764. get typeName(): string;
  72765. /**
  72766. * Get the current class name of the control.
  72767. * @returns current class name
  72768. */
  72769. getClassName(): string;
  72770. protected _getTypeName(): string;
  72771. /**
  72772. * Gets the transform node used by this control
  72773. */
  72774. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  72775. /**
  72776. * Gets the mesh used to render this control
  72777. */
  72778. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  72779. /**
  72780. * Link the control as child of the given node
  72781. * @param node defines the node to link to. Use null to unlink the control
  72782. * @returns the current control
  72783. */
  72784. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  72785. /** @hidden **/
  72786. _prepareNode(scene: BABYLON.Scene): void;
  72787. /**
  72788. * Node creation.
  72789. * Can be overriden by children
  72790. * @param scene defines the scene where the node must be attached
  72791. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  72792. */
  72793. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  72794. /**
  72795. * Affect a material to the given mesh
  72796. * @param mesh defines the mesh which will represent the control
  72797. */
  72798. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  72799. /** @hidden */
  72800. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  72801. /** @hidden */
  72802. _onPointerEnter(target: Control3D): boolean;
  72803. /** @hidden */
  72804. _onPointerOut(target: Control3D): void;
  72805. /** @hidden */
  72806. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  72807. /** @hidden */
  72808. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72809. /** @hidden */
  72810. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  72811. /** @hidden */
  72812. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  72813. /** @hidden */
  72814. _disposeNode(): void;
  72815. /**
  72816. * Releases all associated resources
  72817. */
  72818. dispose(): void;
  72819. }
  72820. }
  72821. declare module BABYLON.GUI {
  72822. /**
  72823. * Class used as a root to all buttons
  72824. */
  72825. export class AbstractButton3D extends Control3D {
  72826. /**
  72827. * Creates a new button
  72828. * @param name defines the control name
  72829. */
  72830. constructor(name?: string);
  72831. protected _getTypeName(): string;
  72832. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  72833. }
  72834. }
  72835. declare module BABYLON.GUI {
  72836. /**
  72837. * Class used to create a button in 3D
  72838. */
  72839. export class Button3D extends AbstractButton3D {
  72840. /** @hidden */
  72841. protected _currentMaterial: BABYLON.Material;
  72842. private _facadeTexture;
  72843. private _content;
  72844. private _contentResolution;
  72845. private _contentScaleRatio;
  72846. /**
  72847. * Gets or sets the texture resolution used to render content (512 by default)
  72848. */
  72849. get contentResolution(): BABYLON.int;
  72850. set contentResolution(value: BABYLON.int);
  72851. /**
  72852. * Gets or sets the texture scale ratio used to render content (2 by default)
  72853. */
  72854. get contentScaleRatio(): number;
  72855. set contentScaleRatio(value: number);
  72856. protected _disposeFacadeTexture(): void;
  72857. protected _resetContent(): void;
  72858. /**
  72859. * Creates a new button
  72860. * @param name defines the control name
  72861. */
  72862. constructor(name?: string);
  72863. /**
  72864. * Gets or sets the GUI 2D content used to display the button's facade
  72865. */
  72866. get content(): Control;
  72867. set content(value: Control);
  72868. /**
  72869. * Apply the facade texture (created from the content property).
  72870. * This function can be overloaded by child classes
  72871. * @param facadeTexture defines the AdvancedDynamicTexture to use
  72872. */
  72873. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  72874. protected _getTypeName(): string;
  72875. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  72876. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  72877. /**
  72878. * Releases all associated resources
  72879. */
  72880. dispose(): void;
  72881. }
  72882. }
  72883. declare module BABYLON.GUI {
  72884. /**
  72885. * Abstract class used to create a container panel deployed on the surface of a volume
  72886. */
  72887. export abstract class VolumeBasedPanel extends Container3D {
  72888. private _columns;
  72889. private _rows;
  72890. private _rowThenColum;
  72891. private _orientation;
  72892. protected _cellWidth: number;
  72893. protected _cellHeight: number;
  72894. /**
  72895. * Gets or sets the distance between elements
  72896. */
  72897. margin: number;
  72898. /**
  72899. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  72900. * | Value | Type | Description |
  72901. * | ----- | ----------------------------------- | ----------- |
  72902. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  72903. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  72904. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  72905. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  72906. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  72907. */
  72908. get orientation(): number;
  72909. set orientation(value: number);
  72910. /**
  72911. * Gets or sets the number of columns requested (10 by default).
  72912. * The panel will automatically compute the number of rows based on number of child controls.
  72913. */
  72914. get columns(): BABYLON.int;
  72915. set columns(value: BABYLON.int);
  72916. /**
  72917. * Gets or sets a the number of rows requested.
  72918. * The panel will automatically compute the number of columns based on number of child controls.
  72919. */
  72920. get rows(): BABYLON.int;
  72921. set rows(value: BABYLON.int);
  72922. /**
  72923. * Creates new VolumeBasedPanel
  72924. */
  72925. constructor();
  72926. protected _arrangeChildren(): void;
  72927. /** Child classes must implement this function to provide correct control positioning */
  72928. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  72929. /** Child classes can implement this function to provide additional processing */
  72930. protected _finalProcessing(): void;
  72931. }
  72932. }
  72933. declare module BABYLON.GUI {
  72934. /**
  72935. * Class used to create a container panel deployed on the surface of a cylinder
  72936. */
  72937. export class CylinderPanel extends VolumeBasedPanel {
  72938. private _radius;
  72939. /**
  72940. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  72941. */
  72942. get radius(): BABYLON.float;
  72943. set radius(value: BABYLON.float);
  72944. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  72945. private _cylindricalMapping;
  72946. }
  72947. }
  72948. declare module BABYLON.GUI {
  72949. /** @hidden */
  72950. export var fluentVertexShader: {
  72951. name: string;
  72952. shader: string;
  72953. };
  72954. }
  72955. declare module BABYLON.GUI {
  72956. /** @hidden */
  72957. export var fluentPixelShader: {
  72958. name: string;
  72959. shader: string;
  72960. };
  72961. }
  72962. declare module BABYLON.GUI {
  72963. /** @hidden */
  72964. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  72965. INNERGLOW: boolean;
  72966. BORDER: boolean;
  72967. HOVERLIGHT: boolean;
  72968. TEXTURE: boolean;
  72969. constructor();
  72970. }
  72971. /**
  72972. * Class used to render controls with fluent desgin
  72973. */
  72974. export class FluentMaterial extends BABYLON.PushMaterial {
  72975. /**
  72976. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  72977. */
  72978. innerGlowColorIntensity: number;
  72979. /**
  72980. * Gets or sets the inner glow color (white by default)
  72981. */
  72982. innerGlowColor: BABYLON.Color3;
  72983. /**
  72984. * Gets or sets alpha value (default is 1.0)
  72985. */
  72986. alpha: number;
  72987. /**
  72988. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  72989. */
  72990. albedoColor: BABYLON.Color3;
  72991. /**
  72992. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  72993. */
  72994. renderBorders: boolean;
  72995. /**
  72996. * Gets or sets border width (default is 0.5)
  72997. */
  72998. borderWidth: number;
  72999. /**
  73000. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  73001. */
  73002. edgeSmoothingValue: number;
  73003. /**
  73004. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  73005. */
  73006. borderMinValue: number;
  73007. /**
  73008. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  73009. */
  73010. renderHoverLight: boolean;
  73011. /**
  73012. * Gets or sets the radius used to render the hover light (default is 1.0)
  73013. */
  73014. hoverRadius: number;
  73015. /**
  73016. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  73017. */
  73018. hoverColor: BABYLON.Color4;
  73019. /**
  73020. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  73021. */
  73022. hoverPosition: BABYLON.Vector3;
  73023. private _albedoTexture;
  73024. /** Gets or sets the texture to use for albedo color */
  73025. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  73026. /**
  73027. * Creates a new Fluent material
  73028. * @param name defines the name of the material
  73029. * @param scene defines the hosting scene
  73030. */
  73031. constructor(name: string, scene: BABYLON.Scene);
  73032. needAlphaBlending(): boolean;
  73033. needAlphaTesting(): boolean;
  73034. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73035. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73036. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73037. getActiveTextures(): BABYLON.BaseTexture[];
  73038. hasTexture(texture: BABYLON.BaseTexture): boolean;
  73039. dispose(forceDisposeEffect?: boolean): void;
  73040. clone(name: string): FluentMaterial;
  73041. serialize(): any;
  73042. getClassName(): string;
  73043. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  73044. }
  73045. }
  73046. declare module BABYLON.GUI {
  73047. /**
  73048. * Class used to create a holographic button in 3D
  73049. */
  73050. export class HolographicButton extends Button3D {
  73051. private _backPlate;
  73052. private _textPlate;
  73053. private _frontPlate;
  73054. private _text;
  73055. private _imageUrl;
  73056. private _shareMaterials;
  73057. private _frontMaterial;
  73058. private _backMaterial;
  73059. private _plateMaterial;
  73060. private _pickedPointObserver;
  73061. private _tooltipFade;
  73062. private _tooltipTextBlock;
  73063. private _tooltipTexture;
  73064. private _tooltipMesh;
  73065. private _tooltipHoverObserver;
  73066. private _tooltipOutObserver;
  73067. private _disposeTooltip;
  73068. /**
  73069. * Rendering ground id of all the mesh in the button
  73070. */
  73071. set renderingGroupId(id: number);
  73072. get renderingGroupId(): number;
  73073. /**
  73074. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  73075. */
  73076. set tooltipText(text: BABYLON.Nullable<string>);
  73077. get tooltipText(): BABYLON.Nullable<string>;
  73078. /**
  73079. * Gets or sets text for the button
  73080. */
  73081. get text(): string;
  73082. set text(value: string);
  73083. /**
  73084. * Gets or sets the image url for the button
  73085. */
  73086. get imageUrl(): string;
  73087. set imageUrl(value: string);
  73088. /**
  73089. * Gets the back material used by this button
  73090. */
  73091. get backMaterial(): FluentMaterial;
  73092. /**
  73093. * Gets the front material used by this button
  73094. */
  73095. get frontMaterial(): FluentMaterial;
  73096. /**
  73097. * Gets the plate material used by this button
  73098. */
  73099. get plateMaterial(): BABYLON.StandardMaterial;
  73100. /**
  73101. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  73102. */
  73103. get shareMaterials(): boolean;
  73104. /**
  73105. * Creates a new button
  73106. * @param name defines the control name
  73107. */
  73108. constructor(name?: string, shareMaterials?: boolean);
  73109. protected _getTypeName(): string;
  73110. private _rebuildContent;
  73111. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  73112. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  73113. private _createBackMaterial;
  73114. private _createFrontMaterial;
  73115. private _createPlateMaterial;
  73116. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  73117. /**
  73118. * Releases all associated resources
  73119. */
  73120. dispose(): void;
  73121. }
  73122. }
  73123. declare module BABYLON.GUI {
  73124. /**
  73125. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  73126. */
  73127. export class MeshButton3D extends Button3D {
  73128. /** @hidden */
  73129. protected _currentMesh: BABYLON.Mesh;
  73130. /**
  73131. * Creates a new 3D button based on a mesh
  73132. * @param mesh mesh to become a 3D button
  73133. * @param name defines the control name
  73134. */
  73135. constructor(mesh: BABYLON.Mesh, name?: string);
  73136. protected _getTypeName(): string;
  73137. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  73138. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  73139. }
  73140. }
  73141. declare module BABYLON.GUI {
  73142. /**
  73143. * Class used to create a container panel deployed on the surface of a plane
  73144. */
  73145. export class PlanePanel extends VolumeBasedPanel {
  73146. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  73147. }
  73148. }
  73149. declare module BABYLON.GUI {
  73150. /**
  73151. * Class used to create a container panel where items get randomized planar mapping
  73152. */
  73153. export class ScatterPanel extends VolumeBasedPanel {
  73154. private _iteration;
  73155. /**
  73156. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  73157. */
  73158. get iteration(): BABYLON.float;
  73159. set iteration(value: BABYLON.float);
  73160. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  73161. private _scatterMapping;
  73162. protected _finalProcessing(): void;
  73163. }
  73164. }
  73165. declare module BABYLON.GUI {
  73166. /**
  73167. * Class used to create a container panel deployed on the surface of a sphere
  73168. */
  73169. export class SpherePanel extends VolumeBasedPanel {
  73170. private _radius;
  73171. /**
  73172. * Gets or sets the radius of the sphere where to project controls (5 by default)
  73173. */
  73174. get radius(): BABYLON.float;
  73175. set radius(value: BABYLON.float);
  73176. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  73177. private _sphericalMapping;
  73178. }
  73179. }
  73180. declare module BABYLON.GUI {
  73181. /**
  73182. * Class used to create a stack panel in 3D on XY plane
  73183. */
  73184. export class StackPanel3D extends Container3D {
  73185. private _isVertical;
  73186. /**
  73187. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  73188. */
  73189. get isVertical(): boolean;
  73190. set isVertical(value: boolean);
  73191. /**
  73192. * Gets or sets the distance between elements
  73193. */
  73194. margin: number;
  73195. /**
  73196. * Creates new StackPanel
  73197. * @param isVertical
  73198. */
  73199. constructor(isVertical?: boolean);
  73200. protected _arrangeChildren(): void;
  73201. }
  73202. }
  73203. declare module BABYLON {
  73204. /**
  73205. * Configuration for glTF validation
  73206. */
  73207. export interface IGLTFValidationConfiguration {
  73208. /**
  73209. * The url of the glTF validator.
  73210. */
  73211. url: string;
  73212. }
  73213. /**
  73214. * glTF validation
  73215. */
  73216. export class GLTFValidation {
  73217. /**
  73218. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  73219. */
  73220. static Configuration: IGLTFValidationConfiguration;
  73221. private static _LoadScriptPromise;
  73222. /**
  73223. * Validate a glTF asset using the glTF-Validator.
  73224. * @param data The JSON of a glTF or the array buffer of a binary glTF
  73225. * @param rootUrl The root url for the glTF
  73226. * @param fileName The file name for the glTF
  73227. * @param getExternalResource The callback to get external resources for the glTF validator
  73228. * @returns A promise that resolves with the glTF validation results once complete
  73229. */
  73230. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  73231. }
  73232. }
  73233. declare module BABYLON {
  73234. /**
  73235. * Mode that determines the coordinate system to use.
  73236. */
  73237. export enum GLTFLoaderCoordinateSystemMode {
  73238. /**
  73239. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  73240. */
  73241. AUTO = 0,
  73242. /**
  73243. * Sets the useRightHandedSystem flag on the scene.
  73244. */
  73245. FORCE_RIGHT_HANDED = 1
  73246. }
  73247. /**
  73248. * Mode that determines what animations will start.
  73249. */
  73250. export enum GLTFLoaderAnimationStartMode {
  73251. /**
  73252. * No animation will start.
  73253. */
  73254. NONE = 0,
  73255. /**
  73256. * The first animation will start.
  73257. */
  73258. FIRST = 1,
  73259. /**
  73260. * All animations will start.
  73261. */
  73262. ALL = 2
  73263. }
  73264. /**
  73265. * Interface that contains the data for the glTF asset.
  73266. */
  73267. export interface IGLTFLoaderData {
  73268. /**
  73269. * The object that represents the glTF JSON.
  73270. */
  73271. json: Object;
  73272. /**
  73273. * The BIN chunk of a binary glTF.
  73274. */
  73275. bin: Nullable<IDataBuffer>;
  73276. }
  73277. /**
  73278. * Interface for extending the loader.
  73279. */
  73280. export interface IGLTFLoaderExtension {
  73281. /**
  73282. * The name of this extension.
  73283. */
  73284. readonly name: string;
  73285. /**
  73286. * Defines whether this extension is enabled.
  73287. */
  73288. enabled: boolean;
  73289. /**
  73290. * Defines the order of this extension.
  73291. * The loader sorts the extensions using these values when loading.
  73292. */
  73293. order?: number;
  73294. }
  73295. /**
  73296. * Loader state.
  73297. */
  73298. export enum GLTFLoaderState {
  73299. /**
  73300. * The asset is loading.
  73301. */
  73302. LOADING = 0,
  73303. /**
  73304. * The asset is ready for rendering.
  73305. */
  73306. READY = 1,
  73307. /**
  73308. * The asset is completely loaded.
  73309. */
  73310. COMPLETE = 2
  73311. }
  73312. /** @hidden */
  73313. export interface IGLTFLoader extends IDisposable {
  73314. readonly state: Nullable<GLTFLoaderState>;
  73315. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  73316. meshes: AbstractMesh[];
  73317. particleSystems: IParticleSystem[];
  73318. skeletons: Skeleton[];
  73319. animationGroups: AnimationGroup[];
  73320. }>;
  73321. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  73322. }
  73323. /**
  73324. * File loader for loading glTF files into a scene.
  73325. */
  73326. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  73327. /** @hidden */
  73328. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  73329. /** @hidden */
  73330. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  73331. /**
  73332. * Raised when the asset has been parsed
  73333. */
  73334. onParsedObservable: Observable<IGLTFLoaderData>;
  73335. private _onParsedObserver;
  73336. /**
  73337. * Raised when the asset has been parsed
  73338. */
  73339. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  73340. /**
  73341. * 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.
  73342. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  73343. * Defaults to true.
  73344. * @hidden
  73345. */
  73346. static IncrementalLoading: boolean;
  73347. /**
  73348. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  73349. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  73350. * @hidden
  73351. */
  73352. static HomogeneousCoordinates: boolean;
  73353. /**
  73354. * The coordinate system mode. Defaults to AUTO.
  73355. */
  73356. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  73357. /**
  73358. * The animation start mode. Defaults to FIRST.
  73359. */
  73360. animationStartMode: GLTFLoaderAnimationStartMode;
  73361. /**
  73362. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  73363. */
  73364. compileMaterials: boolean;
  73365. /**
  73366. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  73367. */
  73368. useClipPlane: boolean;
  73369. /**
  73370. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  73371. */
  73372. compileShadowGenerators: boolean;
  73373. /**
  73374. * Defines if the Alpha blended materials are only applied as coverage.
  73375. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  73376. * If true, no extra effects are applied to transparent pixels.
  73377. */
  73378. transparencyAsCoverage: boolean;
  73379. /**
  73380. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  73381. * Enabling will disable offline support and glTF validator.
  73382. * Defaults to false.
  73383. */
  73384. useRangeRequests: boolean;
  73385. /**
  73386. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  73387. */
  73388. createInstances: boolean;
  73389. /**
  73390. * Function called before loading a url referenced by the asset.
  73391. */
  73392. preprocessUrlAsync: (url: string) => Promise<string>;
  73393. /**
  73394. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  73395. */
  73396. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  73397. private _onMeshLoadedObserver;
  73398. /**
  73399. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  73400. */
  73401. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  73402. /**
  73403. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  73404. */
  73405. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  73406. private _onTextureLoadedObserver;
  73407. /**
  73408. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  73409. */
  73410. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  73411. /**
  73412. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  73413. */
  73414. readonly onMaterialLoadedObservable: Observable<Material>;
  73415. private _onMaterialLoadedObserver;
  73416. /**
  73417. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  73418. */
  73419. set onMaterialLoaded(callback: (material: Material) => void);
  73420. /**
  73421. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  73422. */
  73423. readonly onCameraLoadedObservable: Observable<Camera>;
  73424. private _onCameraLoadedObserver;
  73425. /**
  73426. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  73427. */
  73428. set onCameraLoaded(callback: (camera: Camera) => void);
  73429. /**
  73430. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  73431. * For assets with LODs, raised when all of the LODs are complete.
  73432. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  73433. */
  73434. readonly onCompleteObservable: Observable<void>;
  73435. private _onCompleteObserver;
  73436. /**
  73437. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  73438. * For assets with LODs, raised when all of the LODs are complete.
  73439. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  73440. */
  73441. set onComplete(callback: () => void);
  73442. /**
  73443. * Observable raised when an error occurs.
  73444. */
  73445. readonly onErrorObservable: Observable<any>;
  73446. private _onErrorObserver;
  73447. /**
  73448. * Callback raised when an error occurs.
  73449. */
  73450. set onError(callback: (reason: any) => void);
  73451. /**
  73452. * Observable raised after the loader is disposed.
  73453. */
  73454. readonly onDisposeObservable: Observable<void>;
  73455. private _onDisposeObserver;
  73456. /**
  73457. * Callback raised after the loader is disposed.
  73458. */
  73459. set onDispose(callback: () => void);
  73460. /**
  73461. * Observable raised after a loader extension is created.
  73462. * Set additional options for a loader extension in this event.
  73463. */
  73464. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  73465. private _onExtensionLoadedObserver;
  73466. /**
  73467. * Callback raised after a loader extension is created.
  73468. */
  73469. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  73470. /**
  73471. * Defines if the loader logging is enabled.
  73472. */
  73473. get loggingEnabled(): boolean;
  73474. set loggingEnabled(value: boolean);
  73475. /**
  73476. * Defines if the loader should capture performance counters.
  73477. */
  73478. get capturePerformanceCounters(): boolean;
  73479. set capturePerformanceCounters(value: boolean);
  73480. /**
  73481. * Defines if the loader should validate the asset.
  73482. */
  73483. validate: boolean;
  73484. /**
  73485. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  73486. */
  73487. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  73488. private _onValidatedObserver;
  73489. /**
  73490. * Callback raised after a loader extension is created.
  73491. */
  73492. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  73493. private _loader;
  73494. /**
  73495. * Name of the loader ("gltf")
  73496. */
  73497. name: string;
  73498. /** @hidden */
  73499. extensions: ISceneLoaderPluginExtensions;
  73500. /**
  73501. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  73502. */
  73503. dispose(): void;
  73504. /** @hidden */
  73505. _clear(): void;
  73506. /** @hidden */
  73507. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  73508. /** @hidden */
  73509. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  73510. /** @hidden */
  73511. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  73512. meshes: AbstractMesh[];
  73513. particleSystems: IParticleSystem[];
  73514. skeletons: Skeleton[];
  73515. animationGroups: AnimationGroup[];
  73516. }>;
  73517. /** @hidden */
  73518. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  73519. /** @hidden */
  73520. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  73521. /** @hidden */
  73522. canDirectLoad(data: string): boolean;
  73523. /** @hidden */
  73524. directLoad(scene: Scene, data: string): any;
  73525. /**
  73526. * The callback that allows custom handling of the root url based on the response url.
  73527. * @param rootUrl the original root url
  73528. * @param responseURL the response url if available
  73529. * @returns the new root url
  73530. */
  73531. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  73532. /** @hidden */
  73533. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  73534. /**
  73535. * The loader state or null if the loader is not active.
  73536. */
  73537. get loaderState(): Nullable<GLTFLoaderState>;
  73538. /**
  73539. * Returns a promise that resolves when the asset is completely loaded.
  73540. * @returns a promise that resolves when the asset is completely loaded.
  73541. */
  73542. whenCompleteAsync(): Promise<void>;
  73543. private _validate;
  73544. private _getLoader;
  73545. private _parseJson;
  73546. private _unpackBinaryAsync;
  73547. private _unpackBinaryV1Async;
  73548. private _unpackBinaryV2Async;
  73549. private static _parseVersion;
  73550. private static _compareVersion;
  73551. private static readonly _logSpaces;
  73552. private _logIndentLevel;
  73553. private _loggingEnabled;
  73554. /** @hidden */
  73555. _log: (message: string) => void;
  73556. /** @hidden */
  73557. _logOpen(message: string): void;
  73558. /** @hidden */
  73559. _logClose(): void;
  73560. private _logEnabled;
  73561. private _logDisabled;
  73562. private _capturePerformanceCounters;
  73563. /** @hidden */
  73564. _startPerformanceCounter: (counterName: string) => void;
  73565. /** @hidden */
  73566. _endPerformanceCounter: (counterName: string) => void;
  73567. private _startPerformanceCounterEnabled;
  73568. private _startPerformanceCounterDisabled;
  73569. private _endPerformanceCounterEnabled;
  73570. private _endPerformanceCounterDisabled;
  73571. }
  73572. }
  73573. declare module BABYLON.GLTF1 {
  73574. /**
  73575. * Enums
  73576. * @hidden
  73577. */
  73578. export enum EComponentType {
  73579. BYTE = 5120,
  73580. UNSIGNED_BYTE = 5121,
  73581. SHORT = 5122,
  73582. UNSIGNED_SHORT = 5123,
  73583. FLOAT = 5126
  73584. }
  73585. /** @hidden */
  73586. export enum EShaderType {
  73587. FRAGMENT = 35632,
  73588. VERTEX = 35633
  73589. }
  73590. /** @hidden */
  73591. export enum EParameterType {
  73592. BYTE = 5120,
  73593. UNSIGNED_BYTE = 5121,
  73594. SHORT = 5122,
  73595. UNSIGNED_SHORT = 5123,
  73596. INT = 5124,
  73597. UNSIGNED_INT = 5125,
  73598. FLOAT = 5126,
  73599. FLOAT_VEC2 = 35664,
  73600. FLOAT_VEC3 = 35665,
  73601. FLOAT_VEC4 = 35666,
  73602. INT_VEC2 = 35667,
  73603. INT_VEC3 = 35668,
  73604. INT_VEC4 = 35669,
  73605. BOOL = 35670,
  73606. BOOL_VEC2 = 35671,
  73607. BOOL_VEC3 = 35672,
  73608. BOOL_VEC4 = 35673,
  73609. FLOAT_MAT2 = 35674,
  73610. FLOAT_MAT3 = 35675,
  73611. FLOAT_MAT4 = 35676,
  73612. SAMPLER_2D = 35678
  73613. }
  73614. /** @hidden */
  73615. export enum ETextureWrapMode {
  73616. CLAMP_TO_EDGE = 33071,
  73617. MIRRORED_REPEAT = 33648,
  73618. REPEAT = 10497
  73619. }
  73620. /** @hidden */
  73621. export enum ETextureFilterType {
  73622. NEAREST = 9728,
  73623. LINEAR = 9728,
  73624. NEAREST_MIPMAP_NEAREST = 9984,
  73625. LINEAR_MIPMAP_NEAREST = 9985,
  73626. NEAREST_MIPMAP_LINEAR = 9986,
  73627. LINEAR_MIPMAP_LINEAR = 9987
  73628. }
  73629. /** @hidden */
  73630. export enum ETextureFormat {
  73631. ALPHA = 6406,
  73632. RGB = 6407,
  73633. RGBA = 6408,
  73634. LUMINANCE = 6409,
  73635. LUMINANCE_ALPHA = 6410
  73636. }
  73637. /** @hidden */
  73638. export enum ECullingType {
  73639. FRONT = 1028,
  73640. BACK = 1029,
  73641. FRONT_AND_BACK = 1032
  73642. }
  73643. /** @hidden */
  73644. export enum EBlendingFunction {
  73645. ZERO = 0,
  73646. ONE = 1,
  73647. SRC_COLOR = 768,
  73648. ONE_MINUS_SRC_COLOR = 769,
  73649. DST_COLOR = 774,
  73650. ONE_MINUS_DST_COLOR = 775,
  73651. SRC_ALPHA = 770,
  73652. ONE_MINUS_SRC_ALPHA = 771,
  73653. DST_ALPHA = 772,
  73654. ONE_MINUS_DST_ALPHA = 773,
  73655. CONSTANT_COLOR = 32769,
  73656. ONE_MINUS_CONSTANT_COLOR = 32770,
  73657. CONSTANT_ALPHA = 32771,
  73658. ONE_MINUS_CONSTANT_ALPHA = 32772,
  73659. SRC_ALPHA_SATURATE = 776
  73660. }
  73661. /** @hidden */
  73662. export interface IGLTFProperty {
  73663. extensions?: {
  73664. [key: string]: any;
  73665. };
  73666. extras?: Object;
  73667. }
  73668. /** @hidden */
  73669. export interface IGLTFChildRootProperty extends IGLTFProperty {
  73670. name?: string;
  73671. }
  73672. /** @hidden */
  73673. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  73674. bufferView: string;
  73675. byteOffset: number;
  73676. byteStride: number;
  73677. count: number;
  73678. type: string;
  73679. componentType: EComponentType;
  73680. max?: number[];
  73681. min?: number[];
  73682. name?: string;
  73683. }
  73684. /** @hidden */
  73685. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  73686. buffer: string;
  73687. byteOffset: number;
  73688. byteLength: number;
  73689. byteStride: number;
  73690. target?: number;
  73691. }
  73692. /** @hidden */
  73693. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  73694. uri: string;
  73695. byteLength?: number;
  73696. type?: string;
  73697. }
  73698. /** @hidden */
  73699. export interface IGLTFShader extends IGLTFChildRootProperty {
  73700. uri: string;
  73701. type: EShaderType;
  73702. }
  73703. /** @hidden */
  73704. export interface IGLTFProgram extends IGLTFChildRootProperty {
  73705. attributes: string[];
  73706. fragmentShader: string;
  73707. vertexShader: string;
  73708. }
  73709. /** @hidden */
  73710. export interface IGLTFTechniqueParameter {
  73711. type: number;
  73712. count?: number;
  73713. semantic?: string;
  73714. node?: string;
  73715. value?: number | boolean | string | Array<any>;
  73716. source?: string;
  73717. babylonValue?: any;
  73718. }
  73719. /** @hidden */
  73720. export interface IGLTFTechniqueCommonProfile {
  73721. lightingModel: string;
  73722. texcoordBindings: Object;
  73723. parameters?: Array<any>;
  73724. }
  73725. /** @hidden */
  73726. export interface IGLTFTechniqueStatesFunctions {
  73727. blendColor?: number[];
  73728. blendEquationSeparate?: number[];
  73729. blendFuncSeparate?: number[];
  73730. colorMask: boolean[];
  73731. cullFace: number[];
  73732. }
  73733. /** @hidden */
  73734. export interface IGLTFTechniqueStates {
  73735. enable: number[];
  73736. functions: IGLTFTechniqueStatesFunctions;
  73737. }
  73738. /** @hidden */
  73739. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  73740. parameters: {
  73741. [key: string]: IGLTFTechniqueParameter;
  73742. };
  73743. program: string;
  73744. attributes: {
  73745. [key: string]: string;
  73746. };
  73747. uniforms: {
  73748. [key: string]: string;
  73749. };
  73750. states: IGLTFTechniqueStates;
  73751. }
  73752. /** @hidden */
  73753. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  73754. technique?: string;
  73755. values: string[];
  73756. }
  73757. /** @hidden */
  73758. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  73759. attributes: {
  73760. [key: string]: string;
  73761. };
  73762. indices: string;
  73763. material: string;
  73764. mode?: number;
  73765. }
  73766. /** @hidden */
  73767. export interface IGLTFMesh extends IGLTFChildRootProperty {
  73768. primitives: IGLTFMeshPrimitive[];
  73769. }
  73770. /** @hidden */
  73771. export interface IGLTFImage extends IGLTFChildRootProperty {
  73772. uri: string;
  73773. }
  73774. /** @hidden */
  73775. export interface IGLTFSampler extends IGLTFChildRootProperty {
  73776. magFilter?: number;
  73777. minFilter?: number;
  73778. wrapS?: number;
  73779. wrapT?: number;
  73780. }
  73781. /** @hidden */
  73782. export interface IGLTFTexture extends IGLTFChildRootProperty {
  73783. sampler: string;
  73784. source: string;
  73785. format?: ETextureFormat;
  73786. internalFormat?: ETextureFormat;
  73787. target?: number;
  73788. type?: number;
  73789. babylonTexture?: Texture;
  73790. }
  73791. /** @hidden */
  73792. export interface IGLTFAmbienLight {
  73793. color?: number[];
  73794. }
  73795. /** @hidden */
  73796. export interface IGLTFDirectionalLight {
  73797. color?: number[];
  73798. }
  73799. /** @hidden */
  73800. export interface IGLTFPointLight {
  73801. color?: number[];
  73802. constantAttenuation?: number;
  73803. linearAttenuation?: number;
  73804. quadraticAttenuation?: number;
  73805. }
  73806. /** @hidden */
  73807. export interface IGLTFSpotLight {
  73808. color?: number[];
  73809. constantAttenuation?: number;
  73810. fallOfAngle?: number;
  73811. fallOffExponent?: number;
  73812. linearAttenuation?: number;
  73813. quadraticAttenuation?: number;
  73814. }
  73815. /** @hidden */
  73816. export interface IGLTFLight extends IGLTFChildRootProperty {
  73817. type: string;
  73818. }
  73819. /** @hidden */
  73820. export interface IGLTFCameraOrthographic {
  73821. xmag: number;
  73822. ymag: number;
  73823. zfar: number;
  73824. znear: number;
  73825. }
  73826. /** @hidden */
  73827. export interface IGLTFCameraPerspective {
  73828. aspectRatio: number;
  73829. yfov: number;
  73830. zfar: number;
  73831. znear: number;
  73832. }
  73833. /** @hidden */
  73834. export interface IGLTFCamera extends IGLTFChildRootProperty {
  73835. type: string;
  73836. }
  73837. /** @hidden */
  73838. export interface IGLTFAnimationChannelTarget {
  73839. id: string;
  73840. path: string;
  73841. }
  73842. /** @hidden */
  73843. export interface IGLTFAnimationChannel {
  73844. sampler: string;
  73845. target: IGLTFAnimationChannelTarget;
  73846. }
  73847. /** @hidden */
  73848. export interface IGLTFAnimationSampler {
  73849. input: string;
  73850. output: string;
  73851. interpolation?: string;
  73852. }
  73853. /** @hidden */
  73854. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  73855. channels?: IGLTFAnimationChannel[];
  73856. parameters?: {
  73857. [key: string]: string;
  73858. };
  73859. samplers?: {
  73860. [key: string]: IGLTFAnimationSampler;
  73861. };
  73862. }
  73863. /** @hidden */
  73864. export interface IGLTFNodeInstanceSkin {
  73865. skeletons: string[];
  73866. skin: string;
  73867. meshes: string[];
  73868. }
  73869. /** @hidden */
  73870. export interface IGLTFSkins extends IGLTFChildRootProperty {
  73871. bindShapeMatrix: number[];
  73872. inverseBindMatrices: string;
  73873. jointNames: string[];
  73874. babylonSkeleton?: Skeleton;
  73875. }
  73876. /** @hidden */
  73877. export interface IGLTFNode extends IGLTFChildRootProperty {
  73878. camera?: string;
  73879. children: string[];
  73880. skin?: string;
  73881. jointName?: string;
  73882. light?: string;
  73883. matrix: number[];
  73884. mesh?: string;
  73885. meshes?: string[];
  73886. rotation?: number[];
  73887. scale?: number[];
  73888. translation?: number[];
  73889. babylonNode?: Node;
  73890. }
  73891. /** @hidden */
  73892. export interface IGLTFScene extends IGLTFChildRootProperty {
  73893. nodes: string[];
  73894. }
  73895. /** @hidden */
  73896. export interface IGLTFRuntime {
  73897. extensions: {
  73898. [key: string]: any;
  73899. };
  73900. accessors: {
  73901. [key: string]: IGLTFAccessor;
  73902. };
  73903. buffers: {
  73904. [key: string]: IGLTFBuffer;
  73905. };
  73906. bufferViews: {
  73907. [key: string]: IGLTFBufferView;
  73908. };
  73909. meshes: {
  73910. [key: string]: IGLTFMesh;
  73911. };
  73912. lights: {
  73913. [key: string]: IGLTFLight;
  73914. };
  73915. cameras: {
  73916. [key: string]: IGLTFCamera;
  73917. };
  73918. nodes: {
  73919. [key: string]: IGLTFNode;
  73920. };
  73921. images: {
  73922. [key: string]: IGLTFImage;
  73923. };
  73924. textures: {
  73925. [key: string]: IGLTFTexture;
  73926. };
  73927. shaders: {
  73928. [key: string]: IGLTFShader;
  73929. };
  73930. programs: {
  73931. [key: string]: IGLTFProgram;
  73932. };
  73933. samplers: {
  73934. [key: string]: IGLTFSampler;
  73935. };
  73936. techniques: {
  73937. [key: string]: IGLTFTechnique;
  73938. };
  73939. materials: {
  73940. [key: string]: IGLTFMaterial;
  73941. };
  73942. animations: {
  73943. [key: string]: IGLTFAnimation;
  73944. };
  73945. skins: {
  73946. [key: string]: IGLTFSkins;
  73947. };
  73948. currentScene?: Object;
  73949. scenes: {
  73950. [key: string]: IGLTFScene;
  73951. };
  73952. extensionsUsed: string[];
  73953. extensionsRequired?: string[];
  73954. buffersCount: number;
  73955. shaderscount: number;
  73956. scene: Scene;
  73957. rootUrl: string;
  73958. loadedBufferCount: number;
  73959. loadedBufferViews: {
  73960. [name: string]: ArrayBufferView;
  73961. };
  73962. loadedShaderCount: number;
  73963. importOnlyMeshes: boolean;
  73964. importMeshesNames?: string[];
  73965. dummyNodes: Node[];
  73966. }
  73967. /** @hidden */
  73968. export interface INodeToRoot {
  73969. bone: Bone;
  73970. node: IGLTFNode;
  73971. id: string;
  73972. }
  73973. /** @hidden */
  73974. export interface IJointNode {
  73975. node: IGLTFNode;
  73976. id: string;
  73977. }
  73978. }
  73979. declare module BABYLON.GLTF1 {
  73980. /**
  73981. * Utils functions for GLTF
  73982. * @hidden
  73983. */
  73984. export class GLTFUtils {
  73985. /**
  73986. * Sets the given "parameter" matrix
  73987. * @param scene: the Scene object
  73988. * @param source: the source node where to pick the matrix
  73989. * @param parameter: the GLTF technique parameter
  73990. * @param uniformName: the name of the shader's uniform
  73991. * @param shaderMaterial: the shader material
  73992. */
  73993. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  73994. /**
  73995. * Sets the given "parameter" matrix
  73996. * @param shaderMaterial: the shader material
  73997. * @param uniform: the name of the shader's uniform
  73998. * @param value: the value of the uniform
  73999. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  74000. */
  74001. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  74002. /**
  74003. * Returns the wrap mode of the texture
  74004. * @param mode: the mode value
  74005. */
  74006. static GetWrapMode(mode: number): number;
  74007. /**
  74008. * Returns the byte stride giving an accessor
  74009. * @param accessor: the GLTF accessor objet
  74010. */
  74011. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  74012. /**
  74013. * Returns the texture filter mode giving a mode value
  74014. * @param mode: the filter mode value
  74015. */
  74016. static GetTextureFilterMode(mode: number): ETextureFilterType;
  74017. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  74018. /**
  74019. * Returns a buffer from its accessor
  74020. * @param gltfRuntime: the GLTF runtime
  74021. * @param accessor: the GLTF accessor
  74022. */
  74023. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  74024. /**
  74025. * Decodes a buffer view into a string
  74026. * @param view: the buffer view
  74027. */
  74028. static DecodeBufferToText(view: ArrayBufferView): string;
  74029. /**
  74030. * Returns the default material of gltf. Related to
  74031. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  74032. * @param scene: the Babylon.js scene
  74033. */
  74034. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  74035. private static _DefaultMaterial;
  74036. }
  74037. }
  74038. declare module BABYLON.GLTF1 {
  74039. /**
  74040. * Implementation of the base glTF spec
  74041. * @hidden
  74042. */
  74043. export class GLTFLoaderBase {
  74044. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  74045. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  74046. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  74047. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  74048. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  74049. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  74050. }
  74051. /**
  74052. * glTF V1 Loader
  74053. * @hidden
  74054. */
  74055. export class GLTFLoader implements IGLTFLoader {
  74056. static Extensions: {
  74057. [name: string]: GLTFLoaderExtension;
  74058. };
  74059. static RegisterExtension(extension: GLTFLoaderExtension): void;
  74060. state: Nullable<GLTFLoaderState>;
  74061. dispose(): void;
  74062. private _importMeshAsync;
  74063. /**
  74064. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  74065. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  74066. * @param scene the scene the meshes should be added to
  74067. * @param data gltf data containing information of the meshes in a loaded file
  74068. * @param rootUrl root url to load from
  74069. * @param onProgress event that fires when loading progress has occured
  74070. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  74071. */
  74072. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  74073. meshes: AbstractMesh[];
  74074. particleSystems: IParticleSystem[];
  74075. skeletons: Skeleton[];
  74076. animationGroups: AnimationGroup[];
  74077. }>;
  74078. private _loadAsync;
  74079. /**
  74080. * Imports all objects from a loaded gltf file and adds them to the scene
  74081. * @param scene the scene the objects should be added to
  74082. * @param data gltf data containing information of the meshes in a loaded file
  74083. * @param rootUrl root url to load from
  74084. * @param onProgress event that fires when loading progress has occured
  74085. * @returns a promise which completes when objects have been loaded to the scene
  74086. */
  74087. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  74088. private _loadShadersAsync;
  74089. private _loadBuffersAsync;
  74090. private _createNodes;
  74091. }
  74092. /** @hidden */
  74093. export abstract class GLTFLoaderExtension {
  74094. private _name;
  74095. constructor(name: string);
  74096. get name(): string;
  74097. /**
  74098. * Defines an override for loading the runtime
  74099. * Return true to stop further extensions from loading the runtime
  74100. */
  74101. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  74102. /**
  74103. * Defines an onverride for creating gltf runtime
  74104. * Return true to stop further extensions from creating the runtime
  74105. */
  74106. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  74107. /**
  74108. * Defines an override for loading buffers
  74109. * Return true to stop further extensions from loading this buffer
  74110. */
  74111. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  74112. /**
  74113. * Defines an override for loading texture buffers
  74114. * Return true to stop further extensions from loading this texture data
  74115. */
  74116. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  74117. /**
  74118. * Defines an override for creating textures
  74119. * Return true to stop further extensions from loading this texture
  74120. */
  74121. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  74122. /**
  74123. * Defines an override for loading shader strings
  74124. * Return true to stop further extensions from loading this shader data
  74125. */
  74126. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  74127. /**
  74128. * Defines an override for loading materials
  74129. * Return true to stop further extensions from loading this material
  74130. */
  74131. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  74132. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  74133. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  74134. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  74135. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  74136. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  74137. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  74138. private static LoadTextureBufferAsync;
  74139. private static CreateTextureAsync;
  74140. private static ApplyExtensions;
  74141. }
  74142. }
  74143. declare module BABYLON.GLTF1 {
  74144. /** @hidden */
  74145. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  74146. private _bin;
  74147. constructor();
  74148. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  74149. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  74150. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  74151. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  74152. }
  74153. }
  74154. declare module BABYLON.GLTF1 {
  74155. /** @hidden */
  74156. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  74157. constructor();
  74158. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  74159. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  74160. private _loadTexture;
  74161. }
  74162. }
  74163. declare module BABYLON.GLTF2.Loader {
  74164. /**
  74165. * Loader interface with an index field.
  74166. */
  74167. export interface IArrayItem {
  74168. /**
  74169. * The index of this item in the array.
  74170. */
  74171. index: number;
  74172. }
  74173. /**
  74174. * Loader interface with additional members.
  74175. */
  74176. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  74177. /** @hidden */
  74178. _data?: Promise<ArrayBufferView>;
  74179. /** @hidden */
  74180. _babylonVertexBuffer?: Promise<VertexBuffer>;
  74181. }
  74182. /**
  74183. * Loader interface with additional members.
  74184. */
  74185. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  74186. }
  74187. /** @hidden */
  74188. export interface _IAnimationSamplerData {
  74189. input: Float32Array;
  74190. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  74191. output: Float32Array;
  74192. }
  74193. /**
  74194. * Loader interface with additional members.
  74195. */
  74196. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  74197. /** @hidden */
  74198. _data?: Promise<_IAnimationSamplerData>;
  74199. }
  74200. /**
  74201. * Loader interface with additional members.
  74202. */
  74203. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  74204. channels: IAnimationChannel[];
  74205. samplers: IAnimationSampler[];
  74206. /** @hidden */
  74207. _babylonAnimationGroup?: AnimationGroup;
  74208. }
  74209. /**
  74210. * Loader interface with additional members.
  74211. */
  74212. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  74213. /** @hidden */
  74214. _data?: Promise<ArrayBufferView>;
  74215. }
  74216. /**
  74217. * Loader interface with additional members.
  74218. */
  74219. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  74220. /** @hidden */
  74221. _data?: Promise<ArrayBufferView>;
  74222. /** @hidden */
  74223. _babylonBuffer?: Promise<Buffer>;
  74224. }
  74225. /**
  74226. * Loader interface with additional members.
  74227. */
  74228. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  74229. }
  74230. /**
  74231. * Loader interface with additional members.
  74232. */
  74233. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  74234. /** @hidden */
  74235. _data?: Promise<ArrayBufferView>;
  74236. }
  74237. /**
  74238. * Loader interface with additional members.
  74239. */
  74240. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  74241. }
  74242. /**
  74243. * Loader interface with additional members.
  74244. */
  74245. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  74246. }
  74247. /**
  74248. * Loader interface with additional members.
  74249. */
  74250. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  74251. baseColorTexture?: ITextureInfo;
  74252. metallicRoughnessTexture?: ITextureInfo;
  74253. }
  74254. /**
  74255. * Loader interface with additional members.
  74256. */
  74257. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  74258. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  74259. normalTexture?: IMaterialNormalTextureInfo;
  74260. occlusionTexture?: IMaterialOcclusionTextureInfo;
  74261. emissiveTexture?: ITextureInfo;
  74262. /** @hidden */
  74263. _data?: {
  74264. [babylonDrawMode: number]: {
  74265. babylonMaterial: Material;
  74266. babylonMeshes: AbstractMesh[];
  74267. promise: Promise<void>;
  74268. };
  74269. };
  74270. }
  74271. /**
  74272. * Loader interface with additional members.
  74273. */
  74274. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  74275. primitives: IMeshPrimitive[];
  74276. }
  74277. /**
  74278. * Loader interface with additional members.
  74279. */
  74280. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  74281. /** @hidden */
  74282. _instanceData?: {
  74283. babylonSourceMesh: Mesh;
  74284. promise: Promise<any>;
  74285. };
  74286. }
  74287. /**
  74288. * Loader interface with additional members.
  74289. */
  74290. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  74291. /**
  74292. * The parent glTF node.
  74293. */
  74294. parent?: INode;
  74295. /** @hidden */
  74296. _babylonTransformNode?: TransformNode;
  74297. /** @hidden */
  74298. _primitiveBabylonMeshes?: AbstractMesh[];
  74299. /** @hidden */
  74300. _babylonBones?: Bone[];
  74301. /** @hidden */
  74302. _numMorphTargets?: number;
  74303. }
  74304. /** @hidden */
  74305. export interface _ISamplerData {
  74306. noMipMaps: boolean;
  74307. samplingMode: number;
  74308. wrapU: number;
  74309. wrapV: number;
  74310. }
  74311. /**
  74312. * Loader interface with additional members.
  74313. */
  74314. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  74315. /** @hidden */
  74316. _data?: _ISamplerData;
  74317. }
  74318. /**
  74319. * Loader interface with additional members.
  74320. */
  74321. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  74322. }
  74323. /**
  74324. * Loader interface with additional members.
  74325. */
  74326. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  74327. /** @hidden */
  74328. _data?: {
  74329. babylonSkeleton: Skeleton;
  74330. promise: Promise<void>;
  74331. };
  74332. }
  74333. /**
  74334. * Loader interface with additional members.
  74335. */
  74336. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  74337. }
  74338. /**
  74339. * Loader interface with additional members.
  74340. */
  74341. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  74342. }
  74343. /**
  74344. * Loader interface with additional members.
  74345. */
  74346. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  74347. accessors?: IAccessor[];
  74348. animations?: IAnimation[];
  74349. buffers?: IBuffer[];
  74350. bufferViews?: IBufferView[];
  74351. cameras?: ICamera[];
  74352. images?: IImage[];
  74353. materials?: IMaterial[];
  74354. meshes?: IMesh[];
  74355. nodes?: INode[];
  74356. samplers?: ISampler[];
  74357. scenes?: IScene[];
  74358. skins?: ISkin[];
  74359. textures?: ITexture[];
  74360. }
  74361. }
  74362. declare module BABYLON.GLTF2 {
  74363. /**
  74364. * Interface for a glTF loader extension.
  74365. */
  74366. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  74367. /**
  74368. * Called after the loader state changes to LOADING.
  74369. */
  74370. onLoading?(): void;
  74371. /**
  74372. * Called after the loader state changes to READY.
  74373. */
  74374. onReady?(): void;
  74375. /**
  74376. * Define this method to modify the default behavior when loading scenes.
  74377. * @param context The context when loading the asset
  74378. * @param scene The glTF scene property
  74379. * @returns A promise that resolves when the load is complete or null if not handled
  74380. */
  74381. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  74382. /**
  74383. * Define this method to modify the default behavior when loading nodes.
  74384. * @param context The context when loading the asset
  74385. * @param node The glTF node property
  74386. * @param assign A function called synchronously after parsing the glTF properties
  74387. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  74388. */
  74389. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  74390. /**
  74391. * Define this method to modify the default behavior when loading cameras.
  74392. * @param context The context when loading the asset
  74393. * @param camera The glTF camera property
  74394. * @param assign A function called synchronously after parsing the glTF properties
  74395. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  74396. */
  74397. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  74398. /**
  74399. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  74400. * @param context The context when loading the asset
  74401. * @param primitive The glTF mesh primitive property
  74402. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  74403. */
  74404. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  74405. /**
  74406. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  74407. * @param context The context when loading the asset
  74408. * @param name The mesh name when loading the asset
  74409. * @param node The glTF node when loading the asset
  74410. * @param mesh The glTF mesh when loading the asset
  74411. * @param primitive The glTF mesh primitive property
  74412. * @param assign A function called synchronously after parsing the glTF properties
  74413. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  74414. */
  74415. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  74416. /**
  74417. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  74418. * @param context The context when loading the asset
  74419. * @param material The glTF material property
  74420. * @param assign A function called synchronously after parsing the glTF properties
  74421. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  74422. */
  74423. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  74424. /**
  74425. * Define this method to modify the default behavior when creating materials.
  74426. * @param context The context when loading the asset
  74427. * @param material The glTF material property
  74428. * @param babylonDrawMode The draw mode for the Babylon material
  74429. * @returns The Babylon material or null if not handled
  74430. */
  74431. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  74432. /**
  74433. * Define this method to modify the default behavior when loading material properties.
  74434. * @param context The context when loading the asset
  74435. * @param material The glTF material property
  74436. * @param babylonMaterial The Babylon material
  74437. * @returns A promise that resolves when the load is complete or null if not handled
  74438. */
  74439. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  74440. /**
  74441. * Define this method to modify the default behavior when loading texture infos.
  74442. * @param context The context when loading the asset
  74443. * @param textureInfo The glTF texture info property
  74444. * @param assign A function called synchronously after parsing the glTF properties
  74445. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  74446. */
  74447. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  74448. /**
  74449. * Define this method to modify the default behavior when loading animations.
  74450. * @param context The context when loading the asset
  74451. * @param animation The glTF animation property
  74452. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  74453. */
  74454. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  74455. /**
  74456. * @hidden Define this method to modify the default behavior when loading skins.
  74457. * @param context The context when loading the asset
  74458. * @param node The glTF node property
  74459. * @param skin The glTF skin property
  74460. * @returns A promise that resolves when the load is complete or null if not handled
  74461. */
  74462. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  74463. /**
  74464. * @hidden Define this method to modify the default behavior when loading uris.
  74465. * @param context The context when loading the asset
  74466. * @param property The glTF property associated with the uri
  74467. * @param uri The uri to load
  74468. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  74469. */
  74470. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  74471. /**
  74472. * Define this method to modify the default behavior when loading buffer views.
  74473. * @param context The context when loading the asset
  74474. * @param bufferView The glTF buffer view property
  74475. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  74476. */
  74477. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  74478. /**
  74479. * Define this method to modify the default behavior when loading buffers.
  74480. * @param context The context when loading the asset
  74481. * @param buffer The glTF buffer property
  74482. * @param byteOffset The byte offset to load
  74483. * @param byteLength The byte length to load
  74484. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  74485. */
  74486. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  74487. }
  74488. }
  74489. declare module BABYLON.GLTF2 {
  74490. /**
  74491. * Helper class for working with arrays when loading the glTF asset
  74492. */
  74493. export class ArrayItem {
  74494. /**
  74495. * Gets an item from the given array.
  74496. * @param context The context when loading the asset
  74497. * @param array The array to get the item from
  74498. * @param index The index to the array
  74499. * @returns The array item
  74500. */
  74501. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  74502. /**
  74503. * Assign an `index` field to each item of the given array.
  74504. * @param array The array of items
  74505. */
  74506. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  74507. }
  74508. /**
  74509. * The glTF 2.0 loader
  74510. */
  74511. export class GLTFLoader implements IGLTFLoader {
  74512. /** @hidden */
  74513. _completePromises: Promise<any>[];
  74514. private _disposed;
  74515. private _parent;
  74516. private _state;
  74517. private _extensions;
  74518. private _rootUrl;
  74519. private _fileName;
  74520. private _uniqueRootUrl;
  74521. private _gltf;
  74522. private _bin;
  74523. private _babylonScene;
  74524. private _rootBabylonMesh;
  74525. private _defaultBabylonMaterialData;
  74526. private _progressCallback?;
  74527. private _requests;
  74528. private static readonly _DefaultSampler;
  74529. private static _RegisteredExtensions;
  74530. /**
  74531. * Registers a loader extension.
  74532. * @param name The name of the loader extension.
  74533. * @param factory The factory function that creates the loader extension.
  74534. */
  74535. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  74536. /**
  74537. * Unregisters a loader extension.
  74538. * @param name The name of the loader extension.
  74539. * @returns A boolean indicating whether the extension has been unregistered
  74540. */
  74541. static UnregisterExtension(name: string): boolean;
  74542. /**
  74543. * Gets the loader state.
  74544. */
  74545. get state(): Nullable<GLTFLoaderState>;
  74546. /**
  74547. * The object that represents the glTF JSON.
  74548. */
  74549. get gltf(): IGLTF;
  74550. /**
  74551. * The BIN chunk of a binary glTF.
  74552. */
  74553. get bin(): Nullable<IDataBuffer>;
  74554. /**
  74555. * The parent file loader.
  74556. */
  74557. get parent(): GLTFFileLoader;
  74558. /**
  74559. * The Babylon scene when loading the asset.
  74560. */
  74561. get babylonScene(): Scene;
  74562. /**
  74563. * The root Babylon mesh when loading the asset.
  74564. */
  74565. get rootBabylonMesh(): Mesh;
  74566. /** @hidden */
  74567. constructor(parent: GLTFFileLoader);
  74568. /** @hidden */
  74569. dispose(): void;
  74570. /** @hidden */
  74571. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  74572. meshes: AbstractMesh[];
  74573. particleSystems: IParticleSystem[];
  74574. skeletons: Skeleton[];
  74575. animationGroups: AnimationGroup[];
  74576. }>;
  74577. /** @hidden */
  74578. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  74579. private _loadAsync;
  74580. private _loadData;
  74581. private _setupData;
  74582. private _loadExtensions;
  74583. private _checkExtensions;
  74584. private _setState;
  74585. private _createRootNode;
  74586. /**
  74587. * Loads a glTF scene.
  74588. * @param context The context when loading the asset
  74589. * @param scene The glTF scene property
  74590. * @returns A promise that resolves when the load is complete
  74591. */
  74592. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  74593. private _forEachPrimitive;
  74594. private _getMeshes;
  74595. private _getSkeletons;
  74596. private _getAnimationGroups;
  74597. private _startAnimations;
  74598. /**
  74599. * Loads a glTF node.
  74600. * @param context The context when loading the asset
  74601. * @param node The glTF node property
  74602. * @param assign A function called synchronously after parsing the glTF properties
  74603. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  74604. */
  74605. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  74606. private _loadMeshAsync;
  74607. /**
  74608. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  74609. * @param context The context when loading the asset
  74610. * @param name The mesh name when loading the asset
  74611. * @param node The glTF node when loading the asset
  74612. * @param mesh The glTF mesh when loading the asset
  74613. * @param primitive The glTF mesh primitive property
  74614. * @param assign A function called synchronously after parsing the glTF properties
  74615. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  74616. */
  74617. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  74618. private _loadVertexDataAsync;
  74619. private _createMorphTargets;
  74620. private _loadMorphTargetsAsync;
  74621. private _loadMorphTargetVertexDataAsync;
  74622. private static _LoadTransform;
  74623. private _loadSkinAsync;
  74624. private _loadBones;
  74625. private _loadBone;
  74626. private _loadSkinInverseBindMatricesDataAsync;
  74627. private _updateBoneMatrices;
  74628. private _getNodeMatrix;
  74629. /**
  74630. * Loads a glTF camera.
  74631. * @param context The context when loading the asset
  74632. * @param camera The glTF camera property
  74633. * @param assign A function called synchronously after parsing the glTF properties
  74634. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  74635. */
  74636. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  74637. private _loadAnimationsAsync;
  74638. /**
  74639. * Loads a glTF animation.
  74640. * @param context The context when loading the asset
  74641. * @param animation The glTF animation property
  74642. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  74643. */
  74644. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  74645. /**
  74646. * @hidden Loads a glTF animation channel.
  74647. * @param context The context when loading the asset
  74648. * @param animationContext The context of the animation when loading the asset
  74649. * @param animation The glTF animation property
  74650. * @param channel The glTF animation channel property
  74651. * @param babylonAnimationGroup The babylon animation group property
  74652. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  74653. * @returns A void promise when the channel load is complete
  74654. */
  74655. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  74656. private _loadAnimationSamplerAsync;
  74657. private _loadBufferAsync;
  74658. /**
  74659. * Loads a glTF buffer view.
  74660. * @param context The context when loading the asset
  74661. * @param bufferView The glTF buffer view property
  74662. * @returns A promise that resolves with the loaded data when the load is complete
  74663. */
  74664. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  74665. private _loadAccessorAsync;
  74666. private _loadFloatAccessorAsync;
  74667. private _loadIndicesAccessorAsync;
  74668. private _loadVertexBufferViewAsync;
  74669. private _loadVertexAccessorAsync;
  74670. private _loadMaterialMetallicRoughnessPropertiesAsync;
  74671. /** @hidden */
  74672. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  74673. private _createDefaultMaterial;
  74674. /**
  74675. * Creates a Babylon material from a glTF material.
  74676. * @param context The context when loading the asset
  74677. * @param material The glTF material property
  74678. * @param babylonDrawMode The draw mode for the Babylon material
  74679. * @returns The Babylon material
  74680. */
  74681. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  74682. /**
  74683. * Loads properties from a glTF material into a Babylon material.
  74684. * @param context The context when loading the asset
  74685. * @param material The glTF material property
  74686. * @param babylonMaterial The Babylon material
  74687. * @returns A promise that resolves when the load is complete
  74688. */
  74689. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  74690. /**
  74691. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  74692. * @param context The context when loading the asset
  74693. * @param material The glTF material property
  74694. * @param babylonMaterial The Babylon material
  74695. * @returns A promise that resolves when the load is complete
  74696. */
  74697. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  74698. /**
  74699. * Loads the alpha properties from a glTF material into a Babylon material.
  74700. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  74701. * @param context The context when loading the asset
  74702. * @param material The glTF material property
  74703. * @param babylonMaterial The Babylon material
  74704. */
  74705. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  74706. /**
  74707. * Loads a glTF texture info.
  74708. * @param context The context when loading the asset
  74709. * @param textureInfo The glTF texture info property
  74710. * @param assign A function called synchronously after parsing the glTF properties
  74711. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  74712. */
  74713. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  74714. private _loadTextureAsync;
  74715. private _loadSampler;
  74716. /**
  74717. * Loads a glTF image.
  74718. * @param context The context when loading the asset
  74719. * @param image The glTF image property
  74720. * @returns A promise that resolves with the loaded data when the load is complete
  74721. */
  74722. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  74723. /**
  74724. * Loads a glTF uri.
  74725. * @param context The context when loading the asset
  74726. * @param property The glTF property associated with the uri
  74727. * @param uri The base64 or relative uri
  74728. * @returns A promise that resolves with the loaded data when the load is complete
  74729. */
  74730. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  74731. private _onProgress;
  74732. /**
  74733. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  74734. * @param babylonObject the Babylon object with metadata
  74735. * @param pointer the JSON pointer
  74736. */
  74737. static AddPointerMetadata(babylonObject: {
  74738. metadata: any;
  74739. }, pointer: string): void;
  74740. private static _GetTextureWrapMode;
  74741. private static _GetTextureSamplingMode;
  74742. private static _GetTypedArrayConstructor;
  74743. private static _GetTypedArray;
  74744. private static _GetNumComponents;
  74745. private static _ValidateUri;
  74746. private static _GetDrawMode;
  74747. private _compileMaterialsAsync;
  74748. private _compileShadowGeneratorsAsync;
  74749. private _forEachExtensions;
  74750. private _applyExtensions;
  74751. private _extensionsOnLoading;
  74752. private _extensionsOnReady;
  74753. private _extensionsLoadSceneAsync;
  74754. private _extensionsLoadNodeAsync;
  74755. private _extensionsLoadCameraAsync;
  74756. private _extensionsLoadVertexDataAsync;
  74757. private _extensionsLoadMeshPrimitiveAsync;
  74758. private _extensionsLoadMaterialAsync;
  74759. private _extensionsCreateMaterial;
  74760. private _extensionsLoadMaterialPropertiesAsync;
  74761. private _extensionsLoadTextureInfoAsync;
  74762. private _extensionsLoadAnimationAsync;
  74763. private _extensionsLoadSkinAsync;
  74764. private _extensionsLoadUriAsync;
  74765. private _extensionsLoadBufferViewAsync;
  74766. private _extensionsLoadBufferAsync;
  74767. /**
  74768. * Helper method called by a loader extension to load an glTF extension.
  74769. * @param context The context when loading the asset
  74770. * @param property The glTF property to load the extension from
  74771. * @param extensionName The name of the extension to load
  74772. * @param actionAsync The action to run
  74773. * @returns The promise returned by actionAsync or null if the extension does not exist
  74774. */
  74775. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  74776. /**
  74777. * Helper method called by a loader extension to load a glTF extra.
  74778. * @param context The context when loading the asset
  74779. * @param property The glTF property to load the extra from
  74780. * @param extensionName The name of the extension to load
  74781. * @param actionAsync The action to run
  74782. * @returns The promise returned by actionAsync or null if the extra does not exist
  74783. */
  74784. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  74785. /**
  74786. * Checks for presence of an extension.
  74787. * @param name The name of the extension to check
  74788. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  74789. */
  74790. isExtensionUsed(name: string): boolean;
  74791. /**
  74792. * Increments the indentation level and logs a message.
  74793. * @param message The message to log
  74794. */
  74795. logOpen(message: string): void;
  74796. /**
  74797. * Decrements the indentation level.
  74798. */
  74799. logClose(): void;
  74800. /**
  74801. * Logs a message
  74802. * @param message The message to log
  74803. */
  74804. log(message: string): void;
  74805. /**
  74806. * Starts a performance counter.
  74807. * @param counterName The name of the performance counter
  74808. */
  74809. startPerformanceCounter(counterName: string): void;
  74810. /**
  74811. * Ends a performance counter.
  74812. * @param counterName The name of the performance counter
  74813. */
  74814. endPerformanceCounter(counterName: string): void;
  74815. }
  74816. }
  74817. declare module BABYLON.GLTF2.Loader.Extensions {
  74818. /**
  74819. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  74820. */
  74821. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  74822. /**
  74823. * The name of this extension.
  74824. */
  74825. readonly name: string;
  74826. /**
  74827. * Defines whether this extension is enabled.
  74828. */
  74829. enabled: boolean;
  74830. private _loader;
  74831. private _lights?;
  74832. /** @hidden */
  74833. constructor(loader: GLTFLoader);
  74834. /** @hidden */
  74835. dispose(): void;
  74836. /** @hidden */
  74837. onLoading(): void;
  74838. /** @hidden */
  74839. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  74840. private _loadLightAsync;
  74841. }
  74842. }
  74843. declare module BABYLON.GLTF2.Loader.Extensions {
  74844. /**
  74845. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  74846. */
  74847. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  74848. /**
  74849. * The name of this extension.
  74850. */
  74851. readonly name: string;
  74852. /**
  74853. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  74854. */
  74855. dracoCompression?: DracoCompression;
  74856. /**
  74857. * Defines whether this extension is enabled.
  74858. */
  74859. enabled: boolean;
  74860. private _loader;
  74861. /** @hidden */
  74862. constructor(loader: GLTFLoader);
  74863. /** @hidden */
  74864. dispose(): void;
  74865. /** @hidden */
  74866. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  74867. }
  74868. }
  74869. declare module BABYLON.GLTF2.Loader.Extensions {
  74870. /**
  74871. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  74872. */
  74873. export class KHR_lights implements IGLTFLoaderExtension {
  74874. /**
  74875. * The name of this extension.
  74876. */
  74877. readonly name: string;
  74878. /**
  74879. * Defines whether this extension is enabled.
  74880. */
  74881. enabled: boolean;
  74882. private _loader;
  74883. private _lights?;
  74884. /** @hidden */
  74885. constructor(loader: GLTFLoader);
  74886. /** @hidden */
  74887. dispose(): void;
  74888. /** @hidden */
  74889. onLoading(): void;
  74890. /** @hidden */
  74891. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  74892. }
  74893. }
  74894. declare module BABYLON.GLTF2.Loader.Extensions {
  74895. /**
  74896. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  74897. */
  74898. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  74899. /**
  74900. * The name of this extension.
  74901. */
  74902. readonly name: string;
  74903. /**
  74904. * Defines whether this extension is enabled.
  74905. */
  74906. enabled: boolean;
  74907. /**
  74908. * Defines a number that determines the order the extensions are applied.
  74909. */
  74910. order: number;
  74911. private _loader;
  74912. /** @hidden */
  74913. constructor(loader: GLTFLoader);
  74914. /** @hidden */
  74915. dispose(): void;
  74916. /** @hidden */
  74917. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  74918. private _loadSpecularGlossinessPropertiesAsync;
  74919. }
  74920. }
  74921. declare module BABYLON.GLTF2.Loader.Extensions {
  74922. /**
  74923. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  74924. */
  74925. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  74926. /**
  74927. * The name of this extension.
  74928. */
  74929. readonly name: string;
  74930. /**
  74931. * Defines whether this extension is enabled.
  74932. */
  74933. enabled: boolean;
  74934. /**
  74935. * Defines a number that determines the order the extensions are applied.
  74936. */
  74937. order: number;
  74938. private _loader;
  74939. /** @hidden */
  74940. constructor(loader: GLTFLoader);
  74941. /** @hidden */
  74942. dispose(): void;
  74943. /** @hidden */
  74944. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  74945. private _loadUnlitPropertiesAsync;
  74946. }
  74947. }
  74948. declare module BABYLON.GLTF2.Loader.Extensions {
  74949. /**
  74950. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  74951. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  74952. * !!! Experimental Extension Subject to Changes !!!
  74953. */
  74954. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  74955. /**
  74956. * The name of this extension.
  74957. */
  74958. readonly name: string;
  74959. /**
  74960. * Defines whether this extension is enabled.
  74961. */
  74962. enabled: boolean;
  74963. /**
  74964. * Defines a number that determines the order the extensions are applied.
  74965. */
  74966. order: number;
  74967. private _loader;
  74968. /** @hidden */
  74969. constructor(loader: GLTFLoader);
  74970. /** @hidden */
  74971. dispose(): void;
  74972. /** @hidden */
  74973. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  74974. private _loadClearCoatPropertiesAsync;
  74975. }
  74976. }
  74977. declare module BABYLON.GLTF2.Loader.Extensions {
  74978. /**
  74979. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  74980. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  74981. * !!! Experimental Extension Subject to Changes !!!
  74982. */
  74983. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  74984. /**
  74985. * The name of this extension.
  74986. */
  74987. readonly name: string;
  74988. /**
  74989. * Defines whether this extension is enabled.
  74990. */
  74991. enabled: boolean;
  74992. /**
  74993. * Defines a number that determines the order the extensions are applied.
  74994. */
  74995. order: number;
  74996. private _loader;
  74997. /** @hidden */
  74998. constructor(loader: GLTFLoader);
  74999. /** @hidden */
  75000. dispose(): void;
  75001. /** @hidden */
  75002. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75003. private _loadSheenPropertiesAsync;
  75004. }
  75005. }
  75006. declare module BABYLON.GLTF2.Loader.Extensions {
  75007. /**
  75008. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  75009. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  75010. * !!! Experimental Extension Subject to Changes !!!
  75011. */
  75012. export class KHR_materials_specular implements IGLTFLoaderExtension {
  75013. /**
  75014. * The name of this extension.
  75015. */
  75016. readonly name: string;
  75017. /**
  75018. * Defines whether this extension is enabled.
  75019. */
  75020. enabled: boolean;
  75021. /**
  75022. * Defines a number that determines the order the extensions are applied.
  75023. */
  75024. order: number;
  75025. private _loader;
  75026. /** @hidden */
  75027. constructor(loader: GLTFLoader);
  75028. /** @hidden */
  75029. dispose(): void;
  75030. /** @hidden */
  75031. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75032. private _loadSpecularPropertiesAsync;
  75033. }
  75034. }
  75035. declare module BABYLON.GLTF2.Loader.Extensions {
  75036. /**
  75037. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  75038. */
  75039. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  75040. /**
  75041. * The name of this extension.
  75042. */
  75043. readonly name: string;
  75044. /**
  75045. * Defines whether this extension is enabled.
  75046. */
  75047. enabled: boolean;
  75048. /** @hidden */
  75049. constructor(loader: GLTFLoader);
  75050. /** @hidden */
  75051. dispose(): void;
  75052. }
  75053. }
  75054. declare module BABYLON.GLTF2.Loader.Extensions {
  75055. /**
  75056. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  75057. */
  75058. export class KHR_texture_transform implements IGLTFLoaderExtension {
  75059. /**
  75060. * The name of this extension.
  75061. */
  75062. readonly name: string;
  75063. /**
  75064. * Defines whether this extension is enabled.
  75065. */
  75066. enabled: boolean;
  75067. private _loader;
  75068. /** @hidden */
  75069. constructor(loader: GLTFLoader);
  75070. /** @hidden */
  75071. dispose(): void;
  75072. /** @hidden */
  75073. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  75074. }
  75075. }
  75076. declare module BABYLON.GLTF2.Loader.Extensions {
  75077. /**
  75078. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  75079. */
  75080. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  75081. /**
  75082. * The name of this extension.
  75083. */
  75084. readonly name: string;
  75085. /**
  75086. * Defines whether this extension is enabled.
  75087. */
  75088. enabled: boolean;
  75089. private _loader;
  75090. private _clips;
  75091. private _emitters;
  75092. /** @hidden */
  75093. constructor(loader: GLTFLoader);
  75094. /** @hidden */
  75095. dispose(): void;
  75096. /** @hidden */
  75097. onLoading(): void;
  75098. /** @hidden */
  75099. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  75100. /** @hidden */
  75101. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  75102. /** @hidden */
  75103. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  75104. private _loadClipAsync;
  75105. private _loadEmitterAsync;
  75106. private _getEventAction;
  75107. private _loadAnimationEventAsync;
  75108. }
  75109. }
  75110. declare module BABYLON.GLTF2.Loader.Extensions {
  75111. /**
  75112. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  75113. */
  75114. export class MSFT_lod implements IGLTFLoaderExtension {
  75115. /**
  75116. * The name of this extension.
  75117. */
  75118. readonly name: string;
  75119. /**
  75120. * Defines whether this extension is enabled.
  75121. */
  75122. enabled: boolean;
  75123. /**
  75124. * Defines a number that determines the order the extensions are applied.
  75125. */
  75126. order: number;
  75127. /**
  75128. * Maximum number of LODs to load, starting from the lowest LOD.
  75129. */
  75130. maxLODsToLoad: number;
  75131. /**
  75132. * Observable raised when all node LODs of one level are loaded.
  75133. * The event data is the index of the loaded LOD starting from zero.
  75134. * Dispose the loader to cancel the loading of the next level of LODs.
  75135. */
  75136. onNodeLODsLoadedObservable: Observable<number>;
  75137. /**
  75138. * Observable raised when all material LODs of one level are loaded.
  75139. * The event data is the index of the loaded LOD starting from zero.
  75140. * Dispose the loader to cancel the loading of the next level of LODs.
  75141. */
  75142. onMaterialLODsLoadedObservable: Observable<number>;
  75143. private _loader;
  75144. private _nodeIndexLOD;
  75145. private _nodeSignalLODs;
  75146. private _nodePromiseLODs;
  75147. private _materialIndexLOD;
  75148. private _materialSignalLODs;
  75149. private _materialPromiseLODs;
  75150. private _indexLOD;
  75151. private _bufferLODs;
  75152. /** @hidden */
  75153. constructor(loader: GLTFLoader);
  75154. /** @hidden */
  75155. dispose(): void;
  75156. /** @hidden */
  75157. onReady(): void;
  75158. /** @hidden */
  75159. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  75160. /** @hidden */
  75161. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  75162. /** @hidden */
  75163. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  75164. /** @hidden */
  75165. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  75166. private _loadBufferLOD;
  75167. /**
  75168. * Gets an array of LOD properties from lowest to highest.
  75169. */
  75170. private _getLODs;
  75171. private _disposeUnusedMaterials;
  75172. }
  75173. }
  75174. declare module BABYLON.GLTF2.Loader.Extensions {
  75175. /** @hidden */
  75176. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  75177. readonly name: string;
  75178. enabled: boolean;
  75179. private _loader;
  75180. constructor(loader: GLTFLoader);
  75181. dispose(): void;
  75182. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75183. }
  75184. }
  75185. declare module BABYLON.GLTF2.Loader.Extensions {
  75186. /** @hidden */
  75187. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  75188. readonly name: string;
  75189. enabled: boolean;
  75190. private _loader;
  75191. constructor(loader: GLTFLoader);
  75192. dispose(): void;
  75193. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75194. }
  75195. }
  75196. declare module BABYLON.GLTF2.Loader.Extensions {
  75197. /**
  75198. * Store glTF extras (if present) in BJS objects' metadata
  75199. */
  75200. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  75201. /**
  75202. * The name of this extension.
  75203. */
  75204. readonly name: string;
  75205. /**
  75206. * Defines whether this extension is enabled.
  75207. */
  75208. enabled: boolean;
  75209. private _loader;
  75210. private _assignExtras;
  75211. /** @hidden */
  75212. constructor(loader: GLTFLoader);
  75213. /** @hidden */
  75214. dispose(): void;
  75215. /** @hidden */
  75216. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  75217. /** @hidden */
  75218. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  75219. /** @hidden */
  75220. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  75221. }
  75222. }
  75223. declare module BABYLON {
  75224. /**
  75225. * Class reading and parsing the MTL file bundled with the obj file.
  75226. */
  75227. export class MTLFileLoader {
  75228. /**
  75229. * Invert Y-Axis of referenced textures on load
  75230. */
  75231. static INVERT_TEXTURE_Y: boolean;
  75232. /**
  75233. * All material loaded from the mtl will be set here
  75234. */
  75235. materials: StandardMaterial[];
  75236. /**
  75237. * This function will read the mtl file and create each material described inside
  75238. * This function could be improve by adding :
  75239. * -some component missing (Ni, Tf...)
  75240. * -including the specific options available
  75241. *
  75242. * @param scene defines the scene the material will be created in
  75243. * @param data defines the mtl data to parse
  75244. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  75245. */
  75246. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  75247. /**
  75248. * Gets the texture for the material.
  75249. *
  75250. * If the material is imported from input file,
  75251. * We sanitize the url to ensure it takes the textre from aside the material.
  75252. *
  75253. * @param rootUrl The root url to load from
  75254. * @param value The value stored in the mtl
  75255. * @return The Texture
  75256. */
  75257. private static _getTexture;
  75258. }
  75259. }
  75260. declare module BABYLON {
  75261. /**
  75262. * Options for loading OBJ/MTL files
  75263. */
  75264. type MeshLoadOptions = {
  75265. /**
  75266. * Defines if UVs are optimized by default during load.
  75267. */
  75268. OptimizeWithUV: boolean;
  75269. /**
  75270. * Defines custom scaling of UV coordinates of loaded meshes.
  75271. */
  75272. UVScaling: Vector2;
  75273. /**
  75274. * Invert model on y-axis (does a model scaling inversion)
  75275. */
  75276. InvertY: boolean;
  75277. /**
  75278. * Invert Y-Axis of referenced textures on load
  75279. */
  75280. InvertTextureY: boolean;
  75281. /**
  75282. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  75283. */
  75284. ImportVertexColors: boolean;
  75285. /**
  75286. * Compute the normals for the model, even if normals are present in the file.
  75287. */
  75288. ComputeNormals: boolean;
  75289. /**
  75290. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  75291. */
  75292. SkipMaterials: boolean;
  75293. /**
  75294. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  75295. */
  75296. MaterialLoadingFailsSilently: boolean;
  75297. };
  75298. /**
  75299. * OBJ file type loader.
  75300. * This is a babylon scene loader plugin.
  75301. */
  75302. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  75303. /**
  75304. * Defines if UVs are optimized by default during load.
  75305. */
  75306. static OPTIMIZE_WITH_UV: boolean;
  75307. /**
  75308. * Invert model on y-axis (does a model scaling inversion)
  75309. */
  75310. static INVERT_Y: boolean;
  75311. /**
  75312. * Invert Y-Axis of referenced textures on load
  75313. */
  75314. static get INVERT_TEXTURE_Y(): boolean;
  75315. static set INVERT_TEXTURE_Y(value: boolean);
  75316. /**
  75317. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  75318. */
  75319. static IMPORT_VERTEX_COLORS: boolean;
  75320. /**
  75321. * Compute the normals for the model, even if normals are present in the file.
  75322. */
  75323. static COMPUTE_NORMALS: boolean;
  75324. /**
  75325. * Defines custom scaling of UV coordinates of loaded meshes.
  75326. */
  75327. static UV_SCALING: Vector2;
  75328. /**
  75329. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  75330. */
  75331. static SKIP_MATERIALS: boolean;
  75332. /**
  75333. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  75334. *
  75335. * Defaults to true for backwards compatibility.
  75336. */
  75337. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  75338. /**
  75339. * Defines the name of the plugin.
  75340. */
  75341. name: string;
  75342. /**
  75343. * Defines the extension the plugin is able to load.
  75344. */
  75345. extensions: string;
  75346. /** @hidden */
  75347. obj: RegExp;
  75348. /** @hidden */
  75349. group: RegExp;
  75350. /** @hidden */
  75351. mtllib: RegExp;
  75352. /** @hidden */
  75353. usemtl: RegExp;
  75354. /** @hidden */
  75355. smooth: RegExp;
  75356. /** @hidden */
  75357. vertexPattern: RegExp;
  75358. /** @hidden */
  75359. normalPattern: RegExp;
  75360. /** @hidden */
  75361. uvPattern: RegExp;
  75362. /** @hidden */
  75363. facePattern1: RegExp;
  75364. /** @hidden */
  75365. facePattern2: RegExp;
  75366. /** @hidden */
  75367. facePattern3: RegExp;
  75368. /** @hidden */
  75369. facePattern4: RegExp;
  75370. /** @hidden */
  75371. facePattern5: RegExp;
  75372. private _meshLoadOptions;
  75373. /**
  75374. * Creates loader for .OBJ files
  75375. *
  75376. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  75377. */
  75378. constructor(meshLoadOptions?: MeshLoadOptions);
  75379. private static get currentMeshLoadOptions();
  75380. /**
  75381. * Calls synchronously the MTL file attached to this obj.
  75382. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  75383. * Without this function materials are not displayed in the first frame (but displayed after).
  75384. * In consequence it is impossible to get material information in your HTML file
  75385. *
  75386. * @param url The URL of the MTL file
  75387. * @param rootUrl
  75388. * @param onSuccess Callback function to be called when the MTL file is loaded
  75389. * @private
  75390. */
  75391. private _loadMTL;
  75392. /**
  75393. * Instantiates a OBJ file loader plugin.
  75394. * @returns the created plugin
  75395. */
  75396. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  75397. /**
  75398. * If the data string can be loaded directly.
  75399. *
  75400. * @param data string containing the file data
  75401. * @returns if the data can be loaded directly
  75402. */
  75403. canDirectLoad(data: string): boolean;
  75404. /**
  75405. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  75406. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  75407. * @param scene the scene the meshes should be added to
  75408. * @param data the OBJ data to load
  75409. * @param rootUrl root url to load from
  75410. * @param onProgress event that fires when loading progress has occured
  75411. * @param fileName Defines the name of the file to load
  75412. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  75413. */
  75414. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  75415. meshes: AbstractMesh[];
  75416. particleSystems: IParticleSystem[];
  75417. skeletons: Skeleton[];
  75418. animationGroups: AnimationGroup[];
  75419. }>;
  75420. /**
  75421. * Imports all objects from the loaded OBJ data and adds them to the scene
  75422. * @param scene the scene the objects should be added to
  75423. * @param data the OBJ data to load
  75424. * @param rootUrl root url to load from
  75425. * @param onProgress event that fires when loading progress has occured
  75426. * @param fileName Defines the name of the file to load
  75427. * @returns a promise which completes when objects have been loaded to the scene
  75428. */
  75429. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  75430. /**
  75431. * Load into an asset container.
  75432. * @param scene The scene to load into
  75433. * @param data The data to import
  75434. * @param rootUrl The root url for scene and resources
  75435. * @param onProgress The callback when the load progresses
  75436. * @param fileName Defines the name of the file to load
  75437. * @returns The loaded asset container
  75438. */
  75439. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  75440. /**
  75441. * Read the OBJ file and create an Array of meshes.
  75442. * Each mesh contains all information given by the OBJ and the MTL file.
  75443. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  75444. *
  75445. * @param meshesNames
  75446. * @param scene Scene The scene where are displayed the data
  75447. * @param data String The content of the obj file
  75448. * @param rootUrl String The path to the folder
  75449. * @returns Array<AbstractMesh>
  75450. * @private
  75451. */
  75452. private _parseSolid;
  75453. }
  75454. }
  75455. declare module BABYLON {
  75456. /**
  75457. * STL file type loader.
  75458. * This is a babylon scene loader plugin.
  75459. */
  75460. export class STLFileLoader implements ISceneLoaderPlugin {
  75461. /** @hidden */
  75462. solidPattern: RegExp;
  75463. /** @hidden */
  75464. facetsPattern: RegExp;
  75465. /** @hidden */
  75466. normalPattern: RegExp;
  75467. /** @hidden */
  75468. vertexPattern: RegExp;
  75469. /**
  75470. * Defines the name of the plugin.
  75471. */
  75472. name: string;
  75473. /**
  75474. * Defines the extensions the stl loader is able to load.
  75475. * force data to come in as an ArrayBuffer
  75476. * we'll convert to string if it looks like it's an ASCII .stl
  75477. */
  75478. extensions: ISceneLoaderPluginExtensions;
  75479. /**
  75480. * Import meshes into a scene.
  75481. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  75482. * @param scene The scene to import into
  75483. * @param data The data to import
  75484. * @param rootUrl The root url for scene and resources
  75485. * @param meshes The meshes array to import into
  75486. * @param particleSystems The particle systems array to import into
  75487. * @param skeletons The skeletons array to import into
  75488. * @param onError The callback when import fails
  75489. * @returns True if successful or false otherwise
  75490. */
  75491. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  75492. /**
  75493. * Load into a scene.
  75494. * @param scene The scene to load into
  75495. * @param data The data to import
  75496. * @param rootUrl The root url for scene and resources
  75497. * @param onError The callback when import fails
  75498. * @returns true if successful or false otherwise
  75499. */
  75500. load(scene: Scene, data: any, rootUrl: string): boolean;
  75501. /**
  75502. * Load into an asset container.
  75503. * @param scene The scene to load into
  75504. * @param data The data to import
  75505. * @param rootUrl The root url for scene and resources
  75506. * @param onError The callback when import fails
  75507. * @returns The loaded asset container
  75508. */
  75509. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  75510. private _isBinary;
  75511. private _parseBinary;
  75512. private _parseASCII;
  75513. }
  75514. }
  75515. declare module BABYLON {
  75516. /**
  75517. * Class for generating OBJ data from a Babylon scene.
  75518. */
  75519. export class OBJExport {
  75520. /**
  75521. * Exports the geometry of a Mesh array in .OBJ file format (text)
  75522. * @param mesh defines the list of meshes to serialize
  75523. * @param materials defines if materials should be exported
  75524. * @param matlibname defines the name of the associated mtl file
  75525. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  75526. * @returns the OBJ content
  75527. */
  75528. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  75529. /**
  75530. * Exports the material(s) of a mesh in .MTL file format (text)
  75531. * @param mesh defines the mesh to extract the material from
  75532. * @returns the mtl content
  75533. */
  75534. static MTL(mesh: Mesh): string;
  75535. }
  75536. }
  75537. declare module BABYLON {
  75538. /** @hidden */
  75539. export var __IGLTFExporterExtension: number;
  75540. /**
  75541. * Interface for extending the exporter
  75542. * @hidden
  75543. */
  75544. export interface IGLTFExporterExtension {
  75545. /**
  75546. * The name of this extension
  75547. */
  75548. readonly name: string;
  75549. /**
  75550. * Defines whether this extension is enabled
  75551. */
  75552. enabled: boolean;
  75553. /**
  75554. * Defines whether this extension is required
  75555. */
  75556. required: boolean;
  75557. }
  75558. }
  75559. declare module BABYLON.GLTF2.Exporter {
  75560. /** @hidden */
  75561. export var __IGLTFExporterExtensionV2: number;
  75562. /**
  75563. * Interface for a glTF exporter extension
  75564. * @hidden
  75565. */
  75566. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  75567. /**
  75568. * Define this method to modify the default behavior before exporting a texture
  75569. * @param context The context when loading the asset
  75570. * @param babylonTexture The Babylon.js texture
  75571. * @param mimeType The mime-type of the generated image
  75572. * @returns A promise that resolves with the exported texture
  75573. */
  75574. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  75575. /**
  75576. * Define this method to get notified when a texture info is created
  75577. * @param context The context when loading the asset
  75578. * @param textureInfo The glTF texture info
  75579. * @param babylonTexture The Babylon.js texture
  75580. */
  75581. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  75582. /**
  75583. * Define this method to modify the default behavior when exporting texture info
  75584. * @param context The context when loading the asset
  75585. * @param meshPrimitive glTF mesh primitive
  75586. * @param babylonSubMesh Babylon submesh
  75587. * @param binaryWriter glTF serializer binary writer instance
  75588. * @returns nullable IMeshPrimitive promise
  75589. */
  75590. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  75591. /**
  75592. * Define this method to modify the default behavior when exporting a node
  75593. * @param context The context when exporting the node
  75594. * @param node glTF node
  75595. * @param babylonNode BabylonJS node
  75596. * @returns nullable INode promise
  75597. */
  75598. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Promise<INode>;
  75599. /**
  75600. * Define this method to modify the default behavior when exporting a material
  75601. * @param material glTF material
  75602. * @param babylonMaterial BabylonJS material
  75603. * @returns nullable IMaterial promise
  75604. */
  75605. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  75606. /**
  75607. * Define this method to return additional textures to export from a material
  75608. * @param material glTF material
  75609. * @param babylonMaterial BabylonJS material
  75610. * @returns List of textures
  75611. */
  75612. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  75613. /** Gets a boolean indicating that this extension was used */
  75614. wasUsed: boolean;
  75615. /** Gets a boolean indicating that this extension is required for the file to work */
  75616. required: boolean;
  75617. /**
  75618. * Called after the exporter state changes to EXPORTING
  75619. */
  75620. onExporting?(): void;
  75621. }
  75622. }
  75623. declare module BABYLON.GLTF2.Exporter {
  75624. /**
  75625. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  75626. * @hidden
  75627. */
  75628. export class _GLTFMaterialExporter {
  75629. /**
  75630. * Represents the dielectric specular values for R, G and B
  75631. */
  75632. private static readonly _DielectricSpecular;
  75633. /**
  75634. * Allows the maximum specular power to be defined for material calculations
  75635. */
  75636. private static readonly _MaxSpecularPower;
  75637. /**
  75638. * Mapping to store textures
  75639. */
  75640. private _textureMap;
  75641. /**
  75642. * Numeric tolerance value
  75643. */
  75644. private static readonly _Epsilon;
  75645. /**
  75646. * Reference to the glTF Exporter
  75647. */
  75648. private _exporter;
  75649. constructor(exporter: _Exporter);
  75650. /**
  75651. * Specifies if two colors are approximately equal in value
  75652. * @param color1 first color to compare to
  75653. * @param color2 second color to compare to
  75654. * @param epsilon threshold value
  75655. */
  75656. private static FuzzyEquals;
  75657. /**
  75658. * Gets the materials from a Babylon scene and converts them to glTF materials
  75659. * @param scene babylonjs scene
  75660. * @param mimeType texture mime type
  75661. * @param images array of images
  75662. * @param textures array of textures
  75663. * @param materials array of materials
  75664. * @param imageData mapping of texture names to base64 textures
  75665. * @param hasTextureCoords specifies if texture coordinates are present on the material
  75666. */
  75667. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  75668. /**
  75669. * Makes a copy of the glTF material without the texture parameters
  75670. * @param originalMaterial original glTF material
  75671. * @returns glTF material without texture parameters
  75672. */
  75673. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  75674. /**
  75675. * Specifies if the material has any texture parameters present
  75676. * @param material glTF Material
  75677. * @returns boolean specifying if texture parameters are present
  75678. */
  75679. _hasTexturesPresent(material: IMaterial): boolean;
  75680. /**
  75681. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  75682. * @param babylonStandardMaterial
  75683. * @returns glTF Metallic Roughness Material representation
  75684. */
  75685. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  75686. /**
  75687. * Computes the metallic factor
  75688. * @param diffuse diffused value
  75689. * @param specular specular value
  75690. * @param oneMinusSpecularStrength one minus the specular strength
  75691. * @returns metallic value
  75692. */
  75693. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  75694. /**
  75695. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  75696. * @param glTFMaterial glTF material
  75697. * @param babylonMaterial Babylon material
  75698. */
  75699. private static _SetAlphaMode;
  75700. /**
  75701. * Converts a Babylon Standard Material to a glTF Material
  75702. * @param babylonStandardMaterial BJS Standard Material
  75703. * @param mimeType mime type to use for the textures
  75704. * @param images array of glTF image interfaces
  75705. * @param textures array of glTF texture interfaces
  75706. * @param materials array of glTF material interfaces
  75707. * @param imageData map of image file name to data
  75708. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  75709. */
  75710. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  75711. private _finishMaterial;
  75712. /**
  75713. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  75714. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  75715. * @param mimeType mime type to use for the textures
  75716. * @param images array of glTF image interfaces
  75717. * @param textures array of glTF texture interfaces
  75718. * @param materials array of glTF material interfaces
  75719. * @param imageData map of image file name to data
  75720. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  75721. */
  75722. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  75723. /**
  75724. * Converts an image typed array buffer to a base64 image
  75725. * @param buffer typed array buffer
  75726. * @param width width of the image
  75727. * @param height height of the image
  75728. * @param mimeType mimetype of the image
  75729. * @returns base64 image string
  75730. */
  75731. private _createBase64FromCanvasAsync;
  75732. /**
  75733. * Generates a white texture based on the specified width and height
  75734. * @param width width of the texture in pixels
  75735. * @param height height of the texture in pixels
  75736. * @param scene babylonjs scene
  75737. * @returns white texture
  75738. */
  75739. private _createWhiteTexture;
  75740. /**
  75741. * 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
  75742. * @param texture1 first texture to resize
  75743. * @param texture2 second texture to resize
  75744. * @param scene babylonjs scene
  75745. * @returns resized textures or null
  75746. */
  75747. private _resizeTexturesToSameDimensions;
  75748. /**
  75749. * Converts an array of pixels to a Float32Array
  75750. * Throws an error if the pixel format is not supported
  75751. * @param pixels - array buffer containing pixel values
  75752. * @returns Float32 of pixels
  75753. */
  75754. private _convertPixelArrayToFloat32;
  75755. /**
  75756. * Convert Specular Glossiness Textures to Metallic Roughness
  75757. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  75758. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  75759. * @param diffuseTexture texture used to store diffuse information
  75760. * @param specularGlossinessTexture texture used to store specular and glossiness information
  75761. * @param factors specular glossiness material factors
  75762. * @param mimeType the mime type to use for the texture
  75763. * @returns pbr metallic roughness interface or null
  75764. */
  75765. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  75766. /**
  75767. * Converts specular glossiness material properties to metallic roughness
  75768. * @param specularGlossiness interface with specular glossiness material properties
  75769. * @returns interface with metallic roughness material properties
  75770. */
  75771. private _convertSpecularGlossinessToMetallicRoughness;
  75772. /**
  75773. * Calculates the surface reflectance, independent of lighting conditions
  75774. * @param color Color source to calculate brightness from
  75775. * @returns number representing the perceived brightness, or zero if color is undefined
  75776. */
  75777. private _getPerceivedBrightness;
  75778. /**
  75779. * Returns the maximum color component value
  75780. * @param color
  75781. * @returns maximum color component value, or zero if color is null or undefined
  75782. */
  75783. private _getMaxComponent;
  75784. /**
  75785. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  75786. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  75787. * @param mimeType mime type to use for the textures
  75788. * @param images array of glTF image interfaces
  75789. * @param textures array of glTF texture interfaces
  75790. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  75791. * @param imageData map of image file name to data
  75792. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  75793. * @returns glTF PBR Metallic Roughness factors
  75794. */
  75795. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  75796. private _getGLTFTextureSampler;
  75797. private _getGLTFTextureWrapMode;
  75798. private _getGLTFTextureWrapModesSampler;
  75799. /**
  75800. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  75801. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  75802. * @param mimeType mime type to use for the textures
  75803. * @param images array of glTF image interfaces
  75804. * @param textures array of glTF texture interfaces
  75805. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  75806. * @param imageData map of image file name to data
  75807. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  75808. * @returns glTF PBR Metallic Roughness factors
  75809. */
  75810. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  75811. /**
  75812. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  75813. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  75814. * @param mimeType mime type to use for the textures
  75815. * @param images array of glTF image interfaces
  75816. * @param textures array of glTF texture interfaces
  75817. * @param materials array of glTF material interfaces
  75818. * @param imageData map of image file name to data
  75819. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  75820. */
  75821. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  75822. private setMetallicRoughnessPbrMaterial;
  75823. private getPixelsFromTexture;
  75824. /**
  75825. * Extracts a texture from a Babylon texture into file data and glTF data
  75826. * @param babylonTexture Babylon texture to extract
  75827. * @param mimeType Mime Type of the babylonTexture
  75828. * @return glTF texture info, or null if the texture format is not supported
  75829. */
  75830. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  75831. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  75832. /**
  75833. * Builds a texture from base64 string
  75834. * @param base64Texture base64 texture string
  75835. * @param baseTextureName Name to use for the texture
  75836. * @param mimeType image mime type for the texture
  75837. * @param images array of images
  75838. * @param textures array of textures
  75839. * @param imageData map of image data
  75840. * @returns glTF texture info, or null if the texture format is not supported
  75841. */
  75842. private _getTextureInfoFromBase64;
  75843. }
  75844. }
  75845. declare module BABYLON {
  75846. /**
  75847. * Class for holding and downloading glTF file data
  75848. */
  75849. export class GLTFData {
  75850. /**
  75851. * Object which contains the file name as the key and its data as the value
  75852. */
  75853. glTFFiles: {
  75854. [fileName: string]: string | Blob;
  75855. };
  75856. /**
  75857. * Initializes the glTF file object
  75858. */
  75859. constructor();
  75860. /**
  75861. * Downloads the glTF data as files based on their names and data
  75862. */
  75863. downloadFiles(): void;
  75864. }
  75865. }
  75866. declare module BABYLON {
  75867. /**
  75868. * Holds a collection of exporter options and parameters
  75869. */
  75870. export interface IExportOptions {
  75871. /**
  75872. * Function which indicates whether a babylon node should be exported or not
  75873. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  75874. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  75875. */
  75876. shouldExportNode?(node: Node): boolean;
  75877. /**
  75878. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  75879. * @param metadata source metadata to read from
  75880. * @returns the data to store to glTF node extras
  75881. */
  75882. metadataSelector?(metadata: any): any;
  75883. /**
  75884. * The sample rate to bake animation curves
  75885. */
  75886. animationSampleRate?: number;
  75887. /**
  75888. * Begin serialization without waiting for the scene to be ready
  75889. */
  75890. exportWithoutWaitingForScene?: boolean;
  75891. }
  75892. /**
  75893. * Class for generating glTF data from a Babylon scene.
  75894. */
  75895. export class GLTF2Export {
  75896. /**
  75897. * Exports the geometry of the scene to .gltf file format asynchronously
  75898. * @param scene Babylon scene with scene hierarchy information
  75899. * @param filePrefix File prefix to use when generating the glTF file
  75900. * @param options Exporter options
  75901. * @returns Returns an object with a .gltf file and associates texture names
  75902. * as keys and their data and paths as values
  75903. */
  75904. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  75905. private static _PreExportAsync;
  75906. private static _PostExportAsync;
  75907. /**
  75908. * Exports the geometry of the scene to .glb file format asychronously
  75909. * @param scene Babylon scene with scene hierarchy information
  75910. * @param filePrefix File prefix to use when generating glb file
  75911. * @param options Exporter options
  75912. * @returns Returns an object with a .glb filename as key and data as value
  75913. */
  75914. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  75915. }
  75916. }
  75917. declare module BABYLON.GLTF2.Exporter {
  75918. /**
  75919. * @hidden
  75920. */
  75921. export class _GLTFUtilities {
  75922. /**
  75923. * Creates a buffer view based on the supplied arguments
  75924. * @param bufferIndex index value of the specified buffer
  75925. * @param byteOffset byte offset value
  75926. * @param byteLength byte length of the bufferView
  75927. * @param byteStride byte distance between conequential elements
  75928. * @param name name of the buffer view
  75929. * @returns bufferView for glTF
  75930. */
  75931. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  75932. /**
  75933. * Creates an accessor based on the supplied arguments
  75934. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  75935. * @param name The name of the accessor
  75936. * @param type The type of the accessor
  75937. * @param componentType The datatype of components in the attribute
  75938. * @param count The number of attributes referenced by this accessor
  75939. * @param byteOffset The offset relative to the start of the bufferView in bytes
  75940. * @param min Minimum value of each component in this attribute
  75941. * @param max Maximum value of each component in this attribute
  75942. * @returns accessor for glTF
  75943. */
  75944. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  75945. /**
  75946. * Calculates the minimum and maximum values of an array of position floats
  75947. * @param positions Positions array of a mesh
  75948. * @param vertexStart Starting vertex offset to calculate min and max values
  75949. * @param vertexCount Number of vertices to check for min and max values
  75950. * @returns min number array and max number array
  75951. */
  75952. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  75953. min: number[];
  75954. max: number[];
  75955. };
  75956. /**
  75957. * Converts a new right-handed Vector3
  75958. * @param vector vector3 array
  75959. * @returns right-handed Vector3
  75960. */
  75961. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  75962. /**
  75963. * Converts a Vector3 to right-handed
  75964. * @param vector Vector3 to convert to right-handed
  75965. */
  75966. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  75967. /**
  75968. * Converts a three element number array to right-handed
  75969. * @param vector number array to convert to right-handed
  75970. */
  75971. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  75972. /**
  75973. * Converts a new right-handed Vector3
  75974. * @param vector vector3 array
  75975. * @returns right-handed Vector3
  75976. */
  75977. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  75978. /**
  75979. * Converts a Vector3 to right-handed
  75980. * @param vector Vector3 to convert to right-handed
  75981. */
  75982. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  75983. /**
  75984. * Converts a three element number array to right-handed
  75985. * @param vector number array to convert to right-handed
  75986. */
  75987. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  75988. /**
  75989. * Converts a Vector4 to right-handed
  75990. * @param vector Vector4 to convert to right-handed
  75991. */
  75992. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  75993. /**
  75994. * Converts a Vector4 to right-handed
  75995. * @param vector Vector4 to convert to right-handed
  75996. */
  75997. static _GetRightHandedArray4FromRef(vector: number[]): void;
  75998. /**
  75999. * Converts a Quaternion to right-handed
  76000. * @param quaternion Source quaternion to convert to right-handed
  76001. */
  76002. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  76003. /**
  76004. * Converts a Quaternion to right-handed
  76005. * @param quaternion Source quaternion to convert to right-handed
  76006. */
  76007. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  76008. static _NormalizeTangentFromRef(tangent: Vector4): void;
  76009. }
  76010. }
  76011. declare module BABYLON.GLTF2.Exporter {
  76012. /**
  76013. * Converts Babylon Scene into glTF 2.0.
  76014. * @hidden
  76015. */
  76016. export class _Exporter {
  76017. /**
  76018. * Stores the glTF to export
  76019. */
  76020. _glTF: IGLTF;
  76021. /**
  76022. * Stores all generated buffer views, which represents views into the main glTF buffer data
  76023. */
  76024. _bufferViews: IBufferView[];
  76025. /**
  76026. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  76027. */
  76028. _accessors: IAccessor[];
  76029. /**
  76030. * Stores all the generated nodes, which contains transform and/or mesh information per node
  76031. */
  76032. private _nodes;
  76033. /**
  76034. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  76035. */
  76036. private _scenes;
  76037. /**
  76038. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  76039. */
  76040. private _meshes;
  76041. /**
  76042. * Stores all the generated material information, which represents the appearance of each primitive
  76043. */
  76044. _materials: IMaterial[];
  76045. _materialMap: {
  76046. [materialID: number]: number;
  76047. };
  76048. /**
  76049. * Stores all the generated texture information, which is referenced by glTF materials
  76050. */
  76051. _textures: ITexture[];
  76052. /**
  76053. * Stores all the generated image information, which is referenced by glTF textures
  76054. */
  76055. _images: IImage[];
  76056. /**
  76057. * Stores all the texture samplers
  76058. */
  76059. _samplers: ISampler[];
  76060. /**
  76061. * Stores all the generated animation samplers, which is referenced by glTF animations
  76062. */
  76063. /**
  76064. * Stores the animations for glTF models
  76065. */
  76066. private _animations;
  76067. /**
  76068. * Stores the total amount of bytes stored in the glTF buffer
  76069. */
  76070. private _totalByteLength;
  76071. /**
  76072. * Stores a reference to the Babylon scene containing the source geometry and material information
  76073. */
  76074. _babylonScene: Scene;
  76075. /**
  76076. * Stores a map of the image data, where the key is the file name and the value
  76077. * is the image data
  76078. */
  76079. _imageData: {
  76080. [fileName: string]: {
  76081. data: Uint8Array;
  76082. mimeType: ImageMimeType;
  76083. };
  76084. };
  76085. /**
  76086. * Stores a map of the unique id of a node to its index in the node array
  76087. */
  76088. private _nodeMap;
  76089. /**
  76090. * Specifies if the Babylon scene should be converted to right-handed on export
  76091. */
  76092. _convertToRightHandedSystem: boolean;
  76093. /**
  76094. * Baked animation sample rate
  76095. */
  76096. private _animationSampleRate;
  76097. private _options;
  76098. private _localEngine;
  76099. _glTFMaterialExporter: _GLTFMaterialExporter;
  76100. private _extensions;
  76101. private static _ExtensionNames;
  76102. private static _ExtensionFactories;
  76103. private _applyExtension;
  76104. private _applyExtensions;
  76105. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  76106. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  76107. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Promise<Nullable<INode>>;
  76108. _extensionsPostExportMaterialAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  76109. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  76110. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  76111. private _forEachExtensions;
  76112. private _extensionsOnExporting;
  76113. /**
  76114. * Load glTF serializer extensions
  76115. */
  76116. private _loadExtensions;
  76117. /**
  76118. * Creates a glTF Exporter instance, which can accept optional exporter options
  76119. * @param babylonScene Babylon scene object
  76120. * @param options Options to modify the behavior of the exporter
  76121. */
  76122. constructor(babylonScene: Scene, options?: IExportOptions);
  76123. dispose(): void;
  76124. /**
  76125. * Registers a glTF exporter extension
  76126. * @param name Name of the extension to export
  76127. * @param factory The factory function that creates the exporter extension
  76128. */
  76129. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  76130. /**
  76131. * Un-registers an exporter extension
  76132. * @param name The name fo the exporter extension
  76133. * @returns A boolean indicating whether the extension has been un-registered
  76134. */
  76135. static UnregisterExtension(name: string): boolean;
  76136. /**
  76137. * Lazy load a local engine
  76138. */
  76139. _getLocalEngine(): Engine;
  76140. private reorderIndicesBasedOnPrimitiveMode;
  76141. /**
  76142. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  76143. * clock-wise during export to glTF
  76144. * @param submesh BabylonJS submesh
  76145. * @param primitiveMode Primitive mode of the mesh
  76146. * @param sideOrientation the winding order of the submesh
  76147. * @param vertexBufferKind The type of vertex attribute
  76148. * @param meshAttributeArray The vertex attribute data
  76149. * @param byteOffset The offset to the binary data
  76150. * @param binaryWriter The binary data for the glTF file
  76151. */
  76152. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  76153. /**
  76154. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  76155. * clock-wise during export to glTF
  76156. * @param submesh BabylonJS submesh
  76157. * @param primitiveMode Primitive mode of the mesh
  76158. * @param sideOrientation the winding order of the submesh
  76159. * @param vertexBufferKind The type of vertex attribute
  76160. * @param meshAttributeArray The vertex attribute data
  76161. * @param byteOffset The offset to the binary data
  76162. * @param binaryWriter The binary data for the glTF file
  76163. */
  76164. private reorderTriangleFillMode;
  76165. /**
  76166. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  76167. * clock-wise during export to glTF
  76168. * @param submesh BabylonJS submesh
  76169. * @param primitiveMode Primitive mode of the mesh
  76170. * @param sideOrientation the winding order of the submesh
  76171. * @param vertexBufferKind The type of vertex attribute
  76172. * @param meshAttributeArray The vertex attribute data
  76173. * @param byteOffset The offset to the binary data
  76174. * @param binaryWriter The binary data for the glTF file
  76175. */
  76176. private reorderTriangleStripDrawMode;
  76177. /**
  76178. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  76179. * clock-wise during export to glTF
  76180. * @param submesh BabylonJS submesh
  76181. * @param primitiveMode Primitive mode of the mesh
  76182. * @param sideOrientation the winding order of the submesh
  76183. * @param vertexBufferKind The type of vertex attribute
  76184. * @param meshAttributeArray The vertex attribute data
  76185. * @param byteOffset The offset to the binary data
  76186. * @param binaryWriter The binary data for the glTF file
  76187. */
  76188. private reorderTriangleFanMode;
  76189. /**
  76190. * Writes the vertex attribute data to binary
  76191. * @param vertices The vertices to write to the binary writer
  76192. * @param byteOffset The offset into the binary writer to overwrite binary data
  76193. * @param vertexAttributeKind The vertex attribute type
  76194. * @param meshAttributeArray The vertex attribute data
  76195. * @param binaryWriter The writer containing the binary data
  76196. */
  76197. private writeVertexAttributeData;
  76198. /**
  76199. * Writes mesh attribute data to a data buffer
  76200. * Returns the bytelength of the data
  76201. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  76202. * @param meshAttributeArray Array containing the attribute data
  76203. * @param binaryWriter The buffer to write the binary data to
  76204. * @param indices Used to specify the order of the vertex data
  76205. */
  76206. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  76207. /**
  76208. * Generates glTF json data
  76209. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  76210. * @param glTFPrefix Text to use when prefixing a glTF file
  76211. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  76212. * @returns json data as string
  76213. */
  76214. private generateJSON;
  76215. /**
  76216. * Generates data for .gltf and .bin files based on the glTF prefix string
  76217. * @param glTFPrefix Text to use when prefixing a glTF file
  76218. * @param dispose Dispose the exporter
  76219. * @returns GLTFData with glTF file data
  76220. */
  76221. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  76222. /**
  76223. * Creates a binary buffer for glTF
  76224. * @returns array buffer for binary data
  76225. */
  76226. private _generateBinaryAsync;
  76227. /**
  76228. * Pads the number to a multiple of 4
  76229. * @param num number to pad
  76230. * @returns padded number
  76231. */
  76232. private _getPadding;
  76233. /**
  76234. * @hidden
  76235. */
  76236. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  76237. /**
  76238. * Sets the TRS for each node
  76239. * @param node glTF Node for storing the transformation data
  76240. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  76241. */
  76242. private setNodeTransformation;
  76243. private getVertexBufferFromMesh;
  76244. /**
  76245. * Creates a bufferview based on the vertices type for the Babylon mesh
  76246. * @param kind Indicates the type of vertices data
  76247. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  76248. * @param binaryWriter The buffer to write the bufferview data to
  76249. */
  76250. private createBufferViewKind;
  76251. /**
  76252. * The primitive mode of the Babylon mesh
  76253. * @param babylonMesh The BabylonJS mesh
  76254. */
  76255. private getMeshPrimitiveMode;
  76256. /**
  76257. * Sets the primitive mode of the glTF mesh primitive
  76258. * @param meshPrimitive glTF mesh primitive
  76259. * @param primitiveMode The primitive mode
  76260. */
  76261. private setPrimitiveMode;
  76262. /**
  76263. * Sets the vertex attribute accessor based of the glTF mesh primitive
  76264. * @param meshPrimitive glTF mesh primitive
  76265. * @param attributeKind vertex attribute
  76266. * @returns boolean specifying if uv coordinates are present
  76267. */
  76268. private setAttributeKind;
  76269. /**
  76270. * Sets data for the primitive attributes of each submesh
  76271. * @param mesh glTF Mesh object to store the primitive attribute information
  76272. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  76273. * @param binaryWriter Buffer to write the attribute data to
  76274. */
  76275. private setPrimitiveAttributesAsync;
  76276. /**
  76277. * Creates a glTF scene based on the array of meshes
  76278. * Returns the the total byte offset
  76279. * @param babylonScene Babylon scene to get the mesh data from
  76280. * @param binaryWriter Buffer to write binary data to
  76281. */
  76282. private createSceneAsync;
  76283. /**
  76284. * Creates a mapping of Node unique id to node index and handles animations
  76285. * @param babylonScene Babylon Scene
  76286. * @param nodes Babylon transform nodes
  76287. * @param binaryWriter Buffer to write binary data to
  76288. * @returns Node mapping of unique id to index
  76289. */
  76290. private createNodeMapAndAnimationsAsync;
  76291. /**
  76292. * Creates a glTF node from a Babylon mesh
  76293. * @param babylonMesh Source Babylon mesh
  76294. * @param binaryWriter Buffer for storing geometry data
  76295. * @returns glTF node
  76296. */
  76297. private createNodeAsync;
  76298. }
  76299. /**
  76300. * @hidden
  76301. *
  76302. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  76303. */
  76304. export class _BinaryWriter {
  76305. /**
  76306. * Array buffer which stores all binary data
  76307. */
  76308. private _arrayBuffer;
  76309. /**
  76310. * View of the array buffer
  76311. */
  76312. private _dataView;
  76313. /**
  76314. * byte offset of data in array buffer
  76315. */
  76316. private _byteOffset;
  76317. /**
  76318. * Initialize binary writer with an initial byte length
  76319. * @param byteLength Initial byte length of the array buffer
  76320. */
  76321. constructor(byteLength: number);
  76322. /**
  76323. * Resize the array buffer to the specified byte length
  76324. * @param byteLength
  76325. */
  76326. private resizeBuffer;
  76327. /**
  76328. * Get an array buffer with the length of the byte offset
  76329. * @returns ArrayBuffer resized to the byte offset
  76330. */
  76331. getArrayBuffer(): ArrayBuffer;
  76332. /**
  76333. * Get the byte offset of the array buffer
  76334. * @returns byte offset
  76335. */
  76336. getByteOffset(): number;
  76337. /**
  76338. * Stores an UInt8 in the array buffer
  76339. * @param entry
  76340. * @param byteOffset If defined, specifies where to set the value as an offset.
  76341. */
  76342. setUInt8(entry: number, byteOffset?: number): void;
  76343. /**
  76344. * Gets an UInt32 in the array buffer
  76345. * @param entry
  76346. * @param byteOffset If defined, specifies where to set the value as an offset.
  76347. */
  76348. getUInt32(byteOffset: number): number;
  76349. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  76350. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  76351. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  76352. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  76353. /**
  76354. * Stores a Float32 in the array buffer
  76355. * @param entry
  76356. */
  76357. setFloat32(entry: number, byteOffset?: number): void;
  76358. /**
  76359. * Stores an UInt32 in the array buffer
  76360. * @param entry
  76361. * @param byteOffset If defined, specifies where to set the value as an offset.
  76362. */
  76363. setUInt32(entry: number, byteOffset?: number): void;
  76364. }
  76365. }
  76366. declare module BABYLON.GLTF2.Exporter {
  76367. /**
  76368. * @hidden
  76369. * Interface to store animation data.
  76370. */
  76371. export interface _IAnimationData {
  76372. /**
  76373. * Keyframe data.
  76374. */
  76375. inputs: number[];
  76376. /**
  76377. * Value data.
  76378. */
  76379. outputs: number[][];
  76380. /**
  76381. * Animation interpolation data.
  76382. */
  76383. samplerInterpolation: AnimationSamplerInterpolation;
  76384. /**
  76385. * Minimum keyframe value.
  76386. */
  76387. inputsMin: number;
  76388. /**
  76389. * Maximum keyframe value.
  76390. */
  76391. inputsMax: number;
  76392. }
  76393. /**
  76394. * @hidden
  76395. */
  76396. export interface _IAnimationInfo {
  76397. /**
  76398. * The target channel for the animation
  76399. */
  76400. animationChannelTargetPath: AnimationChannelTargetPath;
  76401. /**
  76402. * The glTF accessor type for the data.
  76403. */
  76404. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  76405. /**
  76406. * Specifies if quaternions should be used.
  76407. */
  76408. useQuaternion: boolean;
  76409. }
  76410. /**
  76411. * @hidden
  76412. * Utility class for generating glTF animation data from BabylonJS.
  76413. */
  76414. export class _GLTFAnimation {
  76415. /**
  76416. * @ignore
  76417. *
  76418. * Creates glTF channel animation from BabylonJS animation.
  76419. * @param babylonTransformNode - BabylonJS mesh.
  76420. * @param animation - animation.
  76421. * @param animationChannelTargetPath - The target animation channel.
  76422. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  76423. * @param useQuaternion - Specifies if quaternions are used.
  76424. * @returns nullable IAnimationData
  76425. */
  76426. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  76427. private static _DeduceAnimationInfo;
  76428. /**
  76429. * @ignore
  76430. * Create node animations from the transform node animations
  76431. * @param babylonNode
  76432. * @param runtimeGLTFAnimation
  76433. * @param idleGLTFAnimations
  76434. * @param nodeMap
  76435. * @param nodes
  76436. * @param binaryWriter
  76437. * @param bufferViews
  76438. * @param accessors
  76439. * @param convertToRightHandedSystem
  76440. */
  76441. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  76442. [key: number]: number;
  76443. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  76444. /**
  76445. * @ignore
  76446. * Create node animations from the animation groups
  76447. * @param babylonScene
  76448. * @param glTFAnimations
  76449. * @param nodeMap
  76450. * @param nodes
  76451. * @param binaryWriter
  76452. * @param bufferViews
  76453. * @param accessors
  76454. * @param convertToRightHandedSystem
  76455. */
  76456. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  76457. [key: number]: number;
  76458. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  76459. private static AddAnimation;
  76460. /**
  76461. * Create a baked animation
  76462. * @param babylonTransformNode BabylonJS mesh
  76463. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  76464. * @param animationChannelTargetPath animation target channel
  76465. * @param minFrame minimum animation frame
  76466. * @param maxFrame maximum animation frame
  76467. * @param fps frames per second of the animation
  76468. * @param inputs input key frames of the animation
  76469. * @param outputs output key frame data of the animation
  76470. * @param convertToRightHandedSystem converts the values to right-handed
  76471. * @param useQuaternion specifies if quaternions should be used
  76472. */
  76473. private static _CreateBakedAnimation;
  76474. private static _ConvertFactorToVector3OrQuaternion;
  76475. private static _SetInterpolatedValue;
  76476. /**
  76477. * Creates linear animation from the animation key frames
  76478. * @param babylonTransformNode BabylonJS mesh
  76479. * @param animation BabylonJS animation
  76480. * @param animationChannelTargetPath The target animation channel
  76481. * @param frameDelta The difference between the last and first frame of the animation
  76482. * @param inputs Array to store the key frame times
  76483. * @param outputs Array to store the key frame data
  76484. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  76485. * @param useQuaternion Specifies if quaternions are used in the animation
  76486. */
  76487. private static _CreateLinearOrStepAnimation;
  76488. /**
  76489. * Creates cubic spline animation from the animation key frames
  76490. * @param babylonTransformNode BabylonJS mesh
  76491. * @param animation BabylonJS animation
  76492. * @param animationChannelTargetPath The target animation channel
  76493. * @param frameDelta The difference between the last and first frame of the animation
  76494. * @param inputs Array to store the key frame times
  76495. * @param outputs Array to store the key frame data
  76496. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  76497. * @param useQuaternion Specifies if quaternions are used in the animation
  76498. */
  76499. private static _CreateCubicSplineAnimation;
  76500. private static _GetBasePositionRotationOrScale;
  76501. /**
  76502. * Adds a key frame value
  76503. * @param keyFrame
  76504. * @param animation
  76505. * @param outputs
  76506. * @param animationChannelTargetPath
  76507. * @param basePositionRotationOrScale
  76508. * @param convertToRightHandedSystem
  76509. * @param useQuaternion
  76510. */
  76511. private static _AddKeyframeValue;
  76512. /**
  76513. * Determine the interpolation based on the key frames
  76514. * @param keyFrames
  76515. * @param animationChannelTargetPath
  76516. * @param useQuaternion
  76517. */
  76518. private static _DeduceInterpolation;
  76519. /**
  76520. * Adds an input tangent or output tangent to the output data
  76521. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  76522. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  76523. * @param outputs The animation data by keyframe
  76524. * @param animationChannelTargetPath The target animation channel
  76525. * @param interpolation The interpolation type
  76526. * @param keyFrame The key frame with the animation data
  76527. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  76528. * @param useQuaternion Specifies if quaternions are used
  76529. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  76530. */
  76531. private static AddSplineTangent;
  76532. /**
  76533. * Get the minimum and maximum key frames' frame values
  76534. * @param keyFrames animation key frames
  76535. * @returns the minimum and maximum key frame value
  76536. */
  76537. private static calculateMinMaxKeyFrames;
  76538. }
  76539. }
  76540. declare module BABYLON.GLTF2.Exporter {
  76541. /** @hidden */
  76542. export var textureTransformPixelShader: {
  76543. name: string;
  76544. shader: string;
  76545. };
  76546. }
  76547. declare module BABYLON.GLTF2.Exporter.Extensions {
  76548. /**
  76549. * @hidden
  76550. */
  76551. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  76552. private _recordedTextures;
  76553. /** Name of this extension */
  76554. readonly name: string;
  76555. /** Defines whether this extension is enabled */
  76556. enabled: boolean;
  76557. /** Defines whether this extension is required */
  76558. required: boolean;
  76559. /** Reference to the glTF exporter */
  76560. private _wasUsed;
  76561. constructor(exporter: _Exporter);
  76562. dispose(): void;
  76563. /** @hidden */
  76564. get wasUsed(): boolean;
  76565. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  76566. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  76567. /**
  76568. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  76569. * @param babylonTexture
  76570. * @param offset
  76571. * @param rotation
  76572. * @param scale
  76573. * @param scene
  76574. */
  76575. private _textureTransformTextureAsync;
  76576. }
  76577. }
  76578. declare module BABYLON.GLTF2.Exporter.Extensions {
  76579. /**
  76580. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  76581. */
  76582. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  76583. /** The name of this extension. */
  76584. readonly name: string;
  76585. /** Defines whether this extension is enabled. */
  76586. enabled: boolean;
  76587. /** Defines whether this extension is required */
  76588. required: boolean;
  76589. /** Reference to the glTF exporter */
  76590. private _exporter;
  76591. private _lights;
  76592. /** @hidden */
  76593. constructor(exporter: _Exporter);
  76594. /** @hidden */
  76595. dispose(): void;
  76596. /** @hidden */
  76597. get wasUsed(): boolean;
  76598. /** @hidden */
  76599. onExporting(): void;
  76600. /**
  76601. * Define this method to modify the default behavior when exporting a node
  76602. * @param context The context when exporting the node
  76603. * @param node glTF node
  76604. * @param babylonNode BabylonJS node
  76605. * @returns nullable INode promise
  76606. */
  76607. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Promise<INode>;
  76608. }
  76609. }
  76610. declare module BABYLON.GLTF2.Exporter.Extensions {
  76611. /**
  76612. * @hidden
  76613. */
  76614. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  76615. /** Name of this extension */
  76616. readonly name: string;
  76617. /** Defines whether this extension is enabled */
  76618. enabled: boolean;
  76619. /** Defines whether this extension is required */
  76620. required: boolean;
  76621. /** Reference to the glTF exporter */
  76622. private _textureInfos;
  76623. private _exportedTextures;
  76624. private _wasUsed;
  76625. constructor(exporter: _Exporter);
  76626. dispose(): void;
  76627. /** @hidden */
  76628. get wasUsed(): boolean;
  76629. private _getTextureIndex;
  76630. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  76631. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  76632. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  76633. }
  76634. }
  76635. declare module BABYLON {
  76636. /**
  76637. * Class for generating STL data from a Babylon scene.
  76638. */
  76639. export class STLExport {
  76640. /**
  76641. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  76642. * @param meshes list defines the mesh to serialize
  76643. * @param download triggers the automatic download of the file.
  76644. * @param fileName changes the downloads fileName.
  76645. * @param binary changes the STL to a binary type.
  76646. * @param isLittleEndian toggle for binary type exporter.
  76647. * @returns the STL as UTF8 string
  76648. */
  76649. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  76650. }
  76651. }
  76652. declare module "babylonjs-gltf2interface" {
  76653. export = BABYLON.GLTF2;
  76654. }
  76655. /**
  76656. * Module for glTF 2.0 Interface
  76657. */
  76658. declare module BABYLON.GLTF2 {
  76659. /**
  76660. * The datatype of the components in the attribute
  76661. */
  76662. const enum AccessorComponentType {
  76663. /**
  76664. * Byte
  76665. */
  76666. BYTE = 5120,
  76667. /**
  76668. * Unsigned Byte
  76669. */
  76670. UNSIGNED_BYTE = 5121,
  76671. /**
  76672. * Short
  76673. */
  76674. SHORT = 5122,
  76675. /**
  76676. * Unsigned Short
  76677. */
  76678. UNSIGNED_SHORT = 5123,
  76679. /**
  76680. * Unsigned Int
  76681. */
  76682. UNSIGNED_INT = 5125,
  76683. /**
  76684. * Float
  76685. */
  76686. FLOAT = 5126,
  76687. }
  76688. /**
  76689. * Specifies if the attirbute is a scalar, vector, or matrix
  76690. */
  76691. const enum AccessorType {
  76692. /**
  76693. * Scalar
  76694. */
  76695. SCALAR = "SCALAR",
  76696. /**
  76697. * Vector2
  76698. */
  76699. VEC2 = "VEC2",
  76700. /**
  76701. * Vector3
  76702. */
  76703. VEC3 = "VEC3",
  76704. /**
  76705. * Vector4
  76706. */
  76707. VEC4 = "VEC4",
  76708. /**
  76709. * Matrix2x2
  76710. */
  76711. MAT2 = "MAT2",
  76712. /**
  76713. * Matrix3x3
  76714. */
  76715. MAT3 = "MAT3",
  76716. /**
  76717. * Matrix4x4
  76718. */
  76719. MAT4 = "MAT4",
  76720. }
  76721. /**
  76722. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  76723. */
  76724. const enum AnimationChannelTargetPath {
  76725. /**
  76726. * Translation
  76727. */
  76728. TRANSLATION = "translation",
  76729. /**
  76730. * Rotation
  76731. */
  76732. ROTATION = "rotation",
  76733. /**
  76734. * Scale
  76735. */
  76736. SCALE = "scale",
  76737. /**
  76738. * Weights
  76739. */
  76740. WEIGHTS = "weights",
  76741. }
  76742. /**
  76743. * Interpolation algorithm
  76744. */
  76745. const enum AnimationSamplerInterpolation {
  76746. /**
  76747. * The animated values are linearly interpolated between keyframes
  76748. */
  76749. LINEAR = "LINEAR",
  76750. /**
  76751. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  76752. */
  76753. STEP = "STEP",
  76754. /**
  76755. * The animation's interpolation is computed using a cubic spline with specified tangents
  76756. */
  76757. CUBICSPLINE = "CUBICSPLINE",
  76758. }
  76759. /**
  76760. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  76761. */
  76762. const enum CameraType {
  76763. /**
  76764. * A perspective camera containing properties to create a perspective projection matrix
  76765. */
  76766. PERSPECTIVE = "perspective",
  76767. /**
  76768. * An orthographic camera containing properties to create an orthographic projection matrix
  76769. */
  76770. ORTHOGRAPHIC = "orthographic",
  76771. }
  76772. /**
  76773. * The mime-type of the image
  76774. */
  76775. const enum ImageMimeType {
  76776. /**
  76777. * JPEG Mime-type
  76778. */
  76779. JPEG = "image/jpeg",
  76780. /**
  76781. * PNG Mime-type
  76782. */
  76783. PNG = "image/png",
  76784. }
  76785. /**
  76786. * The alpha rendering mode of the material
  76787. */
  76788. const enum MaterialAlphaMode {
  76789. /**
  76790. * The alpha value is ignored and the rendered output is fully opaque
  76791. */
  76792. OPAQUE = "OPAQUE",
  76793. /**
  76794. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  76795. */
  76796. MASK = "MASK",
  76797. /**
  76798. * 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)
  76799. */
  76800. BLEND = "BLEND",
  76801. }
  76802. /**
  76803. * The type of the primitives to render
  76804. */
  76805. const enum MeshPrimitiveMode {
  76806. /**
  76807. * Points
  76808. */
  76809. POINTS = 0,
  76810. /**
  76811. * Lines
  76812. */
  76813. LINES = 1,
  76814. /**
  76815. * Line Loop
  76816. */
  76817. LINE_LOOP = 2,
  76818. /**
  76819. * Line Strip
  76820. */
  76821. LINE_STRIP = 3,
  76822. /**
  76823. * Triangles
  76824. */
  76825. TRIANGLES = 4,
  76826. /**
  76827. * Triangle Strip
  76828. */
  76829. TRIANGLE_STRIP = 5,
  76830. /**
  76831. * Triangle Fan
  76832. */
  76833. TRIANGLE_FAN = 6,
  76834. }
  76835. /**
  76836. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  76837. */
  76838. const enum TextureMagFilter {
  76839. /**
  76840. * Nearest
  76841. */
  76842. NEAREST = 9728,
  76843. /**
  76844. * Linear
  76845. */
  76846. LINEAR = 9729,
  76847. }
  76848. /**
  76849. * Minification filter. All valid values correspond to WebGL enums
  76850. */
  76851. const enum TextureMinFilter {
  76852. /**
  76853. * Nearest
  76854. */
  76855. NEAREST = 9728,
  76856. /**
  76857. * Linear
  76858. */
  76859. LINEAR = 9729,
  76860. /**
  76861. * Nearest Mip-Map Nearest
  76862. */
  76863. NEAREST_MIPMAP_NEAREST = 9984,
  76864. /**
  76865. * Linear Mipmap Nearest
  76866. */
  76867. LINEAR_MIPMAP_NEAREST = 9985,
  76868. /**
  76869. * Nearest Mipmap Linear
  76870. */
  76871. NEAREST_MIPMAP_LINEAR = 9986,
  76872. /**
  76873. * Linear Mipmap Linear
  76874. */
  76875. LINEAR_MIPMAP_LINEAR = 9987,
  76876. }
  76877. /**
  76878. * S (U) wrapping mode. All valid values correspond to WebGL enums
  76879. */
  76880. const enum TextureWrapMode {
  76881. /**
  76882. * Clamp to Edge
  76883. */
  76884. CLAMP_TO_EDGE = 33071,
  76885. /**
  76886. * Mirrored Repeat
  76887. */
  76888. MIRRORED_REPEAT = 33648,
  76889. /**
  76890. * Repeat
  76891. */
  76892. REPEAT = 10497,
  76893. }
  76894. /**
  76895. * glTF Property
  76896. */
  76897. interface IProperty {
  76898. /**
  76899. * Dictionary object with extension-specific objects
  76900. */
  76901. extensions?: {
  76902. [key: string]: any;
  76903. };
  76904. /**
  76905. * Application-Specific data
  76906. */
  76907. extras?: any;
  76908. }
  76909. /**
  76910. * glTF Child of Root Property
  76911. */
  76912. interface IChildRootProperty extends IProperty {
  76913. /**
  76914. * The user-defined name of this object
  76915. */
  76916. name?: string;
  76917. }
  76918. /**
  76919. * Indices of those attributes that deviate from their initialization value
  76920. */
  76921. interface IAccessorSparseIndices extends IProperty {
  76922. /**
  76923. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  76924. */
  76925. bufferView: number;
  76926. /**
  76927. * The offset relative to the start of the bufferView in bytes. Must be aligned
  76928. */
  76929. byteOffset?: number;
  76930. /**
  76931. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  76932. */
  76933. componentType: AccessorComponentType;
  76934. }
  76935. /**
  76936. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  76937. */
  76938. interface IAccessorSparseValues extends IProperty {
  76939. /**
  76940. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  76941. */
  76942. bufferView: number;
  76943. /**
  76944. * The offset relative to the start of the bufferView in bytes. Must be aligned
  76945. */
  76946. byteOffset?: number;
  76947. }
  76948. /**
  76949. * Sparse storage of attributes that deviate from their initialization value
  76950. */
  76951. interface IAccessorSparse extends IProperty {
  76952. /**
  76953. * The number of attributes encoded in this sparse accessor
  76954. */
  76955. count: number;
  76956. /**
  76957. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  76958. */
  76959. indices: IAccessorSparseIndices;
  76960. /**
  76961. * 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
  76962. */
  76963. values: IAccessorSparseValues;
  76964. }
  76965. /**
  76966. * 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
  76967. */
  76968. interface IAccessor extends IChildRootProperty {
  76969. /**
  76970. * The index of the bufferview
  76971. */
  76972. bufferView?: number;
  76973. /**
  76974. * The offset relative to the start of the bufferView in bytes
  76975. */
  76976. byteOffset?: number;
  76977. /**
  76978. * The datatype of components in the attribute
  76979. */
  76980. componentType: AccessorComponentType;
  76981. /**
  76982. * Specifies whether integer data values should be normalized
  76983. */
  76984. normalized?: boolean;
  76985. /**
  76986. * The number of attributes referenced by this accessor
  76987. */
  76988. count: number;
  76989. /**
  76990. * Specifies if the attribute is a scalar, vector, or matrix
  76991. */
  76992. type: AccessorType;
  76993. /**
  76994. * Maximum value of each component in this attribute
  76995. */
  76996. max?: number[];
  76997. /**
  76998. * Minimum value of each component in this attribute
  76999. */
  77000. min?: number[];
  77001. /**
  77002. * Sparse storage of attributes that deviate from their initialization value
  77003. */
  77004. sparse?: IAccessorSparse;
  77005. }
  77006. /**
  77007. * Targets an animation's sampler at a node's property
  77008. */
  77009. interface IAnimationChannel extends IProperty {
  77010. /**
  77011. * The index of a sampler in this animation used to compute the value for the target
  77012. */
  77013. sampler: number;
  77014. /**
  77015. * The index of the node and TRS property to target
  77016. */
  77017. target: IAnimationChannelTarget;
  77018. }
  77019. /**
  77020. * The index of the node and TRS property that an animation channel targets
  77021. */
  77022. interface IAnimationChannelTarget extends IProperty {
  77023. /**
  77024. * The index of the node to target
  77025. */
  77026. node: number;
  77027. /**
  77028. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  77029. */
  77030. path: AnimationChannelTargetPath;
  77031. }
  77032. /**
  77033. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  77034. */
  77035. interface IAnimationSampler extends IProperty {
  77036. /**
  77037. * The index of an accessor containing keyframe input values, e.g., time
  77038. */
  77039. input: number;
  77040. /**
  77041. * Interpolation algorithm
  77042. */
  77043. interpolation?: AnimationSamplerInterpolation;
  77044. /**
  77045. * The index of an accessor, containing keyframe output values
  77046. */
  77047. output: number;
  77048. }
  77049. /**
  77050. * A keyframe animation
  77051. */
  77052. interface IAnimation extends IChildRootProperty {
  77053. /**
  77054. * An array of channels, each of which targets an animation's sampler at a node's property
  77055. */
  77056. channels: IAnimationChannel[];
  77057. /**
  77058. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  77059. */
  77060. samplers: IAnimationSampler[];
  77061. }
  77062. /**
  77063. * Metadata about the glTF asset
  77064. */
  77065. interface IAsset extends IChildRootProperty {
  77066. /**
  77067. * A copyright message suitable for display to credit the content creator
  77068. */
  77069. copyright?: string;
  77070. /**
  77071. * Tool that generated this glTF model. Useful for debugging
  77072. */
  77073. generator?: string;
  77074. /**
  77075. * The glTF version that this asset targets
  77076. */
  77077. version: string;
  77078. /**
  77079. * The minimum glTF version that this asset targets
  77080. */
  77081. minVersion?: string;
  77082. }
  77083. /**
  77084. * A buffer points to binary geometry, animation, or skins
  77085. */
  77086. interface IBuffer extends IChildRootProperty {
  77087. /**
  77088. * 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
  77089. */
  77090. uri?: string;
  77091. /**
  77092. * The length of the buffer in bytes
  77093. */
  77094. byteLength: number;
  77095. }
  77096. /**
  77097. * A view into a buffer generally representing a subset of the buffer
  77098. */
  77099. interface IBufferView extends IChildRootProperty {
  77100. /**
  77101. * The index of the buffer
  77102. */
  77103. buffer: number;
  77104. /**
  77105. * The offset into the buffer in bytes
  77106. */
  77107. byteOffset?: number;
  77108. /**
  77109. * The lenth of the bufferView in bytes
  77110. */
  77111. byteLength: number;
  77112. /**
  77113. * The stride, in bytes
  77114. */
  77115. byteStride?: number;
  77116. }
  77117. /**
  77118. * An orthographic camera containing properties to create an orthographic projection matrix
  77119. */
  77120. interface ICameraOrthographic extends IProperty {
  77121. /**
  77122. * The floating-point horizontal magnification of the view. Must not be zero
  77123. */
  77124. xmag: number;
  77125. /**
  77126. * The floating-point vertical magnification of the view. Must not be zero
  77127. */
  77128. ymag: number;
  77129. /**
  77130. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  77131. */
  77132. zfar: number;
  77133. /**
  77134. * The floating-point distance to the near clipping plane
  77135. */
  77136. znear: number;
  77137. }
  77138. /**
  77139. * A perspective camera containing properties to create a perspective projection matrix
  77140. */
  77141. interface ICameraPerspective extends IProperty {
  77142. /**
  77143. * The floating-point aspect ratio of the field of view
  77144. */
  77145. aspectRatio?: number;
  77146. /**
  77147. * The floating-point vertical field of view in radians
  77148. */
  77149. yfov: number;
  77150. /**
  77151. * The floating-point distance to the far clipping plane
  77152. */
  77153. zfar?: number;
  77154. /**
  77155. * The floating-point distance to the near clipping plane
  77156. */
  77157. znear: number;
  77158. }
  77159. /**
  77160. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  77161. */
  77162. interface ICamera extends IChildRootProperty {
  77163. /**
  77164. * An orthographic camera containing properties to create an orthographic projection matrix
  77165. */
  77166. orthographic?: ICameraOrthographic;
  77167. /**
  77168. * A perspective camera containing properties to create a perspective projection matrix
  77169. */
  77170. perspective?: ICameraPerspective;
  77171. /**
  77172. * Specifies if the camera uses a perspective or orthographic projection
  77173. */
  77174. type: CameraType;
  77175. }
  77176. /**
  77177. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  77178. */
  77179. interface IImage extends IChildRootProperty {
  77180. /**
  77181. * 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
  77182. */
  77183. uri?: string;
  77184. /**
  77185. * The image's MIME type
  77186. */
  77187. mimeType?: ImageMimeType;
  77188. /**
  77189. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  77190. */
  77191. bufferView?: number;
  77192. }
  77193. /**
  77194. * Material Normal Texture Info
  77195. */
  77196. interface IMaterialNormalTextureInfo extends ITextureInfo {
  77197. /**
  77198. * The scalar multiplier applied to each normal vector of the normal texture
  77199. */
  77200. scale?: number;
  77201. }
  77202. /**
  77203. * Material Occlusion Texture Info
  77204. */
  77205. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  77206. /**
  77207. * A scalar multiplier controlling the amount of occlusion applied
  77208. */
  77209. strength?: number;
  77210. }
  77211. /**
  77212. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  77213. */
  77214. interface IMaterialPbrMetallicRoughness {
  77215. /**
  77216. * The material's base color factor
  77217. */
  77218. baseColorFactor?: number[];
  77219. /**
  77220. * The base color texture
  77221. */
  77222. baseColorTexture?: ITextureInfo;
  77223. /**
  77224. * The metalness of the material
  77225. */
  77226. metallicFactor?: number;
  77227. /**
  77228. * The roughness of the material
  77229. */
  77230. roughnessFactor?: number;
  77231. /**
  77232. * The metallic-roughness texture
  77233. */
  77234. metallicRoughnessTexture?: ITextureInfo;
  77235. }
  77236. /**
  77237. * The material appearance of a primitive
  77238. */
  77239. interface IMaterial extends IChildRootProperty {
  77240. /**
  77241. * 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
  77242. */
  77243. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  77244. /**
  77245. * The normal map texture
  77246. */
  77247. normalTexture?: IMaterialNormalTextureInfo;
  77248. /**
  77249. * The occlusion map texture
  77250. */
  77251. occlusionTexture?: IMaterialOcclusionTextureInfo;
  77252. /**
  77253. * The emissive map texture
  77254. */
  77255. emissiveTexture?: ITextureInfo;
  77256. /**
  77257. * 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
  77258. */
  77259. emissiveFactor?: number[];
  77260. /**
  77261. * The alpha rendering mode of the material
  77262. */
  77263. alphaMode?: MaterialAlphaMode;
  77264. /**
  77265. * The alpha cutoff value of the material
  77266. */
  77267. alphaCutoff?: number;
  77268. /**
  77269. * Specifies whether the material is double sided
  77270. */
  77271. doubleSided?: boolean;
  77272. }
  77273. /**
  77274. * Geometry to be rendered with the given material
  77275. */
  77276. interface IMeshPrimitive extends IProperty {
  77277. /**
  77278. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  77279. */
  77280. attributes: {
  77281. [name: string]: number;
  77282. };
  77283. /**
  77284. * The index of the accessor that contains the indices
  77285. */
  77286. indices?: number;
  77287. /**
  77288. * The index of the material to apply to this primitive when rendering
  77289. */
  77290. material?: number;
  77291. /**
  77292. * The type of primitives to render. All valid values correspond to WebGL enums
  77293. */
  77294. mode?: MeshPrimitiveMode;
  77295. /**
  77296. * 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
  77297. */
  77298. targets?: {
  77299. [name: string]: number;
  77300. }[];
  77301. }
  77302. /**
  77303. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  77304. */
  77305. interface IMesh extends IChildRootProperty {
  77306. /**
  77307. * An array of primitives, each defining geometry to be rendered with a material
  77308. */
  77309. primitives: IMeshPrimitive[];
  77310. /**
  77311. * Array of weights to be applied to the Morph Targets
  77312. */
  77313. weights?: number[];
  77314. }
  77315. /**
  77316. * A node in the node hierarchy
  77317. */
  77318. interface INode extends IChildRootProperty {
  77319. /**
  77320. * The index of the camera referenced by this node
  77321. */
  77322. camera?: number;
  77323. /**
  77324. * The indices of this node's children
  77325. */
  77326. children?: number[];
  77327. /**
  77328. * The index of the skin referenced by this node
  77329. */
  77330. skin?: number;
  77331. /**
  77332. * A floating-point 4x4 transformation matrix stored in column-major order
  77333. */
  77334. matrix?: number[];
  77335. /**
  77336. * The index of the mesh in this node
  77337. */
  77338. mesh?: number;
  77339. /**
  77340. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  77341. */
  77342. rotation?: number[];
  77343. /**
  77344. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  77345. */
  77346. scale?: number[];
  77347. /**
  77348. * The node's translation along the x, y, and z axes
  77349. */
  77350. translation?: number[];
  77351. /**
  77352. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  77353. */
  77354. weights?: number[];
  77355. }
  77356. /**
  77357. * Texture sampler properties for filtering and wrapping modes
  77358. */
  77359. interface ISampler extends IChildRootProperty {
  77360. /**
  77361. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  77362. */
  77363. magFilter?: TextureMagFilter;
  77364. /**
  77365. * Minification filter. All valid values correspond to WebGL enums
  77366. */
  77367. minFilter?: TextureMinFilter;
  77368. /**
  77369. * S (U) wrapping mode. All valid values correspond to WebGL enums
  77370. */
  77371. wrapS?: TextureWrapMode;
  77372. /**
  77373. * T (V) wrapping mode. All valid values correspond to WebGL enums
  77374. */
  77375. wrapT?: TextureWrapMode;
  77376. }
  77377. /**
  77378. * The root nodes of a scene
  77379. */
  77380. interface IScene extends IChildRootProperty {
  77381. /**
  77382. * The indices of each root node
  77383. */
  77384. nodes: number[];
  77385. }
  77386. /**
  77387. * Joints and matrices defining a skin
  77388. */
  77389. interface ISkin extends IChildRootProperty {
  77390. /**
  77391. * 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
  77392. */
  77393. inverseBindMatrices?: number;
  77394. /**
  77395. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  77396. */
  77397. skeleton?: number;
  77398. /**
  77399. * 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)
  77400. */
  77401. joints: number[];
  77402. }
  77403. /**
  77404. * A texture and its sampler
  77405. */
  77406. interface ITexture extends IChildRootProperty {
  77407. /**
  77408. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  77409. */
  77410. sampler?: number;
  77411. /**
  77412. * The index of the image used by this texture
  77413. */
  77414. source: number;
  77415. }
  77416. /**
  77417. * Reference to a texture
  77418. */
  77419. interface ITextureInfo extends IProperty {
  77420. /**
  77421. * The index of the texture
  77422. */
  77423. index: number;
  77424. /**
  77425. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  77426. */
  77427. texCoord?: number;
  77428. }
  77429. /**
  77430. * The root object for a glTF asset
  77431. */
  77432. interface IGLTF extends IProperty {
  77433. /**
  77434. * An array of accessors. An accessor is a typed view into a bufferView
  77435. */
  77436. accessors?: IAccessor[];
  77437. /**
  77438. * An array of keyframe animations
  77439. */
  77440. animations?: IAnimation[];
  77441. /**
  77442. * Metadata about the glTF asset
  77443. */
  77444. asset: IAsset;
  77445. /**
  77446. * An array of buffers. A buffer points to binary geometry, animation, or skins
  77447. */
  77448. buffers?: IBuffer[];
  77449. /**
  77450. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  77451. */
  77452. bufferViews?: IBufferView[];
  77453. /**
  77454. * An array of cameras
  77455. */
  77456. cameras?: ICamera[];
  77457. /**
  77458. * Names of glTF extensions used somewhere in this asset
  77459. */
  77460. extensionsUsed?: string[];
  77461. /**
  77462. * Names of glTF extensions required to properly load this asset
  77463. */
  77464. extensionsRequired?: string[];
  77465. /**
  77466. * An array of images. An image defines data used to create a texture
  77467. */
  77468. images?: IImage[];
  77469. /**
  77470. * An array of materials. A material defines the appearance of a primitive
  77471. */
  77472. materials?: IMaterial[];
  77473. /**
  77474. * An array of meshes. A mesh is a set of primitives to be rendered
  77475. */
  77476. meshes?: IMesh[];
  77477. /**
  77478. * An array of nodes
  77479. */
  77480. nodes?: INode[];
  77481. /**
  77482. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  77483. */
  77484. samplers?: ISampler[];
  77485. /**
  77486. * The index of the default scene
  77487. */
  77488. scene?: number;
  77489. /**
  77490. * An array of scenes
  77491. */
  77492. scenes?: IScene[];
  77493. /**
  77494. * An array of skins. A skin is defined by joints and matrices
  77495. */
  77496. skins?: ISkin[];
  77497. /**
  77498. * An array of textures
  77499. */
  77500. textures?: ITexture[];
  77501. }
  77502. /**
  77503. * The glTF validation results
  77504. * @ignore
  77505. */
  77506. interface IGLTFValidationResults {
  77507. info: {
  77508. generator: string;
  77509. hasAnimations: boolean;
  77510. hasDefaultScene: boolean;
  77511. hasMaterials: boolean;
  77512. hasMorphTargets: boolean;
  77513. hasSkins: boolean;
  77514. hasTextures: boolean;
  77515. maxAttributesUsed: number;
  77516. primitivesCount: number
  77517. };
  77518. issues: {
  77519. messages: Array<string>;
  77520. numErrors: number;
  77521. numHints: number;
  77522. numInfos: number;
  77523. numWarnings: number;
  77524. truncated: boolean
  77525. };
  77526. mimeType: string;
  77527. uri: string;
  77528. validatedAt: string;
  77529. validatorVersion: string;
  77530. }
  77531. /**
  77532. * The glTF validation options
  77533. */
  77534. interface IGLTFValidationOptions {
  77535. /** Uri to use */
  77536. uri?: string;
  77537. /** Function used to load external resources */
  77538. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  77539. /** Boolean indicating that we need to validate accessor data */
  77540. validateAccessorData?: boolean;
  77541. /** max number of issues allowed */
  77542. maxIssues?: number;
  77543. /** Ignored issues */
  77544. ignoredIssues?: Array<string>;
  77545. /** Value to override severy settings */
  77546. severityOverrides?: Object;
  77547. }
  77548. /**
  77549. * The glTF validator object
  77550. * @ignore
  77551. */
  77552. interface IGLTFValidator {
  77553. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  77554. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  77555. }
  77556. }
  77557. declare module BABYLON {
  77558. /** @hidden */
  77559. export var cellPixelShader: {
  77560. name: string;
  77561. shader: string;
  77562. };
  77563. }
  77564. declare module BABYLON {
  77565. /** @hidden */
  77566. export var cellVertexShader: {
  77567. name: string;
  77568. shader: string;
  77569. };
  77570. }
  77571. declare module BABYLON {
  77572. export class CellMaterial extends BABYLON.PushMaterial {
  77573. private _diffuseTexture;
  77574. diffuseTexture: BABYLON.BaseTexture;
  77575. diffuseColor: BABYLON.Color3;
  77576. _computeHighLevel: boolean;
  77577. computeHighLevel: boolean;
  77578. private _disableLighting;
  77579. disableLighting: boolean;
  77580. private _maxSimultaneousLights;
  77581. maxSimultaneousLights: number;
  77582. private _renderId;
  77583. constructor(name: string, scene: BABYLON.Scene);
  77584. needAlphaBlending(): boolean;
  77585. needAlphaTesting(): boolean;
  77586. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  77587. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  77588. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  77589. getAnimatables(): BABYLON.IAnimatable[];
  77590. getActiveTextures(): BABYLON.BaseTexture[];
  77591. hasTexture(texture: BABYLON.BaseTexture): boolean;
  77592. dispose(forceDisposeEffect?: boolean): void;
  77593. getClassName(): string;
  77594. clone(name: string): CellMaterial;
  77595. serialize(): any;
  77596. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  77597. }
  77598. }
  77599. declare module BABYLON {
  77600. export class CustomShaderStructure {
  77601. FragmentStore: string;
  77602. VertexStore: string;
  77603. constructor();
  77604. }
  77605. export class ShaderSpecialParts {
  77606. constructor();
  77607. Fragment_Begin: string;
  77608. Fragment_Definitions: string;
  77609. Fragment_MainBegin: string;
  77610. Fragment_Custom_Diffuse: string;
  77611. Fragment_Before_Lights: string;
  77612. Fragment_Before_Fog: string;
  77613. Fragment_Custom_Alpha: string;
  77614. Fragment_Before_FragColor: string;
  77615. Vertex_Begin: string;
  77616. Vertex_Definitions: string;
  77617. Vertex_MainBegin: string;
  77618. Vertex_Before_PositionUpdated: string;
  77619. Vertex_Before_NormalUpdated: string;
  77620. Vertex_MainEnd: string;
  77621. }
  77622. export class CustomMaterial extends BABYLON.StandardMaterial {
  77623. static ShaderIndexer: number;
  77624. CustomParts: ShaderSpecialParts;
  77625. _isCreatedShader: boolean;
  77626. _createdShaderName: string;
  77627. _customUniform: string[];
  77628. _newUniforms: string[];
  77629. _newUniformInstances: any[];
  77630. _newSamplerInstances: BABYLON.Texture[];
  77631. FragmentShader: string;
  77632. VertexShader: string;
  77633. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  77634. ReviewUniform(name: string, arr: string[]): string[];
  77635. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  77636. constructor(name: string, scene: BABYLON.Scene);
  77637. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  77638. Fragment_Begin(shaderPart: string): CustomMaterial;
  77639. Fragment_Definitions(shaderPart: string): CustomMaterial;
  77640. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  77641. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  77642. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  77643. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  77644. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  77645. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  77646. Vertex_Begin(shaderPart: string): CustomMaterial;
  77647. Vertex_Definitions(shaderPart: string): CustomMaterial;
  77648. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  77649. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  77650. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  77651. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  77652. }
  77653. }
  77654. declare module BABYLON {
  77655. export class ShaderAlebdoParts {
  77656. constructor();
  77657. Fragment_Begin: string;
  77658. Fragment_Definitions: string;
  77659. Fragment_MainBegin: string;
  77660. Fragment_Custom_Albedo: string;
  77661. Fragment_Before_Lights: string;
  77662. Fragment_Custom_MetallicRoughness: string;
  77663. Fragment_Custom_MicroSurface: string;
  77664. Fragment_Before_Fog: string;
  77665. Fragment_Custom_Alpha: string;
  77666. Fragment_Before_FragColor: string;
  77667. Vertex_Begin: string;
  77668. Vertex_Definitions: string;
  77669. Vertex_MainBegin: string;
  77670. Vertex_Before_PositionUpdated: string;
  77671. Vertex_Before_NormalUpdated: string;
  77672. Vertex_MainEnd: string;
  77673. }
  77674. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  77675. static ShaderIndexer: number;
  77676. CustomParts: ShaderAlebdoParts;
  77677. _isCreatedShader: boolean;
  77678. _createdShaderName: string;
  77679. _customUniform: string[];
  77680. _newUniforms: string[];
  77681. _newUniformInstances: any[];
  77682. _newSamplerInstances: BABYLON.Texture[];
  77683. FragmentShader: string;
  77684. VertexShader: string;
  77685. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  77686. ReviewUniform(name: string, arr: string[]): string[];
  77687. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  77688. constructor(name: string, scene: BABYLON.Scene);
  77689. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  77690. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  77691. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  77692. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  77693. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  77694. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  77695. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  77696. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  77697. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  77698. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  77699. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  77700. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  77701. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  77702. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  77703. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  77704. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  77705. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  77706. }
  77707. }
  77708. declare module BABYLON {
  77709. /** @hidden */
  77710. export var firePixelShader: {
  77711. name: string;
  77712. shader: string;
  77713. };
  77714. }
  77715. declare module BABYLON {
  77716. /** @hidden */
  77717. export var fireVertexShader: {
  77718. name: string;
  77719. shader: string;
  77720. };
  77721. }
  77722. declare module BABYLON {
  77723. export class FireMaterial extends BABYLON.PushMaterial {
  77724. private _diffuseTexture;
  77725. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  77726. private _distortionTexture;
  77727. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  77728. private _opacityTexture;
  77729. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  77730. diffuseColor: BABYLON.Color3;
  77731. speed: number;
  77732. private _scaledDiffuse;
  77733. private _renderId;
  77734. private _lastTime;
  77735. constructor(name: string, scene: BABYLON.Scene);
  77736. needAlphaBlending(): boolean;
  77737. needAlphaTesting(): boolean;
  77738. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  77739. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  77740. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  77741. getAnimatables(): BABYLON.IAnimatable[];
  77742. getActiveTextures(): BABYLON.BaseTexture[];
  77743. hasTexture(texture: BABYLON.BaseTexture): boolean;
  77744. getClassName(): string;
  77745. dispose(forceDisposeEffect?: boolean): void;
  77746. clone(name: string): FireMaterial;
  77747. serialize(): any;
  77748. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  77749. }
  77750. }
  77751. declare module BABYLON {
  77752. /** @hidden */
  77753. export var furPixelShader: {
  77754. name: string;
  77755. shader: string;
  77756. };
  77757. }
  77758. declare module BABYLON {
  77759. /** @hidden */
  77760. export var furVertexShader: {
  77761. name: string;
  77762. shader: string;
  77763. };
  77764. }
  77765. declare module BABYLON {
  77766. export class FurMaterial extends BABYLON.PushMaterial {
  77767. private _diffuseTexture;
  77768. diffuseTexture: BABYLON.BaseTexture;
  77769. private _heightTexture;
  77770. heightTexture: BABYLON.BaseTexture;
  77771. diffuseColor: BABYLON.Color3;
  77772. furLength: number;
  77773. furAngle: number;
  77774. furColor: BABYLON.Color3;
  77775. furOffset: number;
  77776. furSpacing: number;
  77777. furGravity: BABYLON.Vector3;
  77778. furSpeed: number;
  77779. furDensity: number;
  77780. furOcclusion: number;
  77781. furTexture: BABYLON.DynamicTexture;
  77782. private _disableLighting;
  77783. disableLighting: boolean;
  77784. private _maxSimultaneousLights;
  77785. maxSimultaneousLights: number;
  77786. highLevelFur: boolean;
  77787. _meshes: BABYLON.AbstractMesh[];
  77788. private _renderId;
  77789. private _furTime;
  77790. constructor(name: string, scene: BABYLON.Scene);
  77791. get furTime(): number;
  77792. set furTime(furTime: number);
  77793. needAlphaBlending(): boolean;
  77794. needAlphaTesting(): boolean;
  77795. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  77796. updateFur(): void;
  77797. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  77798. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  77799. getAnimatables(): BABYLON.IAnimatable[];
  77800. getActiveTextures(): BABYLON.BaseTexture[];
  77801. hasTexture(texture: BABYLON.BaseTexture): boolean;
  77802. dispose(forceDisposeEffect?: boolean): void;
  77803. clone(name: string): FurMaterial;
  77804. serialize(): any;
  77805. getClassName(): string;
  77806. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  77807. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  77808. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  77809. }
  77810. }
  77811. declare module BABYLON {
  77812. /** @hidden */
  77813. export var gradientPixelShader: {
  77814. name: string;
  77815. shader: string;
  77816. };
  77817. }
  77818. declare module BABYLON {
  77819. /** @hidden */
  77820. export var gradientVertexShader: {
  77821. name: string;
  77822. shader: string;
  77823. };
  77824. }
  77825. declare module BABYLON {
  77826. export class GradientMaterial extends BABYLON.PushMaterial {
  77827. private _maxSimultaneousLights;
  77828. maxSimultaneousLights: number;
  77829. topColor: BABYLON.Color3;
  77830. topColorAlpha: number;
  77831. bottomColor: BABYLON.Color3;
  77832. bottomColorAlpha: number;
  77833. offset: number;
  77834. scale: number;
  77835. smoothness: number;
  77836. private _disableLighting;
  77837. disableLighting: boolean;
  77838. private _renderId;
  77839. constructor(name: string, scene: BABYLON.Scene);
  77840. needAlphaBlending(): boolean;
  77841. needAlphaTesting(): boolean;
  77842. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  77843. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  77844. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  77845. getAnimatables(): BABYLON.IAnimatable[];
  77846. dispose(forceDisposeEffect?: boolean): void;
  77847. clone(name: string): GradientMaterial;
  77848. serialize(): any;
  77849. getClassName(): string;
  77850. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  77851. }
  77852. }
  77853. declare module BABYLON {
  77854. /** @hidden */
  77855. export var gridPixelShader: {
  77856. name: string;
  77857. shader: string;
  77858. };
  77859. }
  77860. declare module BABYLON {
  77861. /** @hidden */
  77862. export var gridVertexShader: {
  77863. name: string;
  77864. shader: string;
  77865. };
  77866. }
  77867. declare module BABYLON {
  77868. /**
  77869. * The grid materials allows you to wrap any shape with a grid.
  77870. * Colors are customizable.
  77871. */
  77872. export class GridMaterial extends BABYLON.PushMaterial {
  77873. /**
  77874. * Main color of the grid (e.g. between lines)
  77875. */
  77876. mainColor: BABYLON.Color3;
  77877. /**
  77878. * Color of the grid lines.
  77879. */
  77880. lineColor: BABYLON.Color3;
  77881. /**
  77882. * The scale of the grid compared to unit.
  77883. */
  77884. gridRatio: number;
  77885. /**
  77886. * Allows setting an offset for the grid lines.
  77887. */
  77888. gridOffset: BABYLON.Vector3;
  77889. /**
  77890. * The frequency of thicker lines.
  77891. */
  77892. majorUnitFrequency: number;
  77893. /**
  77894. * The visibility of minor units in the grid.
  77895. */
  77896. minorUnitVisibility: number;
  77897. /**
  77898. * The grid opacity outside of the lines.
  77899. */
  77900. opacity: number;
  77901. /**
  77902. * Determine RBG output is premultiplied by alpha value.
  77903. */
  77904. preMultiplyAlpha: boolean;
  77905. private _opacityTexture;
  77906. opacityTexture: BABYLON.BaseTexture;
  77907. private _gridControl;
  77908. private _renderId;
  77909. /**
  77910. * constructor
  77911. * @param name The name given to the material in order to identify it afterwards.
  77912. * @param scene The scene the material is used in.
  77913. */
  77914. constructor(name: string, scene: BABYLON.Scene);
  77915. /**
  77916. * Returns wehter or not the grid requires alpha blending.
  77917. */
  77918. needAlphaBlending(): boolean;
  77919. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  77920. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  77921. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  77922. /**
  77923. * Dispose the material and its associated resources.
  77924. * @param forceDisposeEffect will also dispose the used effect when true
  77925. */
  77926. dispose(forceDisposeEffect?: boolean): void;
  77927. clone(name: string): GridMaterial;
  77928. serialize(): any;
  77929. getClassName(): string;
  77930. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  77931. }
  77932. }
  77933. declare module BABYLON {
  77934. /** @hidden */
  77935. export var lavaPixelShader: {
  77936. name: string;
  77937. shader: string;
  77938. };
  77939. }
  77940. declare module BABYLON {
  77941. /** @hidden */
  77942. export var lavaVertexShader: {
  77943. name: string;
  77944. shader: string;
  77945. };
  77946. }
  77947. declare module BABYLON {
  77948. export class LavaMaterial extends BABYLON.PushMaterial {
  77949. private _diffuseTexture;
  77950. diffuseTexture: BABYLON.BaseTexture;
  77951. noiseTexture: BABYLON.BaseTexture;
  77952. fogColor: BABYLON.Color3;
  77953. speed: number;
  77954. movingSpeed: number;
  77955. lowFrequencySpeed: number;
  77956. fogDensity: number;
  77957. private _lastTime;
  77958. diffuseColor: BABYLON.Color3;
  77959. private _disableLighting;
  77960. disableLighting: boolean;
  77961. private _unlit;
  77962. unlit: boolean;
  77963. private _maxSimultaneousLights;
  77964. maxSimultaneousLights: number;
  77965. private _scaledDiffuse;
  77966. private _renderId;
  77967. constructor(name: string, scene: BABYLON.Scene);
  77968. needAlphaBlending(): boolean;
  77969. needAlphaTesting(): boolean;
  77970. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  77971. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  77972. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  77973. getAnimatables(): BABYLON.IAnimatable[];
  77974. getActiveTextures(): BABYLON.BaseTexture[];
  77975. hasTexture(texture: BABYLON.BaseTexture): boolean;
  77976. dispose(forceDisposeEffect?: boolean): void;
  77977. clone(name: string): LavaMaterial;
  77978. serialize(): any;
  77979. getClassName(): string;
  77980. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  77981. }
  77982. }
  77983. declare module BABYLON {
  77984. /** @hidden */
  77985. export var mixPixelShader: {
  77986. name: string;
  77987. shader: string;
  77988. };
  77989. }
  77990. declare module BABYLON {
  77991. /** @hidden */
  77992. export var mixVertexShader: {
  77993. name: string;
  77994. shader: string;
  77995. };
  77996. }
  77997. declare module BABYLON {
  77998. export class MixMaterial extends BABYLON.PushMaterial {
  77999. /**
  78000. * Mix textures
  78001. */
  78002. private _mixTexture1;
  78003. mixTexture1: BABYLON.BaseTexture;
  78004. private _mixTexture2;
  78005. mixTexture2: BABYLON.BaseTexture;
  78006. /**
  78007. * Diffuse textures
  78008. */
  78009. private _diffuseTexture1;
  78010. diffuseTexture1: BABYLON.Texture;
  78011. private _diffuseTexture2;
  78012. diffuseTexture2: BABYLON.Texture;
  78013. private _diffuseTexture3;
  78014. diffuseTexture3: BABYLON.Texture;
  78015. private _diffuseTexture4;
  78016. diffuseTexture4: BABYLON.Texture;
  78017. private _diffuseTexture5;
  78018. diffuseTexture5: BABYLON.Texture;
  78019. private _diffuseTexture6;
  78020. diffuseTexture6: BABYLON.Texture;
  78021. private _diffuseTexture7;
  78022. diffuseTexture7: BABYLON.Texture;
  78023. private _diffuseTexture8;
  78024. diffuseTexture8: BABYLON.Texture;
  78025. /**
  78026. * Uniforms
  78027. */
  78028. diffuseColor: BABYLON.Color3;
  78029. specularColor: BABYLON.Color3;
  78030. specularPower: number;
  78031. private _disableLighting;
  78032. disableLighting: boolean;
  78033. private _maxSimultaneousLights;
  78034. maxSimultaneousLights: number;
  78035. private _renderId;
  78036. constructor(name: string, scene: BABYLON.Scene);
  78037. needAlphaBlending(): boolean;
  78038. needAlphaTesting(): boolean;
  78039. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78040. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78041. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78042. getAnimatables(): BABYLON.IAnimatable[];
  78043. getActiveTextures(): BABYLON.BaseTexture[];
  78044. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78045. dispose(forceDisposeEffect?: boolean): void;
  78046. clone(name: string): MixMaterial;
  78047. serialize(): any;
  78048. getClassName(): string;
  78049. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  78050. }
  78051. }
  78052. declare module BABYLON {
  78053. /** @hidden */
  78054. export var normalPixelShader: {
  78055. name: string;
  78056. shader: string;
  78057. };
  78058. }
  78059. declare module BABYLON {
  78060. /** @hidden */
  78061. export var normalVertexShader: {
  78062. name: string;
  78063. shader: string;
  78064. };
  78065. }
  78066. declare module BABYLON {
  78067. export class NormalMaterial extends BABYLON.PushMaterial {
  78068. private _diffuseTexture;
  78069. diffuseTexture: BABYLON.BaseTexture;
  78070. diffuseColor: BABYLON.Color3;
  78071. private _disableLighting;
  78072. disableLighting: boolean;
  78073. private _maxSimultaneousLights;
  78074. maxSimultaneousLights: number;
  78075. private _renderId;
  78076. constructor(name: string, scene: BABYLON.Scene);
  78077. needAlphaBlending(): boolean;
  78078. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  78079. needAlphaTesting(): boolean;
  78080. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78081. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78082. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78083. getAnimatables(): BABYLON.IAnimatable[];
  78084. getActiveTextures(): BABYLON.BaseTexture[];
  78085. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78086. dispose(forceDisposeEffect?: boolean): void;
  78087. clone(name: string): NormalMaterial;
  78088. serialize(): any;
  78089. getClassName(): string;
  78090. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  78091. }
  78092. }
  78093. declare module BABYLON {
  78094. /** @hidden */
  78095. export var shadowOnlyPixelShader: {
  78096. name: string;
  78097. shader: string;
  78098. };
  78099. }
  78100. declare module BABYLON {
  78101. /** @hidden */
  78102. export var shadowOnlyVertexShader: {
  78103. name: string;
  78104. shader: string;
  78105. };
  78106. }
  78107. declare module BABYLON {
  78108. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  78109. private _renderId;
  78110. private _activeLight;
  78111. constructor(name: string, scene: BABYLON.Scene);
  78112. shadowColor: BABYLON.Color3;
  78113. needAlphaBlending(): boolean;
  78114. needAlphaTesting(): boolean;
  78115. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78116. get activeLight(): BABYLON.IShadowLight;
  78117. set activeLight(light: BABYLON.IShadowLight);
  78118. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78119. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78120. clone(name: string): ShadowOnlyMaterial;
  78121. serialize(): any;
  78122. getClassName(): string;
  78123. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  78124. }
  78125. }
  78126. declare module BABYLON {
  78127. /** @hidden */
  78128. export var simplePixelShader: {
  78129. name: string;
  78130. shader: string;
  78131. };
  78132. }
  78133. declare module BABYLON {
  78134. /** @hidden */
  78135. export var simpleVertexShader: {
  78136. name: string;
  78137. shader: string;
  78138. };
  78139. }
  78140. declare module BABYLON {
  78141. export class SimpleMaterial extends BABYLON.PushMaterial {
  78142. private _diffuseTexture;
  78143. diffuseTexture: BABYLON.BaseTexture;
  78144. diffuseColor: BABYLON.Color3;
  78145. private _disableLighting;
  78146. disableLighting: boolean;
  78147. private _maxSimultaneousLights;
  78148. maxSimultaneousLights: number;
  78149. private _renderId;
  78150. constructor(name: string, scene: BABYLON.Scene);
  78151. needAlphaBlending(): boolean;
  78152. needAlphaTesting(): boolean;
  78153. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78154. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78155. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78156. getAnimatables(): BABYLON.IAnimatable[];
  78157. getActiveTextures(): BABYLON.BaseTexture[];
  78158. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78159. dispose(forceDisposeEffect?: boolean): void;
  78160. clone(name: string): SimpleMaterial;
  78161. serialize(): any;
  78162. getClassName(): string;
  78163. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  78164. }
  78165. }
  78166. declare module BABYLON {
  78167. /** @hidden */
  78168. export var skyPixelShader: {
  78169. name: string;
  78170. shader: string;
  78171. };
  78172. }
  78173. declare module BABYLON {
  78174. /** @hidden */
  78175. export var skyVertexShader: {
  78176. name: string;
  78177. shader: string;
  78178. };
  78179. }
  78180. declare module BABYLON {
  78181. /**
  78182. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  78183. * @see https://doc.babylonjs.com/extensions/sky
  78184. */
  78185. export class SkyMaterial extends BABYLON.PushMaterial {
  78186. /**
  78187. * Defines the overall luminance of sky in interval ]0, 1[.
  78188. */
  78189. luminance: number;
  78190. /**
  78191. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  78192. */
  78193. turbidity: number;
  78194. /**
  78195. * Defines the sky appearance (light intensity).
  78196. */
  78197. rayleigh: number;
  78198. /**
  78199. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  78200. */
  78201. mieCoefficient: number;
  78202. /**
  78203. * Defines the amount of haze particles following the Mie scattering theory.
  78204. */
  78205. mieDirectionalG: number;
  78206. /**
  78207. * Defines the distance of the sun according to the active scene camera.
  78208. */
  78209. distance: number;
  78210. /**
  78211. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  78212. * "inclined".
  78213. */
  78214. inclination: number;
  78215. /**
  78216. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  78217. * an object direction and a reference direction.
  78218. */
  78219. azimuth: number;
  78220. /**
  78221. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  78222. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  78223. */
  78224. sunPosition: BABYLON.Vector3;
  78225. /**
  78226. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  78227. * .sunPosition property.
  78228. */
  78229. useSunPosition: boolean;
  78230. /**
  78231. * Defines an offset vector used to get a horizon offset.
  78232. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  78233. */
  78234. cameraOffset: BABYLON.Vector3;
  78235. private _cameraPosition;
  78236. private _renderId;
  78237. /**
  78238. * Instantiates a new sky material.
  78239. * This material allows to create dynamic and texture free
  78240. * effects for skyboxes by taking care of the atmosphere state.
  78241. * @see https://doc.babylonjs.com/extensions/sky
  78242. * @param name Define the name of the material in the scene
  78243. * @param scene Define the scene the material belong to
  78244. */
  78245. constructor(name: string, scene: BABYLON.Scene);
  78246. /**
  78247. * Specifies if the material will require alpha blending
  78248. * @returns a boolean specifying if alpha blending is needed
  78249. */
  78250. needAlphaBlending(): boolean;
  78251. /**
  78252. * Specifies if this material should be rendered in alpha test mode
  78253. * @returns false as the sky material doesn't need alpha testing.
  78254. */
  78255. needAlphaTesting(): boolean;
  78256. /**
  78257. * Get the texture used for alpha test purpose.
  78258. * @returns null as the sky material has no texture.
  78259. */
  78260. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78261. /**
  78262. * Get if the submesh is ready to be used and all its information available.
  78263. * Child classes can use it to update shaders
  78264. * @param mesh defines the mesh to check
  78265. * @param subMesh defines which submesh to check
  78266. * @param useInstances specifies that instances should be used
  78267. * @returns a boolean indicating that the submesh is ready or not
  78268. */
  78269. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78270. /**
  78271. * Binds the submesh to this material by preparing the effect and shader to draw
  78272. * @param world defines the world transformation matrix
  78273. * @param mesh defines the mesh containing the submesh
  78274. * @param subMesh defines the submesh to bind the material to
  78275. */
  78276. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78277. /**
  78278. * Get the list of animatables in the material.
  78279. * @returns the list of animatables object used in the material
  78280. */
  78281. getAnimatables(): BABYLON.IAnimatable[];
  78282. /**
  78283. * Disposes the material
  78284. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  78285. */
  78286. dispose(forceDisposeEffect?: boolean): void;
  78287. /**
  78288. * Makes a duplicate of the material, and gives it a new name
  78289. * @param name defines the new name for the duplicated material
  78290. * @returns the cloned material
  78291. */
  78292. clone(name: string): SkyMaterial;
  78293. /**
  78294. * Serializes this material in a JSON representation
  78295. * @returns the serialized material object
  78296. */
  78297. serialize(): any;
  78298. /**
  78299. * Gets the current class name of the material e.g. "SkyMaterial"
  78300. * Mainly use in serialization.
  78301. * @returns the class name
  78302. */
  78303. getClassName(): string;
  78304. /**
  78305. * Creates a sky material from parsed material data
  78306. * @param source defines the JSON representation of the material
  78307. * @param scene defines the hosting scene
  78308. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  78309. * @returns a new sky material
  78310. */
  78311. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  78312. }
  78313. }
  78314. declare module BABYLON {
  78315. /** @hidden */
  78316. export var terrainPixelShader: {
  78317. name: string;
  78318. shader: string;
  78319. };
  78320. }
  78321. declare module BABYLON {
  78322. /** @hidden */
  78323. export var terrainVertexShader: {
  78324. name: string;
  78325. shader: string;
  78326. };
  78327. }
  78328. declare module BABYLON {
  78329. export class TerrainMaterial extends BABYLON.PushMaterial {
  78330. private _mixTexture;
  78331. mixTexture: BABYLON.BaseTexture;
  78332. private _diffuseTexture1;
  78333. diffuseTexture1: BABYLON.Texture;
  78334. private _diffuseTexture2;
  78335. diffuseTexture2: BABYLON.Texture;
  78336. private _diffuseTexture3;
  78337. diffuseTexture3: BABYLON.Texture;
  78338. private _bumpTexture1;
  78339. bumpTexture1: BABYLON.Texture;
  78340. private _bumpTexture2;
  78341. bumpTexture2: BABYLON.Texture;
  78342. private _bumpTexture3;
  78343. bumpTexture3: BABYLON.Texture;
  78344. diffuseColor: BABYLON.Color3;
  78345. specularColor: BABYLON.Color3;
  78346. specularPower: number;
  78347. private _disableLighting;
  78348. disableLighting: boolean;
  78349. private _maxSimultaneousLights;
  78350. maxSimultaneousLights: number;
  78351. private _renderId;
  78352. constructor(name: string, scene: BABYLON.Scene);
  78353. needAlphaBlending(): boolean;
  78354. needAlphaTesting(): boolean;
  78355. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78356. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78357. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78358. getAnimatables(): BABYLON.IAnimatable[];
  78359. getActiveTextures(): BABYLON.BaseTexture[];
  78360. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78361. dispose(forceDisposeEffect?: boolean): void;
  78362. clone(name: string): TerrainMaterial;
  78363. serialize(): any;
  78364. getClassName(): string;
  78365. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  78366. }
  78367. }
  78368. declare module BABYLON {
  78369. /** @hidden */
  78370. export var triplanarPixelShader: {
  78371. name: string;
  78372. shader: string;
  78373. };
  78374. }
  78375. declare module BABYLON {
  78376. /** @hidden */
  78377. export var triplanarVertexShader: {
  78378. name: string;
  78379. shader: string;
  78380. };
  78381. }
  78382. declare module BABYLON {
  78383. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  78384. mixTexture: BABYLON.BaseTexture;
  78385. private _diffuseTextureX;
  78386. diffuseTextureX: BABYLON.BaseTexture;
  78387. private _diffuseTextureY;
  78388. diffuseTextureY: BABYLON.BaseTexture;
  78389. private _diffuseTextureZ;
  78390. diffuseTextureZ: BABYLON.BaseTexture;
  78391. private _normalTextureX;
  78392. normalTextureX: BABYLON.BaseTexture;
  78393. private _normalTextureY;
  78394. normalTextureY: BABYLON.BaseTexture;
  78395. private _normalTextureZ;
  78396. normalTextureZ: BABYLON.BaseTexture;
  78397. tileSize: number;
  78398. diffuseColor: BABYLON.Color3;
  78399. specularColor: BABYLON.Color3;
  78400. specularPower: number;
  78401. private _disableLighting;
  78402. disableLighting: boolean;
  78403. private _maxSimultaneousLights;
  78404. maxSimultaneousLights: number;
  78405. private _renderId;
  78406. constructor(name: string, scene: BABYLON.Scene);
  78407. needAlphaBlending(): boolean;
  78408. needAlphaTesting(): boolean;
  78409. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78410. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78411. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78412. getAnimatables(): BABYLON.IAnimatable[];
  78413. getActiveTextures(): BABYLON.BaseTexture[];
  78414. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78415. dispose(forceDisposeEffect?: boolean): void;
  78416. clone(name: string): TriPlanarMaterial;
  78417. serialize(): any;
  78418. getClassName(): string;
  78419. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  78420. }
  78421. }
  78422. declare module BABYLON {
  78423. /** @hidden */
  78424. export var waterPixelShader: {
  78425. name: string;
  78426. shader: string;
  78427. };
  78428. }
  78429. declare module BABYLON {
  78430. /** @hidden */
  78431. export var waterVertexShader: {
  78432. name: string;
  78433. shader: string;
  78434. };
  78435. }
  78436. declare module BABYLON {
  78437. export class WaterMaterial extends BABYLON.PushMaterial {
  78438. renderTargetSize: BABYLON.Vector2;
  78439. private _bumpTexture;
  78440. bumpTexture: BABYLON.BaseTexture;
  78441. diffuseColor: BABYLON.Color3;
  78442. specularColor: BABYLON.Color3;
  78443. specularPower: number;
  78444. private _disableLighting;
  78445. disableLighting: boolean;
  78446. private _maxSimultaneousLights;
  78447. maxSimultaneousLights: number;
  78448. /**
  78449. * @param {number}: Represents the wind force
  78450. */
  78451. windForce: number;
  78452. /**
  78453. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  78454. */
  78455. windDirection: BABYLON.Vector2;
  78456. /**
  78457. * @param {number}: Wave height, represents the height of the waves
  78458. */
  78459. waveHeight: number;
  78460. /**
  78461. * @param {number}: Bump height, represents the bump height related to the bump map
  78462. */
  78463. bumpHeight: number;
  78464. /**
  78465. * @param {boolean}: Add a smaller moving bump to less steady waves.
  78466. */
  78467. private _bumpSuperimpose;
  78468. bumpSuperimpose: boolean;
  78469. /**
  78470. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  78471. */
  78472. private _fresnelSeparate;
  78473. fresnelSeparate: boolean;
  78474. /**
  78475. * @param {boolean}: bump Waves modify the reflection.
  78476. */
  78477. private _bumpAffectsReflection;
  78478. bumpAffectsReflection: boolean;
  78479. /**
  78480. * @param {number}: The water color blended with the refraction (near)
  78481. */
  78482. waterColor: BABYLON.Color3;
  78483. /**
  78484. * @param {number}: The blend factor related to the water color
  78485. */
  78486. colorBlendFactor: number;
  78487. /**
  78488. * @param {number}: The water color blended with the reflection (far)
  78489. */
  78490. waterColor2: BABYLON.Color3;
  78491. /**
  78492. * @param {number}: The blend factor related to the water color (reflection, far)
  78493. */
  78494. colorBlendFactor2: number;
  78495. /**
  78496. * @param {number}: Represents the maximum length of a wave
  78497. */
  78498. waveLength: number;
  78499. /**
  78500. * @param {number}: Defines the waves speed
  78501. */
  78502. waveSpeed: number;
  78503. /**
  78504. * Sets or gets wether or not automatic clipping should be enabled or not. Setting to true will save performances and
  78505. * will avoid calculating useless pixels in the pixel shader of the water material.
  78506. */
  78507. disableClipPlane: boolean;
  78508. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  78509. private _mesh;
  78510. private _refractionRTT;
  78511. private _reflectionRTT;
  78512. private _reflectionTransform;
  78513. private _lastTime;
  78514. private _lastDeltaTime;
  78515. private _renderId;
  78516. private _useLogarithmicDepth;
  78517. private _waitingRenderList;
  78518. private _imageProcessingConfiguration;
  78519. private _imageProcessingObserver;
  78520. /**
  78521. * Gets a boolean indicating that current material needs to register RTT
  78522. */
  78523. get hasRenderTargetTextures(): boolean;
  78524. /**
  78525. * Constructor
  78526. */
  78527. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  78528. get useLogarithmicDepth(): boolean;
  78529. set useLogarithmicDepth(value: boolean);
  78530. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  78531. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  78532. addToRenderList(node: any): void;
  78533. enableRenderTargets(enable: boolean): void;
  78534. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  78535. get renderTargetsEnabled(): boolean;
  78536. needAlphaBlending(): boolean;
  78537. needAlphaTesting(): boolean;
  78538. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78539. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78540. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78541. private _createRenderTargets;
  78542. getAnimatables(): BABYLON.IAnimatable[];
  78543. getActiveTextures(): BABYLON.BaseTexture[];
  78544. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78545. dispose(forceDisposeEffect?: boolean): void;
  78546. clone(name: string): WaterMaterial;
  78547. serialize(): any;
  78548. getClassName(): string;
  78549. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  78550. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  78551. }
  78552. }
  78553. declare module BABYLON {
  78554. /** @hidden */
  78555. export var asciiartPixelShader: {
  78556. name: string;
  78557. shader: string;
  78558. };
  78559. }
  78560. declare module BABYLON {
  78561. /**
  78562. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  78563. *
  78564. * It basically takes care rendering the font front the given font size to a texture.
  78565. * This is used later on in the postprocess.
  78566. */
  78567. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  78568. private _font;
  78569. private _text;
  78570. private _charSize;
  78571. /**
  78572. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  78573. */
  78574. get charSize(): number;
  78575. /**
  78576. * Create a new instance of the Ascii Art FontTexture class
  78577. * @param name the name of the texture
  78578. * @param font the font to use, use the W3C CSS notation
  78579. * @param text the caracter set to use in the rendering.
  78580. * @param scene the scene that owns the texture
  78581. */
  78582. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  78583. /**
  78584. * Gets the max char width of a font.
  78585. * @param font the font to use, use the W3C CSS notation
  78586. * @return the max char width
  78587. */
  78588. private getFontWidth;
  78589. /**
  78590. * Gets the max char height of a font.
  78591. * @param font the font to use, use the W3C CSS notation
  78592. * @return the max char height
  78593. */
  78594. private getFontHeight;
  78595. /**
  78596. * Clones the current AsciiArtTexture.
  78597. * @return the clone of the texture.
  78598. */
  78599. clone(): AsciiArtFontTexture;
  78600. /**
  78601. * Parses a json object representing the texture and returns an instance of it.
  78602. * @param source the source JSON representation
  78603. * @param scene the scene to create the texture for
  78604. * @return the parsed texture
  78605. */
  78606. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  78607. }
  78608. /**
  78609. * Option available in the Ascii Art Post Process.
  78610. */
  78611. export interface IAsciiArtPostProcessOptions {
  78612. /**
  78613. * The font to use following the w3c font definition.
  78614. */
  78615. font?: string;
  78616. /**
  78617. * The character set to use in the postprocess.
  78618. */
  78619. characterSet?: string;
  78620. /**
  78621. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  78622. * This number is defined between 0 and 1;
  78623. */
  78624. mixToTile?: number;
  78625. /**
  78626. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  78627. * This number is defined between 0 and 1;
  78628. */
  78629. mixToNormal?: number;
  78630. }
  78631. /**
  78632. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  78633. *
  78634. * Simmply add it to your scene and let the nerd that lives in you have fun.
  78635. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  78636. */
  78637. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  78638. /**
  78639. * The font texture used to render the char in the post process.
  78640. */
  78641. private _asciiArtFontTexture;
  78642. /**
  78643. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  78644. * This number is defined between 0 and 1;
  78645. */
  78646. mixToTile: number;
  78647. /**
  78648. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  78649. * This number is defined between 0 and 1;
  78650. */
  78651. mixToNormal: number;
  78652. /**
  78653. * Instantiates a new Ascii Art Post Process.
  78654. * @param name the name to give to the postprocess
  78655. * @camera the camera to apply the post process to.
  78656. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  78657. */
  78658. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  78659. }
  78660. }
  78661. declare module BABYLON {
  78662. /** @hidden */
  78663. export var digitalrainPixelShader: {
  78664. name: string;
  78665. shader: string;
  78666. };
  78667. }
  78668. declare module BABYLON {
  78669. /**
  78670. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  78671. *
  78672. * It basically takes care rendering the font front the given font size to a texture.
  78673. * This is used later on in the postprocess.
  78674. */
  78675. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  78676. private _font;
  78677. private _text;
  78678. private _charSize;
  78679. /**
  78680. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  78681. */
  78682. get charSize(): number;
  78683. /**
  78684. * Create a new instance of the Digital Rain FontTexture class
  78685. * @param name the name of the texture
  78686. * @param font the font to use, use the W3C CSS notation
  78687. * @param text the caracter set to use in the rendering.
  78688. * @param scene the scene that owns the texture
  78689. */
  78690. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  78691. /**
  78692. * Gets the max char width of a font.
  78693. * @param font the font to use, use the W3C CSS notation
  78694. * @return the max char width
  78695. */
  78696. private getFontWidth;
  78697. /**
  78698. * Gets the max char height of a font.
  78699. * @param font the font to use, use the W3C CSS notation
  78700. * @return the max char height
  78701. */
  78702. private getFontHeight;
  78703. /**
  78704. * Clones the current DigitalRainFontTexture.
  78705. * @return the clone of the texture.
  78706. */
  78707. clone(): DigitalRainFontTexture;
  78708. /**
  78709. * Parses a json object representing the texture and returns an instance of it.
  78710. * @param source the source JSON representation
  78711. * @param scene the scene to create the texture for
  78712. * @return the parsed texture
  78713. */
  78714. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  78715. }
  78716. /**
  78717. * Option available in the Digital Rain Post Process.
  78718. */
  78719. export interface IDigitalRainPostProcessOptions {
  78720. /**
  78721. * The font to use following the w3c font definition.
  78722. */
  78723. font?: string;
  78724. /**
  78725. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  78726. * This number is defined between 0 and 1;
  78727. */
  78728. mixToTile?: number;
  78729. /**
  78730. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  78731. * This number is defined between 0 and 1;
  78732. */
  78733. mixToNormal?: number;
  78734. }
  78735. /**
  78736. * DigitalRainPostProcess helps rendering everithing in digital rain.
  78737. *
  78738. * Simmply add it to your scene and let the nerd that lives in you have fun.
  78739. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  78740. */
  78741. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  78742. /**
  78743. * The font texture used to render the char in the post process.
  78744. */
  78745. private _digitalRainFontTexture;
  78746. /**
  78747. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  78748. * This number is defined between 0 and 1;
  78749. */
  78750. mixToTile: number;
  78751. /**
  78752. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  78753. * This number is defined between 0 and 1;
  78754. */
  78755. mixToNormal: number;
  78756. /**
  78757. * Instantiates a new Digital Rain Post Process.
  78758. * @param name the name to give to the postprocess
  78759. * @camera the camera to apply the post process to.
  78760. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  78761. */
  78762. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  78763. }
  78764. }
  78765. declare module BABYLON {
  78766. /** @hidden */
  78767. export var oceanPostProcessPixelShader: {
  78768. name: string;
  78769. shader: string;
  78770. };
  78771. }
  78772. declare module BABYLON {
  78773. /**
  78774. * Option available in the Ocean Post Process.
  78775. */
  78776. export interface IOceanPostProcessOptions {
  78777. /**
  78778. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  78779. */
  78780. reflectionSize?: number | {
  78781. width: number;
  78782. height: number;
  78783. } | {
  78784. ratio: number;
  78785. };
  78786. /**
  78787. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  78788. */
  78789. refractionSize?: number | {
  78790. width: number;
  78791. height: number;
  78792. } | {
  78793. ratio: number;
  78794. };
  78795. }
  78796. /**
  78797. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  78798. *
  78799. * Simmply add it to your scene and let the nerd that lives in you have fun.
  78800. * Example usage:
  78801. * var pp = new OceanPostProcess("myOcean", camera);
  78802. * pp.reflectionEnabled = true;
  78803. * pp.refractionEnabled = true;
  78804. */
  78805. export class OceanPostProcess extends BABYLON.PostProcess {
  78806. /**
  78807. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  78808. */
  78809. get reflectionEnabled(): boolean;
  78810. /**
  78811. * Sets weither or not the real-time reflection is enabled on the ocean.
  78812. * Is set to true, the reflection mirror texture will be used as reflection texture.
  78813. */
  78814. set reflectionEnabled(enabled: boolean);
  78815. /**
  78816. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  78817. */
  78818. get refractionEnabled(): boolean;
  78819. /**
  78820. * Sets weither or not the real-time refraction is enabled on the ocean.
  78821. * Is set to true, the refraction render target texture will be used as refraction texture.
  78822. */
  78823. set refractionEnabled(enabled: boolean);
  78824. /**
  78825. * Gets wether or not the post-processes is supported by the running hardware.
  78826. * This requires draw buffer supports.
  78827. */
  78828. get isSupported(): boolean;
  78829. /**
  78830. * This is the reflection mirror texture used to display reflections on the ocean.
  78831. * By default, render list is empty.
  78832. */
  78833. reflectionTexture: BABYLON.MirrorTexture;
  78834. /**
  78835. * This is the refraction render target texture used to display refraction on the ocean.
  78836. * By default, render list is empty.
  78837. */
  78838. refractionTexture: BABYLON.RenderTargetTexture;
  78839. private _time;
  78840. private _cameraRotation;
  78841. private _cameraViewMatrix;
  78842. private _reflectionEnabled;
  78843. private _refractionEnabled;
  78844. private _geometryRenderer;
  78845. /**
  78846. * Instantiates a new Ocean Post Process.
  78847. * @param name the name to give to the postprocess.
  78848. * @camera the camera to apply the post process to.
  78849. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  78850. */
  78851. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  78852. /**
  78853. * Returns the appropriate defines according to the current configuration.
  78854. */
  78855. private _getDefines;
  78856. /**
  78857. * Computes the current camera rotation as the shader requires a camera rotation.
  78858. */
  78859. private _computeCameraRotation;
  78860. }
  78861. }
  78862. declare module BABYLON {
  78863. /** @hidden */
  78864. export var brickProceduralTexturePixelShader: {
  78865. name: string;
  78866. shader: string;
  78867. };
  78868. }
  78869. declare module BABYLON {
  78870. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  78871. private _numberOfBricksHeight;
  78872. private _numberOfBricksWidth;
  78873. private _jointColor;
  78874. private _brickColor;
  78875. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  78876. updateShaderUniforms(): void;
  78877. get numberOfBricksHeight(): number;
  78878. set numberOfBricksHeight(value: number);
  78879. get numberOfBricksWidth(): number;
  78880. set numberOfBricksWidth(value: number);
  78881. get jointColor(): BABYLON.Color3;
  78882. set jointColor(value: BABYLON.Color3);
  78883. get brickColor(): BABYLON.Color3;
  78884. set brickColor(value: BABYLON.Color3);
  78885. /**
  78886. * Serializes this brick procedural texture
  78887. * @returns a serialized brick procedural texture object
  78888. */
  78889. serialize(): any;
  78890. /**
  78891. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  78892. * @param parsedTexture defines parsed texture data
  78893. * @param scene defines the current scene
  78894. * @param rootUrl defines the root URL containing brick procedural texture information
  78895. * @returns a parsed Brick Procedural BABYLON.Texture
  78896. */
  78897. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  78898. }
  78899. }
  78900. declare module BABYLON {
  78901. /** @hidden */
  78902. export var cloudProceduralTexturePixelShader: {
  78903. name: string;
  78904. shader: string;
  78905. };
  78906. }
  78907. declare module BABYLON {
  78908. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  78909. private _skyColor;
  78910. private _cloudColor;
  78911. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  78912. updateShaderUniforms(): void;
  78913. get skyColor(): BABYLON.Color4;
  78914. set skyColor(value: BABYLON.Color4);
  78915. get cloudColor(): BABYLON.Color4;
  78916. set cloudColor(value: BABYLON.Color4);
  78917. /**
  78918. * Serializes this cloud procedural texture
  78919. * @returns a serialized cloud procedural texture object
  78920. */
  78921. serialize(): any;
  78922. /**
  78923. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  78924. * @param parsedTexture defines parsed texture data
  78925. * @param scene defines the current scene
  78926. * @param rootUrl defines the root URL containing cloud procedural texture information
  78927. * @returns a parsed Cloud Procedural BABYLON.Texture
  78928. */
  78929. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  78930. }
  78931. }
  78932. declare module BABYLON {
  78933. /** @hidden */
  78934. export var fireProceduralTexturePixelShader: {
  78935. name: string;
  78936. shader: string;
  78937. };
  78938. }
  78939. declare module BABYLON {
  78940. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  78941. private _time;
  78942. private _speed;
  78943. private _autoGenerateTime;
  78944. private _fireColors;
  78945. private _alphaThreshold;
  78946. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  78947. updateShaderUniforms(): void;
  78948. render(useCameraPostProcess?: boolean): void;
  78949. static get PurpleFireColors(): BABYLON.Color3[];
  78950. static get GreenFireColors(): BABYLON.Color3[];
  78951. static get RedFireColors(): BABYLON.Color3[];
  78952. static get BlueFireColors(): BABYLON.Color3[];
  78953. get autoGenerateTime(): boolean;
  78954. set autoGenerateTime(value: boolean);
  78955. get fireColors(): BABYLON.Color3[];
  78956. set fireColors(value: BABYLON.Color3[]);
  78957. get time(): number;
  78958. set time(value: number);
  78959. get speed(): BABYLON.Vector2;
  78960. set speed(value: BABYLON.Vector2);
  78961. get alphaThreshold(): number;
  78962. set alphaThreshold(value: number);
  78963. /**
  78964. * Serializes this fire procedural texture
  78965. * @returns a serialized fire procedural texture object
  78966. */
  78967. serialize(): any;
  78968. /**
  78969. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  78970. * @param parsedTexture defines parsed texture data
  78971. * @param scene defines the current scene
  78972. * @param rootUrl defines the root URL containing fire procedural texture information
  78973. * @returns a parsed Fire Procedural BABYLON.Texture
  78974. */
  78975. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  78976. }
  78977. }
  78978. declare module BABYLON {
  78979. /** @hidden */
  78980. export var grassProceduralTexturePixelShader: {
  78981. name: string;
  78982. shader: string;
  78983. };
  78984. }
  78985. declare module BABYLON {
  78986. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  78987. private _grassColors;
  78988. private _groundColor;
  78989. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  78990. updateShaderUniforms(): void;
  78991. get grassColors(): BABYLON.Color3[];
  78992. set grassColors(value: BABYLON.Color3[]);
  78993. get groundColor(): BABYLON.Color3;
  78994. set groundColor(value: BABYLON.Color3);
  78995. /**
  78996. * Serializes this grass procedural texture
  78997. * @returns a serialized grass procedural texture object
  78998. */
  78999. serialize(): any;
  79000. /**
  79001. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  79002. * @param parsedTexture defines parsed texture data
  79003. * @param scene defines the current scene
  79004. * @param rootUrl defines the root URL containing grass procedural texture information
  79005. * @returns a parsed Grass Procedural BABYLON.Texture
  79006. */
  79007. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  79008. }
  79009. }
  79010. declare module BABYLON {
  79011. /** @hidden */
  79012. export var marbleProceduralTexturePixelShader: {
  79013. name: string;
  79014. shader: string;
  79015. };
  79016. }
  79017. declare module BABYLON {
  79018. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  79019. private _numberOfTilesHeight;
  79020. private _numberOfTilesWidth;
  79021. private _amplitude;
  79022. private _jointColor;
  79023. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79024. updateShaderUniforms(): void;
  79025. get numberOfTilesHeight(): number;
  79026. set numberOfTilesHeight(value: number);
  79027. get amplitude(): number;
  79028. set amplitude(value: number);
  79029. get numberOfTilesWidth(): number;
  79030. set numberOfTilesWidth(value: number);
  79031. get jointColor(): BABYLON.Color3;
  79032. set jointColor(value: BABYLON.Color3);
  79033. /**
  79034. * Serializes this marble procedural texture
  79035. * @returns a serialized marble procedural texture object
  79036. */
  79037. serialize(): any;
  79038. /**
  79039. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  79040. * @param parsedTexture defines parsed texture data
  79041. * @param scene defines the current scene
  79042. * @param rootUrl defines the root URL containing marble procedural texture information
  79043. * @returns a parsed Marble Procedural BABYLON.Texture
  79044. */
  79045. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  79046. }
  79047. }
  79048. declare module BABYLON {
  79049. /** @hidden */
  79050. export var normalMapProceduralTexturePixelShader: {
  79051. name: string;
  79052. shader: string;
  79053. };
  79054. }
  79055. declare module BABYLON {
  79056. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  79057. private _baseTexture;
  79058. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79059. updateShaderUniforms(): void;
  79060. render(useCameraPostProcess?: boolean): void;
  79061. resize(size: any, generateMipMaps: any): void;
  79062. get baseTexture(): BABYLON.Texture;
  79063. set baseTexture(texture: BABYLON.Texture);
  79064. /**
  79065. * Serializes this normal map procedural texture
  79066. * @returns a serialized normal map procedural texture object
  79067. */
  79068. serialize(): any;
  79069. /**
  79070. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  79071. * @param parsedTexture defines parsed texture data
  79072. * @param scene defines the current scene
  79073. * @param rootUrl defines the root URL containing normal map procedural texture information
  79074. * @returns a parsed Normal Map Procedural BABYLON.Texture
  79075. */
  79076. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  79077. }
  79078. }
  79079. declare module BABYLON {
  79080. /** @hidden */
  79081. export var perlinNoiseProceduralTexturePixelShader: {
  79082. name: string;
  79083. shader: string;
  79084. };
  79085. }
  79086. declare module BABYLON {
  79087. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  79088. time: number;
  79089. timeScale: number;
  79090. translationSpeed: number;
  79091. private _currentTranslation;
  79092. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79093. updateShaderUniforms(): void;
  79094. render(useCameraPostProcess?: boolean): void;
  79095. resize(size: any, generateMipMaps: any): void;
  79096. /**
  79097. * Serializes this perlin noise procedural texture
  79098. * @returns a serialized perlin noise procedural texture object
  79099. */
  79100. serialize(): any;
  79101. /**
  79102. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  79103. * @param parsedTexture defines parsed texture data
  79104. * @param scene defines the current scene
  79105. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  79106. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  79107. */
  79108. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  79109. }
  79110. }
  79111. declare module BABYLON {
  79112. /** @hidden */
  79113. export var roadProceduralTexturePixelShader: {
  79114. name: string;
  79115. shader: string;
  79116. };
  79117. }
  79118. declare module BABYLON {
  79119. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  79120. private _roadColor;
  79121. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79122. updateShaderUniforms(): void;
  79123. get roadColor(): BABYLON.Color3;
  79124. set roadColor(value: BABYLON.Color3);
  79125. /**
  79126. * Serializes this road procedural texture
  79127. * @returns a serialized road procedural texture object
  79128. */
  79129. serialize(): any;
  79130. /**
  79131. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  79132. * @param parsedTexture defines parsed texture data
  79133. * @param scene defines the current scene
  79134. * @param rootUrl defines the root URL containing road procedural texture information
  79135. * @returns a parsed Road Procedural BABYLON.Texture
  79136. */
  79137. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  79138. }
  79139. }
  79140. declare module BABYLON {
  79141. /** @hidden */
  79142. export var starfieldProceduralTexturePixelShader: {
  79143. name: string;
  79144. shader: string;
  79145. };
  79146. }
  79147. declare module BABYLON {
  79148. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  79149. private _time;
  79150. private _alpha;
  79151. private _beta;
  79152. private _zoom;
  79153. private _formuparam;
  79154. private _stepsize;
  79155. private _tile;
  79156. private _brightness;
  79157. private _darkmatter;
  79158. private _distfading;
  79159. private _saturation;
  79160. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79161. updateShaderUniforms(): void;
  79162. get time(): number;
  79163. set time(value: number);
  79164. get alpha(): number;
  79165. set alpha(value: number);
  79166. get beta(): number;
  79167. set beta(value: number);
  79168. get formuparam(): number;
  79169. set formuparam(value: number);
  79170. get stepsize(): number;
  79171. set stepsize(value: number);
  79172. get zoom(): number;
  79173. set zoom(value: number);
  79174. get tile(): number;
  79175. set tile(value: number);
  79176. get brightness(): number;
  79177. set brightness(value: number);
  79178. get darkmatter(): number;
  79179. set darkmatter(value: number);
  79180. get distfading(): number;
  79181. set distfading(value: number);
  79182. get saturation(): number;
  79183. set saturation(value: number);
  79184. /**
  79185. * Serializes this starfield procedural texture
  79186. * @returns a serialized starfield procedural texture object
  79187. */
  79188. serialize(): any;
  79189. /**
  79190. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  79191. * @param parsedTexture defines parsed texture data
  79192. * @param scene defines the current scene
  79193. * @param rootUrl defines the root URL containing startfield procedural texture information
  79194. * @returns a parsed Starfield Procedural BABYLON.Texture
  79195. */
  79196. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  79197. }
  79198. }
  79199. declare module BABYLON {
  79200. /** @hidden */
  79201. export var woodProceduralTexturePixelShader: {
  79202. name: string;
  79203. shader: string;
  79204. };
  79205. }
  79206. declare module BABYLON {
  79207. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  79208. private _ampScale;
  79209. private _woodColor;
  79210. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79211. updateShaderUniforms(): void;
  79212. get ampScale(): number;
  79213. set ampScale(value: number);
  79214. get woodColor(): BABYLON.Color3;
  79215. set woodColor(value: BABYLON.Color3);
  79216. /**
  79217. * Serializes this wood procedural texture
  79218. * @returns a serialized wood procedural texture object
  79219. */
  79220. serialize(): any;
  79221. /**
  79222. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  79223. * @param parsedTexture defines parsed texture data
  79224. * @param scene defines the current scene
  79225. * @param rootUrl defines the root URL containing wood procedural texture information
  79226. * @returns a parsed Wood Procedural BABYLON.Texture
  79227. */
  79228. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  79229. }
  79230. }