documentation.d.ts 3.3 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726687276872868729687306873168732687336873468735687366873768738687396874068741687426874368744687456874668747687486874968750687516875268753687546875568756687576875868759687606876168762687636876468765687666876768768687696877068771687726877368774687756877668777687786877968780687816878268783687846878568786687876878868789687906879168792687936879468795687966879768798687996880068801688026880368804688056880668807688086880968810688116881268813688146881568816688176881868819688206882168822688236882468825688266882768828688296883068831688326883368834688356883668837688386883968840688416884268843688446884568846688476884868849688506885168852688536885468855688566885768858688596886068861688626886368864688656886668867688686886968870688716887268873688746887568876688776887868879688806888168882688836888468885688866888768888688896889068891688926889368894688956889668897688986889968900689016890268903689046890568906689076890868909689106891168912689136891468915689166891768918689196892068921689226892368924689256892668927689286892968930689316893268933689346893568936689376893868939689406894168942689436894468945689466894768948689496895068951689526895368954689556895668957689586895968960689616896268963689646896568966689676896868969689706897168972689736897468975689766897768978689796898068981689826898368984689856898668987689886898968990689916899268993689946899568996689976899868999690006900169002690036900469005690066900769008690096901069011690126901369014690156901669017690186901969020690216902269023690246902569026690276902869029690306903169032690336903469035690366903769038690396904069041690426904369044690456904669047690486904969050690516905269053690546905569056690576905869059690606906169062690636906469065690666906769068690696907069071690726907369074690756907669077690786907969080690816908269083690846908569086690876908869089690906909169092690936909469095690966909769098690996910069101691026910369104691056910669107691086910969110691116911269113691146911569116691176911869119691206912169122691236912469125691266912769128691296913069131691326913369134691356913669137691386913969140691416914269143691446914569146691476914869149691506915169152691536915469155691566915769158691596916069161691626916369164691656916669167691686916969170691716917269173691746917569176691776917869179691806918169182691836918469185691866918769188691896919069191691926919369194691956919669197691986919969200692016920269203692046920569206692076920869209692106921169212692136921469215692166921769218692196922069221692226922369224692256922669227692286922969230692316923269233692346923569236692376923869239692406924169242692436924469245692466924769248692496925069251692526925369254692556925669257692586925969260692616926269263692646926569266692676926869269692706927169272692736927469275692766927769278692796928069281692826928369284692856928669287692886928969290692916929269293692946929569296692976929869299693006930169302693036930469305693066930769308693096931069311693126931369314693156931669317693186931969320693216932269323693246932569326693276932869329693306933169332693336933469335693366933769338693396934069341693426934369344693456934669347693486934969350693516935269353693546935569356693576935869359693606936169362693636936469365693666936769368693696937069371693726937369374693756937669377693786937969380693816938269383693846938569386693876938869389693906939169392693936939469395693966939769398693996940069401694026940369404694056940669407694086940969410694116941269413694146941569416694176941869419694206942169422694236942469425694266942769428694296943069431694326943369434694356943669437694386943969440694416944269443694446944569446694476944869449694506945169452694536945469455694566945769458694596946069461694626946369464694656946669467694686946969470694716947269473694746947569476694776947869479694806948169482694836948469485694866948769488694896949069491694926949369494694956949669497694986949969500695016950269503695046950569506695076950869509695106951169512695136951469515695166951769518695196952069521695226952369524695256952669527695286952969530695316953269533695346953569536695376953869539695406954169542695436954469545695466954769548695496955069551695526955369554695556955669557695586955969560695616956269563695646956569566695676956869569695706957169572695736957469575695766957769578695796958069581695826958369584695856958669587695886958969590695916959269593695946959569596695976959869599696006960169602696036960469605696066960769608696096961069611696126961369614696156961669617696186961969620696216962269623696246962569626696276962869629696306963169632696336963469635696366963769638696396964069641696426964369644696456964669647696486964969650696516965269653696546965569656696576965869659696606966169662696636966469665696666966769668696696967069671696726967369674696756967669677696786967969680696816968269683696846968569686696876968869689696906969169692696936969469695696966969769698696996970069701697026970369704697056970669707697086970969710697116971269713697146971569716697176971869719697206972169722697236972469725697266972769728697296973069731697326973369734697356973669737697386973969740697416974269743697446974569746697476974869749697506975169752697536975469755697566975769758697596976069761697626976369764697656976669767697686976969770697716977269773697746977569776697776977869779697806978169782697836978469785697866978769788697896979069791697926979369794697956979669797697986979969800698016980269803698046980569806698076980869809698106981169812698136981469815698166981769818698196982069821698226982369824698256982669827698286982969830698316983269833698346983569836698376983869839698406984169842698436984469845698466984769848698496985069851698526985369854698556985669857698586985969860698616986269863698646986569866698676986869869698706987169872698736987469875698766987769878698796988069881698826988369884698856988669887698886988969890698916989269893698946989569896698976989869899699006990169902699036990469905699066990769908699096991069911699126991369914699156991669917699186991969920699216992269923699246992569926699276992869929699306993169932699336993469935699366993769938699396994069941699426994369944699456994669947699486994969950699516995269953699546995569956699576995869959699606996169962699636996469965699666996769968699696997069971699726997369974699756997669977699786997969980699816998269983699846998569986699876998869989699906999169992699936999469995699966999769998699997000070001700027000370004700057000670007700087000970010700117001270013700147001570016700177001870019700207002170022700237002470025700267002770028700297003070031700327003370034700357003670037700387003970040700417004270043700447004570046700477004870049700507005170052700537005470055700567005770058700597006070061700627006370064700657006670067700687006970070700717007270073700747007570076700777007870079700807008170082700837008470085700867008770088700897009070091700927009370094700957009670097700987009970100701017010270103701047010570106701077010870109701107011170112701137011470115701167011770118701197012070121701227012370124701257012670127701287012970130701317013270133701347013570136701377013870139701407014170142701437014470145701467014770148701497015070151701527015370154701557015670157701587015970160701617016270163701647016570166701677016870169701707017170172701737017470175701767017770178701797018070181701827018370184701857018670187701887018970190701917019270193701947019570196701977019870199702007020170202702037020470205702067020770208702097021070211702127021370214702157021670217702187021970220702217022270223702247022570226702277022870229702307023170232702337023470235702367023770238702397024070241702427024370244702457024670247702487024970250702517025270253702547025570256702577025870259702607026170262702637026470265702667026770268702697027070271702727027370274702757027670277702787027970280702817028270283702847028570286702877028870289702907029170292702937029470295702967029770298702997030070301703027030370304703057030670307703087030970310703117031270313703147031570316703177031870319703207032170322703237032470325703267032770328703297033070331703327033370334703357033670337703387033970340703417034270343703447034570346703477034870349703507035170352703537035470355703567035770358703597036070361703627036370364703657036670367703687036970370703717037270373703747037570376703777037870379703807038170382703837038470385703867038770388703897039070391703927039370394703957039670397703987039970400704017040270403704047040570406704077040870409704107041170412704137041470415704167041770418704197042070421704227042370424704257042670427704287042970430704317043270433704347043570436704377043870439704407044170442704437044470445704467044770448704497045070451704527045370454704557045670457704587045970460704617046270463704647046570466704677046870469704707047170472704737047470475704767047770478704797048070481704827048370484704857048670487704887048970490704917049270493704947049570496704977049870499705007050170502705037050470505705067050770508705097051070511705127051370514705157051670517705187051970520705217052270523705247052570526705277052870529705307053170532705337053470535705367053770538705397054070541705427054370544705457054670547705487054970550705517055270553705547055570556705577055870559705607056170562705637056470565705667056770568705697057070571705727057370574705757057670577705787057970580705817058270583705847058570586705877058870589705907059170592705937059470595705967059770598705997060070601706027060370604706057060670607706087060970610706117061270613706147061570616706177061870619706207062170622706237062470625706267062770628706297063070631706327063370634706357063670637706387063970640706417064270643706447064570646706477064870649706507065170652706537065470655706567065770658706597066070661706627066370664706657066670667706687066970670706717067270673706747067570676706777067870679706807068170682706837068470685706867068770688706897069070691706927069370694706957069670697706987069970700707017070270703707047070570706707077070870709707107071170712707137071470715707167071770718707197072070721707227072370724707257072670727707287072970730707317073270733707347073570736707377073870739707407074170742707437074470745707467074770748707497075070751707527075370754707557075670757707587075970760707617076270763707647076570766707677076870769707707077170772707737077470775707767077770778707797078070781707827078370784707857078670787707887078970790707917079270793707947079570796707977079870799708007080170802708037080470805708067080770808708097081070811708127081370814708157081670817708187081970820708217082270823708247082570826708277082870829708307083170832708337083470835708367083770838708397084070841708427084370844708457084670847708487084970850708517085270853708547085570856708577085870859708607086170862708637086470865708667086770868708697087070871708727087370874708757087670877708787087970880708817088270883708847088570886708877088870889708907089170892708937089470895708967089770898708997090070901709027090370904709057090670907709087090970910709117091270913709147091570916709177091870919709207092170922709237092470925709267092770928709297093070931709327093370934709357093670937709387093970940709417094270943709447094570946709477094870949709507095170952709537095470955709567095770958709597096070961709627096370964709657096670967709687096970970709717097270973709747097570976709777097870979709807098170982709837098470985709867098770988709897099070991709927099370994709957099670997709987099971000710017100271003710047100571006710077100871009710107101171012710137101471015710167101771018710197102071021710227102371024710257102671027710287102971030710317103271033710347103571036710377103871039710407104171042710437104471045710467104771048710497105071051710527105371054710557105671057710587105971060710617106271063710647106571066710677106871069710707107171072710737107471075710767107771078710797108071081710827108371084710857108671087710887108971090710917109271093710947109571096710977109871099711007110171102711037110471105711067110771108711097111071111711127111371114711157111671117711187111971120711217112271123711247112571126711277112871129711307113171132711337113471135711367113771138711397114071141711427114371144711457114671147711487114971150711517115271153711547115571156711577115871159711607116171162711637116471165711667116771168711697117071171711727117371174711757117671177711787117971180711817118271183711847118571186711877118871189711907119171192711937119471195711967119771198711997120071201712027120371204712057120671207712087120971210712117121271213712147121571216712177121871219712207122171222712237122471225712267122771228712297123071231712327123371234712357123671237712387123971240712417124271243712447124571246712477124871249712507125171252712537125471255712567125771258712597126071261712627126371264712657126671267712687126971270712717127271273712747127571276712777127871279712807128171282712837128471285712867128771288712897129071291712927129371294712957129671297712987129971300713017130271303713047130571306713077130871309713107131171312713137131471315713167131771318713197132071321713227132371324713257132671327713287132971330713317133271333713347133571336713377133871339713407134171342713437134471345713467134771348713497135071351713527135371354713557135671357713587135971360713617136271363713647136571366713677136871369713707137171372713737137471375713767137771378713797138071381713827138371384713857138671387713887138971390713917139271393713947139571396713977139871399714007140171402714037140471405714067140771408714097141071411714127141371414714157141671417714187141971420714217142271423714247142571426714277142871429714307143171432714337143471435714367143771438714397144071441714427144371444714457144671447714487144971450714517145271453714547145571456714577145871459714607146171462714637146471465714667146771468714697147071471714727147371474714757147671477714787147971480714817148271483714847148571486714877148871489714907149171492714937149471495714967149771498714997150071501715027150371504715057150671507715087150971510715117151271513715147151571516715177151871519715207152171522715237152471525715267152771528715297153071531715327153371534715357153671537715387153971540715417154271543715447154571546715477154871549715507155171552715537155471555715567155771558715597156071561715627156371564715657156671567715687156971570715717157271573715747157571576715777157871579715807158171582715837158471585715867158771588715897159071591715927159371594715957159671597715987159971600716017160271603716047160571606716077160871609716107161171612716137161471615716167161771618716197162071621716227162371624716257162671627716287162971630716317163271633716347163571636716377163871639716407164171642716437164471645716467164771648716497165071651716527165371654716557165671657716587165971660716617166271663716647166571666716677166871669716707167171672716737167471675716767167771678716797168071681716827168371684716857168671687716887168971690716917169271693716947169571696716977169871699717007170171702717037170471705717067170771708717097171071711717127171371714717157171671717717187171971720717217172271723717247172571726717277172871729717307173171732717337173471735717367173771738717397174071741717427174371744717457174671747717487174971750717517175271753717547175571756717577175871759717607176171762717637176471765717667176771768717697177071771717727177371774717757177671777717787177971780717817178271783717847178571786717877178871789717907179171792717937179471795717967179771798717997180071801718027180371804718057180671807718087180971810718117181271813718147181571816718177181871819718207182171822718237182471825718267182771828718297183071831718327183371834718357183671837718387183971840718417184271843718447184571846718477184871849718507185171852718537185471855718567185771858718597186071861718627186371864718657186671867718687186971870718717187271873718747187571876718777187871879718807188171882718837188471885718867188771888718897189071891718927189371894718957189671897718987189971900719017190271903719047190571906719077190871909719107191171912719137191471915719167191771918719197192071921719227192371924719257192671927719287192971930719317193271933719347193571936719377193871939719407194171942719437194471945719467194771948719497195071951719527195371954719557195671957719587195971960719617196271963719647196571966719677196871969719707197171972719737197471975719767197771978719797198071981719827198371984719857198671987719887198971990719917199271993719947199571996719977199871999720007200172002720037200472005720067200772008720097201072011720127201372014720157201672017720187201972020720217202272023720247202572026720277202872029720307203172032720337203472035720367203772038720397204072041720427204372044720457204672047720487204972050720517205272053720547205572056720577205872059720607206172062720637206472065720667206772068720697207072071720727207372074720757207672077720787207972080720817208272083720847208572086720877208872089720907209172092720937209472095720967209772098720997210072101721027210372104721057210672107721087210972110721117211272113721147211572116721177211872119721207212172122721237212472125721267212772128721297213072131721327213372134721357213672137721387213972140721417214272143721447214572146721477214872149721507215172152721537215472155721567215772158721597216072161721627216372164721657216672167721687216972170721717217272173721747217572176721777217872179721807218172182721837218472185721867218772188721897219072191721927219372194721957219672197721987219972200722017220272203722047220572206722077220872209722107221172212722137221472215722167221772218722197222072221722227222372224722257222672227722287222972230722317223272233722347223572236722377223872239722407224172242722437224472245722467224772248722497225072251722527225372254722557225672257722587225972260722617226272263722647226572266722677226872269722707227172272722737227472275722767227772278722797228072281722827228372284722857228672287722887228972290722917229272293722947229572296722977229872299723007230172302723037230472305723067230772308723097231072311723127231372314723157231672317723187231972320723217232272323723247232572326723277232872329723307233172332723337233472335723367233772338723397234072341723427234372344723457234672347723487234972350723517235272353723547235572356723577235872359723607236172362723637236472365723667236772368723697237072371723727237372374723757237672377723787237972380723817238272383723847238572386723877238872389723907239172392723937239472395723967239772398723997240072401724027240372404724057240672407724087240972410724117241272413724147241572416724177241872419724207242172422724237242472425724267242772428724297243072431724327243372434724357243672437724387243972440724417244272443724447244572446724477244872449724507245172452724537245472455724567245772458724597246072461724627246372464724657246672467724687246972470724717247272473724747247572476724777247872479724807248172482724837248472485724867248772488724897249072491724927249372494724957249672497724987249972500725017250272503725047250572506725077250872509725107251172512725137251472515725167251772518725197252072521725227252372524725257252672527725287252972530725317253272533725347253572536725377253872539725407254172542725437254472545725467254772548725497255072551725527255372554725557255672557725587255972560725617256272563725647256572566725677256872569725707257172572725737257472575725767257772578725797258072581725827258372584725857258672587725887258972590725917259272593725947259572596725977259872599726007260172602726037260472605726067260772608726097261072611726127261372614726157261672617726187261972620726217262272623726247262572626726277262872629726307263172632726337263472635726367263772638726397264072641726427264372644726457264672647726487264972650726517265272653726547265572656726577265872659726607266172662726637266472665726667266772668726697267072671726727267372674726757267672677726787267972680726817268272683726847268572686726877268872689726907269172692726937269472695726967269772698726997270072701727027270372704727057270672707727087270972710727117271272713727147271572716727177271872719727207272172722727237272472725727267272772728727297273072731727327273372734727357273672737727387273972740727417274272743727447274572746727477274872749727507275172752727537275472755727567275772758727597276072761727627276372764727657276672767727687276972770727717277272773727747277572776727777277872779727807278172782727837278472785727867278772788727897279072791727927279372794727957279672797727987279972800728017280272803728047280572806728077280872809728107281172812728137281472815728167281772818728197282072821728227282372824728257282672827728287282972830728317283272833728347283572836728377283872839728407284172842728437284472845728467284772848728497285072851728527285372854728557285672857728587285972860728617286272863728647286572866728677286872869728707287172872728737287472875728767287772878728797288072881728827288372884728857288672887728887288972890728917289272893728947289572896728977289872899729007290172902729037290472905729067290772908729097291072911729127291372914729157291672917729187291972920729217292272923729247292572926729277292872929729307293172932729337293472935729367293772938729397294072941729427294372944729457294672947729487294972950729517295272953729547295572956729577295872959729607296172962729637296472965729667296772968729697297072971729727297372974729757297672977729787297972980729817298272983729847298572986729877298872989729907299172992729937299472995729967299772998729997300073001730027300373004730057300673007730087300973010730117301273013730147301573016730177301873019730207302173022730237302473025730267302773028730297303073031730327303373034730357303673037730387303973040730417304273043730447304573046730477304873049730507305173052730537305473055730567305773058730597306073061730627306373064730657306673067730687306973070730717307273073730747307573076730777307873079730807308173082730837308473085730867308773088730897309073091730927309373094730957309673097730987309973100731017310273103731047310573106731077310873109731107311173112731137311473115731167311773118731197312073121731227312373124731257312673127731287312973130731317313273133731347313573136731377313873139731407314173142731437314473145731467314773148731497315073151731527315373154731557315673157731587315973160731617316273163731647316573166731677316873169731707317173172731737317473175731767317773178731797318073181731827318373184731857318673187731887318973190731917319273193731947319573196731977319873199732007320173202732037320473205732067320773208732097321073211732127321373214732157321673217732187321973220732217322273223732247322573226732277322873229732307323173232732337323473235732367323773238732397324073241732427324373244732457324673247732487324973250732517325273253732547325573256732577325873259732607326173262732637326473265732667326773268732697327073271732727327373274732757327673277732787327973280732817328273283732847328573286732877328873289732907329173292732937329473295732967329773298732997330073301733027330373304733057330673307733087330973310733117331273313733147331573316733177331873319733207332173322733237332473325733267332773328733297333073331733327333373334733357333673337733387333973340733417334273343733447334573346733477334873349733507335173352733537335473355733567335773358733597336073361733627336373364733657336673367733687336973370733717337273373733747337573376733777337873379733807338173382733837338473385733867338773388733897339073391733927339373394733957339673397733987339973400734017340273403734047340573406734077340873409734107341173412734137341473415734167341773418734197342073421734227342373424734257342673427734287342973430734317343273433734347343573436734377343873439734407344173442734437344473445734467344773448734497345073451734527345373454734557345673457734587345973460734617346273463734647346573466734677346873469734707347173472734737347473475734767347773478734797348073481734827348373484734857348673487734887348973490734917349273493734947349573496734977349873499735007350173502735037350473505735067350773508735097351073511735127351373514735157351673517735187351973520735217352273523735247352573526735277352873529735307353173532735337353473535735367353773538735397354073541735427354373544735457354673547735487354973550735517355273553735547355573556735577355873559735607356173562735637356473565735667356773568735697357073571735727357373574735757357673577735787357973580735817358273583735847358573586735877358873589735907359173592735937359473595735967359773598735997360073601736027360373604736057360673607736087360973610736117361273613736147361573616736177361873619736207362173622736237362473625736267362773628736297363073631736327363373634736357363673637736387363973640736417364273643736447364573646736477364873649736507365173652736537365473655736567365773658736597366073661736627366373664736657366673667736687366973670736717367273673736747367573676736777367873679736807368173682736837368473685736867368773688736897369073691736927369373694736957369673697736987369973700737017370273703737047370573706737077370873709737107371173712737137371473715737167371773718737197372073721737227372373724737257372673727737287372973730737317373273733737347373573736737377373873739737407374173742737437374473745737467374773748737497375073751737527375373754737557375673757737587375973760737617376273763737647376573766737677376873769737707377173772737737377473775737767377773778737797378073781737827378373784737857378673787737887378973790737917379273793737947379573796737977379873799738007380173802738037380473805738067380773808738097381073811738127381373814738157381673817738187381973820738217382273823738247382573826738277382873829738307383173832738337383473835738367383773838738397384073841738427384373844738457384673847738487384973850738517385273853738547385573856738577385873859738607386173862738637386473865738667386773868738697387073871738727387373874738757387673877738787387973880738817388273883738847388573886738877388873889738907389173892738937389473895738967389773898738997390073901739027390373904739057390673907739087390973910739117391273913739147391573916739177391873919739207392173922739237392473925739267392773928739297393073931739327393373934739357393673937739387393973940739417394273943739447394573946739477394873949739507395173952739537395473955739567395773958739597396073961739627396373964739657396673967739687396973970739717397273973739747397573976739777397873979739807398173982739837398473985739867398773988739897399073991739927399373994739957399673997739987399974000740017400274003740047400574006740077400874009740107401174012740137401474015740167401774018740197402074021740227402374024740257402674027740287402974030740317403274033740347403574036740377403874039740407404174042740437404474045740467404774048740497405074051740527405374054740557405674057740587405974060740617406274063740647406574066740677406874069740707407174072740737407474075740767407774078740797408074081740827408374084740857408674087740887408974090740917409274093740947409574096740977409874099741007410174102741037410474105741067410774108741097411074111741127411374114741157411674117741187411974120741217412274123741247412574126741277412874129741307413174132741337413474135741367413774138741397414074141741427414374144741457414674147741487414974150741517415274153741547415574156741577415874159741607416174162741637416474165741667416774168741697417074171741727417374174741757417674177741787417974180741817418274183741847418574186741877418874189741907419174192741937419474195741967419774198741997420074201742027420374204742057420674207742087420974210742117421274213742147421574216742177421874219742207422174222742237422474225742267422774228742297423074231742327423374234742357423674237742387423974240742417424274243742447424574246742477424874249742507425174252742537425474255742567425774258742597426074261742627426374264742657426674267742687426974270742717427274273742747427574276742777427874279742807428174282742837428474285742867428774288742897429074291742927429374294742957429674297742987429974300743017430274303743047430574306743077430874309743107431174312743137431474315743167431774318743197432074321743227432374324743257432674327743287432974330743317433274333743347433574336743377433874339743407434174342743437434474345743467434774348743497435074351743527435374354743557435674357743587435974360743617436274363743647436574366743677436874369743707437174372743737437474375743767437774378743797438074381743827438374384743857438674387743887438974390743917439274393743947439574396743977439874399744007440174402744037440474405744067440774408744097441074411744127441374414744157441674417744187441974420744217442274423744247442574426744277442874429744307443174432744337443474435744367443774438744397444074441744427444374444744457444674447744487444974450744517445274453744547445574456744577445874459744607446174462744637446474465744667446774468744697447074471744727447374474744757447674477744787447974480744817448274483744847448574486744877448874489744907449174492744937449474495744967449774498744997450074501745027450374504745057450674507745087450974510745117451274513745147451574516745177451874519745207452174522745237452474525745267452774528745297453074531745327453374534745357453674537745387453974540745417454274543745447454574546745477454874549745507455174552745537455474555745567455774558745597456074561745627456374564745657456674567745687456974570745717457274573745747457574576745777457874579745807458174582745837458474585745867458774588745897459074591745927459374594745957459674597745987459974600746017460274603746047460574606746077460874609746107461174612746137461474615746167461774618746197462074621746227462374624746257462674627746287462974630746317463274633746347463574636746377463874639746407464174642746437464474645746467464774648746497465074651746527465374654746557465674657746587465974660746617466274663746647466574666746677466874669746707467174672746737467474675746767467774678746797468074681746827468374684746857468674687746887468974690746917469274693746947469574696746977469874699747007470174702747037470474705747067470774708747097471074711747127471374714747157471674717747187471974720747217472274723747247472574726747277472874729747307473174732747337473474735747367473774738747397474074741747427474374744747457474674747747487474974750747517475274753747547475574756747577475874759747607476174762747637476474765747667476774768747697477074771747727477374774747757477674777747787477974780747817478274783747847478574786747877478874789747907479174792747937479474795747967479774798747997480074801748027480374804748057480674807748087480974810748117481274813748147481574816748177481874819748207482174822748237482474825748267482774828748297483074831748327483374834748357483674837748387483974840748417484274843748447484574846748477484874849748507485174852748537485474855748567485774858748597486074861748627486374864748657486674867748687486974870748717487274873748747487574876748777487874879748807488174882748837488474885748867488774888748897489074891748927489374894748957489674897748987489974900749017490274903749047490574906749077490874909749107491174912749137491474915749167491774918749197492074921749227492374924749257492674927749287492974930749317493274933749347493574936749377493874939749407494174942749437494474945749467494774948749497495074951749527495374954749557495674957749587495974960749617496274963749647496574966749677496874969749707497174972749737497474975749767497774978749797498074981749827498374984749857498674987749887498974990749917499274993749947499574996749977499874999750007500175002750037500475005750067500775008750097501075011750127501375014750157501675017750187501975020750217502275023750247502575026750277502875029750307503175032750337503475035750367503775038750397504075041750427504375044750457504675047750487504975050750517505275053750547505575056750577505875059750607506175062750637506475065750667506775068750697507075071750727507375074750757507675077750787507975080750817508275083750847508575086750877508875089750907509175092750937509475095750967509775098750997510075101751027510375104751057510675107751087510975110751117511275113751147511575116751177511875119751207512175122751237512475125751267512775128751297513075131751327513375134751357513675137751387513975140751417514275143751447514575146751477514875149751507515175152751537515475155751567515775158751597516075161751627516375164751657516675167751687516975170751717517275173751747517575176751777517875179751807518175182751837518475185751867518775188751897519075191751927519375194751957519675197751987519975200752017520275203752047520575206752077520875209752107521175212752137521475215752167521775218752197522075221752227522375224752257522675227752287522975230752317523275233752347523575236752377523875239752407524175242752437524475245752467524775248752497525075251752527525375254752557525675257752587525975260752617526275263752647526575266752677526875269752707527175272752737527475275752767527775278752797528075281752827528375284752857528675287752887528975290752917529275293752947529575296752977529875299753007530175302753037530475305753067530775308753097531075311753127531375314753157531675317753187531975320753217532275323753247532575326753277532875329753307533175332753337533475335753367533775338753397534075341753427534375344753457534675347753487534975350753517535275353753547535575356753577535875359753607536175362753637536475365753667536775368753697537075371753727537375374753757537675377753787537975380753817538275383753847538575386753877538875389753907539175392753937539475395753967539775398753997540075401754027540375404754057540675407754087540975410754117541275413754147541575416754177541875419754207542175422754237542475425754267542775428754297543075431754327543375434754357543675437754387543975440754417544275443754447544575446754477544875449754507545175452754537545475455754567545775458754597546075461754627546375464754657546675467754687546975470754717547275473754747547575476754777547875479754807548175482754837548475485754867548775488754897549075491754927549375494754957549675497754987549975500755017550275503755047550575506755077550875509755107551175512755137551475515755167551775518755197552075521755227552375524755257552675527755287552975530755317553275533755347553575536755377553875539755407554175542755437554475545755467554775548755497555075551755527555375554755557555675557755587555975560755617556275563755647556575566755677556875569755707557175572755737557475575755767557775578755797558075581755827558375584755857558675587755887558975590755917559275593755947559575596755977559875599756007560175602756037560475605756067560775608756097561075611756127561375614756157561675617756187561975620756217562275623756247562575626756277562875629756307563175632756337563475635756367563775638756397564075641756427564375644756457564675647756487564975650756517565275653756547565575656756577565875659756607566175662756637566475665756667566775668756697567075671756727567375674756757567675677756787567975680756817568275683756847568575686756877568875689756907569175692756937569475695756967569775698756997570075701757027570375704757057570675707757087570975710757117571275713757147571575716757177571875719757207572175722757237572475725757267572775728757297573075731757327573375734757357573675737757387573975740757417574275743757447574575746757477574875749757507575175752757537575475755757567575775758757597576075761757627576375764757657576675767757687576975770757717577275773757747577575776757777577875779757807578175782757837578475785757867578775788757897579075791757927579375794757957579675797757987579975800758017580275803758047580575806758077580875809758107581175812758137581475815758167581775818758197582075821758227582375824758257582675827758287582975830758317583275833758347583575836758377583875839758407584175842758437584475845758467584775848758497585075851758527585375854758557585675857758587585975860758617586275863758647586575866758677586875869758707587175872758737587475875758767587775878758797588075881758827588375884758857588675887758887588975890758917589275893758947589575896758977589875899759007590175902759037590475905759067590775908759097591075911759127591375914759157591675917759187591975920759217592275923759247592575926759277592875929759307593175932759337593475935759367593775938759397594075941759427594375944759457594675947759487594975950759517595275953759547595575956759577595875959759607596175962759637596475965759667596775968759697597075971759727597375974759757597675977759787597975980759817598275983759847598575986759877598875989759907599175992759937599475995759967599775998759997600076001760027600376004760057600676007760087600976010760117601276013760147601576016760177601876019760207602176022760237602476025760267602776028760297603076031760327603376034760357603676037760387603976040760417604276043760447604576046760477604876049760507605176052760537605476055760567605776058760597606076061760627606376064760657606676067760687606976070760717607276073760747607576076760777607876079760807608176082760837608476085760867608776088760897609076091760927609376094760957609676097760987609976100761017610276103761047610576106761077610876109761107611176112761137611476115761167611776118761197612076121761227612376124761257612676127761287612976130761317613276133761347613576136761377613876139761407614176142761437614476145761467614776148761497615076151761527615376154761557615676157761587615976160761617616276163761647616576166761677616876169761707617176172761737617476175761767617776178761797618076181761827618376184761857618676187761887618976190761917619276193761947619576196761977619876199762007620176202762037620476205762067620776208762097621076211762127621376214762157621676217762187621976220762217622276223762247622576226762277622876229762307623176232762337623476235762367623776238762397624076241762427624376244762457624676247762487624976250762517625276253762547625576256762577625876259762607626176262762637626476265762667626776268762697627076271762727627376274762757627676277762787627976280762817628276283762847628576286762877628876289762907629176292762937629476295762967629776298762997630076301763027630376304763057630676307763087630976310763117631276313763147631576316763177631876319763207632176322763237632476325763267632776328763297633076331763327633376334763357633676337763387633976340763417634276343763447634576346763477634876349763507635176352763537635476355763567635776358763597636076361763627636376364763657636676367763687636976370763717637276373763747637576376763777637876379763807638176382763837638476385763867638776388763897639076391763927639376394763957639676397763987639976400764017640276403764047640576406764077640876409764107641176412764137641476415764167641776418764197642076421764227642376424764257642676427764287642976430764317643276433764347643576436764377643876439764407644176442764437644476445764467644776448764497645076451764527645376454764557645676457764587645976460764617646276463764647646576466764677646876469764707647176472764737647476475764767647776478764797648076481764827648376484764857648676487764887648976490764917649276493764947649576496764977649876499765007650176502765037650476505765067650776508765097651076511765127651376514765157651676517765187651976520765217652276523765247652576526765277652876529765307653176532765337653476535765367653776538765397654076541765427654376544765457654676547765487654976550765517655276553765547655576556765577655876559765607656176562765637656476565765667656776568765697657076571765727657376574765757657676577765787657976580765817658276583765847658576586765877658876589765907659176592765937659476595765967659776598765997660076601766027660376604766057660676607766087660976610766117661276613766147661576616766177661876619766207662176622766237662476625766267662776628766297663076631766327663376634766357663676637766387663976640766417664276643766447664576646766477664876649766507665176652766537665476655766567665776658766597666076661766627666376664766657666676667766687666976670766717667276673766747667576676766777667876679766807668176682766837668476685766867668776688766897669076691766927669376694766957669676697766987669976700767017670276703767047670576706767077670876709767107671176712767137671476715767167671776718767197672076721767227672376724767257672676727767287672976730767317673276733767347673576736767377673876739767407674176742767437674476745767467674776748767497675076751767527675376754767557675676757767587675976760767617676276763767647676576766767677676876769767707677176772767737677476775767767677776778767797678076781767827678376784767857678676787767887678976790767917679276793767947679576796767977679876799768007680176802768037680476805768067680776808768097681076811768127681376814768157681676817768187681976820768217682276823768247682576826768277682876829768307683176832768337683476835768367683776838768397684076841768427684376844768457684676847768487684976850768517685276853768547685576856768577685876859768607686176862768637686476865768667686776868768697687076871768727687376874768757687676877768787687976880768817688276883768847688576886768877688876889768907689176892768937689476895768967689776898768997690076901769027690376904769057690676907769087690976910769117691276913769147691576916769177691876919769207692176922769237692476925769267692776928769297693076931769327693376934769357693676937769387693976940769417694276943769447694576946769477694876949769507695176952769537695476955769567695776958769597696076961769627696376964769657696676967769687696976970769717697276973769747697576976769777697876979769807698176982769837698476985769867698776988769897699076991769927699376994769957699676997769987699977000770017700277003770047700577006770077700877009770107701177012770137701477015770167701777018770197702077021770227702377024770257702677027770287702977030770317703277033770347703577036770377703877039770407704177042770437704477045770467704777048770497705077051770527705377054770557705677057770587705977060770617706277063770647706577066770677706877069770707707177072770737707477075770767707777078770797708077081770827708377084770857708677087770887708977090770917709277093770947709577096770977709877099771007710177102771037710477105771067710777108771097711077111771127711377114771157711677117771187711977120771217712277123771247712577126771277712877129771307713177132771337713477135771367713777138771397714077141771427714377144771457714677147771487714977150771517715277153771547715577156771577715877159771607716177162771637716477165771667716777168771697717077171771727717377174771757717677177771787717977180771817718277183771847718577186771877718877189771907719177192771937719477195771967719777198771997720077201772027720377204772057720677207772087720977210772117721277213772147721577216772177721877219772207722177222772237722477225772267722777228772297723077231772327723377234772357723677237772387723977240772417724277243772447724577246772477724877249772507725177252772537725477255772567725777258772597726077261772627726377264772657726677267772687726977270772717727277273772747727577276772777727877279772807728177282772837728477285772867728777288772897729077291772927729377294772957729677297772987729977300773017730277303773047730577306773077730877309773107731177312773137731477315773167731777318773197732077321773227732377324773257732677327773287732977330773317733277333773347733577336773377733877339773407734177342773437734477345773467734777348773497735077351773527735377354773557735677357773587735977360773617736277363773647736577366773677736877369773707737177372773737737477375773767737777378773797738077381773827738377384773857738677387773887738977390773917739277393773947739577396773977739877399774007740177402774037740477405774067740777408774097741077411774127741377414774157741677417774187741977420774217742277423774247742577426774277742877429774307743177432774337743477435774367743777438774397744077441774427744377444774457744677447774487744977450774517745277453774547745577456774577745877459774607746177462774637746477465774667746777468774697747077471774727747377474774757747677477774787747977480774817748277483774847748577486774877748877489774907749177492774937749477495774967749777498774997750077501775027750377504775057750677507775087750977510775117751277513775147751577516775177751877519775207752177522775237752477525775267752777528775297753077531775327753377534775357753677537775387753977540775417754277543775447754577546775477754877549775507755177552775537755477555775567755777558775597756077561775627756377564775657756677567775687756977570775717757277573775747757577576775777757877579775807758177582775837758477585775867758777588775897759077591775927759377594775957759677597775987759977600776017760277603776047760577606776077760877609776107761177612776137761477615776167761777618776197762077621776227762377624776257762677627776287762977630776317763277633776347763577636776377763877639776407764177642776437764477645776467764777648776497765077651776527765377654776557765677657776587765977660776617766277663776647766577666776677766877669776707767177672776737767477675776767767777678776797768077681776827768377684776857768677687776887768977690776917769277693776947769577696776977769877699777007770177702777037770477705777067770777708777097771077711777127771377714777157771677717777187771977720777217772277723777247772577726777277772877729777307773177732777337773477735777367773777738777397774077741777427774377744777457774677747777487774977750777517775277753777547775577756777577775877759777607776177762777637776477765777667776777768777697777077771777727777377774777757777677777777787777977780777817778277783777847778577786777877778877789777907779177792777937779477795777967779777798777997780077801778027780377804778057780677807778087780977810778117781277813778147781577816778177781877819778207782177822778237782477825778267782777828778297783077831778327783377834778357783677837778387783977840778417784277843778447784577846778477784877849778507785177852778537785477855778567785777858778597786077861778627786377864778657786677867778687786977870778717787277873778747787577876778777787877879778807788177882778837788477885778867788777888778897789077891778927789377894778957789677897778987789977900779017790277903779047790577906779077790877909779107791177912779137791477915779167791777918779197792077921779227792377924779257792677927779287792977930779317793277933779347793577936779377793877939779407794177942779437794477945779467794777948779497795077951779527795377954779557795677957779587795977960779617796277963779647796577966779677796877969779707797177972779737797477975779767797777978779797798077981779827798377984779857798677987779887798977990779917799277993779947799577996779977799877999780007800178002780037800478005780067800778008780097801078011780127801378014780157801678017780187801978020780217802278023780247802578026780277802878029780307803178032780337803478035780367803778038780397804078041780427804378044780457804678047780487804978050780517805278053780547805578056780577805878059780607806178062780637806478065780667806778068780697807078071780727807378074780757807678077780787807978080780817808278083780847808578086780877808878089780907809178092780937809478095780967809778098780997810078101781027810378104781057810678107781087810978110781117811278113781147811578116781177811878119781207812178122781237812478125781267812778128781297813078131781327813378134781357813678137781387813978140781417814278143781447814578146781477814878149781507815178152781537815478155781567815778158781597816078161781627816378164781657816678167781687816978170781717817278173781747817578176781777817878179781807818178182781837818478185781867818778188781897819078191781927819378194781957819678197781987819978200782017820278203782047820578206782077820878209782107821178212782137821478215782167821778218782197822078221782227822378224782257822678227782287822978230782317823278233782347823578236782377823878239782407824178242782437824478245782467824778248782497825078251782527825378254782557825678257782587825978260782617826278263782647826578266782677826878269782707827178272782737827478275782767827778278782797828078281782827828378284782857828678287782887828978290782917829278293782947829578296782977829878299783007830178302783037830478305783067830778308783097831078311783127831378314783157831678317783187831978320783217832278323783247832578326783277832878329783307833178332783337833478335783367833778338783397834078341783427834378344783457834678347783487834978350783517835278353783547835578356783577835878359783607836178362783637836478365783667836778368783697837078371783727837378374783757837678377783787837978380783817838278383783847838578386783877838878389783907839178392783937839478395783967839778398783997840078401784027840378404784057840678407784087840978410784117841278413784147841578416784177841878419784207842178422784237842478425784267842778428784297843078431784327843378434784357843678437784387843978440784417844278443784447844578446784477844878449784507845178452784537845478455784567845778458784597846078461784627846378464784657846678467784687846978470784717847278473784747847578476784777847878479784807848178482784837848478485784867848778488784897849078491784927849378494784957849678497784987849978500785017850278503785047850578506785077850878509785107851178512785137851478515785167851778518785197852078521785227852378524785257852678527785287852978530785317853278533785347853578536785377853878539785407854178542785437854478545785467854778548785497855078551785527855378554785557855678557785587855978560785617856278563785647856578566785677856878569785707857178572785737857478575785767857778578785797858078581785827858378584785857858678587785887858978590785917859278593785947859578596785977859878599786007860178602786037860478605786067860778608786097861078611786127861378614786157861678617786187861978620786217862278623786247862578626786277862878629786307863178632786337863478635786367863778638786397864078641786427864378644786457864678647786487864978650786517865278653786547865578656786577865878659786607866178662786637866478665786667866778668786697867078671786727867378674786757867678677786787867978680786817868278683786847868578686786877868878689786907869178692786937869478695786967869778698786997870078701787027870378704787057870678707787087870978710787117871278713787147871578716787177871878719787207872178722787237872478725787267872778728787297873078731787327873378734787357873678737787387873978740787417874278743787447874578746787477874878749787507875178752787537875478755787567875778758787597876078761787627876378764787657876678767787687876978770787717877278773787747877578776787777877878779787807878178782787837878478785787867878778788787897879078791787927879378794787957879678797787987879978800788017880278803788047880578806788077880878809788107881178812788137881478815788167881778818788197882078821788227882378824788257882678827788287882978830788317883278833788347883578836788377883878839788407884178842788437884478845788467884778848788497885078851788527885378854788557885678857788587885978860788617886278863788647886578866788677886878869788707887178872788737887478875788767887778878788797888078881788827888378884788857888678887788887888978890788917889278893788947889578896788977889878899789007890178902789037890478905789067890778908789097891078911789127891378914789157891678917789187891978920789217892278923789247892578926789277892878929789307893178932789337893478935789367893778938789397894078941789427894378944789457894678947789487894978950789517895278953789547895578956789577895878959789607896178962789637896478965789667896778968789697897078971789727897378974789757897678977789787897978980789817898278983789847898578986789877898878989789907899178992789937899478995789967899778998789997900079001790027900379004790057900679007790087900979010790117901279013790147901579016790177901879019790207902179022790237902479025790267902779028790297903079031790327903379034790357903679037790387903979040790417904279043790447904579046790477904879049790507905179052790537905479055790567905779058790597906079061790627906379064790657906679067790687906979070790717907279073790747907579076790777907879079790807908179082790837908479085790867908779088790897909079091790927909379094790957909679097790987909979100791017910279103791047910579106791077910879109791107911179112791137911479115791167911779118791197912079121791227912379124791257912679127791287912979130791317913279133791347913579136791377913879139791407914179142791437914479145791467914779148791497915079151791527915379154791557915679157791587915979160791617916279163791647916579166791677916879169791707917179172791737917479175791767917779178791797918079181791827918379184791857918679187791887918979190791917919279193791947919579196791977919879199792007920179202792037920479205792067920779208792097921079211792127921379214792157921679217792187921979220792217922279223792247922579226792277922879229792307923179232792337923479235792367923779238792397924079241792427924379244792457924679247792487924979250792517925279253792547925579256792577925879259792607926179262792637926479265792667926779268792697927079271792727927379274792757927679277792787927979280792817928279283792847928579286792877928879289792907929179292792937929479295792967929779298792997930079301793027930379304793057930679307793087930979310793117931279313793147931579316793177931879319793207932179322793237932479325793267932779328793297933079331793327933379334793357933679337793387933979340793417934279343793447934579346793477934879349793507935179352793537935479355793567935779358793597936079361793627936379364793657936679367793687936979370793717937279373793747937579376793777937879379793807938179382793837938479385793867938779388793897939079391793927939379394793957939679397793987939979400794017940279403794047940579406794077940879409794107941179412794137941479415794167941779418794197942079421794227942379424794257942679427794287942979430794317943279433794347943579436794377943879439794407944179442794437944479445794467944779448794497945079451794527945379454794557945679457794587945979460794617946279463794647946579466794677946879469794707947179472794737947479475794767947779478794797948079481794827948379484794857948679487794887948979490794917949279493794947949579496794977949879499795007950179502795037950479505795067950779508795097951079511795127951379514795157951679517795187951979520795217952279523795247952579526795277952879529795307953179532795337953479535795367953779538795397954079541795427954379544795457954679547795487954979550795517955279553795547955579556795577955879559795607956179562795637956479565795667956779568795697957079571795727957379574795757957679577795787957979580795817958279583795847958579586795877958879589795907959179592795937959479595795967959779598795997960079601796027960379604796057960679607796087960979610796117961279613796147961579616796177961879619796207962179622796237962479625796267962779628796297963079631796327963379634796357963679637796387963979640796417964279643796447964579646796477964879649796507965179652796537965479655796567965779658796597966079661796627966379664796657966679667796687966979670796717967279673796747967579676796777967879679796807968179682796837968479685796867968779688796897969079691796927969379694796957969679697796987969979700797017970279703797047970579706797077970879709797107971179712797137971479715797167971779718797197972079721797227972379724797257972679727797287972979730797317973279733797347973579736797377973879739797407974179742797437974479745797467974779748797497975079751797527975379754797557975679757797587975979760797617976279763797647976579766797677976879769797707977179772797737977479775797767977779778797797978079781797827978379784797857978679787797887978979790797917979279793797947979579796797977979879799798007980179802798037980479805798067980779808798097981079811798127981379814798157981679817798187981979820798217982279823798247982579826798277982879829798307983179832798337983479835798367983779838798397984079841798427984379844798457984679847798487984979850798517985279853798547985579856798577985879859798607986179862798637986479865798667986779868798697987079871798727987379874798757987679877798787987979880798817988279883798847988579886798877988879889798907989179892798937989479895798967989779898798997990079901799027990379904799057990679907799087990979910799117991279913799147991579916799177991879919799207992179922799237992479925799267992779928799297993079931799327993379934799357993679937799387993979940799417994279943799447994579946799477994879949799507995179952799537995479955799567995779958799597996079961799627996379964799657996679967799687996979970799717997279973799747997579976799777997879979799807998179982799837998479985799867998779988799897999079991799927999379994799957999679997799987999980000800018000280003800048000580006800078000880009800108001180012800138001480015800168001780018800198002080021800228002380024800258002680027800288002980030800318003280033800348003580036800378003880039800408004180042800438004480045800468004780048800498005080051800528005380054800558005680057800588005980060800618006280063800648006580066800678006880069
  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. /** Defines the cross module used constants to avoid circular dependncies */
  583. export class Constants {
  584. /** Defines that alpha blending is disabled */
  585. static readonly ALPHA_DISABLE: number;
  586. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  587. static readonly ALPHA_ADD: number;
  588. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  589. static readonly ALPHA_COMBINE: number;
  590. /** Defines that alpha blending is DEST - SRC * DEST */
  591. static readonly ALPHA_SUBTRACT: number;
  592. /** Defines that alpha blending is SRC * DEST */
  593. static readonly ALPHA_MULTIPLY: number;
  594. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  595. static readonly ALPHA_MAXIMIZED: number;
  596. /** Defines that alpha blending is SRC + DEST */
  597. static readonly ALPHA_ONEONE: number;
  598. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  599. static readonly ALPHA_PREMULTIPLIED: number;
  600. /**
  601. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  602. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  603. */
  604. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  605. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  606. static readonly ALPHA_INTERPOLATE: number;
  607. /**
  608. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  609. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  610. */
  611. static readonly ALPHA_SCREENMODE: number;
  612. /**
  613. * Defines that alpha blending is SRC + DST
  614. * Alpha will be set to SRC ALPHA + DST ALPHA
  615. */
  616. static readonly ALPHA_ONEONE_ONEONE: number;
  617. /**
  618. * Defines that alpha blending is SRC * DST ALPHA + DST
  619. * Alpha will be set to 0
  620. */
  621. static readonly ALPHA_ALPHATOCOLOR: number;
  622. /**
  623. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  624. */
  625. static readonly ALPHA_REVERSEONEMINUS: number;
  626. /**
  627. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  628. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  629. */
  630. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  631. /**
  632. * Defines that alpha blending is SRC + DST
  633. * Alpha will be set to SRC ALPHA
  634. */
  635. static readonly ALPHA_ONEONE_ONEZERO: number;
  636. /**
  637. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  638. * Alpha will be set to DST ALPHA
  639. */
  640. static readonly ALPHA_EXCLUSION: number;
  641. /** Defines that alpha blending equation a SUM */
  642. static readonly ALPHA_EQUATION_ADD: number;
  643. /** Defines that alpha blending equation a SUBSTRACTION */
  644. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  645. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  646. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  647. /** Defines that alpha blending equation a MAX operation */
  648. static readonly ALPHA_EQUATION_MAX: number;
  649. /** Defines that alpha blending equation a MIN operation */
  650. static readonly ALPHA_EQUATION_MIN: number;
  651. /**
  652. * Defines that alpha blending equation a DARKEN operation:
  653. * It takes the min of the src and sums the alpha channels.
  654. */
  655. static readonly ALPHA_EQUATION_DARKEN: number;
  656. /** Defines that the ressource is not delayed*/
  657. static readonly DELAYLOADSTATE_NONE: number;
  658. /** Defines that the ressource was successfully delay loaded */
  659. static readonly DELAYLOADSTATE_LOADED: number;
  660. /** Defines that the ressource is currently delay loading */
  661. static readonly DELAYLOADSTATE_LOADING: number;
  662. /** Defines that the ressource is delayed and has not started loading */
  663. static readonly DELAYLOADSTATE_NOTLOADED: number;
  664. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  665. static readonly NEVER: number;
  666. /** 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 */
  667. static readonly ALWAYS: number;
  668. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  669. static readonly LESS: number;
  670. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  671. static readonly EQUAL: number;
  672. /** 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 */
  673. static readonly LEQUAL: number;
  674. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  675. static readonly GREATER: number;
  676. /** 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 */
  677. static readonly GEQUAL: number;
  678. /** 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 */
  679. static readonly NOTEQUAL: number;
  680. /** Passed to stencilOperation to specify that stencil value must be kept */
  681. static readonly KEEP: number;
  682. /** Passed to stencilOperation to specify that stencil value must be replaced */
  683. static readonly REPLACE: number;
  684. /** Passed to stencilOperation to specify that stencil value must be incremented */
  685. static readonly INCR: number;
  686. /** Passed to stencilOperation to specify that stencil value must be decremented */
  687. static readonly DECR: number;
  688. /** Passed to stencilOperation to specify that stencil value must be inverted */
  689. static readonly INVERT: number;
  690. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  691. static readonly INCR_WRAP: number;
  692. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  693. static readonly DECR_WRAP: number;
  694. /** Texture is not repeating outside of 0..1 UVs */
  695. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  696. /** Texture is repeating outside of 0..1 UVs */
  697. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  698. /** Texture is repeating and mirrored */
  699. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  700. /** ALPHA */
  701. static readonly TEXTUREFORMAT_ALPHA: number;
  702. /** LUMINANCE */
  703. static readonly TEXTUREFORMAT_LUMINANCE: number;
  704. /** LUMINANCE_ALPHA */
  705. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  706. /** RGB */
  707. static readonly TEXTUREFORMAT_RGB: number;
  708. /** RGBA */
  709. static readonly TEXTUREFORMAT_RGBA: number;
  710. /** RED */
  711. static readonly TEXTUREFORMAT_RED: number;
  712. /** RED (2nd reference) */
  713. static readonly TEXTUREFORMAT_R: number;
  714. /** RG */
  715. static readonly TEXTUREFORMAT_RG: number;
  716. /** RED_INTEGER */
  717. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  718. /** RED_INTEGER (2nd reference) */
  719. static readonly TEXTUREFORMAT_R_INTEGER: number;
  720. /** RG_INTEGER */
  721. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  722. /** RGB_INTEGER */
  723. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  724. /** RGBA_INTEGER */
  725. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  726. /** UNSIGNED_BYTE */
  727. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  728. /** UNSIGNED_BYTE (2nd reference) */
  729. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  730. /** FLOAT */
  731. static readonly TEXTURETYPE_FLOAT: number;
  732. /** HALF_FLOAT */
  733. static readonly TEXTURETYPE_HALF_FLOAT: number;
  734. /** BYTE */
  735. static readonly TEXTURETYPE_BYTE: number;
  736. /** SHORT */
  737. static readonly TEXTURETYPE_SHORT: number;
  738. /** UNSIGNED_SHORT */
  739. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  740. /** INT */
  741. static readonly TEXTURETYPE_INT: number;
  742. /** UNSIGNED_INT */
  743. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  744. /** UNSIGNED_SHORT_4_4_4_4 */
  745. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  746. /** UNSIGNED_SHORT_5_5_5_1 */
  747. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  748. /** UNSIGNED_SHORT_5_6_5 */
  749. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  750. /** UNSIGNED_INT_2_10_10_10_REV */
  751. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  752. /** UNSIGNED_INT_24_8 */
  753. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  754. /** UNSIGNED_INT_10F_11F_11F_REV */
  755. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  756. /** UNSIGNED_INT_5_9_9_9_REV */
  757. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  758. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  759. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  760. /** nearest is mag = nearest and min = nearest and no mip */
  761. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  762. /** mag = nearest and min = nearest and mip = none */
  763. static readonly TEXTURE_NEAREST_NEAREST: number;
  764. /** Bilinear is mag = linear and min = linear and no mip */
  765. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  766. /** mag = linear and min = linear and mip = none */
  767. static readonly TEXTURE_LINEAR_LINEAR: number;
  768. /** Trilinear is mag = linear and min = linear and mip = linear */
  769. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  770. /** Trilinear is mag = linear and min = linear and mip = linear */
  771. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  772. /** mag = nearest and min = nearest and mip = nearest */
  773. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  774. /** mag = nearest and min = linear and mip = nearest */
  775. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  776. /** mag = nearest and min = linear and mip = linear */
  777. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  778. /** mag = nearest and min = linear and mip = none */
  779. static readonly TEXTURE_NEAREST_LINEAR: number;
  780. /** nearest is mag = nearest and min = nearest and mip = linear */
  781. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  782. /** mag = linear and min = nearest and mip = nearest */
  783. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  784. /** mag = linear and min = nearest and mip = linear */
  785. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  786. /** Bilinear is mag = linear and min = linear and mip = nearest */
  787. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  788. /** mag = linear and min = nearest and mip = none */
  789. static readonly TEXTURE_LINEAR_NEAREST: number;
  790. /** Explicit coordinates mode */
  791. static readonly TEXTURE_EXPLICIT_MODE: number;
  792. /** Spherical coordinates mode */
  793. static readonly TEXTURE_SPHERICAL_MODE: number;
  794. /** Planar coordinates mode */
  795. static readonly TEXTURE_PLANAR_MODE: number;
  796. /** Cubic coordinates mode */
  797. static readonly TEXTURE_CUBIC_MODE: number;
  798. /** Projection coordinates mode */
  799. static readonly TEXTURE_PROJECTION_MODE: number;
  800. /** Skybox coordinates mode */
  801. static readonly TEXTURE_SKYBOX_MODE: number;
  802. /** Inverse Cubic coordinates mode */
  803. static readonly TEXTURE_INVCUBIC_MODE: number;
  804. /** Equirectangular coordinates mode */
  805. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  806. /** Equirectangular Fixed coordinates mode */
  807. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  808. /** Equirectangular Fixed Mirrored coordinates mode */
  809. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  810. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  811. static readonly SCALEMODE_FLOOR: number;
  812. /** Defines that texture rescaling will look for the nearest power of 2 size */
  813. static readonly SCALEMODE_NEAREST: number;
  814. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  815. static readonly SCALEMODE_CEILING: number;
  816. /**
  817. * The dirty texture flag value
  818. */
  819. static readonly MATERIAL_TextureDirtyFlag: number;
  820. /**
  821. * The dirty light flag value
  822. */
  823. static readonly MATERIAL_LightDirtyFlag: number;
  824. /**
  825. * The dirty fresnel flag value
  826. */
  827. static readonly MATERIAL_FresnelDirtyFlag: number;
  828. /**
  829. * The dirty attribute flag value
  830. */
  831. static readonly MATERIAL_AttributesDirtyFlag: number;
  832. /**
  833. * The dirty misc flag value
  834. */
  835. static readonly MATERIAL_MiscDirtyFlag: number;
  836. /**
  837. * The all dirty flag value
  838. */
  839. static readonly MATERIAL_AllDirtyFlag: number;
  840. /**
  841. * Returns the triangle fill mode
  842. */
  843. static readonly MATERIAL_TriangleFillMode: number;
  844. /**
  845. * Returns the wireframe mode
  846. */
  847. static readonly MATERIAL_WireFrameFillMode: number;
  848. /**
  849. * Returns the point fill mode
  850. */
  851. static readonly MATERIAL_PointFillMode: number;
  852. /**
  853. * Returns the point list draw mode
  854. */
  855. static readonly MATERIAL_PointListDrawMode: number;
  856. /**
  857. * Returns the line list draw mode
  858. */
  859. static readonly MATERIAL_LineListDrawMode: number;
  860. /**
  861. * Returns the line loop draw mode
  862. */
  863. static readonly MATERIAL_LineLoopDrawMode: number;
  864. /**
  865. * Returns the line strip draw mode
  866. */
  867. static readonly MATERIAL_LineStripDrawMode: number;
  868. /**
  869. * Returns the triangle strip draw mode
  870. */
  871. static readonly MATERIAL_TriangleStripDrawMode: number;
  872. /**
  873. * Returns the triangle fan draw mode
  874. */
  875. static readonly MATERIAL_TriangleFanDrawMode: number;
  876. /**
  877. * Stores the clock-wise side orientation
  878. */
  879. static readonly MATERIAL_ClockWiseSideOrientation: number;
  880. /**
  881. * Stores the counter clock-wise side orientation
  882. */
  883. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  884. /**
  885. * Nothing
  886. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  887. */
  888. static readonly ACTION_NothingTrigger: number;
  889. /**
  890. * On pick
  891. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  892. */
  893. static readonly ACTION_OnPickTrigger: number;
  894. /**
  895. * On left pick
  896. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  897. */
  898. static readonly ACTION_OnLeftPickTrigger: number;
  899. /**
  900. * On right pick
  901. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  902. */
  903. static readonly ACTION_OnRightPickTrigger: number;
  904. /**
  905. * On center pick
  906. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  907. */
  908. static readonly ACTION_OnCenterPickTrigger: number;
  909. /**
  910. * On pick down
  911. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  912. */
  913. static readonly ACTION_OnPickDownTrigger: number;
  914. /**
  915. * On double pick
  916. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  917. */
  918. static readonly ACTION_OnDoublePickTrigger: number;
  919. /**
  920. * On pick up
  921. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  922. */
  923. static readonly ACTION_OnPickUpTrigger: number;
  924. /**
  925. * On pick out.
  926. * This trigger will only be raised if you also declared a OnPickDown
  927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  928. */
  929. static readonly ACTION_OnPickOutTrigger: number;
  930. /**
  931. * On long press
  932. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  933. */
  934. static readonly ACTION_OnLongPressTrigger: number;
  935. /**
  936. * On pointer over
  937. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  938. */
  939. static readonly ACTION_OnPointerOverTrigger: number;
  940. /**
  941. * On pointer out
  942. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  943. */
  944. static readonly ACTION_OnPointerOutTrigger: number;
  945. /**
  946. * On every frame
  947. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  948. */
  949. static readonly ACTION_OnEveryFrameTrigger: number;
  950. /**
  951. * On intersection enter
  952. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  953. */
  954. static readonly ACTION_OnIntersectionEnterTrigger: number;
  955. /**
  956. * On intersection exit
  957. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  958. */
  959. static readonly ACTION_OnIntersectionExitTrigger: number;
  960. /**
  961. * On key down
  962. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  963. */
  964. static readonly ACTION_OnKeyDownTrigger: number;
  965. /**
  966. * On key up
  967. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  968. */
  969. static readonly ACTION_OnKeyUpTrigger: number;
  970. /**
  971. * Billboard mode will only apply to Y axis
  972. */
  973. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  974. /**
  975. * Billboard mode will apply to all axes
  976. */
  977. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  978. /**
  979. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  980. */
  981. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  982. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  983. * Test order :
  984. * Is the bounding sphere outside the frustum ?
  985. * If not, are the bounding box vertices outside the frustum ?
  986. * It not, then the cullable object is in the frustum.
  987. */
  988. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  989. /** Culling strategy : Bounding Sphere Only.
  990. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  991. * It's also less accurate than the standard because some not visible objects can still be selected.
  992. * Test : is the bounding sphere outside the frustum ?
  993. * If not, then the cullable object is in the frustum.
  994. */
  995. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  996. /** Culling strategy : Optimistic Inclusion.
  997. * This in an inclusion test first, then the standard exclusion test.
  998. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  999. * 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.
  1000. * Anyway, it's as accurate as the standard strategy.
  1001. * Test :
  1002. * Is the cullable object bounding sphere center in the frustum ?
  1003. * If not, apply the default culling strategy.
  1004. */
  1005. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1006. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1007. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1008. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1009. * 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.
  1010. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1011. * Test :
  1012. * Is the cullable object bounding sphere center in the frustum ?
  1013. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1014. */
  1015. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1016. /**
  1017. * No logging while loading
  1018. */
  1019. static readonly SCENELOADER_NO_LOGGING: number;
  1020. /**
  1021. * Minimal logging while loading
  1022. */
  1023. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1024. /**
  1025. * Summary logging while loading
  1026. */
  1027. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1028. /**
  1029. * Detailled logging while loading
  1030. */
  1031. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1032. }
  1033. }
  1034. declare module BABYLON {
  1035. /**
  1036. * This represents the required contract to create a new type of texture loader.
  1037. */
  1038. export interface IInternalTextureLoader {
  1039. /**
  1040. * Defines wether the loader supports cascade loading the different faces.
  1041. */
  1042. supportCascades: boolean;
  1043. /**
  1044. * This returns if the loader support the current file information.
  1045. * @param extension defines the file extension of the file being loaded
  1046. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1047. * @param fallback defines the fallback internal texture if any
  1048. * @param isBase64 defines whether the texture is encoded as a base64
  1049. * @param isBuffer defines whether the texture data are stored as a buffer
  1050. * @returns true if the loader can load the specified file
  1051. */
  1052. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1053. /**
  1054. * Transform the url before loading if required.
  1055. * @param rootUrl the url of the texture
  1056. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1057. * @returns the transformed texture
  1058. */
  1059. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1060. /**
  1061. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1062. * @param rootUrl the url of the texture
  1063. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1064. * @returns the fallback texture
  1065. */
  1066. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1067. /**
  1068. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1069. * @param data contains the texture data
  1070. * @param texture defines the BabylonJS internal texture
  1071. * @param createPolynomials will be true if polynomials have been requested
  1072. * @param onLoad defines the callback to trigger once the texture is ready
  1073. * @param onError defines the callback to trigger in case of error
  1074. */
  1075. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1076. /**
  1077. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1078. * @param data contains the texture data
  1079. * @param texture defines the BabylonJS internal texture
  1080. * @param callback defines the method to call once ready to upload
  1081. */
  1082. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1083. }
  1084. }
  1085. declare module BABYLON {
  1086. /**
  1087. * Class used to store and describe the pipeline context associated with an effect
  1088. */
  1089. export interface IPipelineContext {
  1090. /**
  1091. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1092. */
  1093. isAsync: boolean;
  1094. /**
  1095. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1096. */
  1097. isReady: boolean;
  1098. /** @hidden */
  1099. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1100. }
  1101. }
  1102. declare module BABYLON {
  1103. /**
  1104. * Class used to store gfx data (like WebGLBuffer)
  1105. */
  1106. export class DataBuffer {
  1107. /**
  1108. * Gets or sets the number of objects referencing this buffer
  1109. */
  1110. references: number;
  1111. /** Gets or sets the size of the underlying buffer */
  1112. capacity: number;
  1113. /**
  1114. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1115. */
  1116. is32Bits: boolean;
  1117. /**
  1118. * Gets the underlying buffer
  1119. */
  1120. get underlyingResource(): any;
  1121. }
  1122. }
  1123. declare module BABYLON {
  1124. /** @hidden */
  1125. export interface IShaderProcessor {
  1126. attributeProcessor?: (attribute: string) => string;
  1127. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1128. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1129. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1130. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1131. lineProcessor?: (line: string, isFragment: boolean) => string;
  1132. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1133. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1134. }
  1135. }
  1136. declare module BABYLON {
  1137. /** @hidden */
  1138. export interface ProcessingOptions {
  1139. defines: string[];
  1140. indexParameters: any;
  1141. isFragment: boolean;
  1142. shouldUseHighPrecisionShader: boolean;
  1143. supportsUniformBuffers: boolean;
  1144. shadersRepository: string;
  1145. includesShadersStore: {
  1146. [key: string]: string;
  1147. };
  1148. processor?: IShaderProcessor;
  1149. version: string;
  1150. platformName: string;
  1151. lookForClosingBracketForUniformBuffer?: boolean;
  1152. }
  1153. }
  1154. declare module BABYLON {
  1155. /** @hidden */
  1156. export class ShaderCodeNode {
  1157. line: string;
  1158. children: ShaderCodeNode[];
  1159. additionalDefineKey?: string;
  1160. additionalDefineValue?: string;
  1161. isValid(preprocessors: {
  1162. [key: string]: string;
  1163. }): boolean;
  1164. process(preprocessors: {
  1165. [key: string]: string;
  1166. }, options: ProcessingOptions): string;
  1167. }
  1168. }
  1169. declare module BABYLON {
  1170. /** @hidden */
  1171. export class ShaderCodeCursor {
  1172. private _lines;
  1173. lineIndex: number;
  1174. get currentLine(): string;
  1175. get canRead(): boolean;
  1176. set lines(value: string[]);
  1177. }
  1178. }
  1179. declare module BABYLON {
  1180. /** @hidden */
  1181. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1182. process(preprocessors: {
  1183. [key: string]: string;
  1184. }, options: ProcessingOptions): string;
  1185. }
  1186. }
  1187. declare module BABYLON {
  1188. /** @hidden */
  1189. export class ShaderDefineExpression {
  1190. isTrue(preprocessors: {
  1191. [key: string]: string;
  1192. }): boolean;
  1193. }
  1194. }
  1195. declare module BABYLON {
  1196. /** @hidden */
  1197. export class ShaderCodeTestNode extends ShaderCodeNode {
  1198. testExpression: ShaderDefineExpression;
  1199. isValid(preprocessors: {
  1200. [key: string]: string;
  1201. }): boolean;
  1202. }
  1203. }
  1204. declare module BABYLON {
  1205. /** @hidden */
  1206. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1207. define: string;
  1208. not: boolean;
  1209. constructor(define: string, not?: boolean);
  1210. isTrue(preprocessors: {
  1211. [key: string]: string;
  1212. }): boolean;
  1213. }
  1214. }
  1215. declare module BABYLON {
  1216. /** @hidden */
  1217. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1218. leftOperand: ShaderDefineExpression;
  1219. rightOperand: ShaderDefineExpression;
  1220. isTrue(preprocessors: {
  1221. [key: string]: string;
  1222. }): boolean;
  1223. }
  1224. }
  1225. declare module BABYLON {
  1226. /** @hidden */
  1227. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1228. leftOperand: ShaderDefineExpression;
  1229. rightOperand: ShaderDefineExpression;
  1230. isTrue(preprocessors: {
  1231. [key: string]: string;
  1232. }): boolean;
  1233. }
  1234. }
  1235. declare module BABYLON {
  1236. /** @hidden */
  1237. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1238. define: string;
  1239. operand: string;
  1240. testValue: string;
  1241. constructor(define: string, operand: string, testValue: string);
  1242. isTrue(preprocessors: {
  1243. [key: string]: string;
  1244. }): boolean;
  1245. }
  1246. }
  1247. declare module BABYLON {
  1248. /**
  1249. * Class used to enable access to offline support
  1250. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1251. */
  1252. export interface IOfflineProvider {
  1253. /**
  1254. * Gets a boolean indicating if scene must be saved in the database
  1255. */
  1256. enableSceneOffline: boolean;
  1257. /**
  1258. * Gets a boolean indicating if textures must be saved in the database
  1259. */
  1260. enableTexturesOffline: boolean;
  1261. /**
  1262. * Open the offline support and make it available
  1263. * @param successCallback defines the callback to call on success
  1264. * @param errorCallback defines the callback to call on error
  1265. */
  1266. open(successCallback: () => void, errorCallback: () => void): void;
  1267. /**
  1268. * Loads an image from the offline support
  1269. * @param url defines the url to load from
  1270. * @param image defines the target DOM image
  1271. */
  1272. loadImage(url: string, image: HTMLImageElement): void;
  1273. /**
  1274. * Loads a file from offline support
  1275. * @param url defines the URL to load from
  1276. * @param sceneLoaded defines a callback to call on success
  1277. * @param progressCallBack defines a callback to call when progress changed
  1278. * @param errorCallback defines a callback to call on error
  1279. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1280. */
  1281. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1282. }
  1283. }
  1284. declare module BABYLON {
  1285. /**
  1286. * Class used to help managing file picking and drag'n'drop
  1287. * File Storage
  1288. */
  1289. export class FilesInputStore {
  1290. /**
  1291. * List of files ready to be loaded
  1292. */
  1293. static FilesToLoad: {
  1294. [key: string]: File;
  1295. };
  1296. }
  1297. }
  1298. declare module BABYLON {
  1299. /**
  1300. * Class used to define a retry strategy when error happens while loading assets
  1301. */
  1302. export class RetryStrategy {
  1303. /**
  1304. * Function used to defines an exponential back off strategy
  1305. * @param maxRetries defines the maximum number of retries (3 by default)
  1306. * @param baseInterval defines the interval between retries
  1307. * @returns the strategy function to use
  1308. */
  1309. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1310. }
  1311. }
  1312. declare module BABYLON {
  1313. /**
  1314. * @ignore
  1315. * Application error to support additional information when loading a file
  1316. */
  1317. export abstract class BaseError extends Error {
  1318. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1319. }
  1320. }
  1321. declare module BABYLON {
  1322. /** @ignore */
  1323. export class LoadFileError extends BaseError {
  1324. request?: WebRequest;
  1325. file?: File;
  1326. /**
  1327. * Creates a new LoadFileError
  1328. * @param message defines the message of the error
  1329. * @param request defines the optional web request
  1330. * @param file defines the optional file
  1331. */
  1332. constructor(message: string, object?: WebRequest | File);
  1333. }
  1334. /** @ignore */
  1335. export class RequestFileError extends BaseError {
  1336. request: WebRequest;
  1337. /**
  1338. * Creates a new LoadFileError
  1339. * @param message defines the message of the error
  1340. * @param request defines the optional web request
  1341. */
  1342. constructor(message: string, request: WebRequest);
  1343. }
  1344. /** @ignore */
  1345. export class ReadFileError extends BaseError {
  1346. file: File;
  1347. /**
  1348. * Creates a new ReadFileError
  1349. * @param message defines the message of the error
  1350. * @param file defines the optional file
  1351. */
  1352. constructor(message: string, file: File);
  1353. }
  1354. /**
  1355. * @hidden
  1356. */
  1357. export class FileTools {
  1358. /**
  1359. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1360. */
  1361. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1362. /**
  1363. * Gets or sets the base URL to use to load assets
  1364. */
  1365. static BaseUrl: string;
  1366. /**
  1367. * Default behaviour for cors in the application.
  1368. * It can be a string if the expected behavior is identical in the entire app.
  1369. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1370. */
  1371. static CorsBehavior: string | ((url: string | string[]) => string);
  1372. /**
  1373. * Gets or sets a function used to pre-process url before using them to load assets
  1374. */
  1375. static PreprocessUrl: (url: string) => string;
  1376. /**
  1377. * Removes unwanted characters from an url
  1378. * @param url defines the url to clean
  1379. * @returns the cleaned url
  1380. */
  1381. private static _CleanUrl;
  1382. /**
  1383. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1384. * @param url define the url we are trying
  1385. * @param element define the dom element where to configure the cors policy
  1386. */
  1387. static SetCorsBehavior(url: string | string[], element: {
  1388. crossOrigin: string | null;
  1389. }): void;
  1390. /**
  1391. * Loads an image as an HTMLImageElement.
  1392. * @param input url string, ArrayBuffer, or Blob to load
  1393. * @param onLoad callback called when the image successfully loads
  1394. * @param onError callback called when the image fails to load
  1395. * @param offlineProvider offline provider for caching
  1396. * @param mimeType optional mime type
  1397. * @returns the HTMLImageElement of the loaded image
  1398. */
  1399. 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>;
  1400. /**
  1401. * Reads a file from a File object
  1402. * @param file defines the file to load
  1403. * @param onSuccess defines the callback to call when data is loaded
  1404. * @param onProgress defines the callback to call during loading process
  1405. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1406. * @param onError defines the callback to call when an error occurs
  1407. * @returns a file request object
  1408. */
  1409. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1410. /**
  1411. * Loads a file from a url
  1412. * @param url url to load
  1413. * @param onSuccess callback called when the file successfully loads
  1414. * @param onProgress callback called while file is loading (if the server supports this mode)
  1415. * @param offlineProvider defines the offline provider for caching
  1416. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1417. * @param onError callback called when the file fails to load
  1418. * @returns a file request object
  1419. */
  1420. 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;
  1421. /**
  1422. * Loads a file
  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 useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1427. * @param onError callback called when the file fails to load
  1428. * @param onOpened callback called when the web request is opened
  1429. * @returns a file request object
  1430. */
  1431. 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;
  1432. /**
  1433. * Checks if the loaded document was accessed via `file:`-Protocol.
  1434. * @returns boolean
  1435. */
  1436. static IsFileURL(): boolean;
  1437. }
  1438. }
  1439. declare module BABYLON {
  1440. /** @hidden */
  1441. export class ShaderProcessor {
  1442. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1443. private static _ProcessPrecision;
  1444. private static _ExtractOperation;
  1445. private static _BuildSubExpression;
  1446. private static _BuildExpression;
  1447. private static _MoveCursorWithinIf;
  1448. private static _MoveCursor;
  1449. private static _EvaluatePreProcessors;
  1450. private static _PreparePreProcessors;
  1451. private static _ProcessShaderConversion;
  1452. private static _ProcessIncludes;
  1453. /**
  1454. * Loads a file from a url
  1455. * @param url url to load
  1456. * @param onSuccess callback called when the file successfully loads
  1457. * @param onProgress callback called while file is loading (if the server supports this mode)
  1458. * @param offlineProvider defines the offline provider for caching
  1459. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1460. * @param onError callback called when the file fails to load
  1461. * @returns a file request object
  1462. * @hidden
  1463. */
  1464. 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;
  1465. }
  1466. }
  1467. declare module BABYLON {
  1468. /**
  1469. * @hidden
  1470. */
  1471. export interface IColor4Like {
  1472. r: float;
  1473. g: float;
  1474. b: float;
  1475. a: float;
  1476. }
  1477. /**
  1478. * @hidden
  1479. */
  1480. export interface IColor3Like {
  1481. r: float;
  1482. g: float;
  1483. b: float;
  1484. }
  1485. /**
  1486. * @hidden
  1487. */
  1488. export interface IVector4Like {
  1489. x: float;
  1490. y: float;
  1491. z: float;
  1492. w: float;
  1493. }
  1494. /**
  1495. * @hidden
  1496. */
  1497. export interface IVector3Like {
  1498. x: float;
  1499. y: float;
  1500. z: float;
  1501. }
  1502. /**
  1503. * @hidden
  1504. */
  1505. export interface IVector2Like {
  1506. x: float;
  1507. y: float;
  1508. }
  1509. /**
  1510. * @hidden
  1511. */
  1512. export interface IMatrixLike {
  1513. toArray(): DeepImmutable<Float32Array>;
  1514. updateFlag: int;
  1515. }
  1516. /**
  1517. * @hidden
  1518. */
  1519. export interface IViewportLike {
  1520. x: float;
  1521. y: float;
  1522. width: float;
  1523. height: float;
  1524. }
  1525. /**
  1526. * @hidden
  1527. */
  1528. export interface IPlaneLike {
  1529. normal: IVector3Like;
  1530. d: float;
  1531. normalize(): void;
  1532. }
  1533. }
  1534. declare module BABYLON {
  1535. /**
  1536. * Interface used to define common properties for effect fallbacks
  1537. */
  1538. export interface IEffectFallbacks {
  1539. /**
  1540. * Removes the defines that should be removed when falling back.
  1541. * @param currentDefines defines the current define statements for the shader.
  1542. * @param effect defines the current effect we try to compile
  1543. * @returns The resulting defines with defines of the current rank removed.
  1544. */
  1545. reduce(currentDefines: string, effect: Effect): string;
  1546. /**
  1547. * Removes the fallback from the bound mesh.
  1548. */
  1549. unBindMesh(): void;
  1550. /**
  1551. * Checks to see if more fallbacks are still availible.
  1552. */
  1553. hasMoreFallbacks: boolean;
  1554. }
  1555. }
  1556. declare module BABYLON {
  1557. /**
  1558. * Class used to evalaute queries containing `and` and `or` operators
  1559. */
  1560. export class AndOrNotEvaluator {
  1561. /**
  1562. * Evaluate a query
  1563. * @param query defines the query to evaluate
  1564. * @param evaluateCallback defines the callback used to filter result
  1565. * @returns true if the query matches
  1566. */
  1567. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1568. private static _HandleParenthesisContent;
  1569. private static _SimplifyNegation;
  1570. }
  1571. }
  1572. declare module BABYLON {
  1573. /**
  1574. * Class used to store custom tags
  1575. */
  1576. export class Tags {
  1577. /**
  1578. * Adds support for tags on the given object
  1579. * @param obj defines the object to use
  1580. */
  1581. static EnableFor(obj: any): void;
  1582. /**
  1583. * Removes tags support
  1584. * @param obj defines the object to use
  1585. */
  1586. static DisableFor(obj: any): void;
  1587. /**
  1588. * Gets a boolean indicating if the given object has tags
  1589. * @param obj defines the object to use
  1590. * @returns a boolean
  1591. */
  1592. static HasTags(obj: any): boolean;
  1593. /**
  1594. * Gets the tags available on a given object
  1595. * @param obj defines the object to use
  1596. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1597. * @returns the tags
  1598. */
  1599. static GetTags(obj: any, asString?: boolean): any;
  1600. /**
  1601. * Adds tags to an object
  1602. * @param obj defines the object to use
  1603. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1604. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1605. */
  1606. static AddTagsTo(obj: any, tagsString: string): void;
  1607. /**
  1608. * @hidden
  1609. */
  1610. static _AddTagTo(obj: any, tag: string): void;
  1611. /**
  1612. * Removes specific tags from a specific object
  1613. * @param obj defines the object to use
  1614. * @param tagsString defines the tags to remove
  1615. */
  1616. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1617. /**
  1618. * @hidden
  1619. */
  1620. static _RemoveTagFrom(obj: any, tag: string): void;
  1621. /**
  1622. * Defines if tags hosted on an object match a given query
  1623. * @param obj defines the object to use
  1624. * @param tagsQuery defines the tag query
  1625. * @returns a boolean
  1626. */
  1627. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1628. }
  1629. }
  1630. declare module BABYLON {
  1631. /**
  1632. * Scalar computation library
  1633. */
  1634. export class Scalar {
  1635. /**
  1636. * Two pi constants convenient for computation.
  1637. */
  1638. static TwoPi: number;
  1639. /**
  1640. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1641. * @param a number
  1642. * @param b number
  1643. * @param epsilon (default = 1.401298E-45)
  1644. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1645. */
  1646. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1647. /**
  1648. * Returns a string : the upper case translation of the number i to hexadecimal.
  1649. * @param i number
  1650. * @returns the upper case translation of the number i to hexadecimal.
  1651. */
  1652. static ToHex(i: number): string;
  1653. /**
  1654. * Returns -1 if value is negative and +1 is value is positive.
  1655. * @param value the value
  1656. * @returns the value itself if it's equal to zero.
  1657. */
  1658. static Sign(value: number): number;
  1659. /**
  1660. * Returns the value itself if it's between min and max.
  1661. * Returns min if the value is lower than min.
  1662. * Returns max if the value is greater than max.
  1663. * @param value the value to clmap
  1664. * @param min the min value to clamp to (default: 0)
  1665. * @param max the max value to clamp to (default: 1)
  1666. * @returns the clamped value
  1667. */
  1668. static Clamp(value: number, min?: number, max?: number): number;
  1669. /**
  1670. * the log2 of value.
  1671. * @param value the value to compute log2 of
  1672. * @returns the log2 of value.
  1673. */
  1674. static Log2(value: number): number;
  1675. /**
  1676. * Loops the value, so that it is never larger than length and never smaller than 0.
  1677. *
  1678. * This is similar to the modulo operator but it works with floating point numbers.
  1679. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1680. * With t = 5 and length = 2.5, the result would be 0.0.
  1681. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1682. * @param value the value
  1683. * @param length the length
  1684. * @returns the looped value
  1685. */
  1686. static Repeat(value: number, length: number): number;
  1687. /**
  1688. * Normalize the value between 0.0 and 1.0 using min and max values
  1689. * @param value value to normalize
  1690. * @param min max to normalize between
  1691. * @param max min to normalize between
  1692. * @returns the normalized value
  1693. */
  1694. static Normalize(value: number, min: number, max: number): number;
  1695. /**
  1696. * Denormalize the value from 0.0 and 1.0 using min and max values
  1697. * @param normalized value to denormalize
  1698. * @param min max to denormalize between
  1699. * @param max min to denormalize between
  1700. * @returns the denormalized value
  1701. */
  1702. static Denormalize(normalized: number, min: number, max: number): number;
  1703. /**
  1704. * Calculates the shortest difference between two given angles given in degrees.
  1705. * @param current current angle in degrees
  1706. * @param target target angle in degrees
  1707. * @returns the delta
  1708. */
  1709. static DeltaAngle(current: number, target: number): number;
  1710. /**
  1711. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1712. * @param tx value
  1713. * @param length length
  1714. * @returns The returned value will move back and forth between 0 and length
  1715. */
  1716. static PingPong(tx: number, length: number): number;
  1717. /**
  1718. * Interpolates between min and max with smoothing at the limits.
  1719. *
  1720. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1721. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1722. * @param from from
  1723. * @param to to
  1724. * @param tx value
  1725. * @returns the smooth stepped value
  1726. */
  1727. static SmoothStep(from: number, to: number, tx: number): number;
  1728. /**
  1729. * Moves a value current towards target.
  1730. *
  1731. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1732. * Negative values of maxDelta pushes the value away from target.
  1733. * @param current current value
  1734. * @param target target value
  1735. * @param maxDelta max distance to move
  1736. * @returns resulting value
  1737. */
  1738. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1739. /**
  1740. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1741. *
  1742. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1743. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1744. * @param current current value
  1745. * @param target target value
  1746. * @param maxDelta max distance to move
  1747. * @returns resulting angle
  1748. */
  1749. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1750. /**
  1751. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1752. * @param start start value
  1753. * @param end target value
  1754. * @param amount amount to lerp between
  1755. * @returns the lerped value
  1756. */
  1757. static Lerp(start: number, end: number, amount: number): number;
  1758. /**
  1759. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1760. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1761. * @param start start value
  1762. * @param end target value
  1763. * @param amount amount to lerp between
  1764. * @returns the lerped value
  1765. */
  1766. static LerpAngle(start: number, end: number, amount: number): number;
  1767. /**
  1768. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1769. * @param a start value
  1770. * @param b target value
  1771. * @param value value between a and b
  1772. * @returns the inverseLerp value
  1773. */
  1774. static InverseLerp(a: number, b: number, value: number): number;
  1775. /**
  1776. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1777. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1778. * @param value1 spline value
  1779. * @param tangent1 spline value
  1780. * @param value2 spline value
  1781. * @param tangent2 spline value
  1782. * @param amount input value
  1783. * @returns hermite result
  1784. */
  1785. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1786. /**
  1787. * Returns a random float number between and min and max values
  1788. * @param min min value of random
  1789. * @param max max value of random
  1790. * @returns random value
  1791. */
  1792. static RandomRange(min: number, max: number): number;
  1793. /**
  1794. * This function returns percentage of a number in a given range.
  1795. *
  1796. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1797. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1798. * @param number to convert to percentage
  1799. * @param min min range
  1800. * @param max max range
  1801. * @returns the percentage
  1802. */
  1803. static RangeToPercent(number: number, min: number, max: number): number;
  1804. /**
  1805. * This function returns number that corresponds to the percentage in a given range.
  1806. *
  1807. * PercentToRange(0.34,0,100) will return 34.
  1808. * @param percent to convert to number
  1809. * @param min min range
  1810. * @param max max range
  1811. * @returns the number
  1812. */
  1813. static PercentToRange(percent: number, min: number, max: number): number;
  1814. /**
  1815. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1816. * @param angle The angle to normalize in radian.
  1817. * @return The converted angle.
  1818. */
  1819. static NormalizeRadians(angle: number): number;
  1820. }
  1821. }
  1822. declare module BABYLON {
  1823. /**
  1824. * Constant used to convert a value to gamma space
  1825. * @ignorenaming
  1826. */
  1827. export const ToGammaSpace: number;
  1828. /**
  1829. * Constant used to convert a value to linear space
  1830. * @ignorenaming
  1831. */
  1832. export const ToLinearSpace = 2.2;
  1833. /**
  1834. * Constant used to define the minimal number value in Babylon.js
  1835. * @ignorenaming
  1836. */
  1837. let Epsilon: number;
  1838. }
  1839. declare module BABYLON {
  1840. /**
  1841. * Class used to represent a viewport on screen
  1842. */
  1843. export class Viewport {
  1844. /** viewport left coordinate */
  1845. x: number;
  1846. /** viewport top coordinate */
  1847. y: number;
  1848. /**viewport width */
  1849. width: number;
  1850. /** viewport height */
  1851. height: number;
  1852. /**
  1853. * Creates a Viewport object located at (x, y) and sized (width, height)
  1854. * @param x defines viewport left coordinate
  1855. * @param y defines viewport top coordinate
  1856. * @param width defines the viewport width
  1857. * @param height defines the viewport height
  1858. */
  1859. constructor(
  1860. /** viewport left coordinate */
  1861. x: number,
  1862. /** viewport top coordinate */
  1863. y: number,
  1864. /**viewport width */
  1865. width: number,
  1866. /** viewport height */
  1867. height: number);
  1868. /**
  1869. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1870. * @param renderWidth defines the rendering width
  1871. * @param renderHeight defines the rendering height
  1872. * @returns a new Viewport
  1873. */
  1874. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1875. /**
  1876. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1877. * @param renderWidth defines the rendering width
  1878. * @param renderHeight defines the rendering height
  1879. * @param ref defines the target viewport
  1880. * @returns the current viewport
  1881. */
  1882. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1883. /**
  1884. * Returns a new Viewport copied from the current one
  1885. * @returns a new Viewport
  1886. */
  1887. clone(): Viewport;
  1888. }
  1889. }
  1890. declare module BABYLON {
  1891. /**
  1892. * Class containing a set of static utilities functions for arrays.
  1893. */
  1894. export class ArrayTools {
  1895. /**
  1896. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1897. * @param size the number of element to construct and put in the array
  1898. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1899. * @returns a new array filled with new objects
  1900. */
  1901. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1902. }
  1903. }
  1904. declare module BABYLON {
  1905. /**
  1906. * Class representing a vector containing 2 coordinates
  1907. */
  1908. export class Vector2 {
  1909. /** defines the first coordinate */
  1910. x: number;
  1911. /** defines the second coordinate */
  1912. y: number;
  1913. /**
  1914. * Creates a new Vector2 from the given x and y coordinates
  1915. * @param x defines the first coordinate
  1916. * @param y defines the second coordinate
  1917. */
  1918. constructor(
  1919. /** defines the first coordinate */
  1920. x?: number,
  1921. /** defines the second coordinate */
  1922. y?: number);
  1923. /**
  1924. * Gets a string with the Vector2 coordinates
  1925. * @returns a string with the Vector2 coordinates
  1926. */
  1927. toString(): string;
  1928. /**
  1929. * Gets class name
  1930. * @returns the string "Vector2"
  1931. */
  1932. getClassName(): string;
  1933. /**
  1934. * Gets current vector hash code
  1935. * @returns the Vector2 hash code as a number
  1936. */
  1937. getHashCode(): number;
  1938. /**
  1939. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1940. * @param array defines the source array
  1941. * @param index defines the offset in source array
  1942. * @returns the current Vector2
  1943. */
  1944. toArray(array: FloatArray, index?: number): Vector2;
  1945. /**
  1946. * Copy the current vector to an array
  1947. * @returns a new array with 2 elements: the Vector2 coordinates.
  1948. */
  1949. asArray(): number[];
  1950. /**
  1951. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1952. * @param source defines the source Vector2
  1953. * @returns the current updated Vector2
  1954. */
  1955. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1956. /**
  1957. * Sets the Vector2 coordinates with the given floats
  1958. * @param x defines the first coordinate
  1959. * @param y defines the second coordinate
  1960. * @returns the current updated Vector2
  1961. */
  1962. copyFromFloats(x: number, y: number): Vector2;
  1963. /**
  1964. * Sets the Vector2 coordinates with the given floats
  1965. * @param x defines the first coordinate
  1966. * @param y defines the second coordinate
  1967. * @returns the current updated Vector2
  1968. */
  1969. set(x: number, y: number): Vector2;
  1970. /**
  1971. * Add another vector with the current one
  1972. * @param otherVector defines the other vector
  1973. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1974. */
  1975. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1976. /**
  1977. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1978. * @param otherVector defines the other vector
  1979. * @param result defines the target vector
  1980. * @returns the unmodified current Vector2
  1981. */
  1982. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1983. /**
  1984. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1985. * @param otherVector defines the other vector
  1986. * @returns the current updated Vector2
  1987. */
  1988. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1989. /**
  1990. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1991. * @param otherVector defines the other vector
  1992. * @returns a new Vector2
  1993. */
  1994. addVector3(otherVector: Vector3): Vector2;
  1995. /**
  1996. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1997. * @param otherVector defines the other vector
  1998. * @returns a new Vector2
  1999. */
  2000. subtract(otherVector: Vector2): Vector2;
  2001. /**
  2002. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2003. * @param otherVector defines the other vector
  2004. * @param result defines the target vector
  2005. * @returns the unmodified current Vector2
  2006. */
  2007. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2008. /**
  2009. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2010. * @param otherVector defines the other vector
  2011. * @returns the current updated Vector2
  2012. */
  2013. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2014. /**
  2015. * Multiplies in place the current Vector2 coordinates by the given ones
  2016. * @param otherVector defines the other vector
  2017. * @returns the current updated Vector2
  2018. */
  2019. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2020. /**
  2021. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2022. * @param otherVector defines the other vector
  2023. * @returns a new Vector2
  2024. */
  2025. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2026. /**
  2027. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2028. * @param otherVector defines the other vector
  2029. * @param result defines the target vector
  2030. * @returns the unmodified current Vector2
  2031. */
  2032. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2033. /**
  2034. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2035. * @param x defines the first coordinate
  2036. * @param y defines the second coordinate
  2037. * @returns a new Vector2
  2038. */
  2039. multiplyByFloats(x: number, y: number): Vector2;
  2040. /**
  2041. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2042. * @param otherVector defines the other vector
  2043. * @returns a new Vector2
  2044. */
  2045. divide(otherVector: Vector2): Vector2;
  2046. /**
  2047. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2048. * @param otherVector defines the other vector
  2049. * @param result defines the target vector
  2050. * @returns the unmodified current Vector2
  2051. */
  2052. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2053. /**
  2054. * Divides the current Vector2 coordinates by the given ones
  2055. * @param otherVector defines the other vector
  2056. * @returns the current updated Vector2
  2057. */
  2058. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2059. /**
  2060. * Gets a new Vector2 with current Vector2 negated coordinates
  2061. * @returns a new Vector2
  2062. */
  2063. negate(): Vector2;
  2064. /**
  2065. * Negate this vector in place
  2066. * @returns this
  2067. */
  2068. negateInPlace(): Vector2;
  2069. /**
  2070. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2071. * @param result defines the Vector3 object where to store the result
  2072. * @returns the current Vector2
  2073. */
  2074. negateToRef(result: Vector2): 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. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2433. * @param result defines the Vector3 object where to store the result
  2434. * @returns the current Vector3
  2435. */
  2436. negateToRef(result: Vector3): Vector3;
  2437. /**
  2438. * Multiplies the Vector3 coordinates by the float "scale"
  2439. * @param scale defines the multiplier factor
  2440. * @returns the current updated Vector3
  2441. */
  2442. scaleInPlace(scale: number): Vector3;
  2443. /**
  2444. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2445. * @param scale defines the multiplier factor
  2446. * @returns a new Vector3
  2447. */
  2448. scale(scale: number): Vector3;
  2449. /**
  2450. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2451. * @param scale defines the multiplier factor
  2452. * @param result defines the Vector3 object where to store the result
  2453. * @returns the current Vector3
  2454. */
  2455. scaleToRef(scale: number, result: Vector3): Vector3;
  2456. /**
  2457. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2458. * @param scale defines the scale factor
  2459. * @param result defines the Vector3 object where to store the result
  2460. * @returns the unmodified current Vector3
  2461. */
  2462. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2463. /**
  2464. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2465. * @param otherVector defines the second operand
  2466. * @returns true if both vectors are equals
  2467. */
  2468. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2469. /**
  2470. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2471. * @param otherVector defines the second operand
  2472. * @param epsilon defines the minimal distance to define values as equals
  2473. * @returns true if both vectors are distant less than epsilon
  2474. */
  2475. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2476. /**
  2477. * Returns true if the current Vector3 coordinates equals the given floats
  2478. * @param x defines the x coordinate of the operand
  2479. * @param y defines the y coordinate of the operand
  2480. * @param z defines the z coordinate of the operand
  2481. * @returns true if both vectors are equals
  2482. */
  2483. equalsToFloats(x: number, y: number, z: number): boolean;
  2484. /**
  2485. * Multiplies the current Vector3 coordinates by the given ones
  2486. * @param otherVector defines the second operand
  2487. * @returns the current updated Vector3
  2488. */
  2489. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2490. /**
  2491. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2492. * @param otherVector defines the second operand
  2493. * @returns the new Vector3
  2494. */
  2495. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2496. /**
  2497. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2498. * @param otherVector defines the second operand
  2499. * @param result defines the Vector3 object where to store the result
  2500. * @returns the current Vector3
  2501. */
  2502. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2503. /**
  2504. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2505. * @param x defines the x coordinate of the operand
  2506. * @param y defines the y coordinate of the operand
  2507. * @param z defines the z coordinate of the operand
  2508. * @returns the new Vector3
  2509. */
  2510. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2511. /**
  2512. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2513. * @param otherVector defines the second operand
  2514. * @returns the new Vector3
  2515. */
  2516. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2517. /**
  2518. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2519. * @param otherVector defines the second operand
  2520. * @param result defines the Vector3 object where to store the result
  2521. * @returns the current Vector3
  2522. */
  2523. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2524. /**
  2525. * Divides the current Vector3 coordinates by the given ones.
  2526. * @param otherVector defines the second operand
  2527. * @returns the current updated Vector3
  2528. */
  2529. divideInPlace(otherVector: Vector3): Vector3;
  2530. /**
  2531. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2532. * @param other defines the second operand
  2533. * @returns the current updated Vector3
  2534. */
  2535. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2536. /**
  2537. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2538. * @param other defines the second operand
  2539. * @returns the current updated Vector3
  2540. */
  2541. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2542. /**
  2543. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2544. * @param x defines the x coordinate of the operand
  2545. * @param y defines the y coordinate of the operand
  2546. * @param z defines the z coordinate of the operand
  2547. * @returns the current updated Vector3
  2548. */
  2549. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2550. /**
  2551. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2552. * @param x defines the x coordinate of the operand
  2553. * @param y defines the y coordinate of the operand
  2554. * @param z defines the z coordinate of the operand
  2555. * @returns the current updated Vector3
  2556. */
  2557. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2558. /**
  2559. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2560. * Check if is non uniform within a certain amount of decimal places to account for this
  2561. * @param epsilon the amount the values can differ
  2562. * @returns if the the vector is non uniform to a certain number of decimal places
  2563. */
  2564. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2565. /**
  2566. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2567. */
  2568. get isNonUniform(): boolean;
  2569. /**
  2570. * Gets a new Vector3 from current Vector3 floored values
  2571. * @returns a new Vector3
  2572. */
  2573. floor(): Vector3;
  2574. /**
  2575. * Gets a new Vector3 from current Vector3 floored values
  2576. * @returns a new Vector3
  2577. */
  2578. fract(): Vector3;
  2579. /**
  2580. * Gets the length of the Vector3
  2581. * @returns the length of the Vector3
  2582. */
  2583. length(): number;
  2584. /**
  2585. * Gets the squared length of the Vector3
  2586. * @returns squared length of the Vector3
  2587. */
  2588. lengthSquared(): number;
  2589. /**
  2590. * Normalize the current Vector3.
  2591. * Please note that this is an in place operation.
  2592. * @returns the current updated Vector3
  2593. */
  2594. normalize(): Vector3;
  2595. /**
  2596. * Reorders the x y z properties of the vector in place
  2597. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2598. * @returns the current updated vector
  2599. */
  2600. reorderInPlace(order: string): this;
  2601. /**
  2602. * Rotates the vector around 0,0,0 by a quaternion
  2603. * @param quaternion the rotation quaternion
  2604. * @param result vector to store the result
  2605. * @returns the resulting vector
  2606. */
  2607. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2608. /**
  2609. * Rotates a vector around a given point
  2610. * @param quaternion the rotation quaternion
  2611. * @param point the point to rotate around
  2612. * @param result vector to store the result
  2613. * @returns the resulting vector
  2614. */
  2615. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2616. /**
  2617. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2618. * The cross product is then orthogonal to both current and "other"
  2619. * @param other defines the right operand
  2620. * @returns the cross product
  2621. */
  2622. cross(other: Vector3): Vector3;
  2623. /**
  2624. * Normalize the current Vector3 with the given input length.
  2625. * Please note that this is an in place operation.
  2626. * @param len the length of the vector
  2627. * @returns the current updated Vector3
  2628. */
  2629. normalizeFromLength(len: number): Vector3;
  2630. /**
  2631. * Normalize the current Vector3 to a new vector
  2632. * @returns the new Vector3
  2633. */
  2634. normalizeToNew(): Vector3;
  2635. /**
  2636. * Normalize the current Vector3 to the reference
  2637. * @param reference define the Vector3 to update
  2638. * @returns the updated Vector3
  2639. */
  2640. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2641. /**
  2642. * Creates a new Vector3 copied from the current Vector3
  2643. * @returns the new Vector3
  2644. */
  2645. clone(): Vector3;
  2646. /**
  2647. * Copies the given vector coordinates to the current Vector3 ones
  2648. * @param source defines the source Vector3
  2649. * @returns the current updated Vector3
  2650. */
  2651. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2652. /**
  2653. * Copies the given floats to the current Vector3 coordinates
  2654. * @param x defines the x coordinate of the operand
  2655. * @param y defines the y coordinate of the operand
  2656. * @param z defines the z coordinate of the operand
  2657. * @returns the current updated Vector3
  2658. */
  2659. copyFromFloats(x: number, y: number, z: number): Vector3;
  2660. /**
  2661. * Copies the given floats to the current Vector3 coordinates
  2662. * @param x defines the x coordinate of the operand
  2663. * @param y defines the y coordinate of the operand
  2664. * @param z defines the z coordinate of the operand
  2665. * @returns the current updated Vector3
  2666. */
  2667. set(x: number, y: number, z: number): Vector3;
  2668. /**
  2669. * Copies the given float to the current Vector3 coordinates
  2670. * @param v defines the x, y and z coordinates of the operand
  2671. * @returns the current updated Vector3
  2672. */
  2673. setAll(v: number): Vector3;
  2674. /**
  2675. * Get the clip factor between two vectors
  2676. * @param vector0 defines the first operand
  2677. * @param vector1 defines the second operand
  2678. * @param axis defines the axis to use
  2679. * @param size defines the size along the axis
  2680. * @returns the clip factor
  2681. */
  2682. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2683. /**
  2684. * Get angle between two vectors
  2685. * @param vector0 angle between vector0 and vector1
  2686. * @param vector1 angle between vector0 and vector1
  2687. * @param normal direction of the normal
  2688. * @return the angle between vector0 and vector1
  2689. */
  2690. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2691. /**
  2692. * Returns a new Vector3 set from the index "offset" of the given array
  2693. * @param array defines the source array
  2694. * @param offset defines the offset in the source array
  2695. * @returns the new Vector3
  2696. */
  2697. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2698. /**
  2699. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2700. * @param array defines the source array
  2701. * @param offset defines the offset in the source array
  2702. * @returns the new Vector3
  2703. * @deprecated Please use FromArray instead.
  2704. */
  2705. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2706. /**
  2707. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2708. * @param array defines the source array
  2709. * @param offset defines the offset in the source array
  2710. * @param result defines the Vector3 where to store the result
  2711. */
  2712. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2713. /**
  2714. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2715. * @param array defines the source array
  2716. * @param offset defines the offset in the source array
  2717. * @param result defines the Vector3 where to store the result
  2718. * @deprecated Please use FromArrayToRef instead.
  2719. */
  2720. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2721. /**
  2722. * Sets the given vector "result" with the given floats.
  2723. * @param x defines the x coordinate of the source
  2724. * @param y defines the y coordinate of the source
  2725. * @param z defines the z coordinate of the source
  2726. * @param result defines the Vector3 where to store the result
  2727. */
  2728. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2729. /**
  2730. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2731. * @returns a new empty Vector3
  2732. */
  2733. static Zero(): Vector3;
  2734. /**
  2735. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2736. * @returns a new unit Vector3
  2737. */
  2738. static One(): Vector3;
  2739. /**
  2740. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2741. * @returns a new up Vector3
  2742. */
  2743. static Up(): Vector3;
  2744. /**
  2745. * Gets a up Vector3 that must not be updated
  2746. */
  2747. static get UpReadOnly(): DeepImmutable<Vector3>;
  2748. /**
  2749. * Gets a zero Vector3 that must not be updated
  2750. */
  2751. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2752. /**
  2753. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2754. * @returns a new down Vector3
  2755. */
  2756. static Down(): Vector3;
  2757. /**
  2758. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2759. * @returns a new forward Vector3
  2760. */
  2761. static Forward(): Vector3;
  2762. /**
  2763. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2764. * @returns a new forward Vector3
  2765. */
  2766. static Backward(): Vector3;
  2767. /**
  2768. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2769. * @returns a new right Vector3
  2770. */
  2771. static Right(): Vector3;
  2772. /**
  2773. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2774. * @returns a new left Vector3
  2775. */
  2776. static Left(): Vector3;
  2777. /**
  2778. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2779. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2780. * @param vector defines the Vector3 to transform
  2781. * @param transformation defines the transformation matrix
  2782. * @returns the transformed Vector3
  2783. */
  2784. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2785. /**
  2786. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2787. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2788. * @param vector defines the Vector3 to transform
  2789. * @param transformation defines the transformation matrix
  2790. * @param result defines the Vector3 where to store the result
  2791. */
  2792. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2793. /**
  2794. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2795. * This method computes tranformed coordinates only, not transformed direction vectors
  2796. * @param x define the x coordinate of the source vector
  2797. * @param y define the y coordinate of the source vector
  2798. * @param z define the z coordinate of the source vector
  2799. * @param transformation defines the transformation matrix
  2800. * @param result defines the Vector3 where to store the result
  2801. */
  2802. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2803. /**
  2804. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2805. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2806. * @param vector defines the Vector3 to transform
  2807. * @param transformation defines the transformation matrix
  2808. * @returns the new Vector3
  2809. */
  2810. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2811. /**
  2812. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2813. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2814. * @param vector defines the Vector3 to transform
  2815. * @param transformation defines the transformation matrix
  2816. * @param result defines the Vector3 where to store the result
  2817. */
  2818. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2819. /**
  2820. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2821. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2822. * @param x define the x coordinate of the source vector
  2823. * @param y define the y coordinate of the source vector
  2824. * @param z define the z coordinate of the source vector
  2825. * @param transformation defines the transformation matrix
  2826. * @param result defines the Vector3 where to store the result
  2827. */
  2828. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2829. /**
  2830. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2831. * @param value1 defines the first control point
  2832. * @param value2 defines the second control point
  2833. * @param value3 defines the third control point
  2834. * @param value4 defines the fourth control point
  2835. * @param amount defines the amount on the spline to use
  2836. * @returns the new Vector3
  2837. */
  2838. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2839. /**
  2840. * 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"
  2841. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2842. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2843. * @param value defines the current value
  2844. * @param min defines the lower range value
  2845. * @param max defines the upper range value
  2846. * @returns the new Vector3
  2847. */
  2848. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2849. /**
  2850. * 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"
  2851. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2852. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2853. * @param value defines the current value
  2854. * @param min defines the lower range value
  2855. * @param max defines the upper range value
  2856. * @param result defines the Vector3 where to store the result
  2857. */
  2858. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2859. /**
  2860. * Checks if a given vector is inside a specific range
  2861. * @param v defines the vector to test
  2862. * @param min defines the minimum range
  2863. * @param max defines the maximum range
  2864. */
  2865. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2866. /**
  2867. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2868. * @param value1 defines the first control point
  2869. * @param tangent1 defines the first tangent vector
  2870. * @param value2 defines the second control point
  2871. * @param tangent2 defines the second tangent vector
  2872. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2873. * @returns the new Vector3
  2874. */
  2875. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2876. /**
  2877. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2878. * @param start defines the start value
  2879. * @param end defines the end value
  2880. * @param amount max defines amount between both (between 0 and 1)
  2881. * @returns the new Vector3
  2882. */
  2883. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2884. /**
  2885. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2886. * @param start defines the start value
  2887. * @param end defines the end value
  2888. * @param amount max defines amount between both (between 0 and 1)
  2889. * @param result defines the Vector3 where to store the result
  2890. */
  2891. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2892. /**
  2893. * Returns the dot product (float) between the vectors "left" and "right"
  2894. * @param left defines the left operand
  2895. * @param right defines the right operand
  2896. * @returns the dot product
  2897. */
  2898. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2899. /**
  2900. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2901. * The cross product is then orthogonal to both "left" and "right"
  2902. * @param left defines the left operand
  2903. * @param right defines the right operand
  2904. * @returns the cross product
  2905. */
  2906. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2907. /**
  2908. * Sets the given vector "result" with the cross product of "left" and "right"
  2909. * The cross product is then orthogonal to both "left" and "right"
  2910. * @param left defines the left operand
  2911. * @param right defines the right operand
  2912. * @param result defines the Vector3 where to store the result
  2913. */
  2914. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2915. /**
  2916. * Returns a new Vector3 as the normalization of the given vector
  2917. * @param vector defines the Vector3 to normalize
  2918. * @returns the new Vector3
  2919. */
  2920. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2921. /**
  2922. * Sets the given vector "result" with the normalization of the given first vector
  2923. * @param vector defines the Vector3 to normalize
  2924. * @param result defines the Vector3 where to store the result
  2925. */
  2926. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2927. /**
  2928. * Project a Vector3 onto screen space
  2929. * @param vector defines the Vector3 to project
  2930. * @param world defines the world matrix to use
  2931. * @param transform defines the transform (view x projection) matrix to use
  2932. * @param viewport defines the screen viewport to use
  2933. * @returns the new Vector3
  2934. */
  2935. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2936. /** @hidden */
  2937. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2938. /**
  2939. * Unproject from screen space to object space
  2940. * @param source defines the screen space Vector3 to use
  2941. * @param viewportWidth defines the current width of the viewport
  2942. * @param viewportHeight defines the current height of the viewport
  2943. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2944. * @param transform defines the transform (view x projection) matrix to use
  2945. * @returns the new Vector3
  2946. */
  2947. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2948. /**
  2949. * Unproject from screen space to object space
  2950. * @param source defines the screen space Vector3 to use
  2951. * @param viewportWidth defines the current width of the viewport
  2952. * @param viewportHeight defines the current height of the viewport
  2953. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2954. * @param view defines the view matrix to use
  2955. * @param projection defines the projection matrix to use
  2956. * @returns the new Vector3
  2957. */
  2958. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2959. /**
  2960. * Unproject from screen space to object space
  2961. * @param source defines the screen space Vector3 to use
  2962. * @param viewportWidth defines the current width of the viewport
  2963. * @param viewportHeight defines the current height of the viewport
  2964. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2965. * @param view defines the view matrix to use
  2966. * @param projection defines the projection matrix to use
  2967. * @param result defines the Vector3 where to store the result
  2968. */
  2969. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2970. /**
  2971. * Unproject from screen space to object space
  2972. * @param sourceX defines the screen space x coordinate to use
  2973. * @param sourceY defines the screen space y coordinate to use
  2974. * @param sourceZ defines the screen space z coordinate to use
  2975. * @param viewportWidth defines the current width of the viewport
  2976. * @param viewportHeight defines the current height of the viewport
  2977. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2978. * @param view defines the view matrix to use
  2979. * @param projection defines the projection matrix to use
  2980. * @param result defines the Vector3 where to store the result
  2981. */
  2982. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2983. /**
  2984. * Gets the minimal coordinate values between two Vector3
  2985. * @param left defines the first operand
  2986. * @param right defines the second operand
  2987. * @returns the new Vector3
  2988. */
  2989. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2990. /**
  2991. * Gets the maximal coordinate values between two Vector3
  2992. * @param left defines the first operand
  2993. * @param right defines the second operand
  2994. * @returns the new Vector3
  2995. */
  2996. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2997. /**
  2998. * Returns the distance between the vectors "value1" and "value2"
  2999. * @param value1 defines the first operand
  3000. * @param value2 defines the second operand
  3001. * @returns the distance
  3002. */
  3003. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3004. /**
  3005. * Returns the squared distance between the vectors "value1" and "value2"
  3006. * @param value1 defines the first operand
  3007. * @param value2 defines the second operand
  3008. * @returns the squared distance
  3009. */
  3010. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3011. /**
  3012. * Returns a new Vector3 located at the center between "value1" and "value2"
  3013. * @param value1 defines the first operand
  3014. * @param value2 defines the second operand
  3015. * @returns the new Vector3
  3016. */
  3017. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3018. /**
  3019. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3020. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3021. * to something in order to rotate it from its local system to the given target system
  3022. * Note: axis1, axis2 and axis3 are normalized during this operation
  3023. * @param axis1 defines the first axis
  3024. * @param axis2 defines the second axis
  3025. * @param axis3 defines the third axis
  3026. * @returns a new Vector3
  3027. */
  3028. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3029. /**
  3030. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3031. * @param axis1 defines the first axis
  3032. * @param axis2 defines the second axis
  3033. * @param axis3 defines the third axis
  3034. * @param ref defines the Vector3 where to store the result
  3035. */
  3036. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3037. }
  3038. /**
  3039. * Vector4 class created for EulerAngle class conversion to Quaternion
  3040. */
  3041. export class Vector4 {
  3042. /** x value of the vector */
  3043. x: number;
  3044. /** y value of the vector */
  3045. y: number;
  3046. /** z value of the vector */
  3047. z: number;
  3048. /** w value of the vector */
  3049. w: number;
  3050. /**
  3051. * Creates a Vector4 object from the given floats.
  3052. * @param x x value of the vector
  3053. * @param y y value of the vector
  3054. * @param z z value of the vector
  3055. * @param w w value of the vector
  3056. */
  3057. constructor(
  3058. /** x value of the vector */
  3059. x: number,
  3060. /** y value of the vector */
  3061. y: number,
  3062. /** z value of the vector */
  3063. z: number,
  3064. /** w value of the vector */
  3065. w: number);
  3066. /**
  3067. * Returns the string with the Vector4 coordinates.
  3068. * @returns a string containing all the vector values
  3069. */
  3070. toString(): string;
  3071. /**
  3072. * Returns the string "Vector4".
  3073. * @returns "Vector4"
  3074. */
  3075. getClassName(): string;
  3076. /**
  3077. * Returns the Vector4 hash code.
  3078. * @returns a unique hash code
  3079. */
  3080. getHashCode(): number;
  3081. /**
  3082. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3083. * @returns the resulting array
  3084. */
  3085. asArray(): number[];
  3086. /**
  3087. * Populates the given array from the given index with the Vector4 coordinates.
  3088. * @param array array to populate
  3089. * @param index index of the array to start at (default: 0)
  3090. * @returns the Vector4.
  3091. */
  3092. toArray(array: FloatArray, index?: number): Vector4;
  3093. /**
  3094. * Adds the given vector to the current Vector4.
  3095. * @param otherVector the vector to add
  3096. * @returns the updated Vector4.
  3097. */
  3098. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3099. /**
  3100. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3101. * @param otherVector the vector to add
  3102. * @returns the resulting vector
  3103. */
  3104. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3105. /**
  3106. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3107. * @param otherVector the vector to add
  3108. * @param result the vector to store the result
  3109. * @returns the current Vector4.
  3110. */
  3111. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3112. /**
  3113. * Subtract in place the given vector from the current Vector4.
  3114. * @param otherVector the vector to subtract
  3115. * @returns the updated Vector4.
  3116. */
  3117. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3118. /**
  3119. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3120. * @param otherVector the vector to add
  3121. * @returns the new vector with the result
  3122. */
  3123. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3124. /**
  3125. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3126. * @param otherVector the vector to subtract
  3127. * @param result the vector to store the result
  3128. * @returns the current Vector4.
  3129. */
  3130. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3131. /**
  3132. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3133. */
  3134. /**
  3135. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3136. * @param x value to subtract
  3137. * @param y value to subtract
  3138. * @param z value to subtract
  3139. * @param w value to subtract
  3140. * @returns new vector containing the result
  3141. */
  3142. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3143. /**
  3144. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3145. * @param x value to subtract
  3146. * @param y value to subtract
  3147. * @param z value to subtract
  3148. * @param w value to subtract
  3149. * @param result the vector to store the result in
  3150. * @returns the current Vector4.
  3151. */
  3152. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3153. /**
  3154. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3155. * @returns a new vector with the negated values
  3156. */
  3157. negate(): Vector4;
  3158. /**
  3159. * Negate this vector in place
  3160. * @returns this
  3161. */
  3162. negateInPlace(): Vector4;
  3163. /**
  3164. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3165. * @param result defines the Vector3 object where to store the result
  3166. * @returns the current Vector4
  3167. */
  3168. negateToRef(result: Vector4): Vector4;
  3169. /**
  3170. * Multiplies the current Vector4 coordinates by scale (float).
  3171. * @param scale the number to scale with
  3172. * @returns the updated Vector4.
  3173. */
  3174. scaleInPlace(scale: number): Vector4;
  3175. /**
  3176. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3177. * @param scale the number to scale with
  3178. * @returns a new vector with the result
  3179. */
  3180. scale(scale: number): Vector4;
  3181. /**
  3182. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3183. * @param scale the number to scale with
  3184. * @param result a vector to store the result in
  3185. * @returns the current Vector4.
  3186. */
  3187. scaleToRef(scale: number, result: Vector4): Vector4;
  3188. /**
  3189. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3190. * @param scale defines the scale factor
  3191. * @param result defines the Vector4 object where to store the result
  3192. * @returns the unmodified current Vector4
  3193. */
  3194. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3195. /**
  3196. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3197. * @param otherVector the vector to compare against
  3198. * @returns true if they are equal
  3199. */
  3200. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3201. /**
  3202. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3203. * @param otherVector vector to compare against
  3204. * @param epsilon (Default: very small number)
  3205. * @returns true if they are equal
  3206. */
  3207. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3208. /**
  3209. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3210. * @param x x value to compare against
  3211. * @param y y value to compare against
  3212. * @param z z value to compare against
  3213. * @param w w value to compare against
  3214. * @returns true if equal
  3215. */
  3216. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3217. /**
  3218. * Multiplies in place the current Vector4 by the given one.
  3219. * @param otherVector vector to multiple with
  3220. * @returns the updated Vector4.
  3221. */
  3222. multiplyInPlace(otherVector: Vector4): Vector4;
  3223. /**
  3224. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3225. * @param otherVector vector to multiple with
  3226. * @returns resulting new vector
  3227. */
  3228. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3229. /**
  3230. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3231. * @param otherVector vector to multiple with
  3232. * @param result vector to store the result
  3233. * @returns the current Vector4.
  3234. */
  3235. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3236. /**
  3237. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3238. * @param x x value multiply with
  3239. * @param y y value multiply with
  3240. * @param z z value multiply with
  3241. * @param w w value multiply with
  3242. * @returns resulting new vector
  3243. */
  3244. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3245. /**
  3246. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3247. * @param otherVector vector to devide with
  3248. * @returns resulting new vector
  3249. */
  3250. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3251. /**
  3252. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3253. * @param otherVector vector to devide with
  3254. * @param result vector to store the result
  3255. * @returns the current Vector4.
  3256. */
  3257. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3258. /**
  3259. * Divides the current Vector3 coordinates by the given ones.
  3260. * @param otherVector vector to devide with
  3261. * @returns the updated Vector3.
  3262. */
  3263. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3264. /**
  3265. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3266. * @param other defines the second operand
  3267. * @returns the current updated Vector4
  3268. */
  3269. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3270. /**
  3271. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3272. * @param other defines the second operand
  3273. * @returns the current updated Vector4
  3274. */
  3275. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3276. /**
  3277. * Gets a new Vector4 from current Vector4 floored values
  3278. * @returns a new Vector4
  3279. */
  3280. floor(): Vector4;
  3281. /**
  3282. * Gets a new Vector4 from current Vector3 floored values
  3283. * @returns a new Vector4
  3284. */
  3285. fract(): Vector4;
  3286. /**
  3287. * Returns the Vector4 length (float).
  3288. * @returns the length
  3289. */
  3290. length(): number;
  3291. /**
  3292. * Returns the Vector4 squared length (float).
  3293. * @returns the length squared
  3294. */
  3295. lengthSquared(): number;
  3296. /**
  3297. * Normalizes in place the Vector4.
  3298. * @returns the updated Vector4.
  3299. */
  3300. normalize(): Vector4;
  3301. /**
  3302. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3303. * @returns this converted to a new vector3
  3304. */
  3305. toVector3(): Vector3;
  3306. /**
  3307. * Returns a new Vector4 copied from the current one.
  3308. * @returns the new cloned vector
  3309. */
  3310. clone(): Vector4;
  3311. /**
  3312. * Updates the current Vector4 with the given one coordinates.
  3313. * @param source the source vector to copy from
  3314. * @returns the updated Vector4.
  3315. */
  3316. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3317. /**
  3318. * Updates the current Vector4 coordinates with the given floats.
  3319. * @param x float to copy from
  3320. * @param y float to copy from
  3321. * @param z float to copy from
  3322. * @param w float to copy from
  3323. * @returns the updated Vector4.
  3324. */
  3325. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3326. /**
  3327. * Updates the current Vector4 coordinates with the given floats.
  3328. * @param x float to set from
  3329. * @param y float to set from
  3330. * @param z float to set from
  3331. * @param w float to set from
  3332. * @returns the updated Vector4.
  3333. */
  3334. set(x: number, y: number, z: number, w: number): Vector4;
  3335. /**
  3336. * Copies the given float to the current Vector3 coordinates
  3337. * @param v defines the x, y, z and w coordinates of the operand
  3338. * @returns the current updated Vector3
  3339. */
  3340. setAll(v: number): Vector4;
  3341. /**
  3342. * Returns a new Vector4 set from the starting index of the given array.
  3343. * @param array the array to pull values from
  3344. * @param offset the offset into the array to start at
  3345. * @returns the new vector
  3346. */
  3347. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3348. /**
  3349. * Updates the given vector "result" from the starting index of the given array.
  3350. * @param array the array to pull values from
  3351. * @param offset the offset into the array to start at
  3352. * @param result the vector to store the result in
  3353. */
  3354. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3355. /**
  3356. * Updates the given vector "result" from the starting index of the given Float32Array.
  3357. * @param array the array to pull values from
  3358. * @param offset the offset into the array to start at
  3359. * @param result the vector to store the result in
  3360. */
  3361. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3362. /**
  3363. * Updates the given vector "result" coordinates from the given floats.
  3364. * @param x float to set from
  3365. * @param y float to set from
  3366. * @param z float to set from
  3367. * @param w float to set from
  3368. * @param result the vector to the floats in
  3369. */
  3370. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3371. /**
  3372. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3373. * @returns the new vector
  3374. */
  3375. static Zero(): Vector4;
  3376. /**
  3377. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3378. * @returns the new vector
  3379. */
  3380. static One(): Vector4;
  3381. /**
  3382. * Returns a new normalized Vector4 from the given one.
  3383. * @param vector the vector to normalize
  3384. * @returns the vector
  3385. */
  3386. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3387. /**
  3388. * Updates the given vector "result" from the normalization of the given one.
  3389. * @param vector the vector to normalize
  3390. * @param result the vector to store the result in
  3391. */
  3392. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3393. /**
  3394. * Returns a vector with the minimum values from the left and right vectors
  3395. * @param left left vector to minimize
  3396. * @param right right vector to minimize
  3397. * @returns a new vector with the minimum of the left and right vector values
  3398. */
  3399. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3400. /**
  3401. * Returns a vector with the maximum values from the left and right vectors
  3402. * @param left left vector to maximize
  3403. * @param right right vector to maximize
  3404. * @returns a new vector with the maximum of the left and right vector values
  3405. */
  3406. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3407. /**
  3408. * Returns the distance (float) between the vectors "value1" and "value2".
  3409. * @param value1 value to calulate the distance between
  3410. * @param value2 value to calulate the distance between
  3411. * @return the distance between the two vectors
  3412. */
  3413. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3414. /**
  3415. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3416. * @param value1 value to calulate the distance between
  3417. * @param value2 value to calulate the distance between
  3418. * @return the distance between the two vectors squared
  3419. */
  3420. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3421. /**
  3422. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3423. * @param value1 value to calulate the center between
  3424. * @param value2 value to calulate the center between
  3425. * @return the center between the two vectors
  3426. */
  3427. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3428. /**
  3429. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3430. * This methods computes transformed normalized direction vectors only.
  3431. * @param vector the vector to transform
  3432. * @param transformation the transformation matrix to apply
  3433. * @returns the new vector
  3434. */
  3435. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3436. /**
  3437. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3438. * This methods computes transformed normalized direction vectors only.
  3439. * @param vector the vector to transform
  3440. * @param transformation the transformation matrix to apply
  3441. * @param result the vector to store the result in
  3442. */
  3443. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3444. /**
  3445. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3446. * This methods computes transformed normalized direction vectors only.
  3447. * @param x value to transform
  3448. * @param y value to transform
  3449. * @param z value to transform
  3450. * @param w value to transform
  3451. * @param transformation the transformation matrix to apply
  3452. * @param result the vector to store the results in
  3453. */
  3454. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3455. /**
  3456. * Creates a new Vector4 from a Vector3
  3457. * @param source defines the source data
  3458. * @param w defines the 4th component (default is 0)
  3459. * @returns a new Vector4
  3460. */
  3461. static FromVector3(source: Vector3, w?: number): Vector4;
  3462. }
  3463. /**
  3464. * Class used to store quaternion data
  3465. * @see https://en.wikipedia.org/wiki/Quaternion
  3466. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3467. */
  3468. export class Quaternion {
  3469. /** defines the first component (0 by default) */
  3470. x: number;
  3471. /** defines the second component (0 by default) */
  3472. y: number;
  3473. /** defines the third component (0 by default) */
  3474. z: number;
  3475. /** defines the fourth component (1.0 by default) */
  3476. w: number;
  3477. /**
  3478. * Creates a new Quaternion from the given floats
  3479. * @param x defines the first component (0 by default)
  3480. * @param y defines the second component (0 by default)
  3481. * @param z defines the third component (0 by default)
  3482. * @param w defines the fourth component (1.0 by default)
  3483. */
  3484. constructor(
  3485. /** defines the first component (0 by default) */
  3486. x?: number,
  3487. /** defines the second component (0 by default) */
  3488. y?: number,
  3489. /** defines the third component (0 by default) */
  3490. z?: number,
  3491. /** defines the fourth component (1.0 by default) */
  3492. w?: number);
  3493. /**
  3494. * Gets a string representation for the current quaternion
  3495. * @returns a string with the Quaternion coordinates
  3496. */
  3497. toString(): string;
  3498. /**
  3499. * Gets the class name of the quaternion
  3500. * @returns the string "Quaternion"
  3501. */
  3502. getClassName(): string;
  3503. /**
  3504. * Gets a hash code for this quaternion
  3505. * @returns the quaternion hash code
  3506. */
  3507. getHashCode(): number;
  3508. /**
  3509. * Copy the quaternion to an array
  3510. * @returns a new array populated with 4 elements from the quaternion coordinates
  3511. */
  3512. asArray(): number[];
  3513. /**
  3514. * Check if two quaternions are equals
  3515. * @param otherQuaternion defines the second operand
  3516. * @return true if the current quaternion and the given one coordinates are strictly equals
  3517. */
  3518. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3519. /**
  3520. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3521. * @param otherQuaternion defines the other quaternion
  3522. * @param epsilon defines the minimal distance to consider equality
  3523. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3524. */
  3525. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3526. /**
  3527. * Clone the current quaternion
  3528. * @returns a new quaternion copied from the current one
  3529. */
  3530. clone(): Quaternion;
  3531. /**
  3532. * Copy a quaternion to the current one
  3533. * @param other defines the other quaternion
  3534. * @returns the updated current quaternion
  3535. */
  3536. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3537. /**
  3538. * Updates the current quaternion with the given float coordinates
  3539. * @param x defines the x coordinate
  3540. * @param y defines the y coordinate
  3541. * @param z defines the z coordinate
  3542. * @param w defines the w coordinate
  3543. * @returns the updated current quaternion
  3544. */
  3545. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3546. /**
  3547. * Updates the current quaternion from the given float coordinates
  3548. * @param x defines the x coordinate
  3549. * @param y defines the y coordinate
  3550. * @param z defines the z coordinate
  3551. * @param w defines the w coordinate
  3552. * @returns the updated current quaternion
  3553. */
  3554. set(x: number, y: number, z: number, w: number): Quaternion;
  3555. /**
  3556. * Adds two quaternions
  3557. * @param other defines the second operand
  3558. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3559. */
  3560. add(other: DeepImmutable<Quaternion>): Quaternion;
  3561. /**
  3562. * Add a quaternion to the current one
  3563. * @param other defines the quaternion to add
  3564. * @returns the current quaternion
  3565. */
  3566. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3567. /**
  3568. * Subtract two quaternions
  3569. * @param other defines the second operand
  3570. * @returns a new quaternion as the subtraction result of the given one from the current one
  3571. */
  3572. subtract(other: Quaternion): Quaternion;
  3573. /**
  3574. * Multiplies the current quaternion by a scale factor
  3575. * @param value defines the scale factor
  3576. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3577. */
  3578. scale(value: number): Quaternion;
  3579. /**
  3580. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3581. * @param scale defines the scale factor
  3582. * @param result defines the Quaternion object where to store the result
  3583. * @returns the unmodified current quaternion
  3584. */
  3585. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3586. /**
  3587. * Multiplies in place the current quaternion by a scale factor
  3588. * @param value defines the scale factor
  3589. * @returns the current modified quaternion
  3590. */
  3591. scaleInPlace(value: number): Quaternion;
  3592. /**
  3593. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3594. * @param scale defines the scale factor
  3595. * @param result defines the Quaternion object where to store the result
  3596. * @returns the unmodified current quaternion
  3597. */
  3598. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3599. /**
  3600. * Multiplies two quaternions
  3601. * @param q1 defines the second operand
  3602. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3603. */
  3604. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3605. /**
  3606. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3607. * @param q1 defines the second operand
  3608. * @param result defines the target quaternion
  3609. * @returns the current quaternion
  3610. */
  3611. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3612. /**
  3613. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3614. * @param q1 defines the second operand
  3615. * @returns the currentupdated quaternion
  3616. */
  3617. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3618. /**
  3619. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3620. * @param ref defines the target quaternion
  3621. * @returns the current quaternion
  3622. */
  3623. conjugateToRef(ref: Quaternion): Quaternion;
  3624. /**
  3625. * Conjugates in place (1-q) the current quaternion
  3626. * @returns the current updated quaternion
  3627. */
  3628. conjugateInPlace(): Quaternion;
  3629. /**
  3630. * Conjugates in place (1-q) the current quaternion
  3631. * @returns a new quaternion
  3632. */
  3633. conjugate(): Quaternion;
  3634. /**
  3635. * Gets length of current quaternion
  3636. * @returns the quaternion length (float)
  3637. */
  3638. length(): number;
  3639. /**
  3640. * Normalize in place the current quaternion
  3641. * @returns the current updated quaternion
  3642. */
  3643. normalize(): Quaternion;
  3644. /**
  3645. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3646. * @param order is a reserved parameter and is ignore for now
  3647. * @returns a new Vector3 containing the Euler angles
  3648. */
  3649. toEulerAngles(order?: string): Vector3;
  3650. /**
  3651. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3652. * @param result defines the vector which will be filled with the Euler angles
  3653. * @param order is a reserved parameter and is ignore for now
  3654. * @returns the current unchanged quaternion
  3655. */
  3656. toEulerAnglesToRef(result: Vector3): Quaternion;
  3657. /**
  3658. * Updates the given rotation matrix with the current quaternion values
  3659. * @param result defines the target matrix
  3660. * @returns the current unchanged quaternion
  3661. */
  3662. toRotationMatrix(result: Matrix): Quaternion;
  3663. /**
  3664. * Updates the current quaternion from the given rotation matrix values
  3665. * @param matrix defines the source matrix
  3666. * @returns the current updated quaternion
  3667. */
  3668. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3669. /**
  3670. * Creates a new quaternion from a rotation matrix
  3671. * @param matrix defines the source matrix
  3672. * @returns a new quaternion created from the given rotation matrix values
  3673. */
  3674. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3675. /**
  3676. * Updates the given quaternion with the given rotation matrix values
  3677. * @param matrix defines the source matrix
  3678. * @param result defines the target quaternion
  3679. */
  3680. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3681. /**
  3682. * Returns the dot product (float) between the quaternions "left" and "right"
  3683. * @param left defines the left operand
  3684. * @param right defines the right operand
  3685. * @returns the dot product
  3686. */
  3687. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3688. /**
  3689. * Checks if the two quaternions are close to each other
  3690. * @param quat0 defines the first quaternion to check
  3691. * @param quat1 defines the second quaternion to check
  3692. * @returns true if the two quaternions are close to each other
  3693. */
  3694. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3695. /**
  3696. * Creates an empty quaternion
  3697. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3698. */
  3699. static Zero(): Quaternion;
  3700. /**
  3701. * Inverse a given quaternion
  3702. * @param q defines the source quaternion
  3703. * @returns a new quaternion as the inverted current quaternion
  3704. */
  3705. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3706. /**
  3707. * Inverse a given quaternion
  3708. * @param q defines the source quaternion
  3709. * @param result the quaternion the result will be stored in
  3710. * @returns the result quaternion
  3711. */
  3712. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3713. /**
  3714. * Creates an identity quaternion
  3715. * @returns the identity quaternion
  3716. */
  3717. static Identity(): Quaternion;
  3718. /**
  3719. * Gets a boolean indicating if the given quaternion is identity
  3720. * @param quaternion defines the quaternion to check
  3721. * @returns true if the quaternion is identity
  3722. */
  3723. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3724. /**
  3725. * Creates a quaternion from a rotation around an axis
  3726. * @param axis defines the axis to use
  3727. * @param angle defines the angle to use
  3728. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3729. */
  3730. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3731. /**
  3732. * Creates a rotation around an axis and stores it into the given quaternion
  3733. * @param axis defines the axis to use
  3734. * @param angle defines the angle to use
  3735. * @param result defines the target quaternion
  3736. * @returns the target quaternion
  3737. */
  3738. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3739. /**
  3740. * Creates a new quaternion from data stored into an array
  3741. * @param array defines the data source
  3742. * @param offset defines the offset in the source array where the data starts
  3743. * @returns a new quaternion
  3744. */
  3745. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3746. /**
  3747. * Create a quaternion from Euler rotation angles
  3748. * @param x Pitch
  3749. * @param y Yaw
  3750. * @param z Roll
  3751. * @returns the new Quaternion
  3752. */
  3753. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3754. /**
  3755. * Updates a quaternion from Euler rotation angles
  3756. * @param x Pitch
  3757. * @param y Yaw
  3758. * @param z Roll
  3759. * @param result the quaternion to store the result
  3760. * @returns the updated quaternion
  3761. */
  3762. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3763. /**
  3764. * Create a quaternion from Euler rotation vector
  3765. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3766. * @returns the new Quaternion
  3767. */
  3768. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3769. /**
  3770. * Updates a quaternion from Euler rotation vector
  3771. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3772. * @param result the quaternion to store the result
  3773. * @returns the updated quaternion
  3774. */
  3775. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3776. /**
  3777. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3778. * @param yaw defines the rotation around Y axis
  3779. * @param pitch defines the rotation around X axis
  3780. * @param roll defines the rotation around Z axis
  3781. * @returns the new quaternion
  3782. */
  3783. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3784. /**
  3785. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3786. * @param yaw defines the rotation around Y axis
  3787. * @param pitch defines the rotation around X axis
  3788. * @param roll defines the rotation around Z axis
  3789. * @param result defines the target quaternion
  3790. */
  3791. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3792. /**
  3793. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3794. * @param alpha defines the rotation around first axis
  3795. * @param beta defines the rotation around second axis
  3796. * @param gamma defines the rotation around third axis
  3797. * @returns the new quaternion
  3798. */
  3799. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3800. /**
  3801. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3802. * @param alpha defines the rotation around first axis
  3803. * @param beta defines the rotation around second axis
  3804. * @param gamma defines the rotation around third axis
  3805. * @param result defines the target quaternion
  3806. */
  3807. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3808. /**
  3809. * 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)
  3810. * @param axis1 defines the first axis
  3811. * @param axis2 defines the second axis
  3812. * @param axis3 defines the third axis
  3813. * @returns the new quaternion
  3814. */
  3815. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3816. /**
  3817. * 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
  3818. * @param axis1 defines the first axis
  3819. * @param axis2 defines the second axis
  3820. * @param axis3 defines the third axis
  3821. * @param ref defines the target quaternion
  3822. */
  3823. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3824. /**
  3825. * Interpolates between two quaternions
  3826. * @param left defines first quaternion
  3827. * @param right defines second quaternion
  3828. * @param amount defines the gradient to use
  3829. * @returns the new interpolated quaternion
  3830. */
  3831. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3832. /**
  3833. * Interpolates between two quaternions and stores it into a target quaternion
  3834. * @param left defines first quaternion
  3835. * @param right defines second quaternion
  3836. * @param amount defines the gradient to use
  3837. * @param result defines the target quaternion
  3838. */
  3839. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3840. /**
  3841. * Interpolate between two quaternions using Hermite interpolation
  3842. * @param value1 defines first quaternion
  3843. * @param tangent1 defines the incoming tangent
  3844. * @param value2 defines second quaternion
  3845. * @param tangent2 defines the outgoing tangent
  3846. * @param amount defines the target quaternion
  3847. * @returns the new interpolated quaternion
  3848. */
  3849. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3850. }
  3851. /**
  3852. * Class used to store matrix data (4x4)
  3853. */
  3854. export class Matrix {
  3855. private static _updateFlagSeed;
  3856. private static _identityReadOnly;
  3857. private _isIdentity;
  3858. private _isIdentityDirty;
  3859. private _isIdentity3x2;
  3860. private _isIdentity3x2Dirty;
  3861. /**
  3862. * Gets the update flag of the matrix which is an unique number for the matrix.
  3863. * It will be incremented every time the matrix data change.
  3864. * You can use it to speed the comparison between two versions of the same matrix.
  3865. */
  3866. updateFlag: number;
  3867. private readonly _m;
  3868. /**
  3869. * Gets the internal data of the matrix
  3870. */
  3871. get m(): DeepImmutable<Float32Array>;
  3872. /** @hidden */
  3873. _markAsUpdated(): void;
  3874. /** @hidden */
  3875. private _updateIdentityStatus;
  3876. /**
  3877. * Creates an empty matrix (filled with zeros)
  3878. */
  3879. constructor();
  3880. /**
  3881. * Check if the current matrix is identity
  3882. * @returns true is the matrix is the identity matrix
  3883. */
  3884. isIdentity(): boolean;
  3885. /**
  3886. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3887. * @returns true is the matrix is the identity matrix
  3888. */
  3889. isIdentityAs3x2(): boolean;
  3890. /**
  3891. * Gets the determinant of the matrix
  3892. * @returns the matrix determinant
  3893. */
  3894. determinant(): number;
  3895. /**
  3896. * Returns the matrix as a Float32Array
  3897. * @returns the matrix underlying array
  3898. */
  3899. toArray(): DeepImmutable<Float32Array>;
  3900. /**
  3901. * Returns the matrix as a Float32Array
  3902. * @returns the matrix underlying array.
  3903. */
  3904. asArray(): DeepImmutable<Float32Array>;
  3905. /**
  3906. * Inverts the current matrix in place
  3907. * @returns the current inverted matrix
  3908. */
  3909. invert(): Matrix;
  3910. /**
  3911. * Sets all the matrix elements to zero
  3912. * @returns the current matrix
  3913. */
  3914. reset(): Matrix;
  3915. /**
  3916. * Adds the current matrix with a second one
  3917. * @param other defines the matrix to add
  3918. * @returns a new matrix as the addition of the current matrix and the given one
  3919. */
  3920. add(other: DeepImmutable<Matrix>): Matrix;
  3921. /**
  3922. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3923. * @param other defines the matrix to add
  3924. * @param result defines the target matrix
  3925. * @returns the current matrix
  3926. */
  3927. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3928. /**
  3929. * Adds in place the given matrix to the current matrix
  3930. * @param other defines the second operand
  3931. * @returns the current updated matrix
  3932. */
  3933. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3934. /**
  3935. * Sets the given matrix to the current inverted Matrix
  3936. * @param other defines the target matrix
  3937. * @returns the unmodified current matrix
  3938. */
  3939. invertToRef(other: Matrix): Matrix;
  3940. /**
  3941. * add a value at the specified position in the current Matrix
  3942. * @param index the index of the value within the matrix. between 0 and 15.
  3943. * @param value the value to be added
  3944. * @returns the current updated matrix
  3945. */
  3946. addAtIndex(index: number, value: number): Matrix;
  3947. /**
  3948. * mutiply the specified position in the current Matrix by a value
  3949. * @param index the index of the value within the matrix. between 0 and 15.
  3950. * @param value the value to be added
  3951. * @returns the current updated matrix
  3952. */
  3953. multiplyAtIndex(index: number, value: number): Matrix;
  3954. /**
  3955. * Inserts the translation vector (using 3 floats) in the current matrix
  3956. * @param x defines the 1st component of the translation
  3957. * @param y defines the 2nd component of the translation
  3958. * @param z defines the 3rd component of the translation
  3959. * @returns the current updated matrix
  3960. */
  3961. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3962. /**
  3963. * Adds the translation vector (using 3 floats) in the current matrix
  3964. * @param x defines the 1st component of the translation
  3965. * @param y defines the 2nd component of the translation
  3966. * @param z defines the 3rd component of the translation
  3967. * @returns the current updated matrix
  3968. */
  3969. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3970. /**
  3971. * Inserts the translation vector in the current matrix
  3972. * @param vector3 defines the translation to insert
  3973. * @returns the current updated matrix
  3974. */
  3975. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3976. /**
  3977. * Gets the translation value of the current matrix
  3978. * @returns a new Vector3 as the extracted translation from the matrix
  3979. */
  3980. getTranslation(): Vector3;
  3981. /**
  3982. * Fill a Vector3 with the extracted translation from the matrix
  3983. * @param result defines the Vector3 where to store the translation
  3984. * @returns the current matrix
  3985. */
  3986. getTranslationToRef(result: Vector3): Matrix;
  3987. /**
  3988. * Remove rotation and scaling part from the matrix
  3989. * @returns the updated matrix
  3990. */
  3991. removeRotationAndScaling(): Matrix;
  3992. /**
  3993. * Multiply two matrices
  3994. * @param other defines the second operand
  3995. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3996. */
  3997. multiply(other: DeepImmutable<Matrix>): Matrix;
  3998. /**
  3999. * Copy the current matrix from the given one
  4000. * @param other defines the source matrix
  4001. * @returns the current updated matrix
  4002. */
  4003. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4004. /**
  4005. * Populates the given array from the starting index with the current matrix values
  4006. * @param array defines the target array
  4007. * @param offset defines the offset in the target array where to start storing values
  4008. * @returns the current matrix
  4009. */
  4010. copyToArray(array: Float32Array, offset?: number): Matrix;
  4011. /**
  4012. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4013. * @param other defines the second operand
  4014. * @param result defines the matrix where to store the multiplication
  4015. * @returns the current matrix
  4016. */
  4017. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4018. /**
  4019. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4020. * @param other defines the second operand
  4021. * @param result defines the array where to store the multiplication
  4022. * @param offset defines the offset in the target array where to start storing values
  4023. * @returns the current matrix
  4024. */
  4025. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4026. /**
  4027. * Check equality between this matrix and a second one
  4028. * @param value defines the second matrix to compare
  4029. * @returns true is the current matrix and the given one values are strictly equal
  4030. */
  4031. equals(value: DeepImmutable<Matrix>): boolean;
  4032. /**
  4033. * Clone the current matrix
  4034. * @returns a new matrix from the current matrix
  4035. */
  4036. clone(): Matrix;
  4037. /**
  4038. * Returns the name of the current matrix class
  4039. * @returns the string "Matrix"
  4040. */
  4041. getClassName(): string;
  4042. /**
  4043. * Gets the hash code of the current matrix
  4044. * @returns the hash code
  4045. */
  4046. getHashCode(): number;
  4047. /**
  4048. * Decomposes the current Matrix into a translation, rotation and scaling components
  4049. * @param scale defines the scale vector3 given as a reference to update
  4050. * @param rotation defines the rotation quaternion given as a reference to update
  4051. * @param translation defines the translation vector3 given as a reference to update
  4052. * @returns true if operation was successful
  4053. */
  4054. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4055. /**
  4056. * Gets specific row of the matrix
  4057. * @param index defines the number of the row to get
  4058. * @returns the index-th row of the current matrix as a new Vector4
  4059. */
  4060. getRow(index: number): Nullable<Vector4>;
  4061. /**
  4062. * Sets the index-th row of the current matrix to the vector4 values
  4063. * @param index defines the number of the row to set
  4064. * @param row defines the target vector4
  4065. * @returns the updated current matrix
  4066. */
  4067. setRow(index: number, row: Vector4): Matrix;
  4068. /**
  4069. * Compute the transpose of the matrix
  4070. * @returns the new transposed matrix
  4071. */
  4072. transpose(): Matrix;
  4073. /**
  4074. * Compute the transpose of the matrix and store it in a given matrix
  4075. * @param result defines the target matrix
  4076. * @returns the current matrix
  4077. */
  4078. transposeToRef(result: Matrix): Matrix;
  4079. /**
  4080. * Sets the index-th row of the current matrix with the given 4 x float values
  4081. * @param index defines the row index
  4082. * @param x defines the x component to set
  4083. * @param y defines the y component to set
  4084. * @param z defines the z component to set
  4085. * @param w defines the w component to set
  4086. * @returns the updated current matrix
  4087. */
  4088. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4089. /**
  4090. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4091. * @param scale defines the scale factor
  4092. * @returns a new matrix
  4093. */
  4094. scale(scale: number): Matrix;
  4095. /**
  4096. * Scale the current matrix values by a factor to a given result matrix
  4097. * @param scale defines the scale factor
  4098. * @param result defines the matrix to store the result
  4099. * @returns the current matrix
  4100. */
  4101. scaleToRef(scale: number, result: Matrix): Matrix;
  4102. /**
  4103. * Scale the current matrix values by a factor and add the result to a given matrix
  4104. * @param scale defines the scale factor
  4105. * @param result defines the Matrix to store the result
  4106. * @returns the current matrix
  4107. */
  4108. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4109. /**
  4110. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4111. * @param ref matrix to store the result
  4112. */
  4113. toNormalMatrix(ref: Matrix): void;
  4114. /**
  4115. * Gets only rotation part of the current matrix
  4116. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4117. */
  4118. getRotationMatrix(): Matrix;
  4119. /**
  4120. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4121. * @param result defines the target matrix to store data to
  4122. * @returns the current matrix
  4123. */
  4124. getRotationMatrixToRef(result: Matrix): Matrix;
  4125. /**
  4126. * Toggles model matrix from being right handed to left handed in place and vice versa
  4127. */
  4128. toggleModelMatrixHandInPlace(): void;
  4129. /**
  4130. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4131. */
  4132. toggleProjectionMatrixHandInPlace(): void;
  4133. /**
  4134. * Creates a matrix from an array
  4135. * @param array defines the source array
  4136. * @param offset defines an offset in the source array
  4137. * @returns a new Matrix set from the starting index of the given array
  4138. */
  4139. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4140. /**
  4141. * Copy the content of an array into a given matrix
  4142. * @param array defines the source array
  4143. * @param offset defines an offset in the source array
  4144. * @param result defines the target matrix
  4145. */
  4146. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4147. /**
  4148. * Stores an array into a matrix after having multiplied each component by a given factor
  4149. * @param array defines the source array
  4150. * @param offset defines the offset in the source array
  4151. * @param scale defines the scaling factor
  4152. * @param result defines the target matrix
  4153. */
  4154. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4155. /**
  4156. * Gets an identity matrix that must not be updated
  4157. */
  4158. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4159. /**
  4160. * Stores a list of values (16) inside a given matrix
  4161. * @param initialM11 defines 1st value of 1st row
  4162. * @param initialM12 defines 2nd value of 1st row
  4163. * @param initialM13 defines 3rd value of 1st row
  4164. * @param initialM14 defines 4th value of 1st row
  4165. * @param initialM21 defines 1st value of 2nd row
  4166. * @param initialM22 defines 2nd value of 2nd row
  4167. * @param initialM23 defines 3rd value of 2nd row
  4168. * @param initialM24 defines 4th value of 2nd row
  4169. * @param initialM31 defines 1st value of 3rd row
  4170. * @param initialM32 defines 2nd value of 3rd row
  4171. * @param initialM33 defines 3rd value of 3rd row
  4172. * @param initialM34 defines 4th value of 3rd row
  4173. * @param initialM41 defines 1st value of 4th row
  4174. * @param initialM42 defines 2nd value of 4th row
  4175. * @param initialM43 defines 3rd value of 4th row
  4176. * @param initialM44 defines 4th value of 4th row
  4177. * @param result defines the target matrix
  4178. */
  4179. 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;
  4180. /**
  4181. * Creates new matrix from a list of values (16)
  4182. * @param initialM11 defines 1st value of 1st row
  4183. * @param initialM12 defines 2nd value of 1st row
  4184. * @param initialM13 defines 3rd value of 1st row
  4185. * @param initialM14 defines 4th value of 1st row
  4186. * @param initialM21 defines 1st value of 2nd row
  4187. * @param initialM22 defines 2nd value of 2nd row
  4188. * @param initialM23 defines 3rd value of 2nd row
  4189. * @param initialM24 defines 4th value of 2nd row
  4190. * @param initialM31 defines 1st value of 3rd row
  4191. * @param initialM32 defines 2nd value of 3rd row
  4192. * @param initialM33 defines 3rd value of 3rd row
  4193. * @param initialM34 defines 4th value of 3rd row
  4194. * @param initialM41 defines 1st value of 4th row
  4195. * @param initialM42 defines 2nd value of 4th row
  4196. * @param initialM43 defines 3rd value of 4th row
  4197. * @param initialM44 defines 4th value of 4th row
  4198. * @returns the new matrix
  4199. */
  4200. 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;
  4201. /**
  4202. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4203. * @param scale defines the scale vector3
  4204. * @param rotation defines the rotation quaternion
  4205. * @param translation defines the translation vector3
  4206. * @returns a new matrix
  4207. */
  4208. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4209. /**
  4210. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4211. * @param scale defines the scale vector3
  4212. * @param rotation defines the rotation quaternion
  4213. * @param translation defines the translation vector3
  4214. * @param result defines the target matrix
  4215. */
  4216. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4217. /**
  4218. * Creates a new identity matrix
  4219. * @returns a new identity matrix
  4220. */
  4221. static Identity(): Matrix;
  4222. /**
  4223. * Creates a new identity matrix and stores the result in a given matrix
  4224. * @param result defines the target matrix
  4225. */
  4226. static IdentityToRef(result: Matrix): void;
  4227. /**
  4228. * Creates a new zero matrix
  4229. * @returns a new zero matrix
  4230. */
  4231. static Zero(): Matrix;
  4232. /**
  4233. * Creates a new rotation matrix for "angle" radians around the X axis
  4234. * @param angle defines the angle (in radians) to use
  4235. * @return the new matrix
  4236. */
  4237. static RotationX(angle: number): Matrix;
  4238. /**
  4239. * Creates a new matrix as the invert of a given matrix
  4240. * @param source defines the source matrix
  4241. * @returns the new matrix
  4242. */
  4243. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4244. /**
  4245. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4246. * @param angle defines the angle (in radians) to use
  4247. * @param result defines the target matrix
  4248. */
  4249. static RotationXToRef(angle: number, result: Matrix): void;
  4250. /**
  4251. * Creates a new rotation matrix for "angle" radians around the Y axis
  4252. * @param angle defines the angle (in radians) to use
  4253. * @return the new matrix
  4254. */
  4255. static RotationY(angle: number): Matrix;
  4256. /**
  4257. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4258. * @param angle defines the angle (in radians) to use
  4259. * @param result defines the target matrix
  4260. */
  4261. static RotationYToRef(angle: number, result: Matrix): void;
  4262. /**
  4263. * Creates a new rotation matrix for "angle" radians around the Z axis
  4264. * @param angle defines the angle (in radians) to use
  4265. * @return the new matrix
  4266. */
  4267. static RotationZ(angle: number): Matrix;
  4268. /**
  4269. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4270. * @param angle defines the angle (in radians) to use
  4271. * @param result defines the target matrix
  4272. */
  4273. static RotationZToRef(angle: number, result: Matrix): void;
  4274. /**
  4275. * Creates a new rotation matrix for "angle" radians around the given axis
  4276. * @param axis defines the axis to use
  4277. * @param angle defines the angle (in radians) to use
  4278. * @return the new matrix
  4279. */
  4280. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4281. /**
  4282. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4283. * @param axis defines the axis to use
  4284. * @param angle defines the angle (in radians) to use
  4285. * @param result defines the target matrix
  4286. */
  4287. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4288. /**
  4289. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4290. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4291. * @param from defines the vector to align
  4292. * @param to defines the vector to align to
  4293. * @param result defines the target matrix
  4294. */
  4295. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4296. /**
  4297. * Creates a rotation matrix
  4298. * @param yaw defines the yaw angle in radians (Y axis)
  4299. * @param pitch defines the pitch angle in radians (X axis)
  4300. * @param roll defines the roll angle in radians (X axis)
  4301. * @returns the new rotation matrix
  4302. */
  4303. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4304. /**
  4305. * Creates a rotation matrix and stores it in a given matrix
  4306. * @param yaw defines the yaw angle in radians (Y axis)
  4307. * @param pitch defines the pitch angle in radians (X axis)
  4308. * @param roll defines the roll angle in radians (X axis)
  4309. * @param result defines the target matrix
  4310. */
  4311. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4312. /**
  4313. * Creates a scaling matrix
  4314. * @param x defines the scale factor on X axis
  4315. * @param y defines the scale factor on Y axis
  4316. * @param z defines the scale factor on Z axis
  4317. * @returns the new matrix
  4318. */
  4319. static Scaling(x: number, y: number, z: number): Matrix;
  4320. /**
  4321. * Creates a scaling matrix and stores it in a given matrix
  4322. * @param x defines the scale factor on X axis
  4323. * @param y defines the scale factor on Y axis
  4324. * @param z defines the scale factor on Z axis
  4325. * @param result defines the target matrix
  4326. */
  4327. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4328. /**
  4329. * Creates a translation matrix
  4330. * @param x defines the translation on X axis
  4331. * @param y defines the translation on Y axis
  4332. * @param z defines the translationon Z axis
  4333. * @returns the new matrix
  4334. */
  4335. static Translation(x: number, y: number, z: number): Matrix;
  4336. /**
  4337. * Creates a translation matrix and stores it in a given matrix
  4338. * @param x defines the translation on X axis
  4339. * @param y defines the translation on Y axis
  4340. * @param z defines the translationon Z axis
  4341. * @param result defines the target matrix
  4342. */
  4343. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4344. /**
  4345. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4346. * @param startValue defines the start value
  4347. * @param endValue defines the end value
  4348. * @param gradient defines the gradient factor
  4349. * @returns the new matrix
  4350. */
  4351. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4352. /**
  4353. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4354. * @param startValue defines the start value
  4355. * @param endValue defines the end value
  4356. * @param gradient defines the gradient factor
  4357. * @param result defines the Matrix object where to store data
  4358. */
  4359. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4360. /**
  4361. * Builds a new matrix whose values are computed by:
  4362. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4363. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4364. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4365. * @param startValue defines the first matrix
  4366. * @param endValue defines the second matrix
  4367. * @param gradient defines the gradient between the two matrices
  4368. * @returns the new matrix
  4369. */
  4370. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4371. /**
  4372. * Update a matrix to values which are computed by:
  4373. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4374. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4375. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4376. * @param startValue defines the first matrix
  4377. * @param endValue defines the second matrix
  4378. * @param gradient defines the gradient between the two matrices
  4379. * @param result defines the target matrix
  4380. */
  4381. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4382. /**
  4383. * 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"
  4384. * This function works in left handed mode
  4385. * @param eye defines the final position of the entity
  4386. * @param target defines where the entity should look at
  4387. * @param up defines the up vector for the entity
  4388. * @returns the new matrix
  4389. */
  4390. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4391. /**
  4392. * 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".
  4393. * This function works in left handed mode
  4394. * @param eye defines the final position of the entity
  4395. * @param target defines where the entity should look at
  4396. * @param up defines the up vector for the entity
  4397. * @param result defines the target matrix
  4398. */
  4399. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4400. /**
  4401. * 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"
  4402. * This function works in right handed mode
  4403. * @param eye defines the final position of the entity
  4404. * @param target defines where the entity should look at
  4405. * @param up defines the up vector for the entity
  4406. * @returns the new matrix
  4407. */
  4408. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4409. /**
  4410. * 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".
  4411. * This function works in right handed mode
  4412. * @param eye defines the final position of the entity
  4413. * @param target defines where the entity should look at
  4414. * @param up defines the up vector for the entity
  4415. * @param result defines the target matrix
  4416. */
  4417. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4418. /**
  4419. * Create a left-handed orthographic projection matrix
  4420. * @param width defines the viewport width
  4421. * @param height defines the viewport height
  4422. * @param znear defines the near clip plane
  4423. * @param zfar defines the far clip plane
  4424. * @returns a new matrix as a left-handed orthographic projection matrix
  4425. */
  4426. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4427. /**
  4428. * Store a left-handed orthographic projection to a given matrix
  4429. * @param width defines the viewport width
  4430. * @param height defines the viewport height
  4431. * @param znear defines the near clip plane
  4432. * @param zfar defines the far clip plane
  4433. * @param result defines the target matrix
  4434. */
  4435. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4436. /**
  4437. * Create a left-handed orthographic projection matrix
  4438. * @param left defines the viewport left coordinate
  4439. * @param right defines the viewport right coordinate
  4440. * @param bottom defines the viewport bottom coordinate
  4441. * @param top defines the viewport top coordinate
  4442. * @param znear defines the near clip plane
  4443. * @param zfar defines the far clip plane
  4444. * @returns a new matrix as a left-handed orthographic projection matrix
  4445. */
  4446. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4447. /**
  4448. * Stores a left-handed orthographic projection into a given matrix
  4449. * @param left defines the viewport left coordinate
  4450. * @param right defines the viewport right coordinate
  4451. * @param bottom defines the viewport bottom coordinate
  4452. * @param top defines the viewport top coordinate
  4453. * @param znear defines the near clip plane
  4454. * @param zfar defines the far clip plane
  4455. * @param result defines the target matrix
  4456. */
  4457. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4458. /**
  4459. * Creates a right-handed orthographic projection matrix
  4460. * @param left defines the viewport left coordinate
  4461. * @param right defines the viewport right coordinate
  4462. * @param bottom defines the viewport bottom coordinate
  4463. * @param top defines the viewport top coordinate
  4464. * @param znear defines the near clip plane
  4465. * @param zfar defines the far clip plane
  4466. * @returns a new matrix as a right-handed orthographic projection matrix
  4467. */
  4468. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4469. /**
  4470. * Stores a right-handed orthographic projection into a given matrix
  4471. * @param left defines the viewport left coordinate
  4472. * @param right defines the viewport right coordinate
  4473. * @param bottom defines the viewport bottom coordinate
  4474. * @param top defines the viewport top coordinate
  4475. * @param znear defines the near clip plane
  4476. * @param zfar defines the far clip plane
  4477. * @param result defines the target matrix
  4478. */
  4479. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4480. /**
  4481. * Creates a left-handed perspective projection matrix
  4482. * @param width defines the viewport width
  4483. * @param height defines the viewport height
  4484. * @param znear defines the near clip plane
  4485. * @param zfar defines the far clip plane
  4486. * @returns a new matrix as a left-handed perspective projection matrix
  4487. */
  4488. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4489. /**
  4490. * Creates a left-handed perspective projection matrix
  4491. * @param fov defines the horizontal field of view
  4492. * @param aspect defines the aspect ratio
  4493. * @param znear defines the near clip plane
  4494. * @param zfar defines the far clip plane
  4495. * @returns a new matrix as a left-handed perspective projection matrix
  4496. */
  4497. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4498. /**
  4499. * Stores a left-handed perspective projection into a given matrix
  4500. * @param fov defines the horizontal field of view
  4501. * @param aspect defines the aspect ratio
  4502. * @param znear defines the near clip plane
  4503. * @param zfar defines the far clip plane
  4504. * @param result defines the target matrix
  4505. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4506. */
  4507. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4508. /**
  4509. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4510. * @param fov defines the horizontal field of view
  4511. * @param aspect defines the aspect ratio
  4512. * @param znear defines the near clip plane
  4513. * @param zfar not used as infinity is used as far clip
  4514. * @param result defines the target matrix
  4515. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4516. */
  4517. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4518. /**
  4519. * Creates a right-handed perspective projection matrix
  4520. * @param fov defines the horizontal field of view
  4521. * @param aspect defines the aspect ratio
  4522. * @param znear defines the near clip plane
  4523. * @param zfar defines the far clip plane
  4524. * @returns a new matrix as a right-handed perspective projection matrix
  4525. */
  4526. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4527. /**
  4528. * Stores a right-handed perspective projection into a given matrix
  4529. * @param fov defines the horizontal field of view
  4530. * @param aspect defines the aspect ratio
  4531. * @param znear defines the near clip plane
  4532. * @param zfar defines the far clip plane
  4533. * @param result defines the target matrix
  4534. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4535. */
  4536. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4537. /**
  4538. * Stores a right-handed perspective projection into a given matrix
  4539. * @param fov defines the horizontal field of view
  4540. * @param aspect defines the aspect ratio
  4541. * @param znear defines the near clip plane
  4542. * @param zfar not used as infinity is used as far clip
  4543. * @param result defines the target matrix
  4544. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4545. */
  4546. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4547. /**
  4548. * Stores a perspective projection for WebVR info a given matrix
  4549. * @param fov defines the field of view
  4550. * @param znear defines the near clip plane
  4551. * @param zfar defines the far clip plane
  4552. * @param result defines the target matrix
  4553. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4554. */
  4555. static PerspectiveFovWebVRToRef(fov: {
  4556. upDegrees: number;
  4557. downDegrees: number;
  4558. leftDegrees: number;
  4559. rightDegrees: number;
  4560. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4561. /**
  4562. * Computes a complete transformation matrix
  4563. * @param viewport defines the viewport to use
  4564. * @param world defines the world matrix
  4565. * @param view defines the view matrix
  4566. * @param projection defines the projection matrix
  4567. * @param zmin defines the near clip plane
  4568. * @param zmax defines the far clip plane
  4569. * @returns the transformation matrix
  4570. */
  4571. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4572. /**
  4573. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4574. * @param matrix defines the matrix to use
  4575. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4576. */
  4577. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4578. /**
  4579. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4580. * @param matrix defines the matrix to use
  4581. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4582. */
  4583. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4584. /**
  4585. * Compute the transpose of a given matrix
  4586. * @param matrix defines the matrix to transpose
  4587. * @returns the new matrix
  4588. */
  4589. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4590. /**
  4591. * Compute the transpose of a matrix and store it in a target matrix
  4592. * @param matrix defines the matrix to transpose
  4593. * @param result defines the target matrix
  4594. */
  4595. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4596. /**
  4597. * Computes a reflection matrix from a plane
  4598. * @param plane defines the reflection plane
  4599. * @returns a new matrix
  4600. */
  4601. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4602. /**
  4603. * Computes a reflection matrix from a plane
  4604. * @param plane defines the reflection plane
  4605. * @param result defines the target matrix
  4606. */
  4607. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4608. /**
  4609. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4610. * @param xaxis defines the value of the 1st axis
  4611. * @param yaxis defines the value of the 2nd axis
  4612. * @param zaxis defines the value of the 3rd axis
  4613. * @param result defines the target matrix
  4614. */
  4615. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4616. /**
  4617. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4618. * @param quat defines the quaternion to use
  4619. * @param result defines the target matrix
  4620. */
  4621. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4622. }
  4623. /**
  4624. * @hidden
  4625. */
  4626. export class TmpVectors {
  4627. static Vector2: Vector2[];
  4628. static Vector3: Vector3[];
  4629. static Vector4: Vector4[];
  4630. static Quaternion: Quaternion[];
  4631. static Matrix: Matrix[];
  4632. }
  4633. }
  4634. declare module BABYLON {
  4635. /**
  4636. * Defines potential orientation for back face culling
  4637. */
  4638. export enum Orientation {
  4639. /**
  4640. * Clockwise
  4641. */
  4642. CW = 0,
  4643. /** Counter clockwise */
  4644. CCW = 1
  4645. }
  4646. /** Class used to represent a Bezier curve */
  4647. export class BezierCurve {
  4648. /**
  4649. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4650. * @param t defines the time
  4651. * @param x1 defines the left coordinate on X axis
  4652. * @param y1 defines the left coordinate on Y axis
  4653. * @param x2 defines the right coordinate on X axis
  4654. * @param y2 defines the right coordinate on Y axis
  4655. * @returns the interpolated value
  4656. */
  4657. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4658. }
  4659. /**
  4660. * Defines angle representation
  4661. */
  4662. export class Angle {
  4663. private _radians;
  4664. /**
  4665. * Creates an Angle object of "radians" radians (float).
  4666. * @param radians the angle in radians
  4667. */
  4668. constructor(radians: number);
  4669. /**
  4670. * Get value in degrees
  4671. * @returns the Angle value in degrees (float)
  4672. */
  4673. degrees(): number;
  4674. /**
  4675. * Get value in radians
  4676. * @returns the Angle value in radians (float)
  4677. */
  4678. radians(): number;
  4679. /**
  4680. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4681. * @param a defines first vector
  4682. * @param b defines second vector
  4683. * @returns a new Angle
  4684. */
  4685. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4686. /**
  4687. * Gets a new Angle object from the given float in radians
  4688. * @param radians defines the angle value in radians
  4689. * @returns a new Angle
  4690. */
  4691. static FromRadians(radians: number): Angle;
  4692. /**
  4693. * Gets a new Angle object from the given float in degrees
  4694. * @param degrees defines the angle value in degrees
  4695. * @returns a new Angle
  4696. */
  4697. static FromDegrees(degrees: number): Angle;
  4698. }
  4699. /**
  4700. * This represents an arc in a 2d space.
  4701. */
  4702. export class Arc2 {
  4703. /** Defines the start point of the arc */
  4704. startPoint: Vector2;
  4705. /** Defines the mid point of the arc */
  4706. midPoint: Vector2;
  4707. /** Defines the end point of the arc */
  4708. endPoint: Vector2;
  4709. /**
  4710. * Defines the center point of the arc.
  4711. */
  4712. centerPoint: Vector2;
  4713. /**
  4714. * Defines the radius of the arc.
  4715. */
  4716. radius: number;
  4717. /**
  4718. * Defines the angle of the arc (from mid point to end point).
  4719. */
  4720. angle: Angle;
  4721. /**
  4722. * Defines the start angle of the arc (from start point to middle point).
  4723. */
  4724. startAngle: Angle;
  4725. /**
  4726. * Defines the orientation of the arc (clock wise/counter clock wise).
  4727. */
  4728. orientation: Orientation;
  4729. /**
  4730. * Creates an Arc object from the three given points : start, middle and end.
  4731. * @param startPoint Defines the start point of the arc
  4732. * @param midPoint Defines the midlle point of the arc
  4733. * @param endPoint Defines the end point of the arc
  4734. */
  4735. constructor(
  4736. /** Defines the start point of the arc */
  4737. startPoint: Vector2,
  4738. /** Defines the mid point of the arc */
  4739. midPoint: Vector2,
  4740. /** Defines the end point of the arc */
  4741. endPoint: Vector2);
  4742. }
  4743. /**
  4744. * Represents a 2D path made up of multiple 2D points
  4745. */
  4746. export class Path2 {
  4747. private _points;
  4748. private _length;
  4749. /**
  4750. * If the path start and end point are the same
  4751. */
  4752. closed: boolean;
  4753. /**
  4754. * Creates a Path2 object from the starting 2D coordinates x and y.
  4755. * @param x the starting points x value
  4756. * @param y the starting points y value
  4757. */
  4758. constructor(x: number, y: number);
  4759. /**
  4760. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4761. * @param x the added points x value
  4762. * @param y the added points y value
  4763. * @returns the updated Path2.
  4764. */
  4765. addLineTo(x: number, y: number): Path2;
  4766. /**
  4767. * 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.
  4768. * @param midX middle point x value
  4769. * @param midY middle point y value
  4770. * @param endX end point x value
  4771. * @param endY end point y value
  4772. * @param numberOfSegments (default: 36)
  4773. * @returns the updated Path2.
  4774. */
  4775. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4776. /**
  4777. * Closes the Path2.
  4778. * @returns the Path2.
  4779. */
  4780. close(): Path2;
  4781. /**
  4782. * Gets the sum of the distance between each sequential point in the path
  4783. * @returns the Path2 total length (float).
  4784. */
  4785. length(): number;
  4786. /**
  4787. * Gets the points which construct the path
  4788. * @returns the Path2 internal array of points.
  4789. */
  4790. getPoints(): Vector2[];
  4791. /**
  4792. * Retreives the point at the distance aways from the starting point
  4793. * @param normalizedLengthPosition the length along the path to retreive the point from
  4794. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4795. */
  4796. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4797. /**
  4798. * Creates a new path starting from an x and y position
  4799. * @param x starting x value
  4800. * @param y starting y value
  4801. * @returns a new Path2 starting at the coordinates (x, y).
  4802. */
  4803. static StartingAt(x: number, y: number): Path2;
  4804. }
  4805. /**
  4806. * Represents a 3D path made up of multiple 3D points
  4807. */
  4808. export class Path3D {
  4809. /**
  4810. * an array of Vector3, the curve axis of the Path3D
  4811. */
  4812. path: Vector3[];
  4813. private _curve;
  4814. private _distances;
  4815. private _tangents;
  4816. private _normals;
  4817. private _binormals;
  4818. private _raw;
  4819. private _alignTangentsWithPath;
  4820. private readonly _pointAtData;
  4821. /**
  4822. * new Path3D(path, normal, raw)
  4823. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4824. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4825. * @param path an array of Vector3, the curve axis of the Path3D
  4826. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4827. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4828. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4829. */
  4830. constructor(
  4831. /**
  4832. * an array of Vector3, the curve axis of the Path3D
  4833. */
  4834. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4835. /**
  4836. * Returns the Path3D array of successive Vector3 designing its curve.
  4837. * @returns the Path3D array of successive Vector3 designing its curve.
  4838. */
  4839. getCurve(): Vector3[];
  4840. /**
  4841. * Returns the Path3D array of successive Vector3 designing its curve.
  4842. * @returns the Path3D array of successive Vector3 designing its curve.
  4843. */
  4844. getPoints(): Vector3[];
  4845. /**
  4846. * @returns the computed length (float) of the path.
  4847. */
  4848. length(): number;
  4849. /**
  4850. * Returns an array populated with tangent vectors on each Path3D curve point.
  4851. * @returns an array populated with tangent vectors on each Path3D curve point.
  4852. */
  4853. getTangents(): Vector3[];
  4854. /**
  4855. * Returns an array populated with normal vectors on each Path3D curve point.
  4856. * @returns an array populated with normal vectors on each Path3D curve point.
  4857. */
  4858. getNormals(): Vector3[];
  4859. /**
  4860. * Returns an array populated with binormal vectors on each Path3D curve point.
  4861. * @returns an array populated with binormal vectors on each Path3D curve point.
  4862. */
  4863. getBinormals(): Vector3[];
  4864. /**
  4865. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4866. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4867. */
  4868. getDistances(): number[];
  4869. /**
  4870. * Returns an interpolated point along this path
  4871. * @param position the position of the point along this path, from 0.0 to 1.0
  4872. * @returns a new Vector3 as the point
  4873. */
  4874. getPointAt(position: number): Vector3;
  4875. /**
  4876. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4877. * @param position the position of the point along this path, from 0.0 to 1.0
  4878. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4879. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4880. */
  4881. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4882. /**
  4883. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4884. * @param position the position of the point along this path, from 0.0 to 1.0
  4885. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4886. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4887. */
  4888. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4889. /**
  4890. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4891. * @param position the position of the point along this path, from 0.0 to 1.0
  4892. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4893. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4894. */
  4895. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4896. /**
  4897. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4898. * @param position the position of the point along this path, from 0.0 to 1.0
  4899. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4900. */
  4901. getDistanceAt(position: number): number;
  4902. /**
  4903. * Returns the array index of the previous point of an interpolated point along this path
  4904. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4905. * @returns the array index
  4906. */
  4907. getPreviousPointIndexAt(position: number): number;
  4908. /**
  4909. * 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)
  4910. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4911. * @returns the sub position
  4912. */
  4913. getSubPositionAt(position: number): number;
  4914. /**
  4915. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4916. * @param target the vector of which to get the closest position to
  4917. * @returns the position of the closest virtual point on this path to the target vector
  4918. */
  4919. getClosestPositionTo(target: Vector3): number;
  4920. /**
  4921. * Returns a sub path (slice) of this path
  4922. * @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
  4923. * @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
  4924. * @returns a sub path (slice) of this path
  4925. */
  4926. slice(start?: number, end?: number): Path3D;
  4927. /**
  4928. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4929. * @param path path which all values are copied into the curves points
  4930. * @param firstNormal which should be projected onto the curve
  4931. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4932. * @returns the same object updated.
  4933. */
  4934. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4935. private _compute;
  4936. private _getFirstNonNullVector;
  4937. private _getLastNonNullVector;
  4938. private _normalVector;
  4939. /**
  4940. * Updates the point at data for an interpolated point along this curve
  4941. * @param position the position of the point along this curve, from 0.0 to 1.0
  4942. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4943. * @returns the (updated) point at data
  4944. */
  4945. private _updatePointAtData;
  4946. /**
  4947. * Updates the point at data from the specified parameters
  4948. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4949. * @param point the interpolated point
  4950. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4951. */
  4952. private _setPointAtData;
  4953. /**
  4954. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4955. */
  4956. private _updateInterpolationMatrix;
  4957. }
  4958. /**
  4959. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4960. * A Curve3 is designed from a series of successive Vector3.
  4961. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4962. */
  4963. export class Curve3 {
  4964. private _points;
  4965. private _length;
  4966. /**
  4967. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4968. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4969. * @param v1 (Vector3) the control point
  4970. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4971. * @param nbPoints (integer) the wanted number of points in the curve
  4972. * @returns the created Curve3
  4973. */
  4974. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4975. /**
  4976. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4977. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4978. * @param v1 (Vector3) the first control point
  4979. * @param v2 (Vector3) the second control point
  4980. * @param v3 (Vector3) the end point of the Cubic Bezier
  4981. * @param nbPoints (integer) the wanted number of points in the curve
  4982. * @returns the created Curve3
  4983. */
  4984. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4985. /**
  4986. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4987. * @param p1 (Vector3) the origin point of the Hermite Spline
  4988. * @param t1 (Vector3) the tangent vector at the origin point
  4989. * @param p2 (Vector3) the end point of the Hermite Spline
  4990. * @param t2 (Vector3) the tangent vector at the end point
  4991. * @param nbPoints (integer) the wanted number of points in the curve
  4992. * @returns the created Curve3
  4993. */
  4994. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4995. /**
  4996. * Returns a Curve3 object along a CatmullRom Spline curve :
  4997. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4998. * @param nbPoints (integer) the wanted number of points between each curve control points
  4999. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5000. * @returns the created Curve3
  5001. */
  5002. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5003. /**
  5004. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5005. * A Curve3 is designed from a series of successive Vector3.
  5006. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5007. * @param points points which make up the curve
  5008. */
  5009. constructor(points: Vector3[]);
  5010. /**
  5011. * @returns the Curve3 stored array of successive Vector3
  5012. */
  5013. getPoints(): Vector3[];
  5014. /**
  5015. * @returns the computed length (float) of the curve.
  5016. */
  5017. length(): number;
  5018. /**
  5019. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5020. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5021. * curveA and curveB keep unchanged.
  5022. * @param curve the curve to continue from this curve
  5023. * @returns the newly constructed curve
  5024. */
  5025. continue(curve: DeepImmutable<Curve3>): Curve3;
  5026. private _computeLength;
  5027. }
  5028. }
  5029. declare module BABYLON {
  5030. /**
  5031. * This represents the main contract an easing function should follow.
  5032. * Easing functions are used throughout the animation system.
  5033. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5034. */
  5035. export interface IEasingFunction {
  5036. /**
  5037. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5038. * of the easing function.
  5039. * The link below provides some of the most common examples of easing functions.
  5040. * @see https://easings.net/
  5041. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5042. * @returns the corresponding value on the curve defined by the easing function
  5043. */
  5044. ease(gradient: number): number;
  5045. }
  5046. /**
  5047. * Base class used for every default easing function.
  5048. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5049. */
  5050. export class EasingFunction implements IEasingFunction {
  5051. /**
  5052. * Interpolation follows the mathematical formula associated with the easing function.
  5053. */
  5054. static readonly EASINGMODE_EASEIN: number;
  5055. /**
  5056. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5057. */
  5058. static readonly EASINGMODE_EASEOUT: number;
  5059. /**
  5060. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5061. */
  5062. static readonly EASINGMODE_EASEINOUT: number;
  5063. private _easingMode;
  5064. /**
  5065. * Sets the easing mode of the current function.
  5066. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5067. */
  5068. setEasingMode(easingMode: number): void;
  5069. /**
  5070. * Gets the current easing mode.
  5071. * @returns the easing mode
  5072. */
  5073. getEasingMode(): number;
  5074. /**
  5075. * @hidden
  5076. */
  5077. easeInCore(gradient: number): number;
  5078. /**
  5079. * Given an input gradient between 0 and 1, this returns the corresponding value
  5080. * of the easing function.
  5081. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5082. * @returns the corresponding value on the curve defined by the easing function
  5083. */
  5084. ease(gradient: number): number;
  5085. }
  5086. /**
  5087. * Easing function with a circle shape (see link below).
  5088. * @see https://easings.net/#easeInCirc
  5089. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5090. */
  5091. export class CircleEase extends EasingFunction implements IEasingFunction {
  5092. /** @hidden */
  5093. easeInCore(gradient: number): number;
  5094. }
  5095. /**
  5096. * Easing function with a ease back shape (see link below).
  5097. * @see https://easings.net/#easeInBack
  5098. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5099. */
  5100. export class BackEase extends EasingFunction implements IEasingFunction {
  5101. /** Defines the amplitude of the function */
  5102. amplitude: number;
  5103. /**
  5104. * Instantiates a back ease easing
  5105. * @see https://easings.net/#easeInBack
  5106. * @param amplitude Defines the amplitude of the function
  5107. */
  5108. constructor(
  5109. /** Defines the amplitude of the function */
  5110. amplitude?: number);
  5111. /** @hidden */
  5112. easeInCore(gradient: number): number;
  5113. }
  5114. /**
  5115. * Easing function with a bouncing shape (see link below).
  5116. * @see https://easings.net/#easeInBounce
  5117. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5118. */
  5119. export class BounceEase extends EasingFunction implements IEasingFunction {
  5120. /** Defines the number of bounces */
  5121. bounces: number;
  5122. /** Defines the amplitude of the bounce */
  5123. bounciness: number;
  5124. /**
  5125. * Instantiates a bounce easing
  5126. * @see https://easings.net/#easeInBounce
  5127. * @param bounces Defines the number of bounces
  5128. * @param bounciness Defines the amplitude of the bounce
  5129. */
  5130. constructor(
  5131. /** Defines the number of bounces */
  5132. bounces?: number,
  5133. /** Defines the amplitude of the bounce */
  5134. bounciness?: number);
  5135. /** @hidden */
  5136. easeInCore(gradient: number): number;
  5137. }
  5138. /**
  5139. * Easing function with a power of 3 shape (see link below).
  5140. * @see https://easings.net/#easeInCubic
  5141. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5142. */
  5143. export class CubicEase extends EasingFunction implements IEasingFunction {
  5144. /** @hidden */
  5145. easeInCore(gradient: number): number;
  5146. }
  5147. /**
  5148. * Easing function with an elastic shape (see link below).
  5149. * @see https://easings.net/#easeInElastic
  5150. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5151. */
  5152. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5153. /** Defines the number of oscillations*/
  5154. oscillations: number;
  5155. /** Defines the amplitude of the oscillations*/
  5156. springiness: number;
  5157. /**
  5158. * Instantiates an elastic easing function
  5159. * @see https://easings.net/#easeInElastic
  5160. * @param oscillations Defines the number of oscillations
  5161. * @param springiness Defines the amplitude of the oscillations
  5162. */
  5163. constructor(
  5164. /** Defines the number of oscillations*/
  5165. oscillations?: number,
  5166. /** Defines the amplitude of the oscillations*/
  5167. springiness?: number);
  5168. /** @hidden */
  5169. easeInCore(gradient: number): number;
  5170. }
  5171. /**
  5172. * Easing function with an exponential shape (see link below).
  5173. * @see https://easings.net/#easeInExpo
  5174. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5175. */
  5176. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5177. /** Defines the exponent of the function */
  5178. exponent: number;
  5179. /**
  5180. * Instantiates an exponential easing function
  5181. * @see https://easings.net/#easeInExpo
  5182. * @param exponent Defines the exponent of the function
  5183. */
  5184. constructor(
  5185. /** Defines the exponent of the function */
  5186. exponent?: number);
  5187. /** @hidden */
  5188. easeInCore(gradient: number): number;
  5189. }
  5190. /**
  5191. * Easing function with a power shape (see link below).
  5192. * @see https://easings.net/#easeInQuad
  5193. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5194. */
  5195. export class PowerEase extends EasingFunction implements IEasingFunction {
  5196. /** Defines the power of the function */
  5197. power: number;
  5198. /**
  5199. * Instantiates an power base easing function
  5200. * @see https://easings.net/#easeInQuad
  5201. * @param power Defines the power of the function
  5202. */
  5203. constructor(
  5204. /** Defines the power of the function */
  5205. power?: number);
  5206. /** @hidden */
  5207. easeInCore(gradient: number): number;
  5208. }
  5209. /**
  5210. * Easing function with a power of 2 shape (see link below).
  5211. * @see https://easings.net/#easeInQuad
  5212. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5213. */
  5214. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5215. /** @hidden */
  5216. easeInCore(gradient: number): number;
  5217. }
  5218. /**
  5219. * Easing function with a power of 4 shape (see link below).
  5220. * @see https://easings.net/#easeInQuart
  5221. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5222. */
  5223. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5224. /** @hidden */
  5225. easeInCore(gradient: number): number;
  5226. }
  5227. /**
  5228. * Easing function with a power of 5 shape (see link below).
  5229. * @see https://easings.net/#easeInQuint
  5230. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5231. */
  5232. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5233. /** @hidden */
  5234. easeInCore(gradient: number): number;
  5235. }
  5236. /**
  5237. * Easing function with a sin shape (see link below).
  5238. * @see https://easings.net/#easeInSine
  5239. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5240. */
  5241. export class SineEase extends EasingFunction implements IEasingFunction {
  5242. /** @hidden */
  5243. easeInCore(gradient: number): number;
  5244. }
  5245. /**
  5246. * Easing function with a bezier shape (see link below).
  5247. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5248. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5249. */
  5250. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  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. /**
  5260. * Instantiates a bezier function
  5261. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5262. * @param x1 Defines the x component of the start tangent in the bezier curve
  5263. * @param y1 Defines the y component of the start tangent in the bezier curve
  5264. * @param x2 Defines the x component of the end tangent in the bezier curve
  5265. * @param y2 Defines the y component of the end tangent in the bezier curve
  5266. */
  5267. constructor(
  5268. /** Defines the x component of the start tangent in the bezier curve */
  5269. x1?: number,
  5270. /** Defines the y component of the start tangent in the bezier curve */
  5271. y1?: number,
  5272. /** Defines the x component of the end tangent in the bezier curve */
  5273. x2?: number,
  5274. /** Defines the y component of the end tangent in the bezier curve */
  5275. y2?: number);
  5276. /** @hidden */
  5277. easeInCore(gradient: number): number;
  5278. }
  5279. }
  5280. declare module BABYLON {
  5281. /**
  5282. * Class used to hold a RBG color
  5283. */
  5284. export class Color3 {
  5285. /**
  5286. * Defines the red component (between 0 and 1, default is 0)
  5287. */
  5288. r: number;
  5289. /**
  5290. * Defines the green component (between 0 and 1, default is 0)
  5291. */
  5292. g: number;
  5293. /**
  5294. * Defines the blue component (between 0 and 1, default is 0)
  5295. */
  5296. b: number;
  5297. /**
  5298. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5299. * @param r defines the red component (between 0 and 1, default is 0)
  5300. * @param g defines the green component (between 0 and 1, default is 0)
  5301. * @param b defines the blue component (between 0 and 1, default is 0)
  5302. */
  5303. constructor(
  5304. /**
  5305. * Defines the red component (between 0 and 1, default is 0)
  5306. */
  5307. r?: number,
  5308. /**
  5309. * Defines the green component (between 0 and 1, default is 0)
  5310. */
  5311. g?: number,
  5312. /**
  5313. * Defines the blue component (between 0 and 1, default is 0)
  5314. */
  5315. b?: number);
  5316. /**
  5317. * Creates a string with the Color3 current values
  5318. * @returns the string representation of the Color3 object
  5319. */
  5320. toString(): string;
  5321. /**
  5322. * Returns the string "Color3"
  5323. * @returns "Color3"
  5324. */
  5325. getClassName(): string;
  5326. /**
  5327. * Compute the Color3 hash code
  5328. * @returns an unique number that can be used to hash Color3 objects
  5329. */
  5330. getHashCode(): number;
  5331. /**
  5332. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5333. * @param array defines the array where to store the r,g,b components
  5334. * @param index defines an optional index in the target array to define where to start storing values
  5335. * @returns the current Color3 object
  5336. */
  5337. toArray(array: FloatArray, index?: number): Color3;
  5338. /**
  5339. * Returns a new Color4 object from the current Color3 and the given alpha
  5340. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5341. * @returns a new Color4 object
  5342. */
  5343. toColor4(alpha?: number): Color4;
  5344. /**
  5345. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5346. * @returns the new array
  5347. */
  5348. asArray(): number[];
  5349. /**
  5350. * Returns the luminance value
  5351. * @returns a float value
  5352. */
  5353. toLuminance(): number;
  5354. /**
  5355. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5356. * @param otherColor defines the second operand
  5357. * @returns the new Color3 object
  5358. */
  5359. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5360. /**
  5361. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5362. * @param otherColor defines the second operand
  5363. * @param result defines the Color3 object where to store the result
  5364. * @returns the current Color3
  5365. */
  5366. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5367. /**
  5368. * Determines equality between Color3 objects
  5369. * @param otherColor defines the second operand
  5370. * @returns true if the rgb values are equal to the given ones
  5371. */
  5372. equals(otherColor: DeepImmutable<Color3>): boolean;
  5373. /**
  5374. * Determines equality between the current Color3 object and a set of r,b,g values
  5375. * @param r defines the red component to check
  5376. * @param g defines the green component to check
  5377. * @param b defines the blue component to check
  5378. * @returns true if the rgb values are equal to the given ones
  5379. */
  5380. equalsFloats(r: number, g: number, b: number): boolean;
  5381. /**
  5382. * Multiplies in place each rgb value by scale
  5383. * @param scale defines the scaling factor
  5384. * @returns the updated Color3
  5385. */
  5386. scale(scale: number): Color3;
  5387. /**
  5388. * Multiplies the rgb values by scale and stores the result into "result"
  5389. * @param scale defines the scaling factor
  5390. * @param result defines the Color3 object where to store the result
  5391. * @returns the unmodified current Color3
  5392. */
  5393. scaleToRef(scale: number, result: Color3): Color3;
  5394. /**
  5395. * Scale the current Color3 values by a factor and add the result to a given Color3
  5396. * @param scale defines the scale factor
  5397. * @param result defines color to store the result into
  5398. * @returns the unmodified current Color3
  5399. */
  5400. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5401. /**
  5402. * Clamps the rgb values by the min and max values and stores the result into "result"
  5403. * @param min defines minimum clamping value (default is 0)
  5404. * @param max defines maximum clamping value (default is 1)
  5405. * @param result defines color to store the result into
  5406. * @returns the original Color3
  5407. */
  5408. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5409. /**
  5410. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5411. * @param otherColor defines the second operand
  5412. * @returns the new Color3
  5413. */
  5414. add(otherColor: DeepImmutable<Color3>): Color3;
  5415. /**
  5416. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5417. * @param otherColor defines the second operand
  5418. * @param result defines Color3 object to store the result into
  5419. * @returns the unmodified current Color3
  5420. */
  5421. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5422. /**
  5423. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5424. * @param otherColor defines the second operand
  5425. * @returns the new Color3
  5426. */
  5427. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5428. /**
  5429. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5430. * @param otherColor defines the second operand
  5431. * @param result defines Color3 object to store the result into
  5432. * @returns the unmodified current Color3
  5433. */
  5434. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5435. /**
  5436. * Copy the current object
  5437. * @returns a new Color3 copied the current one
  5438. */
  5439. clone(): Color3;
  5440. /**
  5441. * Copies the rgb values from the source in the current Color3
  5442. * @param source defines the source Color3 object
  5443. * @returns the updated Color3 object
  5444. */
  5445. copyFrom(source: DeepImmutable<Color3>): Color3;
  5446. /**
  5447. * Updates the Color3 rgb values from the given floats
  5448. * @param r defines the red component to read from
  5449. * @param g defines the green component to read from
  5450. * @param b defines the blue component to read from
  5451. * @returns the current Color3 object
  5452. */
  5453. copyFromFloats(r: number, g: number, b: number): Color3;
  5454. /**
  5455. * Updates the Color3 rgb values from the given floats
  5456. * @param r defines the red component to read from
  5457. * @param g defines the green component to read from
  5458. * @param b defines the blue component to read from
  5459. * @returns the current Color3 object
  5460. */
  5461. set(r: number, g: number, b: number): Color3;
  5462. /**
  5463. * Compute the Color3 hexadecimal code as a string
  5464. * @returns a string containing the hexadecimal representation of the Color3 object
  5465. */
  5466. toHexString(): string;
  5467. /**
  5468. * Computes a new Color3 converted from the current one to linear space
  5469. * @returns a new Color3 object
  5470. */
  5471. toLinearSpace(): Color3;
  5472. /**
  5473. * Converts current color in rgb space to HSV values
  5474. * @returns a new color3 representing the HSV values
  5475. */
  5476. toHSV(): Color3;
  5477. /**
  5478. * Converts current color in rgb space to HSV values
  5479. * @param result defines the Color3 where to store the HSV values
  5480. */
  5481. toHSVToRef(result: Color3): void;
  5482. /**
  5483. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5484. * @param convertedColor defines the Color3 object where to store the linear space version
  5485. * @returns the unmodified Color3
  5486. */
  5487. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5488. /**
  5489. * Computes a new Color3 converted from the current one to gamma space
  5490. * @returns a new Color3 object
  5491. */
  5492. toGammaSpace(): Color3;
  5493. /**
  5494. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5495. * @param convertedColor defines the Color3 object where to store the gamma space version
  5496. * @returns the unmodified Color3
  5497. */
  5498. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5499. private static _BlackReadOnly;
  5500. /**
  5501. * Convert Hue, saturation and value to a Color3 (RGB)
  5502. * @param hue defines the hue
  5503. * @param saturation defines the saturation
  5504. * @param value defines the value
  5505. * @param result defines the Color3 where to store the RGB values
  5506. */
  5507. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5508. /**
  5509. * Creates a new Color3 from the string containing valid hexadecimal values
  5510. * @param hex defines a string containing valid hexadecimal values
  5511. * @returns a new Color3 object
  5512. */
  5513. static FromHexString(hex: string): Color3;
  5514. /**
  5515. * Creates a new Color3 from the starting index of the given array
  5516. * @param array defines the source array
  5517. * @param offset defines an offset in the source array
  5518. * @returns a new Color3 object
  5519. */
  5520. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5521. /**
  5522. * Creates a new Color3 from integer values (< 256)
  5523. * @param r defines the red component to read from (value between 0 and 255)
  5524. * @param g defines the green component to read from (value between 0 and 255)
  5525. * @param b defines the blue component to read from (value between 0 and 255)
  5526. * @returns a new Color3 object
  5527. */
  5528. static FromInts(r: number, g: number, b: number): Color3;
  5529. /**
  5530. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5531. * @param start defines the start Color3 value
  5532. * @param end defines the end Color3 value
  5533. * @param amount defines the gradient value between start and end
  5534. * @returns a new Color3 object
  5535. */
  5536. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5537. /**
  5538. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5539. * @param left defines the start value
  5540. * @param right defines the end value
  5541. * @param amount defines the gradient factor
  5542. * @param result defines the Color3 object where to store the result
  5543. */
  5544. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5545. /**
  5546. * Returns a Color3 value containing a red color
  5547. * @returns a new Color3 object
  5548. */
  5549. static Red(): Color3;
  5550. /**
  5551. * Returns a Color3 value containing a green color
  5552. * @returns a new Color3 object
  5553. */
  5554. static Green(): Color3;
  5555. /**
  5556. * Returns a Color3 value containing a blue color
  5557. * @returns a new Color3 object
  5558. */
  5559. static Blue(): Color3;
  5560. /**
  5561. * Returns a Color3 value containing a black color
  5562. * @returns a new Color3 object
  5563. */
  5564. static Black(): Color3;
  5565. /**
  5566. * Gets a Color3 value containing a black color that must not be updated
  5567. */
  5568. static get BlackReadOnly(): DeepImmutable<Color3>;
  5569. /**
  5570. * Returns a Color3 value containing a white color
  5571. * @returns a new Color3 object
  5572. */
  5573. static White(): Color3;
  5574. /**
  5575. * Returns a Color3 value containing a purple color
  5576. * @returns a new Color3 object
  5577. */
  5578. static Purple(): Color3;
  5579. /**
  5580. * Returns a Color3 value containing a magenta color
  5581. * @returns a new Color3 object
  5582. */
  5583. static Magenta(): Color3;
  5584. /**
  5585. * Returns a Color3 value containing a yellow color
  5586. * @returns a new Color3 object
  5587. */
  5588. static Yellow(): Color3;
  5589. /**
  5590. * Returns a Color3 value containing a gray color
  5591. * @returns a new Color3 object
  5592. */
  5593. static Gray(): Color3;
  5594. /**
  5595. * Returns a Color3 value containing a teal color
  5596. * @returns a new Color3 object
  5597. */
  5598. static Teal(): Color3;
  5599. /**
  5600. * Returns a Color3 value containing a random color
  5601. * @returns a new Color3 object
  5602. */
  5603. static Random(): Color3;
  5604. }
  5605. /**
  5606. * Class used to hold a RBGA color
  5607. */
  5608. export class Color4 {
  5609. /**
  5610. * Defines the red component (between 0 and 1, default is 0)
  5611. */
  5612. r: number;
  5613. /**
  5614. * Defines the green component (between 0 and 1, default is 0)
  5615. */
  5616. g: number;
  5617. /**
  5618. * Defines the blue component (between 0 and 1, default is 0)
  5619. */
  5620. b: number;
  5621. /**
  5622. * Defines the alpha component (between 0 and 1, default is 1)
  5623. */
  5624. a: number;
  5625. /**
  5626. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5627. * @param r defines the red component (between 0 and 1, default is 0)
  5628. * @param g defines the green component (between 0 and 1, default is 0)
  5629. * @param b defines the blue component (between 0 and 1, default is 0)
  5630. * @param a defines the alpha component (between 0 and 1, default is 1)
  5631. */
  5632. constructor(
  5633. /**
  5634. * Defines the red component (between 0 and 1, default is 0)
  5635. */
  5636. r?: number,
  5637. /**
  5638. * Defines the green component (between 0 and 1, default is 0)
  5639. */
  5640. g?: number,
  5641. /**
  5642. * Defines the blue component (between 0 and 1, default is 0)
  5643. */
  5644. b?: number,
  5645. /**
  5646. * Defines the alpha component (between 0 and 1, default is 1)
  5647. */
  5648. a?: number);
  5649. /**
  5650. * Adds in place the given Color4 values to the current Color4 object
  5651. * @param right defines the second operand
  5652. * @returns the current updated Color4 object
  5653. */
  5654. addInPlace(right: DeepImmutable<Color4>): Color4;
  5655. /**
  5656. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5657. * @returns the new array
  5658. */
  5659. asArray(): number[];
  5660. /**
  5661. * Stores from the starting index in the given array the Color4 successive values
  5662. * @param array defines the array where to store the r,g,b components
  5663. * @param index defines an optional index in the target array to define where to start storing values
  5664. * @returns the current Color4 object
  5665. */
  5666. toArray(array: number[], index?: number): Color4;
  5667. /**
  5668. * Determines equality between Color4 objects
  5669. * @param otherColor defines the second operand
  5670. * @returns true if the rgba values are equal to the given ones
  5671. */
  5672. equals(otherColor: DeepImmutable<Color4>): boolean;
  5673. /**
  5674. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5675. * @param right defines the second operand
  5676. * @returns a new Color4 object
  5677. */
  5678. add(right: DeepImmutable<Color4>): Color4;
  5679. /**
  5680. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5681. * @param right defines the second operand
  5682. * @returns a new Color4 object
  5683. */
  5684. subtract(right: DeepImmutable<Color4>): Color4;
  5685. /**
  5686. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5687. * @param right defines the second operand
  5688. * @param result defines the Color4 object where to store the result
  5689. * @returns the current Color4 object
  5690. */
  5691. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5692. /**
  5693. * Creates a new Color4 with the current Color4 values multiplied by scale
  5694. * @param scale defines the scaling factor to apply
  5695. * @returns a new Color4 object
  5696. */
  5697. scale(scale: number): Color4;
  5698. /**
  5699. * Multiplies the current Color4 values by scale and stores the result in "result"
  5700. * @param scale defines the scaling factor to apply
  5701. * @param result defines the Color4 object where to store the result
  5702. * @returns the current unmodified Color4
  5703. */
  5704. scaleToRef(scale: number, result: Color4): Color4;
  5705. /**
  5706. * Scale the current Color4 values by a factor and add the result to a given Color4
  5707. * @param scale defines the scale factor
  5708. * @param result defines the Color4 object where to store the result
  5709. * @returns the unmodified current Color4
  5710. */
  5711. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5712. /**
  5713. * Clamps the rgb values by the min and max values and stores the result into "result"
  5714. * @param min defines minimum clamping value (default is 0)
  5715. * @param max defines maximum clamping value (default is 1)
  5716. * @param result defines color to store the result into.
  5717. * @returns the cuurent Color4
  5718. */
  5719. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5720. /**
  5721. * Multipy an Color4 value by another and return a new Color4 object
  5722. * @param color defines the Color4 value to multiply by
  5723. * @returns a new Color4 object
  5724. */
  5725. multiply(color: Color4): Color4;
  5726. /**
  5727. * Multipy a Color4 value by another and push the result in a reference value
  5728. * @param color defines the Color4 value to multiply by
  5729. * @param result defines the Color4 to fill the result in
  5730. * @returns the result Color4
  5731. */
  5732. multiplyToRef(color: Color4, result: Color4): Color4;
  5733. /**
  5734. * Creates a string with the Color4 current values
  5735. * @returns the string representation of the Color4 object
  5736. */
  5737. toString(): string;
  5738. /**
  5739. * Returns the string "Color4"
  5740. * @returns "Color4"
  5741. */
  5742. getClassName(): string;
  5743. /**
  5744. * Compute the Color4 hash code
  5745. * @returns an unique number that can be used to hash Color4 objects
  5746. */
  5747. getHashCode(): number;
  5748. /**
  5749. * Creates a new Color4 copied from the current one
  5750. * @returns a new Color4 object
  5751. */
  5752. clone(): Color4;
  5753. /**
  5754. * Copies the given Color4 values into the current one
  5755. * @param source defines the source Color4 object
  5756. * @returns the current updated Color4 object
  5757. */
  5758. copyFrom(source: Color4): Color4;
  5759. /**
  5760. * Copies the given float values into the current one
  5761. * @param r defines the red component to read from
  5762. * @param g defines the green component to read from
  5763. * @param b defines the blue component to read from
  5764. * @param a defines the alpha component to read from
  5765. * @returns the current updated Color4 object
  5766. */
  5767. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5768. /**
  5769. * Copies the given float values into the current one
  5770. * @param r defines the red component to read from
  5771. * @param g defines the green component to read from
  5772. * @param b defines the blue component to read from
  5773. * @param a defines the alpha component to read from
  5774. * @returns the current updated Color4 object
  5775. */
  5776. set(r: number, g: number, b: number, a: number): Color4;
  5777. /**
  5778. * Compute the Color4 hexadecimal code as a string
  5779. * @returns a string containing the hexadecimal representation of the Color4 object
  5780. */
  5781. toHexString(): string;
  5782. /**
  5783. * Computes a new Color4 converted from the current one to linear space
  5784. * @returns a new Color4 object
  5785. */
  5786. toLinearSpace(): Color4;
  5787. /**
  5788. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5789. * @param convertedColor defines the Color4 object where to store the linear space version
  5790. * @returns the unmodified Color4
  5791. */
  5792. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5793. /**
  5794. * Computes a new Color4 converted from the current one to gamma space
  5795. * @returns a new Color4 object
  5796. */
  5797. toGammaSpace(): Color4;
  5798. /**
  5799. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5800. * @param convertedColor defines the Color4 object where to store the gamma space version
  5801. * @returns the unmodified Color4
  5802. */
  5803. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5804. /**
  5805. * Creates a new Color4 from the string containing valid hexadecimal values
  5806. * @param hex defines a string containing valid hexadecimal values
  5807. * @returns a new Color4 object
  5808. */
  5809. static FromHexString(hex: string): Color4;
  5810. /**
  5811. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5812. * @param left defines the start value
  5813. * @param right defines the end value
  5814. * @param amount defines the gradient factor
  5815. * @returns a new Color4 object
  5816. */
  5817. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5818. /**
  5819. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5820. * @param left defines the start value
  5821. * @param right defines the end value
  5822. * @param amount defines the gradient factor
  5823. * @param result defines the Color4 object where to store data
  5824. */
  5825. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5826. /**
  5827. * Creates a new Color4 from a Color3 and an alpha value
  5828. * @param color3 defines the source Color3 to read from
  5829. * @param alpha defines the alpha component (1.0 by default)
  5830. * @returns a new Color4 object
  5831. */
  5832. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5833. /**
  5834. * Creates a new Color4 from the starting index element of the given array
  5835. * @param array defines the source array to read from
  5836. * @param offset defines the offset in the source array
  5837. * @returns a new Color4 object
  5838. */
  5839. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5840. /**
  5841. * Creates a new Color3 from integer values (< 256)
  5842. * @param r defines the red component to read from (value between 0 and 255)
  5843. * @param g defines the green component to read from (value between 0 and 255)
  5844. * @param b defines the blue component to read from (value between 0 and 255)
  5845. * @param a defines the alpha component to read from (value between 0 and 255)
  5846. * @returns a new Color3 object
  5847. */
  5848. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5849. /**
  5850. * Check the content of a given array and convert it to an array containing RGBA data
  5851. * If the original array was already containing count * 4 values then it is returned directly
  5852. * @param colors defines the array to check
  5853. * @param count defines the number of RGBA data to expect
  5854. * @returns an array containing count * 4 values (RGBA)
  5855. */
  5856. static CheckColors4(colors: number[], count: number): number[];
  5857. }
  5858. /**
  5859. * @hidden
  5860. */
  5861. export class TmpColors {
  5862. static Color3: Color3[];
  5863. static Color4: Color4[];
  5864. }
  5865. }
  5866. declare module BABYLON {
  5867. /**
  5868. * Defines an interface which represents an animation key frame
  5869. */
  5870. export interface IAnimationKey {
  5871. /**
  5872. * Frame of the key frame
  5873. */
  5874. frame: number;
  5875. /**
  5876. * Value at the specifies key frame
  5877. */
  5878. value: any;
  5879. /**
  5880. * The input tangent for the cubic hermite spline
  5881. */
  5882. inTangent?: any;
  5883. /**
  5884. * The output tangent for the cubic hermite spline
  5885. */
  5886. outTangent?: any;
  5887. /**
  5888. * The animation interpolation type
  5889. */
  5890. interpolation?: AnimationKeyInterpolation;
  5891. }
  5892. /**
  5893. * Enum for the animation key frame interpolation type
  5894. */
  5895. export enum AnimationKeyInterpolation {
  5896. /**
  5897. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5898. */
  5899. STEP = 1
  5900. }
  5901. }
  5902. declare module BABYLON {
  5903. /**
  5904. * Represents the range of an animation
  5905. */
  5906. export class AnimationRange {
  5907. /**The name of the animation range**/
  5908. name: string;
  5909. /**The starting frame of the animation */
  5910. from: number;
  5911. /**The ending frame of the animation*/
  5912. to: number;
  5913. /**
  5914. * Initializes the range of an animation
  5915. * @param name The name of the animation range
  5916. * @param from The starting frame of the animation
  5917. * @param to The ending frame of the animation
  5918. */
  5919. constructor(
  5920. /**The name of the animation range**/
  5921. name: string,
  5922. /**The starting frame of the animation */
  5923. from: number,
  5924. /**The ending frame of the animation*/
  5925. to: number);
  5926. /**
  5927. * Makes a copy of the animation range
  5928. * @returns A copy of the animation range
  5929. */
  5930. clone(): AnimationRange;
  5931. }
  5932. }
  5933. declare module BABYLON {
  5934. /**
  5935. * Composed of a frame, and an action function
  5936. */
  5937. export class AnimationEvent {
  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. /**
  5945. * Specifies if the animation event is done
  5946. */
  5947. isDone: boolean;
  5948. /**
  5949. * Initializes the animation event
  5950. * @param frame The frame for which the event is triggered
  5951. * @param action The event to perform when triggered
  5952. * @param onlyOnce Specifies if the event should be triggered only once
  5953. */
  5954. constructor(
  5955. /** The frame for which the event is triggered **/
  5956. frame: number,
  5957. /** The event to perform when triggered **/
  5958. action: (currentFrame: number) => void,
  5959. /** Specifies if the event should be triggered only once**/
  5960. onlyOnce?: boolean | undefined);
  5961. /** @hidden */
  5962. _clone(): AnimationEvent;
  5963. }
  5964. }
  5965. declare module BABYLON {
  5966. /**
  5967. * Interface used to define a behavior
  5968. */
  5969. export interface Behavior<T> {
  5970. /** gets or sets behavior's name */
  5971. name: string;
  5972. /**
  5973. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5974. */
  5975. init(): void;
  5976. /**
  5977. * Called when the behavior is attached to a target
  5978. * @param target defines the target where the behavior is attached to
  5979. */
  5980. attach(target: T): void;
  5981. /**
  5982. * Called when the behavior is detached from its target
  5983. */
  5984. detach(): void;
  5985. }
  5986. /**
  5987. * Interface implemented by classes supporting behaviors
  5988. */
  5989. export interface IBehaviorAware<T> {
  5990. /**
  5991. * Attach a behavior
  5992. * @param behavior defines the behavior to attach
  5993. * @returns the current host
  5994. */
  5995. addBehavior(behavior: Behavior<T>): T;
  5996. /**
  5997. * Remove a behavior from the current object
  5998. * @param behavior defines the behavior to detach
  5999. * @returns the current host
  6000. */
  6001. removeBehavior(behavior: Behavior<T>): T;
  6002. /**
  6003. * Gets a behavior using its name to search
  6004. * @param name defines the name to search
  6005. * @returns the behavior or null if not found
  6006. */
  6007. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6008. }
  6009. }
  6010. declare module BABYLON {
  6011. /**
  6012. * Defines an array and its length.
  6013. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6014. */
  6015. export interface ISmartArrayLike<T> {
  6016. /**
  6017. * The data of the array.
  6018. */
  6019. data: Array<T>;
  6020. /**
  6021. * The active length of the array.
  6022. */
  6023. length: number;
  6024. }
  6025. /**
  6026. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6027. */
  6028. export class SmartArray<T> implements ISmartArrayLike<T> {
  6029. /**
  6030. * The full set of data from the array.
  6031. */
  6032. data: Array<T>;
  6033. /**
  6034. * The active length of the array.
  6035. */
  6036. length: number;
  6037. protected _id: number;
  6038. /**
  6039. * Instantiates a Smart Array.
  6040. * @param capacity defines the default capacity of the array.
  6041. */
  6042. constructor(capacity: number);
  6043. /**
  6044. * Pushes a value at the end of the active data.
  6045. * @param value defines the object to push in the array.
  6046. */
  6047. push(value: T): void;
  6048. /**
  6049. * Iterates over the active data and apply the lambda to them.
  6050. * @param func defines the action to apply on each value.
  6051. */
  6052. forEach(func: (content: T) => void): void;
  6053. /**
  6054. * Sorts the full sets of data.
  6055. * @param compareFn defines the comparison function to apply.
  6056. */
  6057. sort(compareFn: (a: T, b: T) => number): void;
  6058. /**
  6059. * Resets the active data to an empty array.
  6060. */
  6061. reset(): void;
  6062. /**
  6063. * Releases all the data from the array as well as the array.
  6064. */
  6065. dispose(): void;
  6066. /**
  6067. * Concats the active data with a given array.
  6068. * @param array defines the data to concatenate with.
  6069. */
  6070. concat(array: any): void;
  6071. /**
  6072. * Returns the position of a value in the active data.
  6073. * @param value defines the value to find the index for
  6074. * @returns the index if found in the active data otherwise -1
  6075. */
  6076. indexOf(value: T): number;
  6077. /**
  6078. * Returns whether an element is part of the active data.
  6079. * @param value defines the value to look for
  6080. * @returns true if found in the active data otherwise false
  6081. */
  6082. contains(value: T): boolean;
  6083. private static _GlobalId;
  6084. }
  6085. /**
  6086. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6087. * The data in this array can only be present once
  6088. */
  6089. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6090. private _duplicateId;
  6091. /**
  6092. * Pushes a value at the end of the active data.
  6093. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6094. * @param value defines the object to push in the array.
  6095. */
  6096. push(value: T): void;
  6097. /**
  6098. * Pushes a value at the end of the active data.
  6099. * If the data is already present, it won t be added again
  6100. * @param value defines the object to push in the array.
  6101. * @returns true if added false if it was already present
  6102. */
  6103. pushNoDuplicate(value: T): boolean;
  6104. /**
  6105. * Resets the active data to an empty array.
  6106. */
  6107. reset(): void;
  6108. /**
  6109. * Concats the active data with a given array.
  6110. * This ensures no dupplicate will be present in the result.
  6111. * @param array defines the data to concatenate with.
  6112. */
  6113. concatWithNoDuplicate(array: any): void;
  6114. }
  6115. }
  6116. declare module BABYLON {
  6117. /**
  6118. * @ignore
  6119. * This is a list of all the different input types that are available in the application.
  6120. * Fo instance: ArcRotateCameraGamepadInput...
  6121. */
  6122. export var CameraInputTypes: {};
  6123. /**
  6124. * This is the contract to implement in order to create a new input class.
  6125. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6126. */
  6127. export interface ICameraInput<TCamera extends Camera> {
  6128. /**
  6129. * Defines the camera the input is attached to.
  6130. */
  6131. camera: Nullable<TCamera>;
  6132. /**
  6133. * Gets the class name of the current intput.
  6134. * @returns the class name
  6135. */
  6136. getClassName(): string;
  6137. /**
  6138. * Get the friendly name associated with the input class.
  6139. * @returns the input friendly name
  6140. */
  6141. getSimpleName(): string;
  6142. /**
  6143. * Attach the input controls to a specific dom element to get the input from.
  6144. * @param element Defines the element the controls should be listened from
  6145. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6146. */
  6147. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6148. /**
  6149. * Detach the current controls from the specified dom element.
  6150. * @param element Defines the element to stop listening the inputs from
  6151. */
  6152. detachControl(element: Nullable<HTMLElement>): void;
  6153. /**
  6154. * Update the current camera state depending on the inputs that have been used this frame.
  6155. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6156. */
  6157. checkInputs?: () => void;
  6158. }
  6159. /**
  6160. * Represents a map of input types to input instance or input index to input instance.
  6161. */
  6162. export interface CameraInputsMap<TCamera extends Camera> {
  6163. /**
  6164. * Accessor to the input by input type.
  6165. */
  6166. [name: string]: ICameraInput<TCamera>;
  6167. /**
  6168. * Accessor to the input by input index.
  6169. */
  6170. [idx: number]: ICameraInput<TCamera>;
  6171. }
  6172. /**
  6173. * This represents the input manager used within a camera.
  6174. * It helps dealing with all the different kind of input attached to a camera.
  6175. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6176. */
  6177. export class CameraInputsManager<TCamera extends Camera> {
  6178. /**
  6179. * Defines the list of inputs attahed to the camera.
  6180. */
  6181. attached: CameraInputsMap<TCamera>;
  6182. /**
  6183. * Defines the dom element the camera is collecting inputs from.
  6184. * This is null if the controls have not been attached.
  6185. */
  6186. attachedElement: Nullable<HTMLElement>;
  6187. /**
  6188. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6189. */
  6190. noPreventDefault: boolean;
  6191. /**
  6192. * Defined the camera the input manager belongs to.
  6193. */
  6194. camera: TCamera;
  6195. /**
  6196. * Update the current camera state depending on the inputs that have been used this frame.
  6197. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6198. */
  6199. checkInputs: () => void;
  6200. /**
  6201. * Instantiate a new Camera Input Manager.
  6202. * @param camera Defines the camera the input manager blongs to
  6203. */
  6204. constructor(camera: TCamera);
  6205. /**
  6206. * Add an input method to a camera
  6207. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6208. * @param input camera input method
  6209. */
  6210. add(input: ICameraInput<TCamera>): void;
  6211. /**
  6212. * Remove a specific input method from a camera
  6213. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6214. * @param inputToRemove camera input method
  6215. */
  6216. remove(inputToRemove: ICameraInput<TCamera>): void;
  6217. /**
  6218. * Remove a specific input type from a camera
  6219. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6220. * @param inputType the type of the input to remove
  6221. */
  6222. removeByType(inputType: string): void;
  6223. private _addCheckInputs;
  6224. /**
  6225. * Attach the input controls to the currently attached dom element to listen the events from.
  6226. * @param input Defines the input to attach
  6227. */
  6228. attachInput(input: ICameraInput<TCamera>): void;
  6229. /**
  6230. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6231. * @param element Defines the dom element to collect the events from
  6232. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6233. */
  6234. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6235. /**
  6236. * Detach the current manager inputs controls from a specific dom element.
  6237. * @param element Defines the dom element to collect the events from
  6238. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6239. */
  6240. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6241. /**
  6242. * Rebuild the dynamic inputCheck function from the current list of
  6243. * defined inputs in the manager.
  6244. */
  6245. rebuildInputCheck(): void;
  6246. /**
  6247. * Remove all attached input methods from a camera
  6248. */
  6249. clear(): void;
  6250. /**
  6251. * Serialize the current input manager attached to a camera.
  6252. * This ensures than once parsed,
  6253. * the input associated to the camera will be identical to the current ones
  6254. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6255. */
  6256. serialize(serializedCamera: any): void;
  6257. /**
  6258. * Parses an input manager serialized JSON to restore the previous list of inputs
  6259. * and states associated to a camera.
  6260. * @param parsedCamera Defines the JSON to parse
  6261. */
  6262. parse(parsedCamera: any): void;
  6263. }
  6264. }
  6265. declare module BABYLON {
  6266. /**
  6267. * Class used to store data that will be store in GPU memory
  6268. */
  6269. export class Buffer {
  6270. private _engine;
  6271. private _buffer;
  6272. /** @hidden */
  6273. _data: Nullable<DataArray>;
  6274. private _updatable;
  6275. private _instanced;
  6276. private _divisor;
  6277. /**
  6278. * Gets the byte stride.
  6279. */
  6280. readonly byteStride: number;
  6281. /**
  6282. * Constructor
  6283. * @param engine the engine
  6284. * @param data the data to use for this buffer
  6285. * @param updatable whether the data is updatable
  6286. * @param stride the stride (optional)
  6287. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6288. * @param instanced whether the buffer is instanced (optional)
  6289. * @param useBytes set to true if the stride in in bytes (optional)
  6290. * @param divisor sets an optional divisor for instances (1 by default)
  6291. */
  6292. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6293. /**
  6294. * Create a new VertexBuffer based on the current buffer
  6295. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6296. * @param offset defines offset in the buffer (0 by default)
  6297. * @param size defines the size in floats of attributes (position is 3 for instance)
  6298. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6299. * @param instanced defines if the vertex buffer contains indexed data
  6300. * @param useBytes defines if the offset and stride are in bytes *
  6301. * @param divisor sets an optional divisor for instances (1 by default)
  6302. * @returns the new vertex buffer
  6303. */
  6304. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6305. /**
  6306. * Gets a boolean indicating if the Buffer is updatable?
  6307. * @returns true if the buffer is updatable
  6308. */
  6309. isUpdatable(): boolean;
  6310. /**
  6311. * Gets current buffer's data
  6312. * @returns a DataArray or null
  6313. */
  6314. getData(): Nullable<DataArray>;
  6315. /**
  6316. * Gets underlying native buffer
  6317. * @returns underlying native buffer
  6318. */
  6319. getBuffer(): Nullable<DataBuffer>;
  6320. /**
  6321. * Gets the stride in float32 units (i.e. byte stride / 4).
  6322. * May not be an integer if the byte stride is not divisible by 4.
  6323. * @returns the stride in float32 units
  6324. * @deprecated Please use byteStride instead.
  6325. */
  6326. getStrideSize(): number;
  6327. /**
  6328. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6329. * @param data defines the data to store
  6330. */
  6331. create(data?: Nullable<DataArray>): void;
  6332. /** @hidden */
  6333. _rebuild(): void;
  6334. /**
  6335. * Update current buffer data
  6336. * @param data defines the data to store
  6337. */
  6338. update(data: DataArray): void;
  6339. /**
  6340. * Updates the data directly.
  6341. * @param data the new data
  6342. * @param offset the new offset
  6343. * @param vertexCount the vertex count (optional)
  6344. * @param useBytes set to true if the offset is in bytes
  6345. */
  6346. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6347. /**
  6348. * Release all resources
  6349. */
  6350. dispose(): void;
  6351. }
  6352. /**
  6353. * Specialized buffer used to store vertex data
  6354. */
  6355. export class VertexBuffer {
  6356. /** @hidden */
  6357. _buffer: Buffer;
  6358. private _kind;
  6359. private _size;
  6360. private _ownsBuffer;
  6361. private _instanced;
  6362. private _instanceDivisor;
  6363. /**
  6364. * The byte type.
  6365. */
  6366. static readonly BYTE: number;
  6367. /**
  6368. * The unsigned byte type.
  6369. */
  6370. static readonly UNSIGNED_BYTE: number;
  6371. /**
  6372. * The short type.
  6373. */
  6374. static readonly SHORT: number;
  6375. /**
  6376. * The unsigned short type.
  6377. */
  6378. static readonly UNSIGNED_SHORT: number;
  6379. /**
  6380. * The integer type.
  6381. */
  6382. static readonly INT: number;
  6383. /**
  6384. * The unsigned integer type.
  6385. */
  6386. static readonly UNSIGNED_INT: number;
  6387. /**
  6388. * The float type.
  6389. */
  6390. static readonly FLOAT: number;
  6391. /**
  6392. * Gets or sets the instance divisor when in instanced mode
  6393. */
  6394. get instanceDivisor(): number;
  6395. set instanceDivisor(value: number);
  6396. /**
  6397. * Gets the byte stride.
  6398. */
  6399. readonly byteStride: number;
  6400. /**
  6401. * Gets the byte offset.
  6402. */
  6403. readonly byteOffset: number;
  6404. /**
  6405. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6406. */
  6407. readonly normalized: boolean;
  6408. /**
  6409. * Gets the data type of each component in the array.
  6410. */
  6411. readonly type: number;
  6412. /**
  6413. * Constructor
  6414. * @param engine the engine
  6415. * @param data the data to use for this vertex buffer
  6416. * @param kind the vertex buffer kind
  6417. * @param updatable whether the data is updatable
  6418. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6419. * @param stride the stride (optional)
  6420. * @param instanced whether the buffer is instanced (optional)
  6421. * @param offset the offset of the data (optional)
  6422. * @param size the number of components (optional)
  6423. * @param type the type of the component (optional)
  6424. * @param normalized whether the data contains normalized data (optional)
  6425. * @param useBytes set to true if stride and offset are in bytes (optional)
  6426. * @param divisor defines the instance divisor to use (1 by default)
  6427. */
  6428. 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);
  6429. /** @hidden */
  6430. _rebuild(): void;
  6431. /**
  6432. * Returns the kind of the VertexBuffer (string)
  6433. * @returns a string
  6434. */
  6435. getKind(): string;
  6436. /**
  6437. * Gets a boolean indicating if the VertexBuffer is updatable?
  6438. * @returns true if the buffer is updatable
  6439. */
  6440. isUpdatable(): boolean;
  6441. /**
  6442. * Gets current buffer's data
  6443. * @returns a DataArray or null
  6444. */
  6445. getData(): Nullable<DataArray>;
  6446. /**
  6447. * Gets underlying native buffer
  6448. * @returns underlying native buffer
  6449. */
  6450. getBuffer(): Nullable<DataBuffer>;
  6451. /**
  6452. * Gets the stride in float32 units (i.e. byte stride / 4).
  6453. * May not be an integer if the byte stride is not divisible by 4.
  6454. * @returns the stride in float32 units
  6455. * @deprecated Please use byteStride instead.
  6456. */
  6457. getStrideSize(): number;
  6458. /**
  6459. * Returns the offset as a multiple of the type byte length.
  6460. * @returns the offset in bytes
  6461. * @deprecated Please use byteOffset instead.
  6462. */
  6463. getOffset(): number;
  6464. /**
  6465. * Returns the number of components per vertex attribute (integer)
  6466. * @returns the size in float
  6467. */
  6468. getSize(): number;
  6469. /**
  6470. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6471. * @returns true if this buffer is instanced
  6472. */
  6473. getIsInstanced(): boolean;
  6474. /**
  6475. * Returns the instancing divisor, zero for non-instanced (integer).
  6476. * @returns a number
  6477. */
  6478. getInstanceDivisor(): number;
  6479. /**
  6480. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6481. * @param data defines the data to store
  6482. */
  6483. create(data?: DataArray): void;
  6484. /**
  6485. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6486. * This function will create a new buffer if the current one is not updatable
  6487. * @param data defines the data to store
  6488. */
  6489. update(data: DataArray): void;
  6490. /**
  6491. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6492. * Returns the directly updated WebGLBuffer.
  6493. * @param data the new data
  6494. * @param offset the new offset
  6495. * @param useBytes set to true if the offset is in bytes
  6496. */
  6497. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6498. /**
  6499. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6500. */
  6501. dispose(): void;
  6502. /**
  6503. * Enumerates each value of this vertex buffer as numbers.
  6504. * @param count the number of values to enumerate
  6505. * @param callback the callback function called for each value
  6506. */
  6507. forEach(count: number, callback: (value: number, index: number) => void): void;
  6508. /**
  6509. * Positions
  6510. */
  6511. static readonly PositionKind: string;
  6512. /**
  6513. * Normals
  6514. */
  6515. static readonly NormalKind: string;
  6516. /**
  6517. * Tangents
  6518. */
  6519. static readonly TangentKind: string;
  6520. /**
  6521. * Texture coordinates
  6522. */
  6523. static readonly UVKind: string;
  6524. /**
  6525. * Texture coordinates 2
  6526. */
  6527. static readonly UV2Kind: string;
  6528. /**
  6529. * Texture coordinates 3
  6530. */
  6531. static readonly UV3Kind: string;
  6532. /**
  6533. * Texture coordinates 4
  6534. */
  6535. static readonly UV4Kind: string;
  6536. /**
  6537. * Texture coordinates 5
  6538. */
  6539. static readonly UV5Kind: string;
  6540. /**
  6541. * Texture coordinates 6
  6542. */
  6543. static readonly UV6Kind: string;
  6544. /**
  6545. * Colors
  6546. */
  6547. static readonly ColorKind: string;
  6548. /**
  6549. * Matrix indices (for bones)
  6550. */
  6551. static readonly MatricesIndicesKind: string;
  6552. /**
  6553. * Matrix weights (for bones)
  6554. */
  6555. static readonly MatricesWeightsKind: string;
  6556. /**
  6557. * Additional matrix indices (for bones)
  6558. */
  6559. static readonly MatricesIndicesExtraKind: string;
  6560. /**
  6561. * Additional matrix weights (for bones)
  6562. */
  6563. static readonly MatricesWeightsExtraKind: string;
  6564. /**
  6565. * Deduces the stride given a kind.
  6566. * @param kind The kind string to deduce
  6567. * @returns The deduced stride
  6568. */
  6569. static DeduceStride(kind: string): number;
  6570. /**
  6571. * Gets the byte length of the given type.
  6572. * @param type the type
  6573. * @returns the number of bytes
  6574. */
  6575. static GetTypeByteLength(type: number): number;
  6576. /**
  6577. * Enumerates each value of the given parameters as numbers.
  6578. * @param data the data to enumerate
  6579. * @param byteOffset the byte offset of the data
  6580. * @param byteStride the byte stride of the data
  6581. * @param componentCount the number of components per element
  6582. * @param componentType the type of the component
  6583. * @param count the number of values to enumerate
  6584. * @param normalized whether the data is normalized
  6585. * @param callback the callback function called for each value
  6586. */
  6587. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6588. private static _GetFloatValue;
  6589. }
  6590. }
  6591. declare module BABYLON {
  6592. /**
  6593. * @hidden
  6594. */
  6595. export class IntersectionInfo {
  6596. bu: Nullable<number>;
  6597. bv: Nullable<number>;
  6598. distance: number;
  6599. faceId: number;
  6600. subMeshId: number;
  6601. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6602. }
  6603. }
  6604. declare module BABYLON {
  6605. /**
  6606. * Represens a plane by the equation ax + by + cz + d = 0
  6607. */
  6608. export class Plane {
  6609. private static _TmpMatrix;
  6610. /**
  6611. * Normal of the plane (a,b,c)
  6612. */
  6613. normal: Vector3;
  6614. /**
  6615. * d component of the plane
  6616. */
  6617. d: number;
  6618. /**
  6619. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6620. * @param a a component of the plane
  6621. * @param b b component of the plane
  6622. * @param c c component of the plane
  6623. * @param d d component of the plane
  6624. */
  6625. constructor(a: number, b: number, c: number, d: number);
  6626. /**
  6627. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6628. */
  6629. asArray(): number[];
  6630. /**
  6631. * @returns a new plane copied from the current Plane.
  6632. */
  6633. clone(): Plane;
  6634. /**
  6635. * @returns the string "Plane".
  6636. */
  6637. getClassName(): string;
  6638. /**
  6639. * @returns the Plane hash code.
  6640. */
  6641. getHashCode(): number;
  6642. /**
  6643. * Normalize the current Plane in place.
  6644. * @returns the updated Plane.
  6645. */
  6646. normalize(): Plane;
  6647. /**
  6648. * Applies a transformation the plane and returns the result
  6649. * @param transformation the transformation matrix to be applied to the plane
  6650. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6651. */
  6652. transform(transformation: DeepImmutable<Matrix>): Plane;
  6653. /**
  6654. * Calcualtte the dot product between the point and the plane normal
  6655. * @param point point to calculate the dot product with
  6656. * @returns the dot product (float) of the point coordinates and the plane normal.
  6657. */
  6658. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6659. /**
  6660. * Updates the current Plane from the plane defined by the three given points.
  6661. * @param point1 one of the points used to contruct the plane
  6662. * @param point2 one of the points used to contruct the plane
  6663. * @param point3 one of the points used to contruct the plane
  6664. * @returns the updated Plane.
  6665. */
  6666. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6667. /**
  6668. * Checks if the plane is facing a given direction
  6669. * @param direction the direction to check if the plane is facing
  6670. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6671. * @returns True is the vector "direction" is the same side than the plane normal.
  6672. */
  6673. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6674. /**
  6675. * Calculates the distance to a point
  6676. * @param point point to calculate distance to
  6677. * @returns the signed distance (float) from the given point to the Plane.
  6678. */
  6679. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6680. /**
  6681. * Creates a plane from an array
  6682. * @param array the array to create a plane from
  6683. * @returns a new Plane from the given array.
  6684. */
  6685. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6686. /**
  6687. * Creates a plane from three points
  6688. * @param point1 point used to create the plane
  6689. * @param point2 point used to create the plane
  6690. * @param point3 point used to create the plane
  6691. * @returns a new Plane defined by the three given points.
  6692. */
  6693. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6694. /**
  6695. * Creates a plane from an origin point and a normal
  6696. * @param origin origin of the plane to be constructed
  6697. * @param normal normal of the plane to be constructed
  6698. * @returns a new Plane the normal vector to this plane at the given origin point.
  6699. * Note : the vector "normal" is updated because normalized.
  6700. */
  6701. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6702. /**
  6703. * Calculates the distance from a plane and a point
  6704. * @param origin origin of the plane to be constructed
  6705. * @param normal normal of the plane to be constructed
  6706. * @param point point to calculate distance to
  6707. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6708. */
  6709. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6710. }
  6711. }
  6712. declare module BABYLON {
  6713. /**
  6714. * Class used to store bounding sphere information
  6715. */
  6716. export class BoundingSphere {
  6717. /**
  6718. * Gets the center of the bounding sphere in local space
  6719. */
  6720. readonly center: Vector3;
  6721. /**
  6722. * Radius of the bounding sphere in local space
  6723. */
  6724. radius: number;
  6725. /**
  6726. * Gets the center of the bounding sphere in world space
  6727. */
  6728. readonly centerWorld: Vector3;
  6729. /**
  6730. * Radius of the bounding sphere in world space
  6731. */
  6732. radiusWorld: number;
  6733. /**
  6734. * Gets the minimum vector in local space
  6735. */
  6736. readonly minimum: Vector3;
  6737. /**
  6738. * Gets the maximum vector in local space
  6739. */
  6740. readonly maximum: Vector3;
  6741. private _worldMatrix;
  6742. private static readonly TmpVector3;
  6743. /**
  6744. * Creates a new bounding sphere
  6745. * @param min defines the minimum vector (in local space)
  6746. * @param max defines the maximum vector (in local space)
  6747. * @param worldMatrix defines the new world matrix
  6748. */
  6749. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6750. /**
  6751. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6752. * @param min defines the new minimum vector (in local space)
  6753. * @param max defines the new maximum vector (in local space)
  6754. * @param worldMatrix defines the new world matrix
  6755. */
  6756. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6757. /**
  6758. * Scale the current bounding sphere by applying a scale factor
  6759. * @param factor defines the scale factor to apply
  6760. * @returns the current bounding box
  6761. */
  6762. scale(factor: number): BoundingSphere;
  6763. /**
  6764. * Gets the world matrix of the bounding box
  6765. * @returns a matrix
  6766. */
  6767. getWorldMatrix(): DeepImmutable<Matrix>;
  6768. /** @hidden */
  6769. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6770. /**
  6771. * Tests if the bounding sphere is intersecting the frustum planes
  6772. * @param frustumPlanes defines the frustum planes to test
  6773. * @returns true if there is an intersection
  6774. */
  6775. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6776. /**
  6777. * Tests if the bounding sphere center is in between the frustum planes.
  6778. * Used for optimistic fast inclusion.
  6779. * @param frustumPlanes defines the frustum planes to test
  6780. * @returns true if the sphere center is in between the frustum planes
  6781. */
  6782. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6783. /**
  6784. * Tests if a point is inside the bounding sphere
  6785. * @param point defines the point to test
  6786. * @returns true if the point is inside the bounding sphere
  6787. */
  6788. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6789. /**
  6790. * Checks if two sphere intersct
  6791. * @param sphere0 sphere 0
  6792. * @param sphere1 sphere 1
  6793. * @returns true if the speres intersect
  6794. */
  6795. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6796. }
  6797. }
  6798. declare module BABYLON {
  6799. /**
  6800. * Class used to store bounding box information
  6801. */
  6802. export class BoundingBox implements ICullable {
  6803. /**
  6804. * Gets the 8 vectors representing the bounding box in local space
  6805. */
  6806. readonly vectors: Vector3[];
  6807. /**
  6808. * Gets the center of the bounding box in local space
  6809. */
  6810. readonly center: Vector3;
  6811. /**
  6812. * Gets the center of the bounding box in world space
  6813. */
  6814. readonly centerWorld: Vector3;
  6815. /**
  6816. * Gets the extend size in local space
  6817. */
  6818. readonly extendSize: Vector3;
  6819. /**
  6820. * Gets the extend size in world space
  6821. */
  6822. readonly extendSizeWorld: Vector3;
  6823. /**
  6824. * Gets the OBB (object bounding box) directions
  6825. */
  6826. readonly directions: Vector3[];
  6827. /**
  6828. * Gets the 8 vectors representing the bounding box in world space
  6829. */
  6830. readonly vectorsWorld: Vector3[];
  6831. /**
  6832. * Gets the minimum vector in world space
  6833. */
  6834. readonly minimumWorld: Vector3;
  6835. /**
  6836. * Gets the maximum vector in world space
  6837. */
  6838. readonly maximumWorld: Vector3;
  6839. /**
  6840. * Gets the minimum vector in local space
  6841. */
  6842. readonly minimum: Vector3;
  6843. /**
  6844. * Gets the maximum vector in local space
  6845. */
  6846. readonly maximum: Vector3;
  6847. private _worldMatrix;
  6848. private static readonly TmpVector3;
  6849. /**
  6850. * @hidden
  6851. */
  6852. _tag: number;
  6853. /**
  6854. * Creates a new bounding box
  6855. * @param min defines the minimum vector (in local space)
  6856. * @param max defines the maximum vector (in local space)
  6857. * @param worldMatrix defines the new world matrix
  6858. */
  6859. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6860. /**
  6861. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6862. * @param min defines the new minimum vector (in local space)
  6863. * @param max defines the new maximum vector (in local space)
  6864. * @param worldMatrix defines the new world matrix
  6865. */
  6866. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6867. /**
  6868. * Scale the current bounding box by applying a scale factor
  6869. * @param factor defines the scale factor to apply
  6870. * @returns the current bounding box
  6871. */
  6872. scale(factor: number): BoundingBox;
  6873. /**
  6874. * Gets the world matrix of the bounding box
  6875. * @returns a matrix
  6876. */
  6877. getWorldMatrix(): DeepImmutable<Matrix>;
  6878. /** @hidden */
  6879. _update(world: DeepImmutable<Matrix>): void;
  6880. /**
  6881. * Tests if the bounding box is intersecting the frustum planes
  6882. * @param frustumPlanes defines the frustum planes to test
  6883. * @returns true if there is an intersection
  6884. */
  6885. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6886. /**
  6887. * Tests if the bounding box is entirely inside the frustum planes
  6888. * @param frustumPlanes defines the frustum planes to test
  6889. * @returns true if there is an inclusion
  6890. */
  6891. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6892. /**
  6893. * Tests if a point is inside the bounding box
  6894. * @param point defines the point to test
  6895. * @returns true if the point is inside the bounding box
  6896. */
  6897. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6898. /**
  6899. * Tests if the bounding box intersects with a bounding sphere
  6900. * @param sphere defines the sphere to test
  6901. * @returns true if there is an intersection
  6902. */
  6903. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6904. /**
  6905. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6906. * @param min defines the min vector to use
  6907. * @param max defines the max vector to use
  6908. * @returns true if there is an intersection
  6909. */
  6910. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6911. /**
  6912. * Tests if two bounding boxes are intersections
  6913. * @param box0 defines the first box to test
  6914. * @param box1 defines the second box to test
  6915. * @returns true if there is an intersection
  6916. */
  6917. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6918. /**
  6919. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6920. * @param minPoint defines the minimum vector of the bounding box
  6921. * @param maxPoint defines the maximum vector of the bounding box
  6922. * @param sphereCenter defines the sphere center
  6923. * @param sphereRadius defines the sphere radius
  6924. * @returns true if there is an intersection
  6925. */
  6926. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6927. /**
  6928. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6929. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6930. * @param frustumPlanes defines the frustum planes to test
  6931. * @return true if there is an inclusion
  6932. */
  6933. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6934. /**
  6935. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6936. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6937. * @param frustumPlanes defines the frustum planes to test
  6938. * @return true if there is an intersection
  6939. */
  6940. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6941. }
  6942. }
  6943. declare module BABYLON {
  6944. /** @hidden */
  6945. export class Collider {
  6946. /** Define if a collision was found */
  6947. collisionFound: boolean;
  6948. /**
  6949. * Define last intersection point in local space
  6950. */
  6951. intersectionPoint: Vector3;
  6952. /**
  6953. * Define last collided mesh
  6954. */
  6955. collidedMesh: Nullable<AbstractMesh>;
  6956. private _collisionPoint;
  6957. private _planeIntersectionPoint;
  6958. private _tempVector;
  6959. private _tempVector2;
  6960. private _tempVector3;
  6961. private _tempVector4;
  6962. private _edge;
  6963. private _baseToVertex;
  6964. private _destinationPoint;
  6965. private _slidePlaneNormal;
  6966. private _displacementVector;
  6967. /** @hidden */
  6968. _radius: Vector3;
  6969. /** @hidden */
  6970. _retry: number;
  6971. private _velocity;
  6972. private _basePoint;
  6973. private _epsilon;
  6974. /** @hidden */
  6975. _velocityWorldLength: number;
  6976. /** @hidden */
  6977. _basePointWorld: Vector3;
  6978. private _velocityWorld;
  6979. private _normalizedVelocity;
  6980. /** @hidden */
  6981. _initialVelocity: Vector3;
  6982. /** @hidden */
  6983. _initialPosition: Vector3;
  6984. private _nearestDistance;
  6985. private _collisionMask;
  6986. get collisionMask(): number;
  6987. set collisionMask(mask: number);
  6988. /**
  6989. * Gets the plane normal used to compute the sliding response (in local space)
  6990. */
  6991. get slidePlaneNormal(): Vector3;
  6992. /** @hidden */
  6993. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6994. /** @hidden */
  6995. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6996. /** @hidden */
  6997. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6998. /** @hidden */
  6999. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7000. /** @hidden */
  7001. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7002. /** @hidden */
  7003. _getResponse(pos: Vector3, vel: Vector3): void;
  7004. }
  7005. }
  7006. declare module BABYLON {
  7007. /**
  7008. * Interface for cullable objects
  7009. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7010. */
  7011. export interface ICullable {
  7012. /**
  7013. * Checks if the object or part of the object is in the frustum
  7014. * @param frustumPlanes Camera near/planes
  7015. * @returns true if the object is in frustum otherwise false
  7016. */
  7017. isInFrustum(frustumPlanes: Plane[]): boolean;
  7018. /**
  7019. * Checks if a cullable object (mesh...) is in the camera frustum
  7020. * Unlike isInFrustum this cheks the full bounding box
  7021. * @param frustumPlanes Camera near/planes
  7022. * @returns true if the object is in frustum otherwise false
  7023. */
  7024. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7025. }
  7026. /**
  7027. * Info for a bounding data of a mesh
  7028. */
  7029. export class BoundingInfo implements ICullable {
  7030. /**
  7031. * Bounding box for the mesh
  7032. */
  7033. readonly boundingBox: BoundingBox;
  7034. /**
  7035. * Bounding sphere for the mesh
  7036. */
  7037. readonly boundingSphere: BoundingSphere;
  7038. private _isLocked;
  7039. private static readonly TmpVector3;
  7040. /**
  7041. * Constructs bounding info
  7042. * @param minimum min vector of the bounding box/sphere
  7043. * @param maximum max vector of the bounding box/sphere
  7044. * @param worldMatrix defines the new world matrix
  7045. */
  7046. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7047. /**
  7048. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7049. * @param min defines the new minimum vector (in local space)
  7050. * @param max defines the new maximum vector (in local space)
  7051. * @param worldMatrix defines the new world matrix
  7052. */
  7053. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7054. /**
  7055. * min vector of the bounding box/sphere
  7056. */
  7057. get minimum(): Vector3;
  7058. /**
  7059. * max vector of the bounding box/sphere
  7060. */
  7061. get maximum(): Vector3;
  7062. /**
  7063. * If the info is locked and won't be updated to avoid perf overhead
  7064. */
  7065. get isLocked(): boolean;
  7066. set isLocked(value: boolean);
  7067. /**
  7068. * Updates the bounding sphere and box
  7069. * @param world world matrix to be used to update
  7070. */
  7071. update(world: DeepImmutable<Matrix>): void;
  7072. /**
  7073. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7074. * @param center New center of the bounding info
  7075. * @param extend New extend of the bounding info
  7076. * @returns the current bounding info
  7077. */
  7078. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7079. /**
  7080. * Scale the current bounding info by applying a scale factor
  7081. * @param factor defines the scale factor to apply
  7082. * @returns the current bounding info
  7083. */
  7084. scale(factor: number): BoundingInfo;
  7085. /**
  7086. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7087. * @param frustumPlanes defines the frustum to test
  7088. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7089. * @returns true if the bounding info is in the frustum planes
  7090. */
  7091. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7092. /**
  7093. * Gets the world distance between the min and max points of the bounding box
  7094. */
  7095. get diagonalLength(): number;
  7096. /**
  7097. * Checks if a cullable object (mesh...) is in the camera frustum
  7098. * Unlike isInFrustum this cheks the full bounding box
  7099. * @param frustumPlanes Camera near/planes
  7100. * @returns true if the object is in frustum otherwise false
  7101. */
  7102. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7103. /** @hidden */
  7104. _checkCollision(collider: Collider): boolean;
  7105. /**
  7106. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7107. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7108. * @param point the point to check intersection with
  7109. * @returns if the point intersects
  7110. */
  7111. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7112. /**
  7113. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7114. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7115. * @param boundingInfo the bounding info to check intersection with
  7116. * @param precise if the intersection should be done using OBB
  7117. * @returns if the bounding info intersects
  7118. */
  7119. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7120. }
  7121. }
  7122. declare module BABYLON {
  7123. /**
  7124. * Extracts minimum and maximum values from a list of indexed positions
  7125. * @param positions defines the positions to use
  7126. * @param indices defines the indices to the positions
  7127. * @param indexStart defines the start index
  7128. * @param indexCount defines the end index
  7129. * @param bias defines bias value to add to the result
  7130. * @return minimum and maximum values
  7131. */
  7132. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7133. minimum: Vector3;
  7134. maximum: Vector3;
  7135. };
  7136. /**
  7137. * Extracts minimum and maximum values from a list of positions
  7138. * @param positions defines the positions to use
  7139. * @param start defines the start index in the positions array
  7140. * @param count defines the number of positions to handle
  7141. * @param bias defines bias value to add to the result
  7142. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7143. * @return minimum and maximum values
  7144. */
  7145. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7146. minimum: Vector3;
  7147. maximum: Vector3;
  7148. };
  7149. }
  7150. declare module BABYLON {
  7151. /** @hidden */
  7152. export class WebGLDataBuffer extends DataBuffer {
  7153. private _buffer;
  7154. constructor(resource: WebGLBuffer);
  7155. get underlyingResource(): any;
  7156. }
  7157. }
  7158. declare module BABYLON {
  7159. /** @hidden */
  7160. export class WebGLPipelineContext implements IPipelineContext {
  7161. engine: ThinEngine;
  7162. program: Nullable<WebGLProgram>;
  7163. context?: WebGLRenderingContext;
  7164. vertexShader?: WebGLShader;
  7165. fragmentShader?: WebGLShader;
  7166. isParallelCompiled: boolean;
  7167. onCompiled?: () => void;
  7168. transformFeedback?: WebGLTransformFeedback | null;
  7169. vertexCompilationError: Nullable<string>;
  7170. fragmentCompilationError: Nullable<string>;
  7171. programLinkError: Nullable<string>;
  7172. programValidationError: Nullable<string>;
  7173. get isAsync(): boolean;
  7174. get isReady(): boolean;
  7175. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7176. }
  7177. }
  7178. declare module BABYLON {
  7179. interface ThinEngine {
  7180. /**
  7181. * Create an uniform buffer
  7182. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7183. * @param elements defines the content of the uniform buffer
  7184. * @returns the webGL uniform buffer
  7185. */
  7186. createUniformBuffer(elements: FloatArray): DataBuffer;
  7187. /**
  7188. * Create a dynamic uniform buffer
  7189. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7190. * @param elements defines the content of the uniform buffer
  7191. * @returns the webGL uniform buffer
  7192. */
  7193. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7194. /**
  7195. * Update an existing uniform buffer
  7196. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7197. * @param uniformBuffer defines the target uniform buffer
  7198. * @param elements defines the content to update
  7199. * @param offset defines the offset in the uniform buffer where update should start
  7200. * @param count defines the size of the data to update
  7201. */
  7202. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7203. /**
  7204. * Bind an uniform buffer to the current webGL context
  7205. * @param buffer defines the buffer to bind
  7206. */
  7207. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7208. /**
  7209. * Bind a buffer to the current webGL context at a given location
  7210. * @param buffer defines the buffer to bind
  7211. * @param location defines the index where to bind the buffer
  7212. */
  7213. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7214. /**
  7215. * Bind a specific block at a given index in a specific shader program
  7216. * @param pipelineContext defines the pipeline context to use
  7217. * @param blockName defines the block name
  7218. * @param index defines the index where to bind the block
  7219. */
  7220. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7221. }
  7222. }
  7223. declare module BABYLON {
  7224. /**
  7225. * Uniform buffer objects.
  7226. *
  7227. * Handles blocks of uniform on the GPU.
  7228. *
  7229. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7230. *
  7231. * For more information, please refer to :
  7232. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7233. */
  7234. export class UniformBuffer {
  7235. private _engine;
  7236. private _buffer;
  7237. private _data;
  7238. private _bufferData;
  7239. private _dynamic?;
  7240. private _uniformLocations;
  7241. private _uniformSizes;
  7242. private _uniformLocationPointer;
  7243. private _needSync;
  7244. private _noUBO;
  7245. private _currentEffect;
  7246. /** @hidden */
  7247. _alreadyBound: boolean;
  7248. private static _MAX_UNIFORM_SIZE;
  7249. private static _tempBuffer;
  7250. /**
  7251. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7252. * This is dynamic to allow compat with webgl 1 and 2.
  7253. * You will need to pass the name of the uniform as well as the value.
  7254. */
  7255. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7256. /**
  7257. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7258. * This is dynamic to allow compat with webgl 1 and 2.
  7259. * You will need to pass the name of the uniform as well as the value.
  7260. */
  7261. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7262. /**
  7263. * Lambda to Update a single float in a uniform buffer.
  7264. * This is dynamic to allow compat with webgl 1 and 2.
  7265. * You will need to pass the name of the uniform as well as the value.
  7266. */
  7267. updateFloat: (name: string, x: number) => void;
  7268. /**
  7269. * Lambda to Update a vec2 of float in a uniform buffer.
  7270. * This is dynamic to allow compat with webgl 1 and 2.
  7271. * You will need to pass the name of the uniform as well as the value.
  7272. */
  7273. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7274. /**
  7275. * Lambda to Update a vec3 of float in a uniform buffer.
  7276. * This is dynamic to allow compat with webgl 1 and 2.
  7277. * You will need to pass the name of the uniform as well as the value.
  7278. */
  7279. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7280. /**
  7281. * Lambda to Update a vec4 of float in a uniform buffer.
  7282. * This is dynamic to allow compat with webgl 1 and 2.
  7283. * You will need to pass the name of the uniform as well as the value.
  7284. */
  7285. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7286. /**
  7287. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7288. * This is dynamic to allow compat with webgl 1 and 2.
  7289. * You will need to pass the name of the uniform as well as the value.
  7290. */
  7291. updateMatrix: (name: string, mat: Matrix) => void;
  7292. /**
  7293. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7294. * This is dynamic to allow compat with webgl 1 and 2.
  7295. * You will need to pass the name of the uniform as well as the value.
  7296. */
  7297. updateVector3: (name: string, vector: Vector3) => void;
  7298. /**
  7299. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7300. * This is dynamic to allow compat with webgl 1 and 2.
  7301. * You will need to pass the name of the uniform as well as the value.
  7302. */
  7303. updateVector4: (name: string, vector: Vector4) => void;
  7304. /**
  7305. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7306. * This is dynamic to allow compat with webgl 1 and 2.
  7307. * You will need to pass the name of the uniform as well as the value.
  7308. */
  7309. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7310. /**
  7311. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7312. * This is dynamic to allow compat with webgl 1 and 2.
  7313. * You will need to pass the name of the uniform as well as the value.
  7314. */
  7315. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7316. /**
  7317. * Instantiates a new Uniform buffer objects.
  7318. *
  7319. * Handles blocks of uniform on the GPU.
  7320. *
  7321. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7322. *
  7323. * For more information, please refer to :
  7324. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7325. * @param engine Define the engine the buffer is associated with
  7326. * @param data Define the data contained in the buffer
  7327. * @param dynamic Define if the buffer is updatable
  7328. */
  7329. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7330. /**
  7331. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7332. * or just falling back on setUniformXXX calls.
  7333. */
  7334. get useUbo(): boolean;
  7335. /**
  7336. * Indicates if the WebGL underlying uniform buffer is in sync
  7337. * with the javascript cache data.
  7338. */
  7339. get isSync(): boolean;
  7340. /**
  7341. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7342. * Also, a dynamic UniformBuffer will disable cache verification and always
  7343. * update the underlying WebGL uniform buffer to the GPU.
  7344. * @returns if Dynamic, otherwise false
  7345. */
  7346. isDynamic(): boolean;
  7347. /**
  7348. * The data cache on JS side.
  7349. * @returns the underlying data as a float array
  7350. */
  7351. getData(): Float32Array;
  7352. /**
  7353. * The underlying WebGL Uniform buffer.
  7354. * @returns the webgl buffer
  7355. */
  7356. getBuffer(): Nullable<DataBuffer>;
  7357. /**
  7358. * std140 layout specifies how to align data within an UBO structure.
  7359. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7360. * for specs.
  7361. */
  7362. private _fillAlignment;
  7363. /**
  7364. * Adds an uniform in the buffer.
  7365. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7366. * for the layout to be correct !
  7367. * @param name Name of the uniform, as used in the uniform block in the shader.
  7368. * @param size Data size, or data directly.
  7369. */
  7370. addUniform(name: string, size: number | number[]): void;
  7371. /**
  7372. * Adds a Matrix 4x4 to the uniform buffer.
  7373. * @param name Name of the uniform, as used in the uniform block in the shader.
  7374. * @param mat A 4x4 matrix.
  7375. */
  7376. addMatrix(name: string, mat: Matrix): void;
  7377. /**
  7378. * Adds a vec2 to the uniform buffer.
  7379. * @param name Name of the uniform, as used in the uniform block in the shader.
  7380. * @param x Define the x component value of the vec2
  7381. * @param y Define the y component value of the vec2
  7382. */
  7383. addFloat2(name: string, x: number, y: number): void;
  7384. /**
  7385. * Adds a vec3 to the uniform buffer.
  7386. * @param name Name of the uniform, as used in the uniform block in the shader.
  7387. * @param x Define the x component value of the vec3
  7388. * @param y Define the y component value of the vec3
  7389. * @param z Define the z component value of the vec3
  7390. */
  7391. addFloat3(name: string, x: number, y: number, z: number): void;
  7392. /**
  7393. * Adds a vec3 to the uniform buffer.
  7394. * @param name Name of the uniform, as used in the uniform block in the shader.
  7395. * @param color Define the vec3 from a Color
  7396. */
  7397. addColor3(name: string, color: Color3): void;
  7398. /**
  7399. * Adds a vec4 to the uniform buffer.
  7400. * @param name Name of the uniform, as used in the uniform block in the shader.
  7401. * @param color Define the rgb components from a Color
  7402. * @param alpha Define the a component of the vec4
  7403. */
  7404. addColor4(name: string, color: Color3, alpha: number): void;
  7405. /**
  7406. * Adds a vec3 to the uniform buffer.
  7407. * @param name Name of the uniform, as used in the uniform block in the shader.
  7408. * @param vector Define the vec3 components from a Vector
  7409. */
  7410. addVector3(name: string, vector: Vector3): void;
  7411. /**
  7412. * Adds a Matrix 3x3 to the uniform buffer.
  7413. * @param name Name of the uniform, as used in the uniform block in the shader.
  7414. */
  7415. addMatrix3x3(name: string): void;
  7416. /**
  7417. * Adds a Matrix 2x2 to the uniform buffer.
  7418. * @param name Name of the uniform, as used in the uniform block in the shader.
  7419. */
  7420. addMatrix2x2(name: string): void;
  7421. /**
  7422. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7423. */
  7424. create(): void;
  7425. /** @hidden */
  7426. _rebuild(): void;
  7427. /**
  7428. * Updates the WebGL Uniform Buffer on the GPU.
  7429. * If the `dynamic` flag is set to true, no cache comparison is done.
  7430. * Otherwise, the buffer will be updated only if the cache differs.
  7431. */
  7432. update(): void;
  7433. /**
  7434. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7435. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7436. * @param data Define the flattened data
  7437. * @param size Define the size of the data.
  7438. */
  7439. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7440. private _valueCache;
  7441. private _cacheMatrix;
  7442. private _updateMatrix3x3ForUniform;
  7443. private _updateMatrix3x3ForEffect;
  7444. private _updateMatrix2x2ForEffect;
  7445. private _updateMatrix2x2ForUniform;
  7446. private _updateFloatForEffect;
  7447. private _updateFloatForUniform;
  7448. private _updateFloat2ForEffect;
  7449. private _updateFloat2ForUniform;
  7450. private _updateFloat3ForEffect;
  7451. private _updateFloat3ForUniform;
  7452. private _updateFloat4ForEffect;
  7453. private _updateFloat4ForUniform;
  7454. private _updateMatrixForEffect;
  7455. private _updateMatrixForUniform;
  7456. private _updateVector3ForEffect;
  7457. private _updateVector3ForUniform;
  7458. private _updateVector4ForEffect;
  7459. private _updateVector4ForUniform;
  7460. private _updateColor3ForEffect;
  7461. private _updateColor3ForUniform;
  7462. private _updateColor4ForEffect;
  7463. private _updateColor4ForUniform;
  7464. /**
  7465. * Sets a sampler uniform on the effect.
  7466. * @param name Define the name of the sampler.
  7467. * @param texture Define the texture to set in the sampler
  7468. */
  7469. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7470. /**
  7471. * Directly updates the value of the uniform in the cache AND on the GPU.
  7472. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7473. * @param data Define the flattened data
  7474. */
  7475. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7476. /**
  7477. * Binds this uniform buffer to an effect.
  7478. * @param effect Define the effect to bind the buffer to
  7479. * @param name Name of the uniform block in the shader.
  7480. */
  7481. bindToEffect(effect: Effect, name: string): void;
  7482. /**
  7483. * Disposes the uniform buffer.
  7484. */
  7485. dispose(): void;
  7486. }
  7487. }
  7488. declare module BABYLON {
  7489. /**
  7490. * Enum that determines the text-wrapping mode to use.
  7491. */
  7492. export enum InspectableType {
  7493. /**
  7494. * Checkbox for booleans
  7495. */
  7496. Checkbox = 0,
  7497. /**
  7498. * Sliders for numbers
  7499. */
  7500. Slider = 1,
  7501. /**
  7502. * Vector3
  7503. */
  7504. Vector3 = 2,
  7505. /**
  7506. * Quaternions
  7507. */
  7508. Quaternion = 3,
  7509. /**
  7510. * Color3
  7511. */
  7512. Color3 = 4,
  7513. /**
  7514. * String
  7515. */
  7516. String = 5
  7517. }
  7518. /**
  7519. * Interface used to define custom inspectable properties.
  7520. * This interface is used by the inspector to display custom property grids
  7521. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7522. */
  7523. export interface IInspectable {
  7524. /**
  7525. * Gets the label to display
  7526. */
  7527. label: string;
  7528. /**
  7529. * Gets the name of the property to edit
  7530. */
  7531. propertyName: string;
  7532. /**
  7533. * Gets the type of the editor to use
  7534. */
  7535. type: InspectableType;
  7536. /**
  7537. * Gets the minimum value of the property when using in "slider" mode
  7538. */
  7539. min?: number;
  7540. /**
  7541. * Gets the maximum value of the property when using in "slider" mode
  7542. */
  7543. max?: number;
  7544. /**
  7545. * Gets the setp to use when using in "slider" mode
  7546. */
  7547. step?: number;
  7548. }
  7549. }
  7550. declare module BABYLON {
  7551. /**
  7552. * Class used to provide helper for timing
  7553. */
  7554. export class TimingTools {
  7555. /**
  7556. * Polyfill for setImmediate
  7557. * @param action defines the action to execute after the current execution block
  7558. */
  7559. static SetImmediate(action: () => void): void;
  7560. }
  7561. }
  7562. declare module BABYLON {
  7563. /**
  7564. * Class used to enable instatition of objects by class name
  7565. */
  7566. export class InstantiationTools {
  7567. /**
  7568. * Use this object to register external classes like custom textures or material
  7569. * to allow the laoders to instantiate them
  7570. */
  7571. static RegisteredExternalClasses: {
  7572. [key: string]: Object;
  7573. };
  7574. /**
  7575. * Tries to instantiate a new object from a given class name
  7576. * @param className defines the class name to instantiate
  7577. * @returns the new object or null if the system was not able to do the instantiation
  7578. */
  7579. static Instantiate(className: string): any;
  7580. }
  7581. }
  7582. declare module BABYLON {
  7583. /**
  7584. * Define options used to create a depth texture
  7585. */
  7586. export class DepthTextureCreationOptions {
  7587. /** Specifies whether or not a stencil should be allocated in the texture */
  7588. generateStencil?: boolean;
  7589. /** Specifies whether or not bilinear filtering is enable on the texture */
  7590. bilinearFiltering?: boolean;
  7591. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7592. comparisonFunction?: number;
  7593. /** Specifies if the created texture is a cube texture */
  7594. isCube?: boolean;
  7595. }
  7596. }
  7597. declare module BABYLON {
  7598. interface ThinEngine {
  7599. /**
  7600. * Creates a depth stencil cube texture.
  7601. * This is only available in WebGL 2.
  7602. * @param size The size of face edge in the cube texture.
  7603. * @param options The options defining the cube texture.
  7604. * @returns The cube texture
  7605. */
  7606. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7607. /**
  7608. * Creates a cube texture
  7609. * @param rootUrl defines the url where the files to load is located
  7610. * @param scene defines the current scene
  7611. * @param files defines the list of files to load (1 per face)
  7612. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7613. * @param onLoad defines an optional callback raised when the texture is loaded
  7614. * @param onError defines an optional callback raised if there is an issue to load the texture
  7615. * @param format defines the format of the data
  7616. * @param forcedExtension defines the extension to use to pick the right loader
  7617. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7618. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7619. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7620. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7621. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7622. * @returns the cube texture as an InternalTexture
  7623. */
  7624. 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;
  7625. /**
  7626. * Creates a cube texture
  7627. * @param rootUrl defines the url where the files to load is located
  7628. * @param scene defines the current scene
  7629. * @param files defines the list of files to load (1 per face)
  7630. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7631. * @param onLoad defines an optional callback raised when the texture is loaded
  7632. * @param onError defines an optional callback raised if there is an issue to load the texture
  7633. * @param format defines the format of the data
  7634. * @param forcedExtension defines the extension to use to pick the right loader
  7635. * @returns the cube texture as an InternalTexture
  7636. */
  7637. 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;
  7638. /**
  7639. * Creates a cube texture
  7640. * @param rootUrl defines the url where the files to load is located
  7641. * @param scene defines the current scene
  7642. * @param files defines the list of files to load (1 per face)
  7643. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7644. * @param onLoad defines an optional callback raised when the texture is loaded
  7645. * @param onError defines an optional callback raised if there is an issue to load the texture
  7646. * @param format defines the format of the data
  7647. * @param forcedExtension defines the extension to use to pick the right loader
  7648. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7649. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7650. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7651. * @returns the cube texture as an InternalTexture
  7652. */
  7653. 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;
  7654. /** @hidden */
  7655. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7656. /** @hidden */
  7657. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7658. /** @hidden */
  7659. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7660. /** @hidden */
  7661. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7662. /**
  7663. * @hidden
  7664. */
  7665. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7666. }
  7667. }
  7668. declare module BABYLON {
  7669. /**
  7670. * Class for creating a cube texture
  7671. */
  7672. export class CubeTexture extends BaseTexture {
  7673. private _delayedOnLoad;
  7674. /**
  7675. * Observable triggered once the texture has been loaded.
  7676. */
  7677. onLoadObservable: Observable<CubeTexture>;
  7678. /**
  7679. * The url of the texture
  7680. */
  7681. url: string;
  7682. /**
  7683. * Gets or sets the center of the bounding box associated with the cube texture.
  7684. * It must define where the camera used to render the texture was set
  7685. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7686. */
  7687. boundingBoxPosition: Vector3;
  7688. private _boundingBoxSize;
  7689. /**
  7690. * Gets or sets the size of the bounding box associated with the cube texture
  7691. * When defined, the cubemap will switch to local mode
  7692. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7693. * @example https://www.babylonjs-playground.com/#RNASML
  7694. */
  7695. set boundingBoxSize(value: Vector3);
  7696. /**
  7697. * Returns the bounding box size
  7698. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7699. */
  7700. get boundingBoxSize(): Vector3;
  7701. protected _rotationY: number;
  7702. /**
  7703. * Sets texture matrix rotation angle around Y axis in radians.
  7704. */
  7705. set rotationY(value: number);
  7706. /**
  7707. * Gets texture matrix rotation angle around Y axis radians.
  7708. */
  7709. get rotationY(): number;
  7710. /**
  7711. * Are mip maps generated for this texture or not.
  7712. */
  7713. get noMipmap(): boolean;
  7714. private _noMipmap;
  7715. private _files;
  7716. protected _forcedExtension: Nullable<string>;
  7717. private _extensions;
  7718. private _textureMatrix;
  7719. private _format;
  7720. private _createPolynomials;
  7721. /** @hidden */
  7722. _prefiltered: boolean;
  7723. /**
  7724. * Creates a cube texture from an array of image urls
  7725. * @param files defines an array of image urls
  7726. * @param scene defines the hosting scene
  7727. * @param noMipmap specifies if mip maps are not used
  7728. * @returns a cube texture
  7729. */
  7730. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7731. /**
  7732. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7733. * @param url defines the url of the prefiltered texture
  7734. * @param scene defines the scene the texture is attached to
  7735. * @param forcedExtension defines the extension of the file if different from the url
  7736. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7737. * @return the prefiltered texture
  7738. */
  7739. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7740. /**
  7741. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7742. * as prefiltered data.
  7743. * @param rootUrl defines the url of the texture or the root name of the six images
  7744. * @param scene defines the scene the texture is attached to
  7745. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7746. * @param noMipmap defines if mipmaps should be created or not
  7747. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7748. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7749. * @param onError defines a callback triggered in case of error during load
  7750. * @param format defines the internal format to use for the texture once loaded
  7751. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7752. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7753. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7754. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7755. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7756. * @return the cube texture
  7757. */
  7758. 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);
  7759. /**
  7760. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7761. */
  7762. get isPrefiltered(): boolean;
  7763. /**
  7764. * Get the current class name of the texture useful for serialization or dynamic coding.
  7765. * @returns "CubeTexture"
  7766. */
  7767. getClassName(): string;
  7768. /**
  7769. * Update the url (and optional buffer) of this texture if url was null during construction.
  7770. * @param url the url of the texture
  7771. * @param forcedExtension defines the extension to use
  7772. * @param onLoad callback called when the texture is loaded (defaults to null)
  7773. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7774. */
  7775. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7776. /**
  7777. * Delays loading of the cube texture
  7778. * @param forcedExtension defines the extension to use
  7779. */
  7780. delayLoad(forcedExtension?: string): void;
  7781. /**
  7782. * Returns the reflection texture matrix
  7783. * @returns the reflection texture matrix
  7784. */
  7785. getReflectionTextureMatrix(): Matrix;
  7786. /**
  7787. * Sets the reflection texture matrix
  7788. * @param value Reflection texture matrix
  7789. */
  7790. setReflectionTextureMatrix(value: Matrix): void;
  7791. /**
  7792. * Parses text to create a cube texture
  7793. * @param parsedTexture define the serialized text to read from
  7794. * @param scene defines the hosting scene
  7795. * @param rootUrl defines the root url of the cube texture
  7796. * @returns a cube texture
  7797. */
  7798. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7799. /**
  7800. * Makes a clone, or deep copy, of the cube texture
  7801. * @returns a new cube texture
  7802. */
  7803. clone(): CubeTexture;
  7804. }
  7805. }
  7806. declare module BABYLON {
  7807. /**
  7808. * Manages the defines for the Material
  7809. */
  7810. export class MaterialDefines {
  7811. /** @hidden */
  7812. protected _keys: string[];
  7813. private _isDirty;
  7814. /** @hidden */
  7815. _renderId: number;
  7816. /** @hidden */
  7817. _areLightsDirty: boolean;
  7818. /** @hidden */
  7819. _areLightsDisposed: boolean;
  7820. /** @hidden */
  7821. _areAttributesDirty: boolean;
  7822. /** @hidden */
  7823. _areTexturesDirty: boolean;
  7824. /** @hidden */
  7825. _areFresnelDirty: boolean;
  7826. /** @hidden */
  7827. _areMiscDirty: boolean;
  7828. /** @hidden */
  7829. _areImageProcessingDirty: boolean;
  7830. /** @hidden */
  7831. _normals: boolean;
  7832. /** @hidden */
  7833. _uvs: boolean;
  7834. /** @hidden */
  7835. _needNormals: boolean;
  7836. /** @hidden */
  7837. _needUVs: boolean;
  7838. [id: string]: any;
  7839. /**
  7840. * Specifies if the material needs to be re-calculated
  7841. */
  7842. get isDirty(): boolean;
  7843. /**
  7844. * Marks the material to indicate that it has been re-calculated
  7845. */
  7846. markAsProcessed(): void;
  7847. /**
  7848. * Marks the material to indicate that it needs to be re-calculated
  7849. */
  7850. markAsUnprocessed(): void;
  7851. /**
  7852. * Marks the material to indicate all of its defines need to be re-calculated
  7853. */
  7854. markAllAsDirty(): void;
  7855. /**
  7856. * Marks the material to indicate that image processing needs to be re-calculated
  7857. */
  7858. markAsImageProcessingDirty(): void;
  7859. /**
  7860. * Marks the material to indicate the lights need to be re-calculated
  7861. * @param disposed Defines whether the light is dirty due to dispose or not
  7862. */
  7863. markAsLightDirty(disposed?: boolean): void;
  7864. /**
  7865. * Marks the attribute state as changed
  7866. */
  7867. markAsAttributesDirty(): void;
  7868. /**
  7869. * Marks the texture state as changed
  7870. */
  7871. markAsTexturesDirty(): void;
  7872. /**
  7873. * Marks the fresnel state as changed
  7874. */
  7875. markAsFresnelDirty(): void;
  7876. /**
  7877. * Marks the misc state as changed
  7878. */
  7879. markAsMiscDirty(): void;
  7880. /**
  7881. * Rebuilds the material defines
  7882. */
  7883. rebuild(): void;
  7884. /**
  7885. * Specifies if two material defines are equal
  7886. * @param other - A material define instance to compare to
  7887. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7888. */
  7889. isEqual(other: MaterialDefines): boolean;
  7890. /**
  7891. * Clones this instance's defines to another instance
  7892. * @param other - material defines to clone values to
  7893. */
  7894. cloneTo(other: MaterialDefines): void;
  7895. /**
  7896. * Resets the material define values
  7897. */
  7898. reset(): void;
  7899. /**
  7900. * Converts the material define values to a string
  7901. * @returns - String of material define information
  7902. */
  7903. toString(): string;
  7904. }
  7905. }
  7906. declare module BABYLON {
  7907. /**
  7908. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7909. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7910. * 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;
  7911. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7912. */
  7913. export class ColorCurves {
  7914. private _dirty;
  7915. private _tempColor;
  7916. private _globalCurve;
  7917. private _highlightsCurve;
  7918. private _midtonesCurve;
  7919. private _shadowsCurve;
  7920. private _positiveCurve;
  7921. private _negativeCurve;
  7922. private _globalHue;
  7923. private _globalDensity;
  7924. private _globalSaturation;
  7925. private _globalExposure;
  7926. /**
  7927. * Gets the global Hue value.
  7928. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7929. */
  7930. get globalHue(): number;
  7931. /**
  7932. * Sets the global Hue value.
  7933. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7934. */
  7935. set globalHue(value: number);
  7936. /**
  7937. * Gets the global Density value.
  7938. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7939. * Values less than zero provide a filter of opposite hue.
  7940. */
  7941. get globalDensity(): number;
  7942. /**
  7943. * Sets the global Density value.
  7944. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7945. * Values less than zero provide a filter of opposite hue.
  7946. */
  7947. set globalDensity(value: number);
  7948. /**
  7949. * Gets the global Saturation value.
  7950. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7951. */
  7952. get globalSaturation(): number;
  7953. /**
  7954. * Sets the global Saturation value.
  7955. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7956. */
  7957. set globalSaturation(value: number);
  7958. /**
  7959. * Gets the global Exposure value.
  7960. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7961. */
  7962. get globalExposure(): number;
  7963. /**
  7964. * Sets the global Exposure value.
  7965. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7966. */
  7967. set globalExposure(value: number);
  7968. private _highlightsHue;
  7969. private _highlightsDensity;
  7970. private _highlightsSaturation;
  7971. private _highlightsExposure;
  7972. /**
  7973. * Gets the highlights Hue value.
  7974. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7975. */
  7976. get highlightsHue(): number;
  7977. /**
  7978. * Sets the highlights Hue value.
  7979. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7980. */
  7981. set highlightsHue(value: number);
  7982. /**
  7983. * Gets the highlights Density value.
  7984. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7985. * Values less than zero provide a filter of opposite hue.
  7986. */
  7987. get highlightsDensity(): number;
  7988. /**
  7989. * Sets the highlights Density value.
  7990. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7991. * Values less than zero provide a filter of opposite hue.
  7992. */
  7993. set highlightsDensity(value: number);
  7994. /**
  7995. * Gets the highlights Saturation value.
  7996. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7997. */
  7998. get highlightsSaturation(): number;
  7999. /**
  8000. * Sets the highlights Saturation value.
  8001. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8002. */
  8003. set highlightsSaturation(value: number);
  8004. /**
  8005. * Gets the highlights Exposure value.
  8006. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8007. */
  8008. get highlightsExposure(): number;
  8009. /**
  8010. * Sets the highlights Exposure value.
  8011. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8012. */
  8013. set highlightsExposure(value: number);
  8014. private _midtonesHue;
  8015. private _midtonesDensity;
  8016. private _midtonesSaturation;
  8017. private _midtonesExposure;
  8018. /**
  8019. * Gets the midtones Hue value.
  8020. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8021. */
  8022. get midtonesHue(): number;
  8023. /**
  8024. * Sets the midtones Hue value.
  8025. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8026. */
  8027. set midtonesHue(value: number);
  8028. /**
  8029. * Gets the midtones Density value.
  8030. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8031. * Values less than zero provide a filter of opposite hue.
  8032. */
  8033. get midtonesDensity(): number;
  8034. /**
  8035. * Sets the midtones Density value.
  8036. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8037. * Values less than zero provide a filter of opposite hue.
  8038. */
  8039. set midtonesDensity(value: number);
  8040. /**
  8041. * Gets the midtones Saturation value.
  8042. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8043. */
  8044. get midtonesSaturation(): number;
  8045. /**
  8046. * Sets the midtones Saturation value.
  8047. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8048. */
  8049. set midtonesSaturation(value: number);
  8050. /**
  8051. * Gets the midtones Exposure value.
  8052. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8053. */
  8054. get midtonesExposure(): number;
  8055. /**
  8056. * Sets the midtones Exposure value.
  8057. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8058. */
  8059. set midtonesExposure(value: number);
  8060. private _shadowsHue;
  8061. private _shadowsDensity;
  8062. private _shadowsSaturation;
  8063. private _shadowsExposure;
  8064. /**
  8065. * Gets the shadows Hue value.
  8066. * 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).
  8067. */
  8068. get shadowsHue(): number;
  8069. /**
  8070. * Sets the shadows Hue value.
  8071. * 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).
  8072. */
  8073. set shadowsHue(value: number);
  8074. /**
  8075. * Gets the shadows Density value.
  8076. * 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.
  8077. * Values less than zero provide a filter of opposite hue.
  8078. */
  8079. get shadowsDensity(): number;
  8080. /**
  8081. * Sets the shadows Density value.
  8082. * 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.
  8083. * Values less than zero provide a filter of opposite hue.
  8084. */
  8085. set shadowsDensity(value: number);
  8086. /**
  8087. * Gets the shadows Saturation value.
  8088. * 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.
  8089. */
  8090. get shadowsSaturation(): number;
  8091. /**
  8092. * Sets the shadows Saturation value.
  8093. * 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.
  8094. */
  8095. set shadowsSaturation(value: number);
  8096. /**
  8097. * Gets the shadows Exposure value.
  8098. * 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.
  8099. */
  8100. get shadowsExposure(): number;
  8101. /**
  8102. * Sets the shadows Exposure value.
  8103. * 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.
  8104. */
  8105. set shadowsExposure(value: number);
  8106. /**
  8107. * Returns the class name
  8108. * @returns The class name
  8109. */
  8110. getClassName(): string;
  8111. /**
  8112. * Binds the color curves to the shader.
  8113. * @param colorCurves The color curve to bind
  8114. * @param effect The effect to bind to
  8115. * @param positiveUniform The positive uniform shader parameter
  8116. * @param neutralUniform The neutral uniform shader parameter
  8117. * @param negativeUniform The negative uniform shader parameter
  8118. */
  8119. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8120. /**
  8121. * Prepare the list of uniforms associated with the ColorCurves effects.
  8122. * @param uniformsList The list of uniforms used in the effect
  8123. */
  8124. static PrepareUniforms(uniformsList: string[]): void;
  8125. /**
  8126. * Returns color grading data based on a hue, density, saturation and exposure value.
  8127. * @param filterHue The hue of the color filter.
  8128. * @param filterDensity The density of the color filter.
  8129. * @param saturation The saturation.
  8130. * @param exposure The exposure.
  8131. * @param result The result data container.
  8132. */
  8133. private getColorGradingDataToRef;
  8134. /**
  8135. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8136. * @param value The input slider value in range [-100,100].
  8137. * @returns Adjusted value.
  8138. */
  8139. private static applyColorGradingSliderNonlinear;
  8140. /**
  8141. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8142. * @param hue The hue (H) input.
  8143. * @param saturation The saturation (S) input.
  8144. * @param brightness The brightness (B) input.
  8145. * @result An RGBA color represented as Vector4.
  8146. */
  8147. private static fromHSBToRef;
  8148. /**
  8149. * Returns a value clamped between min and max
  8150. * @param value The value to clamp
  8151. * @param min The minimum of value
  8152. * @param max The maximum of value
  8153. * @returns The clamped value.
  8154. */
  8155. private static clamp;
  8156. /**
  8157. * Clones the current color curve instance.
  8158. * @return The cloned curves
  8159. */
  8160. clone(): ColorCurves;
  8161. /**
  8162. * Serializes the current color curve instance to a json representation.
  8163. * @return a JSON representation
  8164. */
  8165. serialize(): any;
  8166. /**
  8167. * Parses the color curve from a json representation.
  8168. * @param source the JSON source to parse
  8169. * @return The parsed curves
  8170. */
  8171. static Parse(source: any): ColorCurves;
  8172. }
  8173. }
  8174. declare module BABYLON {
  8175. /**
  8176. * Interface to follow in your material defines to integrate easily the
  8177. * Image proccessing functions.
  8178. * @hidden
  8179. */
  8180. export interface IImageProcessingConfigurationDefines {
  8181. IMAGEPROCESSING: boolean;
  8182. VIGNETTE: boolean;
  8183. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8184. VIGNETTEBLENDMODEOPAQUE: boolean;
  8185. TONEMAPPING: boolean;
  8186. TONEMAPPING_ACES: boolean;
  8187. CONTRAST: boolean;
  8188. EXPOSURE: boolean;
  8189. COLORCURVES: boolean;
  8190. COLORGRADING: boolean;
  8191. COLORGRADING3D: boolean;
  8192. SAMPLER3DGREENDEPTH: boolean;
  8193. SAMPLER3DBGRMAP: boolean;
  8194. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8195. }
  8196. /**
  8197. * @hidden
  8198. */
  8199. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8200. IMAGEPROCESSING: boolean;
  8201. VIGNETTE: boolean;
  8202. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8203. VIGNETTEBLENDMODEOPAQUE: boolean;
  8204. TONEMAPPING: boolean;
  8205. TONEMAPPING_ACES: boolean;
  8206. CONTRAST: boolean;
  8207. COLORCURVES: boolean;
  8208. COLORGRADING: boolean;
  8209. COLORGRADING3D: boolean;
  8210. SAMPLER3DGREENDEPTH: boolean;
  8211. SAMPLER3DBGRMAP: boolean;
  8212. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8213. EXPOSURE: boolean;
  8214. constructor();
  8215. }
  8216. /**
  8217. * This groups together the common properties used for image processing either in direct forward pass
  8218. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8219. * or not.
  8220. */
  8221. export class ImageProcessingConfiguration {
  8222. /**
  8223. * Default tone mapping applied in BabylonJS.
  8224. */
  8225. static readonly TONEMAPPING_STANDARD: number;
  8226. /**
  8227. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8228. * to other engines rendering to increase portability.
  8229. */
  8230. static readonly TONEMAPPING_ACES: number;
  8231. /**
  8232. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8233. */
  8234. colorCurves: Nullable<ColorCurves>;
  8235. private _colorCurvesEnabled;
  8236. /**
  8237. * Gets wether the color curves effect is enabled.
  8238. */
  8239. get colorCurvesEnabled(): boolean;
  8240. /**
  8241. * Sets wether the color curves effect is enabled.
  8242. */
  8243. set colorCurvesEnabled(value: boolean);
  8244. private _colorGradingTexture;
  8245. /**
  8246. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8247. */
  8248. get colorGradingTexture(): Nullable<BaseTexture>;
  8249. /**
  8250. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8251. */
  8252. set colorGradingTexture(value: Nullable<BaseTexture>);
  8253. private _colorGradingEnabled;
  8254. /**
  8255. * Gets wether the color grading effect is enabled.
  8256. */
  8257. get colorGradingEnabled(): boolean;
  8258. /**
  8259. * Sets wether the color grading effect is enabled.
  8260. */
  8261. set colorGradingEnabled(value: boolean);
  8262. private _colorGradingWithGreenDepth;
  8263. /**
  8264. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8265. */
  8266. get colorGradingWithGreenDepth(): boolean;
  8267. /**
  8268. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8269. */
  8270. set colorGradingWithGreenDepth(value: boolean);
  8271. private _colorGradingBGR;
  8272. /**
  8273. * Gets wether the color grading texture contains BGR values.
  8274. */
  8275. get colorGradingBGR(): boolean;
  8276. /**
  8277. * Sets wether the color grading texture contains BGR values.
  8278. */
  8279. set colorGradingBGR(value: boolean);
  8280. /** @hidden */
  8281. _exposure: number;
  8282. /**
  8283. * Gets the Exposure used in the effect.
  8284. */
  8285. get exposure(): number;
  8286. /**
  8287. * Sets the Exposure used in the effect.
  8288. */
  8289. set exposure(value: number);
  8290. private _toneMappingEnabled;
  8291. /**
  8292. * Gets wether the tone mapping effect is enabled.
  8293. */
  8294. get toneMappingEnabled(): boolean;
  8295. /**
  8296. * Sets wether the tone mapping effect is enabled.
  8297. */
  8298. set toneMappingEnabled(value: boolean);
  8299. private _toneMappingType;
  8300. /**
  8301. * Gets the type of tone mapping effect.
  8302. */
  8303. get toneMappingType(): number;
  8304. /**
  8305. * Sets the type of tone mapping effect used in BabylonJS.
  8306. */
  8307. set toneMappingType(value: number);
  8308. protected _contrast: number;
  8309. /**
  8310. * Gets the contrast used in the effect.
  8311. */
  8312. get contrast(): number;
  8313. /**
  8314. * Sets the contrast used in the effect.
  8315. */
  8316. set contrast(value: number);
  8317. /**
  8318. * Vignette stretch size.
  8319. */
  8320. vignetteStretch: number;
  8321. /**
  8322. * Vignette centre X Offset.
  8323. */
  8324. vignetteCentreX: number;
  8325. /**
  8326. * Vignette centre Y Offset.
  8327. */
  8328. vignetteCentreY: number;
  8329. /**
  8330. * Vignette weight or intensity of the vignette effect.
  8331. */
  8332. vignetteWeight: number;
  8333. /**
  8334. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8335. * if vignetteEnabled is set to true.
  8336. */
  8337. vignetteColor: Color4;
  8338. /**
  8339. * Camera field of view used by the Vignette effect.
  8340. */
  8341. vignetteCameraFov: number;
  8342. private _vignetteBlendMode;
  8343. /**
  8344. * Gets the vignette blend mode allowing different kind of effect.
  8345. */
  8346. get vignetteBlendMode(): number;
  8347. /**
  8348. * Sets the vignette blend mode allowing different kind of effect.
  8349. */
  8350. set vignetteBlendMode(value: number);
  8351. private _vignetteEnabled;
  8352. /**
  8353. * Gets wether the vignette effect is enabled.
  8354. */
  8355. get vignetteEnabled(): boolean;
  8356. /**
  8357. * Sets wether the vignette effect is enabled.
  8358. */
  8359. set vignetteEnabled(value: boolean);
  8360. private _applyByPostProcess;
  8361. /**
  8362. * Gets wether the image processing is applied through a post process or not.
  8363. */
  8364. get applyByPostProcess(): boolean;
  8365. /**
  8366. * Sets wether the image processing is applied through a post process or not.
  8367. */
  8368. set applyByPostProcess(value: boolean);
  8369. private _isEnabled;
  8370. /**
  8371. * Gets wether the image processing is enabled or not.
  8372. */
  8373. get isEnabled(): boolean;
  8374. /**
  8375. * Sets wether the image processing is enabled or not.
  8376. */
  8377. set isEnabled(value: boolean);
  8378. /**
  8379. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8380. */
  8381. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8382. /**
  8383. * Method called each time the image processing information changes requires to recompile the effect.
  8384. */
  8385. protected _updateParameters(): void;
  8386. /**
  8387. * Gets the current class name.
  8388. * @return "ImageProcessingConfiguration"
  8389. */
  8390. getClassName(): string;
  8391. /**
  8392. * Prepare the list of uniforms associated with the Image Processing effects.
  8393. * @param uniforms The list of uniforms used in the effect
  8394. * @param defines the list of defines currently in use
  8395. */
  8396. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8397. /**
  8398. * Prepare the list of samplers associated with the Image Processing effects.
  8399. * @param samplersList The list of uniforms used in the effect
  8400. * @param defines the list of defines currently in use
  8401. */
  8402. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8403. /**
  8404. * Prepare the list of defines associated to the shader.
  8405. * @param defines the list of defines to complete
  8406. * @param forPostProcess Define if we are currently in post process mode or not
  8407. */
  8408. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8409. /**
  8410. * Returns true if all the image processing information are ready.
  8411. * @returns True if ready, otherwise, false
  8412. */
  8413. isReady(): boolean;
  8414. /**
  8415. * Binds the image processing to the shader.
  8416. * @param effect The effect to bind to
  8417. * @param overrideAspectRatio Override the aspect ratio of the effect
  8418. */
  8419. bind(effect: Effect, overrideAspectRatio?: number): void;
  8420. /**
  8421. * Clones the current image processing instance.
  8422. * @return The cloned image processing
  8423. */
  8424. clone(): ImageProcessingConfiguration;
  8425. /**
  8426. * Serializes the current image processing instance to a json representation.
  8427. * @return a JSON representation
  8428. */
  8429. serialize(): any;
  8430. /**
  8431. * Parses the image processing from a json representation.
  8432. * @param source the JSON source to parse
  8433. * @return The parsed image processing
  8434. */
  8435. static Parse(source: any): ImageProcessingConfiguration;
  8436. private static _VIGNETTEMODE_MULTIPLY;
  8437. private static _VIGNETTEMODE_OPAQUE;
  8438. /**
  8439. * Used to apply the vignette as a mix with the pixel color.
  8440. */
  8441. static get VIGNETTEMODE_MULTIPLY(): number;
  8442. /**
  8443. * Used to apply the vignette as a replacement of the pixel color.
  8444. */
  8445. static get VIGNETTEMODE_OPAQUE(): number;
  8446. }
  8447. }
  8448. declare module BABYLON {
  8449. /** @hidden */
  8450. export var postprocessVertexShader: {
  8451. name: string;
  8452. shader: string;
  8453. };
  8454. }
  8455. declare module BABYLON {
  8456. interface ThinEngine {
  8457. /**
  8458. * Creates a new render target texture
  8459. * @param size defines the size of the texture
  8460. * @param options defines the options used to create the texture
  8461. * @returns a new render target texture stored in an InternalTexture
  8462. */
  8463. createRenderTargetTexture(size: number | {
  8464. width: number;
  8465. height: number;
  8466. layers?: number;
  8467. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8468. /**
  8469. * Creates a depth stencil texture.
  8470. * This is only available in WebGL 2 or with the depth texture extension available.
  8471. * @param size The size of face edge in the texture.
  8472. * @param options The options defining the texture.
  8473. * @returns The texture
  8474. */
  8475. createDepthStencilTexture(size: number | {
  8476. width: number;
  8477. height: number;
  8478. layers?: number;
  8479. }, options: DepthTextureCreationOptions): InternalTexture;
  8480. /** @hidden */
  8481. _createDepthStencilTexture(size: number | {
  8482. width: number;
  8483. height: number;
  8484. layers?: number;
  8485. }, options: DepthTextureCreationOptions): InternalTexture;
  8486. }
  8487. }
  8488. declare module BABYLON {
  8489. /** Defines supported spaces */
  8490. export enum Space {
  8491. /** Local (object) space */
  8492. LOCAL = 0,
  8493. /** World space */
  8494. WORLD = 1,
  8495. /** Bone space */
  8496. BONE = 2
  8497. }
  8498. /** Defines the 3 main axes */
  8499. export class Axis {
  8500. /** X axis */
  8501. static X: Vector3;
  8502. /** Y axis */
  8503. static Y: Vector3;
  8504. /** Z axis */
  8505. static Z: Vector3;
  8506. }
  8507. }
  8508. declare module BABYLON {
  8509. /**
  8510. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8511. * This is the base of the follow, arc rotate cameras and Free camera
  8512. * @see http://doc.babylonjs.com/features/cameras
  8513. */
  8514. export class TargetCamera extends Camera {
  8515. private static _RigCamTransformMatrix;
  8516. private static _TargetTransformMatrix;
  8517. private static _TargetFocalPoint;
  8518. /**
  8519. * Define the current direction the camera is moving to
  8520. */
  8521. cameraDirection: Vector3;
  8522. /**
  8523. * Define the current rotation the camera is rotating to
  8524. */
  8525. cameraRotation: Vector2;
  8526. /**
  8527. * When set, the up vector of the camera will be updated by the rotation of the camera
  8528. */
  8529. updateUpVectorFromRotation: boolean;
  8530. private _tmpQuaternion;
  8531. /**
  8532. * Define the current rotation of the camera
  8533. */
  8534. rotation: Vector3;
  8535. /**
  8536. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8537. */
  8538. rotationQuaternion: Quaternion;
  8539. /**
  8540. * Define the current speed of the camera
  8541. */
  8542. speed: number;
  8543. /**
  8544. * Add constraint to the camera to prevent it to move freely in all directions and
  8545. * around all axis.
  8546. */
  8547. noRotationConstraint: boolean;
  8548. /**
  8549. * Define the current target of the camera as an object or a position.
  8550. */
  8551. lockedTarget: any;
  8552. /** @hidden */
  8553. _currentTarget: Vector3;
  8554. /** @hidden */
  8555. _initialFocalDistance: number;
  8556. /** @hidden */
  8557. _viewMatrix: Matrix;
  8558. /** @hidden */
  8559. _camMatrix: Matrix;
  8560. /** @hidden */
  8561. _cameraTransformMatrix: Matrix;
  8562. /** @hidden */
  8563. _cameraRotationMatrix: Matrix;
  8564. /** @hidden */
  8565. _referencePoint: Vector3;
  8566. /** @hidden */
  8567. _transformedReferencePoint: Vector3;
  8568. protected _globalCurrentTarget: Vector3;
  8569. protected _globalCurrentUpVector: Vector3;
  8570. /** @hidden */
  8571. _reset: () => void;
  8572. private _defaultUp;
  8573. /**
  8574. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8575. * This is the base of the follow, arc rotate cameras and Free camera
  8576. * @see http://doc.babylonjs.com/features/cameras
  8577. * @param name Defines the name of the camera in the scene
  8578. * @param position Defines the start position of the camera in the scene
  8579. * @param scene Defines the scene the camera belongs to
  8580. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8581. */
  8582. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8583. /**
  8584. * Gets the position in front of the camera at a given distance.
  8585. * @param distance The distance from the camera we want the position to be
  8586. * @returns the position
  8587. */
  8588. getFrontPosition(distance: number): Vector3;
  8589. /** @hidden */
  8590. _getLockedTargetPosition(): Nullable<Vector3>;
  8591. private _storedPosition;
  8592. private _storedRotation;
  8593. private _storedRotationQuaternion;
  8594. /**
  8595. * Store current camera state of the camera (fov, position, rotation, etc..)
  8596. * @returns the camera
  8597. */
  8598. storeState(): Camera;
  8599. /**
  8600. * Restored camera state. You must call storeState() first
  8601. * @returns whether it was successful or not
  8602. * @hidden
  8603. */
  8604. _restoreStateValues(): boolean;
  8605. /** @hidden */
  8606. _initCache(): void;
  8607. /** @hidden */
  8608. _updateCache(ignoreParentClass?: boolean): void;
  8609. /** @hidden */
  8610. _isSynchronizedViewMatrix(): boolean;
  8611. /** @hidden */
  8612. _computeLocalCameraSpeed(): number;
  8613. /**
  8614. * Defines the target the camera should look at.
  8615. * @param target Defines the new target as a Vector or a mesh
  8616. */
  8617. setTarget(target: Vector3): void;
  8618. /**
  8619. * Return the current target position of the camera. This value is expressed in local space.
  8620. * @returns the target position
  8621. */
  8622. getTarget(): Vector3;
  8623. /** @hidden */
  8624. _decideIfNeedsToMove(): boolean;
  8625. /** @hidden */
  8626. _updatePosition(): void;
  8627. /** @hidden */
  8628. _checkInputs(): void;
  8629. protected _updateCameraRotationMatrix(): void;
  8630. /**
  8631. * 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)
  8632. * @returns the current camera
  8633. */
  8634. private _rotateUpVectorWithCameraRotationMatrix;
  8635. private _cachedRotationZ;
  8636. private _cachedQuaternionRotationZ;
  8637. /** @hidden */
  8638. _getViewMatrix(): Matrix;
  8639. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8640. /**
  8641. * @hidden
  8642. */
  8643. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8644. /**
  8645. * @hidden
  8646. */
  8647. _updateRigCameras(): void;
  8648. private _getRigCamPositionAndTarget;
  8649. /**
  8650. * Gets the current object class name.
  8651. * @return the class name
  8652. */
  8653. getClassName(): string;
  8654. }
  8655. }
  8656. declare module BABYLON {
  8657. /**
  8658. * Gather the list of keyboard event types as constants.
  8659. */
  8660. export class KeyboardEventTypes {
  8661. /**
  8662. * The keydown event is fired when a key becomes active (pressed).
  8663. */
  8664. static readonly KEYDOWN: number;
  8665. /**
  8666. * The keyup event is fired when a key has been released.
  8667. */
  8668. static readonly KEYUP: number;
  8669. }
  8670. /**
  8671. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8672. */
  8673. export class KeyboardInfo {
  8674. /**
  8675. * Defines the type of event (KeyboardEventTypes)
  8676. */
  8677. type: number;
  8678. /**
  8679. * Defines the related dom event
  8680. */
  8681. event: KeyboardEvent;
  8682. /**
  8683. * Instantiates a new keyboard info.
  8684. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8685. * @param type Defines the type of event (KeyboardEventTypes)
  8686. * @param event Defines the related dom event
  8687. */
  8688. constructor(
  8689. /**
  8690. * Defines the type of event (KeyboardEventTypes)
  8691. */
  8692. type: number,
  8693. /**
  8694. * Defines the related dom event
  8695. */
  8696. event: KeyboardEvent);
  8697. }
  8698. /**
  8699. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8700. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8701. */
  8702. export class KeyboardInfoPre extends KeyboardInfo {
  8703. /**
  8704. * Defines the type of event (KeyboardEventTypes)
  8705. */
  8706. type: number;
  8707. /**
  8708. * Defines the related dom event
  8709. */
  8710. event: KeyboardEvent;
  8711. /**
  8712. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8713. */
  8714. skipOnPointerObservable: boolean;
  8715. /**
  8716. * Instantiates a new keyboard pre info.
  8717. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8718. * @param type Defines the type of event (KeyboardEventTypes)
  8719. * @param event Defines the related dom event
  8720. */
  8721. constructor(
  8722. /**
  8723. * Defines the type of event (KeyboardEventTypes)
  8724. */
  8725. type: number,
  8726. /**
  8727. * Defines the related dom event
  8728. */
  8729. event: KeyboardEvent);
  8730. }
  8731. }
  8732. declare module BABYLON {
  8733. /**
  8734. * Manage the keyboard inputs to control the movement of a free camera.
  8735. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8736. */
  8737. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8738. /**
  8739. * Defines the camera the input is attached to.
  8740. */
  8741. camera: FreeCamera;
  8742. /**
  8743. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8744. */
  8745. keysUp: number[];
  8746. /**
  8747. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8748. */
  8749. keysDown: number[];
  8750. /**
  8751. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8752. */
  8753. keysLeft: number[];
  8754. /**
  8755. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8756. */
  8757. keysRight: number[];
  8758. private _keys;
  8759. private _onCanvasBlurObserver;
  8760. private _onKeyboardObserver;
  8761. private _engine;
  8762. private _scene;
  8763. /**
  8764. * Attach the input controls to a specific dom element to get the input from.
  8765. * @param element Defines the element the controls should be listened from
  8766. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8767. */
  8768. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8769. /**
  8770. * Detach the current controls from the specified dom element.
  8771. * @param element Defines the element to stop listening the inputs from
  8772. */
  8773. detachControl(element: Nullable<HTMLElement>): void;
  8774. /**
  8775. * Update the current camera state depending on the inputs that have been used this frame.
  8776. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8777. */
  8778. checkInputs(): void;
  8779. /**
  8780. * Gets the class name of the current intput.
  8781. * @returns the class name
  8782. */
  8783. getClassName(): string;
  8784. /** @hidden */
  8785. _onLostFocus(): void;
  8786. /**
  8787. * Get the friendly name associated with the input class.
  8788. * @returns the input friendly name
  8789. */
  8790. getSimpleName(): string;
  8791. }
  8792. }
  8793. declare module BABYLON {
  8794. /**
  8795. * Interface describing all the common properties and methods a shadow light needs to implement.
  8796. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8797. * as well as binding the different shadow properties to the effects.
  8798. */
  8799. export interface IShadowLight extends Light {
  8800. /**
  8801. * The light id in the scene (used in scene.findLighById for instance)
  8802. */
  8803. id: string;
  8804. /**
  8805. * The position the shdow will be casted from.
  8806. */
  8807. position: Vector3;
  8808. /**
  8809. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8810. */
  8811. direction: Vector3;
  8812. /**
  8813. * The transformed position. Position of the light in world space taking parenting in account.
  8814. */
  8815. transformedPosition: Vector3;
  8816. /**
  8817. * The transformed direction. Direction of the light in world space taking parenting in account.
  8818. */
  8819. transformedDirection: Vector3;
  8820. /**
  8821. * The friendly name of the light in the scene.
  8822. */
  8823. name: string;
  8824. /**
  8825. * Defines the shadow projection clipping minimum z value.
  8826. */
  8827. shadowMinZ: number;
  8828. /**
  8829. * Defines the shadow projection clipping maximum z value.
  8830. */
  8831. shadowMaxZ: number;
  8832. /**
  8833. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8834. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8835. */
  8836. computeTransformedInformation(): boolean;
  8837. /**
  8838. * Gets the scene the light belongs to.
  8839. * @returns The scene
  8840. */
  8841. getScene(): Scene;
  8842. /**
  8843. * Callback defining a custom Projection Matrix Builder.
  8844. * This can be used to override the default projection matrix computation.
  8845. */
  8846. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8847. /**
  8848. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8849. * @param matrix The materix to updated with the projection information
  8850. * @param viewMatrix The transform matrix of the light
  8851. * @param renderList The list of mesh to render in the map
  8852. * @returns The current light
  8853. */
  8854. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8855. /**
  8856. * Gets the current depth scale used in ESM.
  8857. * @returns The scale
  8858. */
  8859. getDepthScale(): number;
  8860. /**
  8861. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8862. * @returns true if a cube texture needs to be use
  8863. */
  8864. needCube(): boolean;
  8865. /**
  8866. * Detects if the projection matrix requires to be recomputed this frame.
  8867. * @returns true if it requires to be recomputed otherwise, false.
  8868. */
  8869. needProjectionMatrixCompute(): boolean;
  8870. /**
  8871. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8872. */
  8873. forceProjectionMatrixCompute(): void;
  8874. /**
  8875. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8876. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8877. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8878. */
  8879. getShadowDirection(faceIndex?: number): Vector3;
  8880. /**
  8881. * Gets the minZ used for shadow according to both the scene and the light.
  8882. * @param activeCamera The camera we are returning the min for
  8883. * @returns the depth min z
  8884. */
  8885. getDepthMinZ(activeCamera: Camera): number;
  8886. /**
  8887. * Gets the maxZ used for shadow according to both the scene and the light.
  8888. * @param activeCamera The camera we are returning the max for
  8889. * @returns the depth max z
  8890. */
  8891. getDepthMaxZ(activeCamera: Camera): number;
  8892. }
  8893. /**
  8894. * Base implementation IShadowLight
  8895. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8896. */
  8897. export abstract class ShadowLight extends Light implements IShadowLight {
  8898. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8899. protected _position: Vector3;
  8900. protected _setPosition(value: Vector3): void;
  8901. /**
  8902. * Sets the position the shadow will be casted from. Also use as the light position for both
  8903. * point and spot lights.
  8904. */
  8905. get position(): Vector3;
  8906. /**
  8907. * Sets the position the shadow will be casted from. Also use as the light position for both
  8908. * point and spot lights.
  8909. */
  8910. set position(value: Vector3);
  8911. protected _direction: Vector3;
  8912. protected _setDirection(value: Vector3): void;
  8913. /**
  8914. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8915. * Also use as the light direction on spot and directional lights.
  8916. */
  8917. get direction(): Vector3;
  8918. /**
  8919. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8920. * Also use as the light direction on spot and directional lights.
  8921. */
  8922. set direction(value: Vector3);
  8923. protected _shadowMinZ: number;
  8924. /**
  8925. * Gets the shadow projection clipping minimum z value.
  8926. */
  8927. get shadowMinZ(): number;
  8928. /**
  8929. * Sets the shadow projection clipping minimum z value.
  8930. */
  8931. set shadowMinZ(value: number);
  8932. protected _shadowMaxZ: number;
  8933. /**
  8934. * Sets the shadow projection clipping maximum z value.
  8935. */
  8936. get shadowMaxZ(): number;
  8937. /**
  8938. * Gets the shadow projection clipping maximum z value.
  8939. */
  8940. set shadowMaxZ(value: number);
  8941. /**
  8942. * Callback defining a custom Projection Matrix Builder.
  8943. * This can be used to override the default projection matrix computation.
  8944. */
  8945. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8946. /**
  8947. * The transformed position. Position of the light in world space taking parenting in account.
  8948. */
  8949. transformedPosition: Vector3;
  8950. /**
  8951. * The transformed direction. Direction of the light in world space taking parenting in account.
  8952. */
  8953. transformedDirection: Vector3;
  8954. private _needProjectionMatrixCompute;
  8955. /**
  8956. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8957. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8958. */
  8959. computeTransformedInformation(): boolean;
  8960. /**
  8961. * Return the depth scale used for the shadow map.
  8962. * @returns the depth scale.
  8963. */
  8964. getDepthScale(): number;
  8965. /**
  8966. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8967. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8968. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8969. */
  8970. getShadowDirection(faceIndex?: number): Vector3;
  8971. /**
  8972. * Returns the ShadowLight absolute position in the World.
  8973. * @returns the position vector in world space
  8974. */
  8975. getAbsolutePosition(): Vector3;
  8976. /**
  8977. * Sets the ShadowLight direction toward the passed target.
  8978. * @param target The point to target in local space
  8979. * @returns the updated ShadowLight direction
  8980. */
  8981. setDirectionToTarget(target: Vector3): Vector3;
  8982. /**
  8983. * Returns the light rotation in euler definition.
  8984. * @returns the x y z rotation in local space.
  8985. */
  8986. getRotation(): Vector3;
  8987. /**
  8988. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8989. * @returns true if a cube texture needs to be use
  8990. */
  8991. needCube(): boolean;
  8992. /**
  8993. * Detects if the projection matrix requires to be recomputed this frame.
  8994. * @returns true if it requires to be recomputed otherwise, false.
  8995. */
  8996. needProjectionMatrixCompute(): boolean;
  8997. /**
  8998. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8999. */
  9000. forceProjectionMatrixCompute(): void;
  9001. /** @hidden */
  9002. _initCache(): void;
  9003. /** @hidden */
  9004. _isSynchronized(): boolean;
  9005. /**
  9006. * Computes the world matrix of the node
  9007. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9008. * @returns the world matrix
  9009. */
  9010. computeWorldMatrix(force?: boolean): Matrix;
  9011. /**
  9012. * Gets the minZ used for shadow according to both the scene and the light.
  9013. * @param activeCamera The camera we are returning the min for
  9014. * @returns the depth min z
  9015. */
  9016. getDepthMinZ(activeCamera: Camera): number;
  9017. /**
  9018. * Gets the maxZ used for shadow according to both the scene and the light.
  9019. * @param activeCamera The camera we are returning the max for
  9020. * @returns the depth max z
  9021. */
  9022. getDepthMaxZ(activeCamera: Camera): number;
  9023. /**
  9024. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9025. * @param matrix The materix to updated with the projection information
  9026. * @param viewMatrix The transform matrix of the light
  9027. * @param renderList The list of mesh to render in the map
  9028. * @returns The current light
  9029. */
  9030. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9031. }
  9032. }
  9033. declare module BABYLON {
  9034. /**
  9035. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9036. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9037. */
  9038. export class EffectFallbacks implements IEffectFallbacks {
  9039. private _defines;
  9040. private _currentRank;
  9041. private _maxRank;
  9042. private _mesh;
  9043. /**
  9044. * Removes the fallback from the bound mesh.
  9045. */
  9046. unBindMesh(): void;
  9047. /**
  9048. * Adds a fallback on the specified property.
  9049. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9050. * @param define The name of the define in the shader
  9051. */
  9052. addFallback(rank: number, define: string): void;
  9053. /**
  9054. * Sets the mesh to use CPU skinning when needing to fallback.
  9055. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9056. * @param mesh The mesh to use the fallbacks.
  9057. */
  9058. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9059. /**
  9060. * Checks to see if more fallbacks are still availible.
  9061. */
  9062. get hasMoreFallbacks(): boolean;
  9063. /**
  9064. * Removes the defines that should be removed when falling back.
  9065. * @param currentDefines defines the current define statements for the shader.
  9066. * @param effect defines the current effect we try to compile
  9067. * @returns The resulting defines with defines of the current rank removed.
  9068. */
  9069. reduce(currentDefines: string, effect: Effect): string;
  9070. }
  9071. }
  9072. declare module BABYLON {
  9073. /**
  9074. * "Static Class" containing the most commonly used helper while dealing with material for
  9075. * rendering purpose.
  9076. *
  9077. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9078. *
  9079. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9080. */
  9081. export class MaterialHelper {
  9082. /**
  9083. * Bind the current view position to an effect.
  9084. * @param effect The effect to be bound
  9085. * @param scene The scene the eyes position is used from
  9086. */
  9087. static BindEyePosition(effect: Effect, scene: Scene): void;
  9088. /**
  9089. * Helps preparing the defines values about the UVs in used in the effect.
  9090. * UVs are shared as much as we can accross channels in the shaders.
  9091. * @param texture The texture we are preparing the UVs for
  9092. * @param defines The defines to update
  9093. * @param key The channel key "diffuse", "specular"... used in the shader
  9094. */
  9095. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9096. /**
  9097. * Binds a texture matrix value to its corrsponding uniform
  9098. * @param texture The texture to bind the matrix for
  9099. * @param uniformBuffer The uniform buffer receivin the data
  9100. * @param key The channel key "diffuse", "specular"... used in the shader
  9101. */
  9102. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9103. /**
  9104. * Gets the current status of the fog (should it be enabled?)
  9105. * @param mesh defines the mesh to evaluate for fog support
  9106. * @param scene defines the hosting scene
  9107. * @returns true if fog must be enabled
  9108. */
  9109. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9110. /**
  9111. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9112. * @param mesh defines the current mesh
  9113. * @param scene defines the current scene
  9114. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9115. * @param pointsCloud defines if point cloud rendering has to be turned on
  9116. * @param fogEnabled defines if fog has to be turned on
  9117. * @param alphaTest defines if alpha testing has to be turned on
  9118. * @param defines defines the current list of defines
  9119. */
  9120. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9121. /**
  9122. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9123. * @param scene defines the current scene
  9124. * @param engine defines the current engine
  9125. * @param defines specifies the list of active defines
  9126. * @param useInstances defines if instances have to be turned on
  9127. * @param useClipPlane defines if clip plane have to be turned on
  9128. */
  9129. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9130. /**
  9131. * Prepares the defines for bones
  9132. * @param mesh The mesh containing the geometry data we will draw
  9133. * @param defines The defines to update
  9134. */
  9135. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9136. /**
  9137. * Prepares the defines for morph targets
  9138. * @param mesh The mesh containing the geometry data we will draw
  9139. * @param defines The defines to update
  9140. */
  9141. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9142. /**
  9143. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9144. * @param mesh The mesh containing the geometry data we will draw
  9145. * @param defines The defines to update
  9146. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9147. * @param useBones Precise whether bones should be used or not (override mesh info)
  9148. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9149. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9150. * @returns false if defines are considered not dirty and have not been checked
  9151. */
  9152. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9153. /**
  9154. * Prepares the defines related to multiview
  9155. * @param scene The scene we are intending to draw
  9156. * @param defines The defines to update
  9157. */
  9158. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9159. /**
  9160. * Prepares the defines related to the light information passed in parameter
  9161. * @param scene The scene we are intending to draw
  9162. * @param mesh The mesh the effect is compiling for
  9163. * @param light The light the effect is compiling for
  9164. * @param lightIndex The index of the light
  9165. * @param defines The defines to update
  9166. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9167. * @param state Defines the current state regarding what is needed (normals, etc...)
  9168. */
  9169. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9170. needNormals: boolean;
  9171. needRebuild: boolean;
  9172. shadowEnabled: boolean;
  9173. specularEnabled: boolean;
  9174. lightmapMode: boolean;
  9175. }): void;
  9176. /**
  9177. * Prepares the defines related to the light information passed in parameter
  9178. * @param scene The scene we are intending to draw
  9179. * @param mesh The mesh the effect is compiling for
  9180. * @param defines The defines to update
  9181. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9182. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9183. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9184. * @returns true if normals will be required for the rest of the effect
  9185. */
  9186. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9187. /**
  9188. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9189. * @param lightIndex defines the light index
  9190. * @param uniformsList The uniform list
  9191. * @param samplersList The sampler list
  9192. * @param projectedLightTexture defines if projected texture must be used
  9193. * @param uniformBuffersList defines an optional list of uniform buffers
  9194. */
  9195. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9196. /**
  9197. * Prepares the uniforms and samplers list to be used in the effect
  9198. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9199. * @param samplersList The sampler list
  9200. * @param defines The defines helping in the list generation
  9201. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9202. */
  9203. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9204. /**
  9205. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9206. * @param defines The defines to update while falling back
  9207. * @param fallbacks The authorized effect fallbacks
  9208. * @param maxSimultaneousLights The maximum number of lights allowed
  9209. * @param rank the current rank of the Effect
  9210. * @returns The newly affected rank
  9211. */
  9212. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9213. private static _TmpMorphInfluencers;
  9214. /**
  9215. * Prepares the list of attributes required for morph targets according to the effect defines.
  9216. * @param attribs The current list of supported attribs
  9217. * @param mesh The mesh to prepare the morph targets attributes for
  9218. * @param influencers The number of influencers
  9219. */
  9220. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9221. /**
  9222. * Prepares the list of attributes required for morph targets according to the effect defines.
  9223. * @param attribs The current list of supported attribs
  9224. * @param mesh The mesh to prepare the morph targets attributes for
  9225. * @param defines The current Defines of the effect
  9226. */
  9227. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9228. /**
  9229. * Prepares the list of attributes required for bones according to the effect defines.
  9230. * @param attribs The current list of supported attribs
  9231. * @param mesh The mesh to prepare the bones attributes for
  9232. * @param defines The current Defines of the effect
  9233. * @param fallbacks The current efffect fallback strategy
  9234. */
  9235. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9236. /**
  9237. * Check and prepare the list of attributes required for instances according to the effect defines.
  9238. * @param attribs The current list of supported attribs
  9239. * @param defines The current MaterialDefines of the effect
  9240. */
  9241. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9242. /**
  9243. * Add the list of attributes required for instances to the attribs array.
  9244. * @param attribs The current list of supported attribs
  9245. */
  9246. static PushAttributesForInstances(attribs: string[]): void;
  9247. /**
  9248. * Binds the light information to the effect.
  9249. * @param light The light containing the generator
  9250. * @param effect The effect we are binding the data to
  9251. * @param lightIndex The light index in the effect used to render
  9252. */
  9253. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9254. /**
  9255. * Binds the lights information from the scene to the effect for the given mesh.
  9256. * @param light Light to bind
  9257. * @param lightIndex Light index
  9258. * @param scene The scene where the light belongs to
  9259. * @param effect The effect we are binding the data to
  9260. * @param useSpecular Defines if specular is supported
  9261. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9262. */
  9263. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9264. /**
  9265. * Binds the lights information from the scene to the effect for the given mesh.
  9266. * @param scene The scene the lights belongs to
  9267. * @param mesh The mesh we are binding the information to render
  9268. * @param effect The effect we are binding the data to
  9269. * @param defines The generated defines for the effect
  9270. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9271. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9272. */
  9273. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9274. private static _tempFogColor;
  9275. /**
  9276. * Binds the fog information from the scene to the effect for the given mesh.
  9277. * @param scene The scene the lights belongs to
  9278. * @param mesh The mesh we are binding the information to render
  9279. * @param effect The effect we are binding the data to
  9280. * @param linearSpace Defines if the fog effect is applied in linear space
  9281. */
  9282. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9283. /**
  9284. * Binds the bones information from the mesh to the effect.
  9285. * @param mesh The mesh we are binding the information to render
  9286. * @param effect The effect we are binding the data to
  9287. */
  9288. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9289. /**
  9290. * Binds the morph targets information from the mesh to the effect.
  9291. * @param abstractMesh The mesh we are binding the information to render
  9292. * @param effect The effect we are binding the data to
  9293. */
  9294. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9295. /**
  9296. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9297. * @param defines The generated defines used in the effect
  9298. * @param effect The effect we are binding the data to
  9299. * @param scene The scene we are willing to render with logarithmic scale for
  9300. */
  9301. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9302. /**
  9303. * Binds the clip plane information from the scene to the effect.
  9304. * @param scene The scene the clip plane information are extracted from
  9305. * @param effect The effect we are binding the data to
  9306. */
  9307. static BindClipPlane(effect: Effect, scene: Scene): void;
  9308. }
  9309. }
  9310. declare module BABYLON {
  9311. /** @hidden */
  9312. export var packingFunctions: {
  9313. name: string;
  9314. shader: string;
  9315. };
  9316. }
  9317. declare module BABYLON {
  9318. /** @hidden */
  9319. export var clipPlaneFragmentDeclaration: {
  9320. name: string;
  9321. shader: string;
  9322. };
  9323. }
  9324. declare module BABYLON {
  9325. /** @hidden */
  9326. export var clipPlaneFragment: {
  9327. name: string;
  9328. shader: string;
  9329. };
  9330. }
  9331. declare module BABYLON {
  9332. /** @hidden */
  9333. export var shadowMapPixelShader: {
  9334. name: string;
  9335. shader: string;
  9336. };
  9337. }
  9338. declare module BABYLON {
  9339. /** @hidden */
  9340. export var bonesDeclaration: {
  9341. name: string;
  9342. shader: string;
  9343. };
  9344. }
  9345. declare module BABYLON {
  9346. /** @hidden */
  9347. export var morphTargetsVertexGlobalDeclaration: {
  9348. name: string;
  9349. shader: string;
  9350. };
  9351. }
  9352. declare module BABYLON {
  9353. /** @hidden */
  9354. export var morphTargetsVertexDeclaration: {
  9355. name: string;
  9356. shader: string;
  9357. };
  9358. }
  9359. declare module BABYLON {
  9360. /** @hidden */
  9361. export var instancesDeclaration: {
  9362. name: string;
  9363. shader: string;
  9364. };
  9365. }
  9366. declare module BABYLON {
  9367. /** @hidden */
  9368. export var helperFunctions: {
  9369. name: string;
  9370. shader: string;
  9371. };
  9372. }
  9373. declare module BABYLON {
  9374. /** @hidden */
  9375. export var clipPlaneVertexDeclaration: {
  9376. name: string;
  9377. shader: string;
  9378. };
  9379. }
  9380. declare module BABYLON {
  9381. /** @hidden */
  9382. export var morphTargetsVertex: {
  9383. name: string;
  9384. shader: string;
  9385. };
  9386. }
  9387. declare module BABYLON {
  9388. /** @hidden */
  9389. export var instancesVertex: {
  9390. name: string;
  9391. shader: string;
  9392. };
  9393. }
  9394. declare module BABYLON {
  9395. /** @hidden */
  9396. export var bonesVertex: {
  9397. name: string;
  9398. shader: string;
  9399. };
  9400. }
  9401. declare module BABYLON {
  9402. /** @hidden */
  9403. export var clipPlaneVertex: {
  9404. name: string;
  9405. shader: string;
  9406. };
  9407. }
  9408. declare module BABYLON {
  9409. /** @hidden */
  9410. export var shadowMapVertexShader: {
  9411. name: string;
  9412. shader: string;
  9413. };
  9414. }
  9415. declare module BABYLON {
  9416. /** @hidden */
  9417. export var depthBoxBlurPixelShader: {
  9418. name: string;
  9419. shader: string;
  9420. };
  9421. }
  9422. declare module BABYLON {
  9423. /**
  9424. * Class representing a ray with position and direction
  9425. */
  9426. export class Ray {
  9427. /** origin point */
  9428. origin: Vector3;
  9429. /** direction */
  9430. direction: Vector3;
  9431. /** length of the ray */
  9432. length: number;
  9433. private static readonly TmpVector3;
  9434. private _tmpRay;
  9435. /**
  9436. * Creates a new ray
  9437. * @param origin origin point
  9438. * @param direction direction
  9439. * @param length length of the ray
  9440. */
  9441. constructor(
  9442. /** origin point */
  9443. origin: Vector3,
  9444. /** direction */
  9445. direction: Vector3,
  9446. /** length of the ray */
  9447. length?: number);
  9448. /**
  9449. * Checks if the ray intersects a box
  9450. * @param minimum bound of the box
  9451. * @param maximum bound of the box
  9452. * @param intersectionTreshold extra extend to be added to the box in all direction
  9453. * @returns if the box was hit
  9454. */
  9455. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9456. /**
  9457. * Checks if the ray intersects a box
  9458. * @param box the bounding box to check
  9459. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9460. * @returns if the box was hit
  9461. */
  9462. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9463. /**
  9464. * If the ray hits a sphere
  9465. * @param sphere the bounding sphere to check
  9466. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9467. * @returns true if it hits the sphere
  9468. */
  9469. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9470. /**
  9471. * If the ray hits a triange
  9472. * @param vertex0 triangle vertex
  9473. * @param vertex1 triangle vertex
  9474. * @param vertex2 triangle vertex
  9475. * @returns intersection information if hit
  9476. */
  9477. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9478. /**
  9479. * Checks if ray intersects a plane
  9480. * @param plane the plane to check
  9481. * @returns the distance away it was hit
  9482. */
  9483. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9484. /**
  9485. * Calculate the intercept of a ray on a given axis
  9486. * @param axis to check 'x' | 'y' | 'z'
  9487. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  9488. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  9489. */
  9490. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  9491. /**
  9492. * Checks if ray intersects a mesh
  9493. * @param mesh the mesh to check
  9494. * @param fastCheck if only the bounding box should checked
  9495. * @returns picking info of the intersecton
  9496. */
  9497. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9498. /**
  9499. * Checks if ray intersects a mesh
  9500. * @param meshes the meshes to check
  9501. * @param fastCheck if only the bounding box should checked
  9502. * @param results array to store result in
  9503. * @returns Array of picking infos
  9504. */
  9505. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9506. private _comparePickingInfo;
  9507. private static smallnum;
  9508. private static rayl;
  9509. /**
  9510. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9511. * @param sega the first point of the segment to test the intersection against
  9512. * @param segb the second point of the segment to test the intersection against
  9513. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9514. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9515. */
  9516. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9517. /**
  9518. * Update the ray from viewport position
  9519. * @param x position
  9520. * @param y y position
  9521. * @param viewportWidth viewport width
  9522. * @param viewportHeight viewport height
  9523. * @param world world matrix
  9524. * @param view view matrix
  9525. * @param projection projection matrix
  9526. * @returns this ray updated
  9527. */
  9528. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9529. /**
  9530. * Creates a ray with origin and direction of 0,0,0
  9531. * @returns the new ray
  9532. */
  9533. static Zero(): Ray;
  9534. /**
  9535. * Creates a new ray from screen space and viewport
  9536. * @param x position
  9537. * @param y y position
  9538. * @param viewportWidth viewport width
  9539. * @param viewportHeight viewport height
  9540. * @param world world matrix
  9541. * @param view view matrix
  9542. * @param projection projection matrix
  9543. * @returns new ray
  9544. */
  9545. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9546. /**
  9547. * 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
  9548. * transformed to the given world matrix.
  9549. * @param origin The origin point
  9550. * @param end The end point
  9551. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9552. * @returns the new ray
  9553. */
  9554. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9555. /**
  9556. * Transforms a ray by a matrix
  9557. * @param ray ray to transform
  9558. * @param matrix matrix to apply
  9559. * @returns the resulting new ray
  9560. */
  9561. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9562. /**
  9563. * Transforms a ray by a matrix
  9564. * @param ray ray to transform
  9565. * @param matrix matrix to apply
  9566. * @param result ray to store result in
  9567. */
  9568. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9569. /**
  9570. * Unproject a ray from screen space to object space
  9571. * @param sourceX defines the screen space x coordinate to use
  9572. * @param sourceY defines the screen space y coordinate to use
  9573. * @param viewportWidth defines the current width of the viewport
  9574. * @param viewportHeight defines the current height of the viewport
  9575. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9576. * @param view defines the view matrix to use
  9577. * @param projection defines the projection matrix to use
  9578. */
  9579. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  9580. }
  9581. /**
  9582. * Type used to define predicate used to select faces when a mesh intersection is detected
  9583. */
  9584. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  9585. interface Scene {
  9586. /** @hidden */
  9587. _tempPickingRay: Nullable<Ray>;
  9588. /** @hidden */
  9589. _cachedRayForTransform: Ray;
  9590. /** @hidden */
  9591. _pickWithRayInverseMatrix: Matrix;
  9592. /** @hidden */
  9593. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  9594. /** @hidden */
  9595. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  9596. }
  9597. }
  9598. declare module BABYLON {
  9599. /**
  9600. * Groups all the scene component constants in one place to ease maintenance.
  9601. * @hidden
  9602. */
  9603. export class SceneComponentConstants {
  9604. static readonly NAME_EFFECTLAYER: string;
  9605. static readonly NAME_LAYER: string;
  9606. static readonly NAME_LENSFLARESYSTEM: string;
  9607. static readonly NAME_BOUNDINGBOXRENDERER: string;
  9608. static readonly NAME_PARTICLESYSTEM: string;
  9609. static readonly NAME_GAMEPAD: string;
  9610. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  9611. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  9612. static readonly NAME_DEPTHRENDERER: string;
  9613. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  9614. static readonly NAME_SPRITE: string;
  9615. static readonly NAME_OUTLINERENDERER: string;
  9616. static readonly NAME_PROCEDURALTEXTURE: string;
  9617. static readonly NAME_SHADOWGENERATOR: string;
  9618. static readonly NAME_OCTREE: string;
  9619. static readonly NAME_PHYSICSENGINE: string;
  9620. static readonly NAME_AUDIO: string;
  9621. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  9622. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9623. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  9624. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9625. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  9626. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  9627. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  9628. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  9629. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  9630. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  9631. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  9632. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  9633. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  9634. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  9635. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  9636. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  9637. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  9638. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  9639. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  9640. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  9641. static readonly STEP_AFTERRENDER_AUDIO: number;
  9642. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  9643. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  9644. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  9645. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  9646. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  9647. static readonly STEP_POINTERMOVE_SPRITE: number;
  9648. static readonly STEP_POINTERDOWN_SPRITE: number;
  9649. static readonly STEP_POINTERUP_SPRITE: number;
  9650. }
  9651. /**
  9652. * This represents a scene component.
  9653. *
  9654. * This is used to decouple the dependency the scene is having on the different workloads like
  9655. * layers, post processes...
  9656. */
  9657. export interface ISceneComponent {
  9658. /**
  9659. * The name of the component. Each component must have a unique name.
  9660. */
  9661. name: string;
  9662. /**
  9663. * The scene the component belongs to.
  9664. */
  9665. scene: Scene;
  9666. /**
  9667. * Register the component to one instance of a scene.
  9668. */
  9669. register(): void;
  9670. /**
  9671. * Rebuilds the elements related to this component in case of
  9672. * context lost for instance.
  9673. */
  9674. rebuild(): void;
  9675. /**
  9676. * Disposes the component and the associated ressources.
  9677. */
  9678. dispose(): void;
  9679. }
  9680. /**
  9681. * This represents a SERIALIZABLE scene component.
  9682. *
  9683. * This extends Scene Component to add Serialization methods on top.
  9684. */
  9685. export interface ISceneSerializableComponent extends ISceneComponent {
  9686. /**
  9687. * Adds all the elements from the container to the scene
  9688. * @param container the container holding the elements
  9689. */
  9690. addFromContainer(container: AbstractScene): void;
  9691. /**
  9692. * Removes all the elements in the container from the scene
  9693. * @param container contains the elements to remove
  9694. * @param dispose if the removed element should be disposed (default: false)
  9695. */
  9696. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  9697. /**
  9698. * Serializes the component data to the specified json object
  9699. * @param serializationObject The object to serialize to
  9700. */
  9701. serialize(serializationObject: any): void;
  9702. }
  9703. /**
  9704. * Strong typing of a Mesh related stage step action
  9705. */
  9706. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  9707. /**
  9708. * Strong typing of a Evaluate Sub Mesh related stage step action
  9709. */
  9710. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  9711. /**
  9712. * Strong typing of a Active Mesh related stage step action
  9713. */
  9714. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  9715. /**
  9716. * Strong typing of a Camera related stage step action
  9717. */
  9718. export type CameraStageAction = (camera: Camera) => void;
  9719. /**
  9720. * Strong typing of a Camera Frame buffer related stage step action
  9721. */
  9722. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  9723. /**
  9724. * Strong typing of a Render Target related stage step action
  9725. */
  9726. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  9727. /**
  9728. * Strong typing of a RenderingGroup related stage step action
  9729. */
  9730. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  9731. /**
  9732. * Strong typing of a Mesh Render related stage step action
  9733. */
  9734. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  9735. /**
  9736. * Strong typing of a simple stage step action
  9737. */
  9738. export type SimpleStageAction = () => void;
  9739. /**
  9740. * Strong typing of a render target action.
  9741. */
  9742. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  9743. /**
  9744. * Strong typing of a pointer move action.
  9745. */
  9746. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  9747. /**
  9748. * Strong typing of a pointer up/down action.
  9749. */
  9750. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  9751. /**
  9752. * Representation of a stage in the scene (Basically a list of ordered steps)
  9753. * @hidden
  9754. */
  9755. export class Stage<T extends Function> extends Array<{
  9756. index: number;
  9757. component: ISceneComponent;
  9758. action: T;
  9759. }> {
  9760. /**
  9761. * Hide ctor from the rest of the world.
  9762. * @param items The items to add.
  9763. */
  9764. private constructor();
  9765. /**
  9766. * Creates a new Stage.
  9767. * @returns A new instance of a Stage
  9768. */
  9769. static Create<T extends Function>(): Stage<T>;
  9770. /**
  9771. * Registers a step in an ordered way in the targeted stage.
  9772. * @param index Defines the position to register the step in
  9773. * @param component Defines the component attached to the step
  9774. * @param action Defines the action to launch during the step
  9775. */
  9776. registerStep(index: number, component: ISceneComponent, action: T): void;
  9777. /**
  9778. * Clears all the steps from the stage.
  9779. */
  9780. clear(): void;
  9781. }
  9782. }
  9783. declare module BABYLON {
  9784. interface Scene {
  9785. /** @hidden */
  9786. _pointerOverSprite: Nullable<Sprite>;
  9787. /** @hidden */
  9788. _pickedDownSprite: Nullable<Sprite>;
  9789. /** @hidden */
  9790. _tempSpritePickingRay: Nullable<Ray>;
  9791. /**
  9792. * All of the sprite managers added to this scene
  9793. * @see http://doc.babylonjs.com/babylon101/sprites
  9794. */
  9795. spriteManagers: Array<ISpriteManager>;
  9796. /**
  9797. * An event triggered when sprites rendering is about to start
  9798. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9799. */
  9800. onBeforeSpritesRenderingObservable: Observable<Scene>;
  9801. /**
  9802. * An event triggered when sprites rendering is done
  9803. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9804. */
  9805. onAfterSpritesRenderingObservable: Observable<Scene>;
  9806. /** @hidden */
  9807. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9808. /** Launch a ray to try to pick a sprite in the scene
  9809. * @param x position on screen
  9810. * @param y position on screen
  9811. * @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
  9812. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9813. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9814. * @returns a PickingInfo
  9815. */
  9816. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9817. /** Use the given ray to pick a sprite in the scene
  9818. * @param ray The ray (in world space) to use to pick meshes
  9819. * @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
  9820. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9821. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9822. * @returns a PickingInfo
  9823. */
  9824. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9825. /** @hidden */
  9826. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9827. /** Launch a ray to try to pick sprites in the scene
  9828. * @param x position on screen
  9829. * @param y position on screen
  9830. * @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
  9831. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9832. * @returns a PickingInfo array
  9833. */
  9834. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9835. /** Use the given ray to pick sprites in the scene
  9836. * @param ray The ray (in world space) to use to pick meshes
  9837. * @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
  9838. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9839. * @returns a PickingInfo array
  9840. */
  9841. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9842. /**
  9843. * Force the sprite under the pointer
  9844. * @param sprite defines the sprite to use
  9845. */
  9846. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  9847. /**
  9848. * Gets the sprite under the pointer
  9849. * @returns a Sprite or null if no sprite is under the pointer
  9850. */
  9851. getPointerOverSprite(): Nullable<Sprite>;
  9852. }
  9853. /**
  9854. * Defines the sprite scene component responsible to manage sprites
  9855. * in a given scene.
  9856. */
  9857. export class SpriteSceneComponent implements ISceneComponent {
  9858. /**
  9859. * The component name helpfull to identify the component in the list of scene components.
  9860. */
  9861. readonly name: string;
  9862. /**
  9863. * The scene the component belongs to.
  9864. */
  9865. scene: Scene;
  9866. /** @hidden */
  9867. private _spritePredicate;
  9868. /**
  9869. * Creates a new instance of the component for the given scene
  9870. * @param scene Defines the scene to register the component in
  9871. */
  9872. constructor(scene: Scene);
  9873. /**
  9874. * Registers the component in a given scene
  9875. */
  9876. register(): void;
  9877. /**
  9878. * Rebuilds the elements related to this component in case of
  9879. * context lost for instance.
  9880. */
  9881. rebuild(): void;
  9882. /**
  9883. * Disposes the component and the associated ressources.
  9884. */
  9885. dispose(): void;
  9886. private _pickSpriteButKeepRay;
  9887. private _pointerMove;
  9888. private _pointerDown;
  9889. private _pointerUp;
  9890. }
  9891. }
  9892. declare module BABYLON {
  9893. /** @hidden */
  9894. export var fogFragmentDeclaration: {
  9895. name: string;
  9896. shader: string;
  9897. };
  9898. }
  9899. declare module BABYLON {
  9900. /** @hidden */
  9901. export var fogFragment: {
  9902. name: string;
  9903. shader: string;
  9904. };
  9905. }
  9906. declare module BABYLON {
  9907. /** @hidden */
  9908. export var spritesPixelShader: {
  9909. name: string;
  9910. shader: string;
  9911. };
  9912. }
  9913. declare module BABYLON {
  9914. /** @hidden */
  9915. export var fogVertexDeclaration: {
  9916. name: string;
  9917. shader: string;
  9918. };
  9919. }
  9920. declare module BABYLON {
  9921. /** @hidden */
  9922. export var spritesVertexShader: {
  9923. name: string;
  9924. shader: string;
  9925. };
  9926. }
  9927. declare module BABYLON {
  9928. /**
  9929. * Defines the minimum interface to fullfil in order to be a sprite manager.
  9930. */
  9931. export interface ISpriteManager extends IDisposable {
  9932. /**
  9933. * Restricts the camera to viewing objects with the same layerMask.
  9934. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  9935. */
  9936. layerMask: number;
  9937. /**
  9938. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  9939. */
  9940. isPickable: boolean;
  9941. /**
  9942. * Specifies the rendering group id for this mesh (0 by default)
  9943. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  9944. */
  9945. renderingGroupId: number;
  9946. /**
  9947. * Defines the list of sprites managed by the manager.
  9948. */
  9949. sprites: Array<Sprite>;
  9950. /**
  9951. * Tests the intersection of a sprite with a specific ray.
  9952. * @param ray The ray we are sending to test the collision
  9953. * @param camera The camera space we are sending rays in
  9954. * @param predicate A predicate allowing excluding sprites from the list of object to test
  9955. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  9956. * @returns picking info or null.
  9957. */
  9958. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  9959. /**
  9960. * Intersects the sprites with a ray
  9961. * @param ray defines the ray to intersect with
  9962. * @param camera defines the current active camera
  9963. * @param predicate defines a predicate used to select candidate sprites
  9964. * @returns null if no hit or a PickingInfo array
  9965. */
  9966. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  9967. /**
  9968. * Renders the list of sprites on screen.
  9969. */
  9970. render(): void;
  9971. }
  9972. /**
  9973. * Class used to manage multiple sprites on the same spritesheet
  9974. * @see http://doc.babylonjs.com/babylon101/sprites
  9975. */
  9976. export class SpriteManager implements ISpriteManager {
  9977. /** defines the manager's name */
  9978. name: string;
  9979. /** Gets the list of sprites */
  9980. sprites: Sprite[];
  9981. /** Gets or sets the rendering group id (0 by default) */
  9982. renderingGroupId: number;
  9983. /** Gets or sets camera layer mask */
  9984. layerMask: number;
  9985. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  9986. fogEnabled: boolean;
  9987. /** Gets or sets a boolean indicating if the sprites are pickable */
  9988. isPickable: boolean;
  9989. /** Defines the default width of a cell in the spritesheet */
  9990. cellWidth: number;
  9991. /** Defines the default height of a cell in the spritesheet */
  9992. cellHeight: number;
  9993. /** Associative array from JSON sprite data file */
  9994. private _cellData;
  9995. /** Array of sprite names from JSON sprite data file */
  9996. private _spriteMap;
  9997. /** True when packed cell data from JSON file is ready*/
  9998. private _packedAndReady;
  9999. /**
  10000. * An event triggered when the manager is disposed.
  10001. */
  10002. onDisposeObservable: Observable<SpriteManager>;
  10003. private _onDisposeObserver;
  10004. /**
  10005. * Callback called when the manager is disposed
  10006. */
  10007. set onDispose(callback: () => void);
  10008. private _capacity;
  10009. private _fromPacked;
  10010. private _spriteTexture;
  10011. private _epsilon;
  10012. private _scene;
  10013. private _vertexData;
  10014. private _buffer;
  10015. private _vertexBuffers;
  10016. private _indexBuffer;
  10017. private _effectBase;
  10018. private _effectFog;
  10019. /**
  10020. * Gets or sets the spritesheet texture
  10021. */
  10022. get texture(): Texture;
  10023. set texture(value: Texture);
  10024. /**
  10025. * Creates a new sprite manager
  10026. * @param name defines the manager's name
  10027. * @param imgUrl defines the sprite sheet url
  10028. * @param capacity defines the maximum allowed number of sprites
  10029. * @param cellSize defines the size of a sprite cell
  10030. * @param scene defines the hosting scene
  10031. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10032. * @param samplingMode defines the smapling mode to use with spritesheet
  10033. * @param fromPacked set to false; do not alter
  10034. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10035. */
  10036. constructor(
  10037. /** defines the manager's name */
  10038. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  10039. private _makePacked;
  10040. private _appendSpriteVertex;
  10041. /**
  10042. * Intersects the sprites with a ray
  10043. * @param ray defines the ray to intersect with
  10044. * @param camera defines the current active camera
  10045. * @param predicate defines a predicate used to select candidate sprites
  10046. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  10047. * @returns null if no hit or a PickingInfo
  10048. */
  10049. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10050. /**
  10051. * Intersects the sprites with a ray
  10052. * @param ray defines the ray to intersect with
  10053. * @param camera defines the current active camera
  10054. * @param predicate defines a predicate used to select candidate sprites
  10055. * @returns null if no hit or a PickingInfo array
  10056. */
  10057. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10058. /**
  10059. * Render all child sprites
  10060. */
  10061. render(): void;
  10062. /**
  10063. * Release associated resources
  10064. */
  10065. dispose(): void;
  10066. }
  10067. }
  10068. declare module BABYLON {
  10069. /** Interface used by value gradients (color, factor, ...) */
  10070. export interface IValueGradient {
  10071. /**
  10072. * Gets or sets the gradient value (between 0 and 1)
  10073. */
  10074. gradient: number;
  10075. }
  10076. /** Class used to store color4 gradient */
  10077. export class ColorGradient implements IValueGradient {
  10078. /**
  10079. * Gets or sets the gradient value (between 0 and 1)
  10080. */
  10081. gradient: number;
  10082. /**
  10083. * Gets or sets first associated color
  10084. */
  10085. color1: Color4;
  10086. /**
  10087. * Gets or sets second associated color
  10088. */
  10089. color2?: Color4;
  10090. /**
  10091. * Will get a color picked randomly between color1 and color2.
  10092. * If color2 is undefined then color1 will be used
  10093. * @param result defines the target Color4 to store the result in
  10094. */
  10095. getColorToRef(result: Color4): void;
  10096. }
  10097. /** Class used to store color 3 gradient */
  10098. export class Color3Gradient implements IValueGradient {
  10099. /**
  10100. * Gets or sets the gradient value (between 0 and 1)
  10101. */
  10102. gradient: number;
  10103. /**
  10104. * Gets or sets the associated color
  10105. */
  10106. color: Color3;
  10107. }
  10108. /** Class used to store factor gradient */
  10109. export class FactorGradient implements IValueGradient {
  10110. /**
  10111. * Gets or sets the gradient value (between 0 and 1)
  10112. */
  10113. gradient: number;
  10114. /**
  10115. * Gets or sets first associated factor
  10116. */
  10117. factor1: number;
  10118. /**
  10119. * Gets or sets second associated factor
  10120. */
  10121. factor2?: number;
  10122. /**
  10123. * Will get a number picked randomly between factor1 and factor2.
  10124. * If factor2 is undefined then factor1 will be used
  10125. * @returns the picked number
  10126. */
  10127. getFactor(): number;
  10128. }
  10129. /**
  10130. * Helper used to simplify some generic gradient tasks
  10131. */
  10132. export class GradientHelper {
  10133. /**
  10134. * Gets the current gradient from an array of IValueGradient
  10135. * @param ratio defines the current ratio to get
  10136. * @param gradients defines the array of IValueGradient
  10137. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  10138. */
  10139. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  10140. }
  10141. }
  10142. declare module BABYLON {
  10143. /**
  10144. * Interface for the size containing width and height
  10145. */
  10146. export interface ISize {
  10147. /**
  10148. * Width
  10149. */
  10150. width: number;
  10151. /**
  10152. * Heighht
  10153. */
  10154. height: number;
  10155. }
  10156. /**
  10157. * Size containing widht and height
  10158. */
  10159. export class Size implements ISize {
  10160. /**
  10161. * Width
  10162. */
  10163. width: number;
  10164. /**
  10165. * Height
  10166. */
  10167. height: number;
  10168. /**
  10169. * Creates a Size object from the given width and height (floats).
  10170. * @param width width of the new size
  10171. * @param height height of the new size
  10172. */
  10173. constructor(width: number, height: number);
  10174. /**
  10175. * Returns a string with the Size width and height
  10176. * @returns a string with the Size width and height
  10177. */
  10178. toString(): string;
  10179. /**
  10180. * "Size"
  10181. * @returns the string "Size"
  10182. */
  10183. getClassName(): string;
  10184. /**
  10185. * Returns the Size hash code.
  10186. * @returns a hash code for a unique width and height
  10187. */
  10188. getHashCode(): number;
  10189. /**
  10190. * Updates the current size from the given one.
  10191. * @param src the given size
  10192. */
  10193. copyFrom(src: Size): void;
  10194. /**
  10195. * Updates in place the current Size from the given floats.
  10196. * @param width width of the new size
  10197. * @param height height of the new size
  10198. * @returns the updated Size.
  10199. */
  10200. copyFromFloats(width: number, height: number): Size;
  10201. /**
  10202. * Updates in place the current Size from the given floats.
  10203. * @param width width to set
  10204. * @param height height to set
  10205. * @returns the updated Size.
  10206. */
  10207. set(width: number, height: number): Size;
  10208. /**
  10209. * Multiplies the width and height by numbers
  10210. * @param w factor to multiple the width by
  10211. * @param h factor to multiple the height by
  10212. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  10213. */
  10214. multiplyByFloats(w: number, h: number): Size;
  10215. /**
  10216. * Clones the size
  10217. * @returns a new Size copied from the given one.
  10218. */
  10219. clone(): Size;
  10220. /**
  10221. * True if the current Size and the given one width and height are strictly equal.
  10222. * @param other the other size to compare against
  10223. * @returns True if the current Size and the given one width and height are strictly equal.
  10224. */
  10225. equals(other: Size): boolean;
  10226. /**
  10227. * The surface of the Size : width * height (float).
  10228. */
  10229. get surface(): number;
  10230. /**
  10231. * Create a new size of zero
  10232. * @returns a new Size set to (0.0, 0.0)
  10233. */
  10234. static Zero(): Size;
  10235. /**
  10236. * Sums the width and height of two sizes
  10237. * @param otherSize size to add to this size
  10238. * @returns a new Size set as the addition result of the current Size and the given one.
  10239. */
  10240. add(otherSize: Size): Size;
  10241. /**
  10242. * Subtracts the width and height of two
  10243. * @param otherSize size to subtract to this size
  10244. * @returns a new Size set as the subtraction result of the given one from the current Size.
  10245. */
  10246. subtract(otherSize: Size): Size;
  10247. /**
  10248. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  10249. * @param start starting size to lerp between
  10250. * @param end end size to lerp between
  10251. * @param amount amount to lerp between the start and end values
  10252. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  10253. */
  10254. static Lerp(start: Size, end: Size, amount: number): Size;
  10255. }
  10256. }
  10257. declare module BABYLON {
  10258. interface ThinEngine {
  10259. /**
  10260. * Creates a dynamic texture
  10261. * @param width defines the width of the texture
  10262. * @param height defines the height of the texture
  10263. * @param generateMipMaps defines if the engine should generate the mip levels
  10264. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10265. * @returns the dynamic texture inside an InternalTexture
  10266. */
  10267. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10268. /**
  10269. * Update the content of a dynamic texture
  10270. * @param texture defines the texture to update
  10271. * @param canvas defines the canvas containing the source
  10272. * @param invertY defines if data must be stored with Y axis inverted
  10273. * @param premulAlpha defines if alpha is stored as premultiplied
  10274. * @param format defines the format of the data
  10275. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  10276. */
  10277. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  10278. }
  10279. }
  10280. declare module BABYLON {
  10281. /**
  10282. * Helper class used to generate a canvas to manipulate images
  10283. */
  10284. export class CanvasGenerator {
  10285. /**
  10286. * Create a new canvas (or offscreen canvas depending on the context)
  10287. * @param width defines the expected width
  10288. * @param height defines the expected height
  10289. * @return a new canvas or offscreen canvas
  10290. */
  10291. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  10292. }
  10293. }
  10294. declare module BABYLON {
  10295. /**
  10296. * A class extending Texture allowing drawing on a texture
  10297. * @see http://doc.babylonjs.com/how_to/dynamictexture
  10298. */
  10299. export class DynamicTexture extends Texture {
  10300. private _generateMipMaps;
  10301. private _canvas;
  10302. private _context;
  10303. private _engine;
  10304. /**
  10305. * Creates a DynamicTexture
  10306. * @param name defines the name of the texture
  10307. * @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
  10308. * @param scene defines the scene where you want the texture
  10309. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  10310. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  10311. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  10312. */
  10313. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  10314. /**
  10315. * Get the current class name of the texture useful for serialization or dynamic coding.
  10316. * @returns "DynamicTexture"
  10317. */
  10318. getClassName(): string;
  10319. /**
  10320. * Gets the current state of canRescale
  10321. */
  10322. get canRescale(): boolean;
  10323. private _recreate;
  10324. /**
  10325. * Scales the texture
  10326. * @param ratio the scale factor to apply to both width and height
  10327. */
  10328. scale(ratio: number): void;
  10329. /**
  10330. * Resizes the texture
  10331. * @param width the new width
  10332. * @param height the new height
  10333. */
  10334. scaleTo(width: number, height: number): void;
  10335. /**
  10336. * Gets the context of the canvas used by the texture
  10337. * @returns the canvas context of the dynamic texture
  10338. */
  10339. getContext(): CanvasRenderingContext2D;
  10340. /**
  10341. * Clears the texture
  10342. */
  10343. clear(): void;
  10344. /**
  10345. * Updates the texture
  10346. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10347. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  10348. */
  10349. update(invertY?: boolean, premulAlpha?: boolean): void;
  10350. /**
  10351. * Draws text onto the texture
  10352. * @param text defines the text to be drawn
  10353. * @param x defines the placement of the text from the left
  10354. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  10355. * @param font defines the font to be used with font-style, font-size, font-name
  10356. * @param color defines the color used for the text
  10357. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  10358. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10359. * @param update defines whether texture is immediately update (default is true)
  10360. */
  10361. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  10362. /**
  10363. * Clones the texture
  10364. * @returns the clone of the texture.
  10365. */
  10366. clone(): DynamicTexture;
  10367. /**
  10368. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  10369. * @returns a serialized dynamic texture object
  10370. */
  10371. serialize(): any;
  10372. /** @hidden */
  10373. _rebuild(): void;
  10374. }
  10375. }
  10376. declare module BABYLON {
  10377. interface Engine {
  10378. /**
  10379. * Creates a raw texture
  10380. * @param data defines the data to store in the texture
  10381. * @param width defines the width of the texture
  10382. * @param height defines the height of the texture
  10383. * @param format defines the format of the data
  10384. * @param generateMipMaps defines if the engine should generate the mip levels
  10385. * @param invertY defines if data must be stored with Y axis inverted
  10386. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10387. * @param compression defines the compression used (null by default)
  10388. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10389. * @returns the raw texture inside an InternalTexture
  10390. */
  10391. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  10392. /**
  10393. * Update a raw texture
  10394. * @param texture defines the texture to update
  10395. * @param data defines the data to store in the texture
  10396. * @param format defines the format of the data
  10397. * @param invertY defines if data must be stored with Y axis inverted
  10398. */
  10399. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10400. /**
  10401. * Update a raw texture
  10402. * @param texture defines the texture to update
  10403. * @param data defines the data to store in the texture
  10404. * @param format defines the format of the data
  10405. * @param invertY defines if data must be stored with Y axis inverted
  10406. * @param compression defines the compression used (null by default)
  10407. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10408. */
  10409. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  10410. /**
  10411. * Creates a new raw cube texture
  10412. * @param data defines the array of data to use to create each face
  10413. * @param size defines the size of the textures
  10414. * @param format defines the format of the data
  10415. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10416. * @param generateMipMaps defines if the engine should generate the mip levels
  10417. * @param invertY defines if data must be stored with Y axis inverted
  10418. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10419. * @param compression defines the compression used (null by default)
  10420. * @returns the cube texture as an InternalTexture
  10421. */
  10422. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  10423. /**
  10424. * Update a raw cube texture
  10425. * @param texture defines the texture to udpdate
  10426. * @param data defines the data to store
  10427. * @param format defines the data format
  10428. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10429. * @param invertY defines if data must be stored with Y axis inverted
  10430. */
  10431. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  10432. /**
  10433. * Update a raw cube texture
  10434. * @param texture defines the texture to udpdate
  10435. * @param data defines the data to store
  10436. * @param format defines the data format
  10437. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10438. * @param invertY defines if data must be stored with Y axis inverted
  10439. * @param compression defines the compression used (null by default)
  10440. */
  10441. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  10442. /**
  10443. * Update a raw cube texture
  10444. * @param texture defines the texture to udpdate
  10445. * @param data defines the data to store
  10446. * @param format defines the data format
  10447. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10448. * @param invertY defines if data must be stored with Y axis inverted
  10449. * @param compression defines the compression used (null by default)
  10450. * @param level defines which level of the texture to update
  10451. */
  10452. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  10453. /**
  10454. * Creates a new raw cube texture from a specified url
  10455. * @param url defines the url where the data is located
  10456. * @param scene defines the current scene
  10457. * @param size defines the size of the textures
  10458. * @param format defines the format of the data
  10459. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10460. * @param noMipmap defines if the engine should avoid generating the mip levels
  10461. * @param callback defines a callback used to extract texture data from loaded data
  10462. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10463. * @param onLoad defines a callback called when texture is loaded
  10464. * @param onError defines a callback called if there is an error
  10465. * @returns the cube texture as an InternalTexture
  10466. */
  10467. 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;
  10468. /**
  10469. * Creates a new raw cube texture from a specified url
  10470. * @param url defines the url where the data is located
  10471. * @param scene defines the current scene
  10472. * @param size defines the size of the textures
  10473. * @param format defines the format of the data
  10474. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10475. * @param noMipmap defines if the engine should avoid generating the mip levels
  10476. * @param callback defines a callback used to extract texture data from loaded data
  10477. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10478. * @param onLoad defines a callback called when texture is loaded
  10479. * @param onError defines a callback called if there is an error
  10480. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10481. * @param invertY defines if data must be stored with Y axis inverted
  10482. * @returns the cube texture as an InternalTexture
  10483. */
  10484. 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;
  10485. /**
  10486. * Creates a new raw 3D texture
  10487. * @param data defines the data used to create the texture
  10488. * @param width defines the width of the texture
  10489. * @param height defines the height of the texture
  10490. * @param depth defines the depth of the texture
  10491. * @param format defines the format of the texture
  10492. * @param generateMipMaps defines if the engine must generate mip levels
  10493. * @param invertY defines if data must be stored with Y axis inverted
  10494. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10495. * @param compression defines the compressed used (can be null)
  10496. * @param textureType defines the compressed used (can be null)
  10497. * @returns a new raw 3D texture (stored in an InternalTexture)
  10498. */
  10499. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10500. /**
  10501. * Update a raw 3D texture
  10502. * @param texture defines the texture to update
  10503. * @param data defines the data to store
  10504. * @param format defines the data format
  10505. * @param invertY defines if data must be stored with Y axis inverted
  10506. */
  10507. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10508. /**
  10509. * Update a raw 3D texture
  10510. * @param texture defines the texture to update
  10511. * @param data defines the data to store
  10512. * @param format defines the data format
  10513. * @param invertY defines if data must be stored with Y axis inverted
  10514. * @param compression defines the used compression (can be null)
  10515. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10516. */
  10517. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10518. /**
  10519. * Creates a new raw 2D array texture
  10520. * @param data defines the data used to create the texture
  10521. * @param width defines the width of the texture
  10522. * @param height defines the height of the texture
  10523. * @param depth defines the number of layers of the texture
  10524. * @param format defines the format of the texture
  10525. * @param generateMipMaps defines if the engine must generate mip levels
  10526. * @param invertY defines if data must be stored with Y axis inverted
  10527. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10528. * @param compression defines the compressed used (can be null)
  10529. * @param textureType defines the compressed used (can be null)
  10530. * @returns a new raw 2D array texture (stored in an InternalTexture)
  10531. */
  10532. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10533. /**
  10534. * Update a raw 2D array texture
  10535. * @param texture defines the texture to update
  10536. * @param data defines the data to store
  10537. * @param format defines the data format
  10538. * @param invertY defines if data must be stored with Y axis inverted
  10539. */
  10540. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10541. /**
  10542. * Update a raw 2D array texture
  10543. * @param texture defines the texture to update
  10544. * @param data defines the data to store
  10545. * @param format defines the data format
  10546. * @param invertY defines if data must be stored with Y axis inverted
  10547. * @param compression defines the used compression (can be null)
  10548. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10549. */
  10550. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10551. }
  10552. }
  10553. declare module BABYLON {
  10554. /**
  10555. * Raw texture can help creating a texture directly from an array of data.
  10556. * This can be super useful if you either get the data from an uncompressed source or
  10557. * if you wish to create your texture pixel by pixel.
  10558. */
  10559. export class RawTexture extends Texture {
  10560. /**
  10561. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10562. */
  10563. format: number;
  10564. private _engine;
  10565. /**
  10566. * Instantiates a new RawTexture.
  10567. * Raw texture can help creating a texture directly from an array of data.
  10568. * This can be super useful if you either get the data from an uncompressed source or
  10569. * if you wish to create your texture pixel by pixel.
  10570. * @param data define the array of data to use to create the texture
  10571. * @param width define the width of the texture
  10572. * @param height define the height of the texture
  10573. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10574. * @param scene define the scene the texture belongs to
  10575. * @param generateMipMaps define whether mip maps should be generated or not
  10576. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10577. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10578. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10579. */
  10580. constructor(data: ArrayBufferView, width: number, height: number,
  10581. /**
  10582. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10583. */
  10584. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  10585. /**
  10586. * Updates the texture underlying data.
  10587. * @param data Define the new data of the texture
  10588. */
  10589. update(data: ArrayBufferView): void;
  10590. /**
  10591. * Creates a luminance texture from some data.
  10592. * @param data Define the texture data
  10593. * @param width Define the width of the texture
  10594. * @param height Define the height of the texture
  10595. * @param scene Define the scene the texture belongs to
  10596. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10597. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10598. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10599. * @returns the luminance texture
  10600. */
  10601. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10602. /**
  10603. * Creates a luminance alpha texture from some data.
  10604. * @param data Define the texture data
  10605. * @param width Define the width of the texture
  10606. * @param height Define the height of the texture
  10607. * @param scene Define the scene the texture belongs to
  10608. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10609. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10610. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10611. * @returns the luminance alpha texture
  10612. */
  10613. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10614. /**
  10615. * Creates an alpha texture from some data.
  10616. * @param data Define the texture data
  10617. * @param width Define the width of the texture
  10618. * @param height Define the height of the texture
  10619. * @param scene Define the scene the texture belongs to
  10620. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10621. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10622. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10623. * @returns the alpha texture
  10624. */
  10625. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10626. /**
  10627. * Creates a RGB texture from some data.
  10628. * @param data Define the texture data
  10629. * @param width Define the width of the texture
  10630. * @param height Define the height of the texture
  10631. * @param scene Define the scene the texture belongs to
  10632. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10633. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10634. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10635. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10636. * @returns the RGB alpha texture
  10637. */
  10638. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10639. /**
  10640. * Creates a RGBA texture from some data.
  10641. * @param data Define the texture data
  10642. * @param width Define the width of the texture
  10643. * @param height Define the height of the texture
  10644. * @param scene Define the scene the texture belongs to
  10645. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10646. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10647. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10648. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10649. * @returns the RGBA texture
  10650. */
  10651. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10652. /**
  10653. * Creates a R texture from some data.
  10654. * @param data Define the texture data
  10655. * @param width Define the width of the texture
  10656. * @param height Define the height of the texture
  10657. * @param scene Define the scene the texture belongs to
  10658. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10659. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10660. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10661. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10662. * @returns the R texture
  10663. */
  10664. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10665. }
  10666. }
  10667. declare module BABYLON {
  10668. interface AbstractScene {
  10669. /**
  10670. * The list of procedural textures added to the scene
  10671. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10672. */
  10673. proceduralTextures: Array<ProceduralTexture>;
  10674. }
  10675. /**
  10676. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  10677. * in a given scene.
  10678. */
  10679. export class ProceduralTextureSceneComponent implements ISceneComponent {
  10680. /**
  10681. * The component name helpfull to identify the component in the list of scene components.
  10682. */
  10683. readonly name: string;
  10684. /**
  10685. * The scene the component belongs to.
  10686. */
  10687. scene: Scene;
  10688. /**
  10689. * Creates a new instance of the component for the given scene
  10690. * @param scene Defines the scene to register the component in
  10691. */
  10692. constructor(scene: Scene);
  10693. /**
  10694. * Registers the component in a given scene
  10695. */
  10696. register(): void;
  10697. /**
  10698. * Rebuilds the elements related to this component in case of
  10699. * context lost for instance.
  10700. */
  10701. rebuild(): void;
  10702. /**
  10703. * Disposes the component and the associated ressources.
  10704. */
  10705. dispose(): void;
  10706. private _beforeClear;
  10707. }
  10708. }
  10709. declare module BABYLON {
  10710. interface ThinEngine {
  10711. /**
  10712. * Creates a new render target cube texture
  10713. * @param size defines the size of the texture
  10714. * @param options defines the options used to create the texture
  10715. * @returns a new render target cube texture stored in an InternalTexture
  10716. */
  10717. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  10718. }
  10719. }
  10720. declare module BABYLON {
  10721. /** @hidden */
  10722. export var proceduralVertexShader: {
  10723. name: string;
  10724. shader: string;
  10725. };
  10726. }
  10727. declare module BABYLON {
  10728. /**
  10729. * 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.
  10730. * This is the base class of any Procedural texture and contains most of the shareable code.
  10731. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10732. */
  10733. export class ProceduralTexture extends Texture {
  10734. isCube: boolean;
  10735. /**
  10736. * Define if the texture is enabled or not (disabled texture will not render)
  10737. */
  10738. isEnabled: boolean;
  10739. /**
  10740. * Define if the texture must be cleared before rendering (default is true)
  10741. */
  10742. autoClear: boolean;
  10743. /**
  10744. * Callback called when the texture is generated
  10745. */
  10746. onGenerated: () => void;
  10747. /**
  10748. * Event raised when the texture is generated
  10749. */
  10750. onGeneratedObservable: Observable<ProceduralTexture>;
  10751. /** @hidden */
  10752. _generateMipMaps: boolean;
  10753. /** @hidden **/
  10754. _effect: Effect;
  10755. /** @hidden */
  10756. _textures: {
  10757. [key: string]: Texture;
  10758. };
  10759. private _size;
  10760. private _currentRefreshId;
  10761. private _frameId;
  10762. private _refreshRate;
  10763. private _vertexBuffers;
  10764. private _indexBuffer;
  10765. private _uniforms;
  10766. private _samplers;
  10767. private _fragment;
  10768. private _floats;
  10769. private _ints;
  10770. private _floatsArrays;
  10771. private _colors3;
  10772. private _colors4;
  10773. private _vectors2;
  10774. private _vectors3;
  10775. private _matrices;
  10776. private _fallbackTexture;
  10777. private _fallbackTextureUsed;
  10778. private _engine;
  10779. private _cachedDefines;
  10780. private _contentUpdateId;
  10781. private _contentData;
  10782. /**
  10783. * Instantiates a new procedural texture.
  10784. * 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.
  10785. * This is the base class of any Procedural texture and contains most of the shareable code.
  10786. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10787. * @param name Define the name of the texture
  10788. * @param size Define the size of the texture to create
  10789. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  10790. * @param scene Define the scene the texture belongs to
  10791. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  10792. * @param generateMipMaps Define if the texture should creates mip maps or not
  10793. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  10794. */
  10795. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  10796. /**
  10797. * The effect that is created when initializing the post process.
  10798. * @returns The created effect corresponding the the postprocess.
  10799. */
  10800. getEffect(): Effect;
  10801. /**
  10802. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  10803. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  10804. */
  10805. getContent(): Nullable<ArrayBufferView>;
  10806. private _createIndexBuffer;
  10807. /** @hidden */
  10808. _rebuild(): void;
  10809. /**
  10810. * Resets the texture in order to recreate its associated resources.
  10811. * This can be called in case of context loss
  10812. */
  10813. reset(): void;
  10814. protected _getDefines(): string;
  10815. /**
  10816. * Is the texture ready to be used ? (rendered at least once)
  10817. * @returns true if ready, otherwise, false.
  10818. */
  10819. isReady(): boolean;
  10820. /**
  10821. * Resets the refresh counter of the texture and start bak from scratch.
  10822. * Could be useful to regenerate the texture if it is setup to render only once.
  10823. */
  10824. resetRefreshCounter(): void;
  10825. /**
  10826. * Set the fragment shader to use in order to render the texture.
  10827. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  10828. */
  10829. setFragment(fragment: any): void;
  10830. /**
  10831. * Define the refresh rate of the texture or the rendering frequency.
  10832. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  10833. */
  10834. get refreshRate(): number;
  10835. set refreshRate(value: number);
  10836. /** @hidden */
  10837. _shouldRender(): boolean;
  10838. /**
  10839. * Get the size the texture is rendering at.
  10840. * @returns the size (texture is always squared)
  10841. */
  10842. getRenderSize(): number;
  10843. /**
  10844. * Resize the texture to new value.
  10845. * @param size Define the new size the texture should have
  10846. * @param generateMipMaps Define whether the new texture should create mip maps
  10847. */
  10848. resize(size: number, generateMipMaps: boolean): void;
  10849. private _checkUniform;
  10850. /**
  10851. * Set a texture in the shader program used to render.
  10852. * @param name Define the name of the uniform samplers as defined in the shader
  10853. * @param texture Define the texture to bind to this sampler
  10854. * @return the texture itself allowing "fluent" like uniform updates
  10855. */
  10856. setTexture(name: string, texture: Texture): ProceduralTexture;
  10857. /**
  10858. * Set a float in the shader.
  10859. * @param name Define the name of the uniform as defined in the shader
  10860. * @param value Define the value to give to the uniform
  10861. * @return the texture itself allowing "fluent" like uniform updates
  10862. */
  10863. setFloat(name: string, value: number): ProceduralTexture;
  10864. /**
  10865. * Set a int in the shader.
  10866. * @param name Define the name of the uniform as defined in the shader
  10867. * @param value Define the value to give to the uniform
  10868. * @return the texture itself allowing "fluent" like uniform updates
  10869. */
  10870. setInt(name: string, value: number): ProceduralTexture;
  10871. /**
  10872. * Set an array of floats in the shader.
  10873. * @param name Define the name of the uniform as defined in the shader
  10874. * @param value Define the value to give to the uniform
  10875. * @return the texture itself allowing "fluent" like uniform updates
  10876. */
  10877. setFloats(name: string, value: number[]): ProceduralTexture;
  10878. /**
  10879. * Set a vec3 in the shader from a Color3.
  10880. * @param name Define the name of the uniform as defined in the shader
  10881. * @param value Define the value to give to the uniform
  10882. * @return the texture itself allowing "fluent" like uniform updates
  10883. */
  10884. setColor3(name: string, value: Color3): ProceduralTexture;
  10885. /**
  10886. * Set a vec4 in the shader from a Color4.
  10887. * @param name Define the name of the uniform as defined in the shader
  10888. * @param value Define the value to give to the uniform
  10889. * @return the texture itself allowing "fluent" like uniform updates
  10890. */
  10891. setColor4(name: string, value: Color4): ProceduralTexture;
  10892. /**
  10893. * Set a vec2 in the shader from a Vector2.
  10894. * @param name Define the name of the uniform as defined in the shader
  10895. * @param value Define the value to give to the uniform
  10896. * @return the texture itself allowing "fluent" like uniform updates
  10897. */
  10898. setVector2(name: string, value: Vector2): ProceduralTexture;
  10899. /**
  10900. * Set a vec3 in the shader from a Vector3.
  10901. * @param name Define the name of the uniform as defined in the shader
  10902. * @param value Define the value to give to the uniform
  10903. * @return the texture itself allowing "fluent" like uniform updates
  10904. */
  10905. setVector3(name: string, value: Vector3): ProceduralTexture;
  10906. /**
  10907. * Set a mat4 in the shader from a MAtrix.
  10908. * @param name Define the name of the uniform as defined in the shader
  10909. * @param value Define the value to give to the uniform
  10910. * @return the texture itself allowing "fluent" like uniform updates
  10911. */
  10912. setMatrix(name: string, value: Matrix): ProceduralTexture;
  10913. /**
  10914. * Render the texture to its associated render target.
  10915. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  10916. */
  10917. render(useCameraPostProcess?: boolean): void;
  10918. /**
  10919. * Clone the texture.
  10920. * @returns the cloned texture
  10921. */
  10922. clone(): ProceduralTexture;
  10923. /**
  10924. * Dispose the texture and release its asoociated resources.
  10925. */
  10926. dispose(): void;
  10927. }
  10928. }
  10929. declare module BABYLON {
  10930. /**
  10931. * This represents the base class for particle system in Babylon.
  10932. * 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.
  10933. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  10934. * @example https://doc.babylonjs.com/babylon101/particles
  10935. */
  10936. export class BaseParticleSystem {
  10937. /**
  10938. * Source color is added to the destination color without alpha affecting the result
  10939. */
  10940. static BLENDMODE_ONEONE: number;
  10941. /**
  10942. * Blend current color and particle color using particle’s alpha
  10943. */
  10944. static BLENDMODE_STANDARD: number;
  10945. /**
  10946. * Add current color and particle color multiplied by particle’s alpha
  10947. */
  10948. static BLENDMODE_ADD: number;
  10949. /**
  10950. * Multiply current color with particle color
  10951. */
  10952. static BLENDMODE_MULTIPLY: number;
  10953. /**
  10954. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  10955. */
  10956. static BLENDMODE_MULTIPLYADD: number;
  10957. /**
  10958. * List of animations used by the particle system.
  10959. */
  10960. animations: Animation[];
  10961. /**
  10962. * The id of the Particle system.
  10963. */
  10964. id: string;
  10965. /**
  10966. * The friendly name of the Particle system.
  10967. */
  10968. name: string;
  10969. /**
  10970. * The rendering group used by the Particle system to chose when to render.
  10971. */
  10972. renderingGroupId: number;
  10973. /**
  10974. * The emitter represents the Mesh or position we are attaching the particle system to.
  10975. */
  10976. emitter: Nullable<AbstractMesh | Vector3>;
  10977. /**
  10978. * The maximum number of particles to emit per frame
  10979. */
  10980. emitRate: number;
  10981. /**
  10982. * If you want to launch only a few particles at once, that can be done, as well.
  10983. */
  10984. manualEmitCount: number;
  10985. /**
  10986. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  10987. */
  10988. updateSpeed: number;
  10989. /**
  10990. * The amount of time the particle system is running (depends of the overall update speed).
  10991. */
  10992. targetStopDuration: number;
  10993. /**
  10994. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  10995. */
  10996. disposeOnStop: boolean;
  10997. /**
  10998. * Minimum power of emitting particles.
  10999. */
  11000. minEmitPower: number;
  11001. /**
  11002. * Maximum power of emitting particles.
  11003. */
  11004. maxEmitPower: number;
  11005. /**
  11006. * Minimum life time of emitting particles.
  11007. */
  11008. minLifeTime: number;
  11009. /**
  11010. * Maximum life time of emitting particles.
  11011. */
  11012. maxLifeTime: number;
  11013. /**
  11014. * Minimum Size of emitting particles.
  11015. */
  11016. minSize: number;
  11017. /**
  11018. * Maximum Size of emitting particles.
  11019. */
  11020. maxSize: number;
  11021. /**
  11022. * Minimum scale of emitting particles on X axis.
  11023. */
  11024. minScaleX: number;
  11025. /**
  11026. * Maximum scale of emitting particles on X axis.
  11027. */
  11028. maxScaleX: number;
  11029. /**
  11030. * Minimum scale of emitting particles on Y axis.
  11031. */
  11032. minScaleY: number;
  11033. /**
  11034. * Maximum scale of emitting particles on Y axis.
  11035. */
  11036. maxScaleY: number;
  11037. /**
  11038. * Gets or sets the minimal initial rotation in radians.
  11039. */
  11040. minInitialRotation: number;
  11041. /**
  11042. * Gets or sets the maximal initial rotation in radians.
  11043. */
  11044. maxInitialRotation: number;
  11045. /**
  11046. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11047. */
  11048. minAngularSpeed: number;
  11049. /**
  11050. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11051. */
  11052. maxAngularSpeed: number;
  11053. /**
  11054. * The texture used to render each particle. (this can be a spritesheet)
  11055. */
  11056. particleTexture: Nullable<Texture>;
  11057. /**
  11058. * The layer mask we are rendering the particles through.
  11059. */
  11060. layerMask: number;
  11061. /**
  11062. * This can help using your own shader to render the particle system.
  11063. * The according effect will be created
  11064. */
  11065. customShader: any;
  11066. /**
  11067. * By default particle system starts as soon as they are created. This prevents the
  11068. * automatic start to happen and let you decide when to start emitting particles.
  11069. */
  11070. preventAutoStart: boolean;
  11071. private _noiseTexture;
  11072. /**
  11073. * Gets or sets a texture used to add random noise to particle positions
  11074. */
  11075. get noiseTexture(): Nullable<ProceduralTexture>;
  11076. set noiseTexture(value: Nullable<ProceduralTexture>);
  11077. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11078. noiseStrength: Vector3;
  11079. /**
  11080. * Callback triggered when the particle animation is ending.
  11081. */
  11082. onAnimationEnd: Nullable<() => void>;
  11083. /**
  11084. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11085. */
  11086. blendMode: number;
  11087. /**
  11088. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11089. * to override the particles.
  11090. */
  11091. forceDepthWrite: boolean;
  11092. /** 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 */
  11093. preWarmCycles: number;
  11094. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11095. preWarmStepOffset: number;
  11096. /**
  11097. * 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)
  11098. */
  11099. spriteCellChangeSpeed: number;
  11100. /**
  11101. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11102. */
  11103. startSpriteCellID: number;
  11104. /**
  11105. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11106. */
  11107. endSpriteCellID: number;
  11108. /**
  11109. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11110. */
  11111. spriteCellWidth: number;
  11112. /**
  11113. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11114. */
  11115. spriteCellHeight: number;
  11116. /**
  11117. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11118. */
  11119. spriteRandomStartCell: boolean;
  11120. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11121. translationPivot: Vector2;
  11122. /** @hidden */
  11123. protected _isAnimationSheetEnabled: boolean;
  11124. /**
  11125. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11126. */
  11127. beginAnimationOnStart: boolean;
  11128. /**
  11129. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11130. */
  11131. beginAnimationFrom: number;
  11132. /**
  11133. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11134. */
  11135. beginAnimationTo: number;
  11136. /**
  11137. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11138. */
  11139. beginAnimationLoop: boolean;
  11140. /**
  11141. * Gets or sets a world offset applied to all particles
  11142. */
  11143. worldOffset: Vector3;
  11144. /**
  11145. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11146. */
  11147. get isAnimationSheetEnabled(): boolean;
  11148. set isAnimationSheetEnabled(value: boolean);
  11149. /**
  11150. * Get hosting scene
  11151. * @returns the scene
  11152. */
  11153. getScene(): Scene;
  11154. /**
  11155. * You can use gravity if you want to give an orientation to your particles.
  11156. */
  11157. gravity: Vector3;
  11158. protected _colorGradients: Nullable<Array<ColorGradient>>;
  11159. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  11160. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  11161. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  11162. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  11163. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  11164. protected _dragGradients: Nullable<Array<FactorGradient>>;
  11165. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  11166. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  11167. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  11168. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  11169. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  11170. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  11171. /**
  11172. * Defines the delay in milliseconds before starting the system (0 by default)
  11173. */
  11174. startDelay: number;
  11175. /**
  11176. * Gets the current list of drag gradients.
  11177. * You must use addDragGradient and removeDragGradient to udpate this list
  11178. * @returns the list of drag gradients
  11179. */
  11180. getDragGradients(): Nullable<Array<FactorGradient>>;
  11181. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  11182. limitVelocityDamping: number;
  11183. /**
  11184. * Gets the current list of limit velocity gradients.
  11185. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  11186. * @returns the list of limit velocity gradients
  11187. */
  11188. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  11189. /**
  11190. * Gets the current list of color gradients.
  11191. * You must use addColorGradient and removeColorGradient to udpate this list
  11192. * @returns the list of color gradients
  11193. */
  11194. getColorGradients(): Nullable<Array<ColorGradient>>;
  11195. /**
  11196. * Gets the current list of size gradients.
  11197. * You must use addSizeGradient and removeSizeGradient to udpate this list
  11198. * @returns the list of size gradients
  11199. */
  11200. getSizeGradients(): Nullable<Array<FactorGradient>>;
  11201. /**
  11202. * Gets the current list of color remap gradients.
  11203. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  11204. * @returns the list of color remap gradients
  11205. */
  11206. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  11207. /**
  11208. * Gets the current list of alpha remap gradients.
  11209. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  11210. * @returns the list of alpha remap gradients
  11211. */
  11212. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  11213. /**
  11214. * Gets the current list of life time gradients.
  11215. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  11216. * @returns the list of life time gradients
  11217. */
  11218. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  11219. /**
  11220. * Gets the current list of angular speed gradients.
  11221. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  11222. * @returns the list of angular speed gradients
  11223. */
  11224. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  11225. /**
  11226. * Gets the current list of velocity gradients.
  11227. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  11228. * @returns the list of velocity gradients
  11229. */
  11230. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  11231. /**
  11232. * Gets the current list of start size gradients.
  11233. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  11234. * @returns the list of start size gradients
  11235. */
  11236. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  11237. /**
  11238. * Gets the current list of emit rate gradients.
  11239. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  11240. * @returns the list of emit rate gradients
  11241. */
  11242. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  11243. /**
  11244. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11245. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11246. */
  11247. get direction1(): Vector3;
  11248. set direction1(value: Vector3);
  11249. /**
  11250. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11251. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11252. */
  11253. get direction2(): Vector3;
  11254. set direction2(value: Vector3);
  11255. /**
  11256. * 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.
  11257. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11258. */
  11259. get minEmitBox(): Vector3;
  11260. set minEmitBox(value: Vector3);
  11261. /**
  11262. * 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.
  11263. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11264. */
  11265. get maxEmitBox(): Vector3;
  11266. set maxEmitBox(value: Vector3);
  11267. /**
  11268. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11269. */
  11270. color1: Color4;
  11271. /**
  11272. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11273. */
  11274. color2: Color4;
  11275. /**
  11276. * Color the particle will have at the end of its lifetime
  11277. */
  11278. colorDead: Color4;
  11279. /**
  11280. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  11281. */
  11282. textureMask: Color4;
  11283. /**
  11284. * The particle emitter type defines the emitter used by the particle system.
  11285. * It can be for example box, sphere, or cone...
  11286. */
  11287. particleEmitterType: IParticleEmitterType;
  11288. /** @hidden */
  11289. _isSubEmitter: boolean;
  11290. /**
  11291. * Gets or sets the billboard mode to use when isBillboardBased = true.
  11292. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  11293. */
  11294. billboardMode: number;
  11295. protected _isBillboardBased: boolean;
  11296. /**
  11297. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  11298. */
  11299. get isBillboardBased(): boolean;
  11300. set isBillboardBased(value: boolean);
  11301. /**
  11302. * The scene the particle system belongs to.
  11303. */
  11304. protected _scene: Scene;
  11305. /**
  11306. * Local cache of defines for image processing.
  11307. */
  11308. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  11309. /**
  11310. * Default configuration related to image processing available in the standard Material.
  11311. */
  11312. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  11313. /**
  11314. * Gets the image processing configuration used either in this material.
  11315. */
  11316. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  11317. /**
  11318. * Sets the Default image processing configuration used either in the this material.
  11319. *
  11320. * If sets to null, the scene one is in use.
  11321. */
  11322. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  11323. /**
  11324. * Attaches a new image processing configuration to the Standard Material.
  11325. * @param configuration
  11326. */
  11327. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  11328. /** @hidden */
  11329. protected _reset(): void;
  11330. /** @hidden */
  11331. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  11332. /**
  11333. * Instantiates a particle system.
  11334. * 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.
  11335. * @param name The name of the particle system
  11336. */
  11337. constructor(name: string);
  11338. /**
  11339. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  11340. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11341. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11342. * @returns the emitter
  11343. */
  11344. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  11345. /**
  11346. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  11347. * @param radius The radius of the hemisphere to emit from
  11348. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11349. * @returns the emitter
  11350. */
  11351. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  11352. /**
  11353. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  11354. * @param radius The radius of the sphere to emit from
  11355. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11356. * @returns the emitter
  11357. */
  11358. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  11359. /**
  11360. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  11361. * @param radius The radius of the sphere to emit from
  11362. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  11363. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  11364. * @returns the emitter
  11365. */
  11366. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  11367. /**
  11368. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  11369. * @param radius The radius of the emission cylinder
  11370. * @param height The height of the emission cylinder
  11371. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  11372. * @param directionRandomizer How much to randomize the particle direction [0-1]
  11373. * @returns the emitter
  11374. */
  11375. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  11376. /**
  11377. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  11378. * @param radius The radius of the cylinder to emit from
  11379. * @param height The height of the emission cylinder
  11380. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  11381. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  11382. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  11383. * @returns the emitter
  11384. */
  11385. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  11386. /**
  11387. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  11388. * @param radius The radius of the cone to emit from
  11389. * @param angle The base angle of the cone
  11390. * @returns the emitter
  11391. */
  11392. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  11393. /**
  11394. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  11395. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11396. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11397. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11398. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11399. * @returns the emitter
  11400. */
  11401. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  11402. }
  11403. }
  11404. declare module BABYLON {
  11405. /**
  11406. * Type of sub emitter
  11407. */
  11408. export enum SubEmitterType {
  11409. /**
  11410. * Attached to the particle over it's lifetime
  11411. */
  11412. ATTACHED = 0,
  11413. /**
  11414. * Created when the particle dies
  11415. */
  11416. END = 1
  11417. }
  11418. /**
  11419. * Sub emitter class used to emit particles from an existing particle
  11420. */
  11421. export class SubEmitter {
  11422. /**
  11423. * the particle system to be used by the sub emitter
  11424. */
  11425. particleSystem: ParticleSystem;
  11426. /**
  11427. * Type of the submitter (Default: END)
  11428. */
  11429. type: SubEmitterType;
  11430. /**
  11431. * 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)
  11432. * Note: This only is supported when using an emitter of type Mesh
  11433. */
  11434. inheritDirection: boolean;
  11435. /**
  11436. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  11437. */
  11438. inheritedVelocityAmount: number;
  11439. /**
  11440. * Creates a sub emitter
  11441. * @param particleSystem the particle system to be used by the sub emitter
  11442. */
  11443. constructor(
  11444. /**
  11445. * the particle system to be used by the sub emitter
  11446. */
  11447. particleSystem: ParticleSystem);
  11448. /**
  11449. * Clones the sub emitter
  11450. * @returns the cloned sub emitter
  11451. */
  11452. clone(): SubEmitter;
  11453. /**
  11454. * Serialize current object to a JSON object
  11455. * @returns the serialized object
  11456. */
  11457. serialize(): any;
  11458. /** @hidden */
  11459. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  11460. /**
  11461. * Creates a new SubEmitter from a serialized JSON version
  11462. * @param serializationObject defines the JSON object to read from
  11463. * @param scene defines the hosting scene
  11464. * @param rootUrl defines the rootUrl for data loading
  11465. * @returns a new SubEmitter
  11466. */
  11467. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  11468. /** Release associated resources */
  11469. dispose(): void;
  11470. }
  11471. }
  11472. declare module BABYLON {
  11473. /** @hidden */
  11474. export var imageProcessingDeclaration: {
  11475. name: string;
  11476. shader: string;
  11477. };
  11478. }
  11479. declare module BABYLON {
  11480. /** @hidden */
  11481. export var imageProcessingFunctions: {
  11482. name: string;
  11483. shader: string;
  11484. };
  11485. }
  11486. declare module BABYLON {
  11487. /** @hidden */
  11488. export var particlesPixelShader: {
  11489. name: string;
  11490. shader: string;
  11491. };
  11492. }
  11493. declare module BABYLON {
  11494. /** @hidden */
  11495. export var particlesVertexShader: {
  11496. name: string;
  11497. shader: string;
  11498. };
  11499. }
  11500. declare module BABYLON {
  11501. /**
  11502. * This represents a particle system in Babylon.
  11503. * 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.
  11504. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11505. * @example https://doc.babylonjs.com/babylon101/particles
  11506. */
  11507. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  11508. /**
  11509. * Billboard mode will only apply to Y axis
  11510. */
  11511. static readonly BILLBOARDMODE_Y: number;
  11512. /**
  11513. * Billboard mode will apply to all axes
  11514. */
  11515. static readonly BILLBOARDMODE_ALL: number;
  11516. /**
  11517. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  11518. */
  11519. static readonly BILLBOARDMODE_STRETCHED: number;
  11520. /**
  11521. * This function can be defined to provide custom update for active particles.
  11522. * This function will be called instead of regular update (age, position, color, etc.).
  11523. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  11524. */
  11525. updateFunction: (particles: Particle[]) => void;
  11526. private _emitterWorldMatrix;
  11527. /**
  11528. * This function can be defined to specify initial direction for every new particle.
  11529. * It by default use the emitterType defined function
  11530. */
  11531. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  11532. /**
  11533. * This function can be defined to specify initial position for every new particle.
  11534. * It by default use the emitterType defined function
  11535. */
  11536. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  11537. /**
  11538. * @hidden
  11539. */
  11540. _inheritedVelocityOffset: Vector3;
  11541. /**
  11542. * An event triggered when the system is disposed
  11543. */
  11544. onDisposeObservable: Observable<ParticleSystem>;
  11545. private _onDisposeObserver;
  11546. /**
  11547. * Sets a callback that will be triggered when the system is disposed
  11548. */
  11549. set onDispose(callback: () => void);
  11550. private _particles;
  11551. private _epsilon;
  11552. private _capacity;
  11553. private _stockParticles;
  11554. private _newPartsExcess;
  11555. private _vertexData;
  11556. private _vertexBuffer;
  11557. private _vertexBuffers;
  11558. private _spriteBuffer;
  11559. private _indexBuffer;
  11560. private _effect;
  11561. private _customEffect;
  11562. private _cachedDefines;
  11563. private _scaledColorStep;
  11564. private _colorDiff;
  11565. private _scaledDirection;
  11566. private _scaledGravity;
  11567. private _currentRenderId;
  11568. private _alive;
  11569. private _useInstancing;
  11570. private _started;
  11571. private _stopped;
  11572. private _actualFrame;
  11573. private _scaledUpdateSpeed;
  11574. private _vertexBufferSize;
  11575. /** @hidden */
  11576. _currentEmitRateGradient: Nullable<FactorGradient>;
  11577. /** @hidden */
  11578. _currentEmitRate1: number;
  11579. /** @hidden */
  11580. _currentEmitRate2: number;
  11581. /** @hidden */
  11582. _currentStartSizeGradient: Nullable<FactorGradient>;
  11583. /** @hidden */
  11584. _currentStartSize1: number;
  11585. /** @hidden */
  11586. _currentStartSize2: number;
  11587. private readonly _rawTextureWidth;
  11588. private _rampGradientsTexture;
  11589. private _useRampGradients;
  11590. /** Gets or sets a boolean indicating that ramp gradients must be used
  11591. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  11592. */
  11593. get useRampGradients(): boolean;
  11594. set useRampGradients(value: boolean);
  11595. /**
  11596. * 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.
  11597. * 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: [])
  11598. */
  11599. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  11600. private _subEmitters;
  11601. /**
  11602. * @hidden
  11603. * If the particle systems emitter should be disposed when the particle system is disposed
  11604. */
  11605. _disposeEmitterOnDispose: boolean;
  11606. /**
  11607. * The current active Sub-systems, this property is used by the root particle system only.
  11608. */
  11609. activeSubSystems: Array<ParticleSystem>;
  11610. private _rootParticleSystem;
  11611. /**
  11612. * Gets the current list of active particles
  11613. */
  11614. get particles(): Particle[];
  11615. /**
  11616. * Returns the string "ParticleSystem"
  11617. * @returns a string containing the class name
  11618. */
  11619. getClassName(): string;
  11620. /**
  11621. * Instantiates a particle system.
  11622. * 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.
  11623. * @param name The name of the particle system
  11624. * @param capacity The max number of particles alive at the same time
  11625. * @param scene The scene the particle system belongs to
  11626. * @param customEffect a custom effect used to change the way particles are rendered by default
  11627. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  11628. * @param epsilon Offset used to render the particles
  11629. */
  11630. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  11631. private _addFactorGradient;
  11632. private _removeFactorGradient;
  11633. /**
  11634. * Adds a new life time gradient
  11635. * @param gradient defines the gradient to use (between 0 and 1)
  11636. * @param factor defines the life time factor to affect to the specified gradient
  11637. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11638. * @returns the current particle system
  11639. */
  11640. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11641. /**
  11642. * Remove a specific life time gradient
  11643. * @param gradient defines the gradient to remove
  11644. * @returns the current particle system
  11645. */
  11646. removeLifeTimeGradient(gradient: number): IParticleSystem;
  11647. /**
  11648. * Adds a new size gradient
  11649. * @param gradient defines the gradient to use (between 0 and 1)
  11650. * @param factor defines the size factor to affect to the specified gradient
  11651. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11652. * @returns the current particle system
  11653. */
  11654. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11655. /**
  11656. * Remove a specific size gradient
  11657. * @param gradient defines the gradient to remove
  11658. * @returns the current particle system
  11659. */
  11660. removeSizeGradient(gradient: number): IParticleSystem;
  11661. /**
  11662. * Adds a new color remap gradient
  11663. * @param gradient defines the gradient to use (between 0 and 1)
  11664. * @param min defines the color remap minimal range
  11665. * @param max defines the color remap maximal range
  11666. * @returns the current particle system
  11667. */
  11668. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11669. /**
  11670. * Remove a specific color remap gradient
  11671. * @param gradient defines the gradient to remove
  11672. * @returns the current particle system
  11673. */
  11674. removeColorRemapGradient(gradient: number): IParticleSystem;
  11675. /**
  11676. * Adds a new alpha remap gradient
  11677. * @param gradient defines the gradient to use (between 0 and 1)
  11678. * @param min defines the alpha remap minimal range
  11679. * @param max defines the alpha remap maximal range
  11680. * @returns the current particle system
  11681. */
  11682. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11683. /**
  11684. * Remove a specific alpha remap gradient
  11685. * @param gradient defines the gradient to remove
  11686. * @returns the current particle system
  11687. */
  11688. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  11689. /**
  11690. * Adds a new angular speed gradient
  11691. * @param gradient defines the gradient to use (between 0 and 1)
  11692. * @param factor defines the angular speed to affect to the specified gradient
  11693. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11694. * @returns the current particle system
  11695. */
  11696. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11697. /**
  11698. * Remove a specific angular speed gradient
  11699. * @param gradient defines the gradient to remove
  11700. * @returns the current particle system
  11701. */
  11702. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  11703. /**
  11704. * Adds a new velocity gradient
  11705. * @param gradient defines the gradient to use (between 0 and 1)
  11706. * @param factor defines the velocity to affect to the specified gradient
  11707. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11708. * @returns the current particle system
  11709. */
  11710. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11711. /**
  11712. * Remove a specific velocity gradient
  11713. * @param gradient defines the gradient to remove
  11714. * @returns the current particle system
  11715. */
  11716. removeVelocityGradient(gradient: number): IParticleSystem;
  11717. /**
  11718. * Adds a new limit velocity gradient
  11719. * @param gradient defines the gradient to use (between 0 and 1)
  11720. * @param factor defines the limit velocity value to affect to the specified gradient
  11721. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11722. * @returns the current particle system
  11723. */
  11724. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11725. /**
  11726. * Remove a specific limit velocity gradient
  11727. * @param gradient defines the gradient to remove
  11728. * @returns the current particle system
  11729. */
  11730. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  11731. /**
  11732. * Adds a new drag gradient
  11733. * @param gradient defines the gradient to use (between 0 and 1)
  11734. * @param factor defines the drag value to affect to the specified gradient
  11735. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11736. * @returns the current particle system
  11737. */
  11738. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11739. /**
  11740. * Remove a specific drag gradient
  11741. * @param gradient defines the gradient to remove
  11742. * @returns the current particle system
  11743. */
  11744. removeDragGradient(gradient: number): IParticleSystem;
  11745. /**
  11746. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  11747. * @param gradient defines the gradient to use (between 0 and 1)
  11748. * @param factor defines the emit rate value to affect to the specified gradient
  11749. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11750. * @returns the current particle system
  11751. */
  11752. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11753. /**
  11754. * Remove a specific emit rate gradient
  11755. * @param gradient defines the gradient to remove
  11756. * @returns the current particle system
  11757. */
  11758. removeEmitRateGradient(gradient: number): IParticleSystem;
  11759. /**
  11760. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  11761. * @param gradient defines the gradient to use (between 0 and 1)
  11762. * @param factor defines the start size value to affect to the specified gradient
  11763. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11764. * @returns the current particle system
  11765. */
  11766. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11767. /**
  11768. * Remove a specific start size gradient
  11769. * @param gradient defines the gradient to remove
  11770. * @returns the current particle system
  11771. */
  11772. removeStartSizeGradient(gradient: number): IParticleSystem;
  11773. private _createRampGradientTexture;
  11774. /**
  11775. * Gets the current list of ramp gradients.
  11776. * You must use addRampGradient and removeRampGradient to udpate this list
  11777. * @returns the list of ramp gradients
  11778. */
  11779. getRampGradients(): Nullable<Array<Color3Gradient>>;
  11780. /**
  11781. * Adds a new ramp gradient used to remap particle colors
  11782. * @param gradient defines the gradient to use (between 0 and 1)
  11783. * @param color defines the color to affect to the specified gradient
  11784. * @returns the current particle system
  11785. */
  11786. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  11787. /**
  11788. * Remove a specific ramp gradient
  11789. * @param gradient defines the gradient to remove
  11790. * @returns the current particle system
  11791. */
  11792. removeRampGradient(gradient: number): ParticleSystem;
  11793. /**
  11794. * Adds a new color gradient
  11795. * @param gradient defines the gradient to use (between 0 and 1)
  11796. * @param color1 defines the color to affect to the specified gradient
  11797. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  11798. * @returns this particle system
  11799. */
  11800. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  11801. /**
  11802. * Remove a specific color gradient
  11803. * @param gradient defines the gradient to remove
  11804. * @returns this particle system
  11805. */
  11806. removeColorGradient(gradient: number): IParticleSystem;
  11807. private _fetchR;
  11808. protected _reset(): void;
  11809. private _resetEffect;
  11810. private _createVertexBuffers;
  11811. private _createIndexBuffer;
  11812. /**
  11813. * Gets the maximum number of particles active at the same time.
  11814. * @returns The max number of active particles.
  11815. */
  11816. getCapacity(): number;
  11817. /**
  11818. * Gets whether there are still active particles in the system.
  11819. * @returns True if it is alive, otherwise false.
  11820. */
  11821. isAlive(): boolean;
  11822. /**
  11823. * Gets if the system has been started. (Note: this will still be true after stop is called)
  11824. * @returns True if it has been started, otherwise false.
  11825. */
  11826. isStarted(): boolean;
  11827. private _prepareSubEmitterInternalArray;
  11828. /**
  11829. * Starts the particle system and begins to emit
  11830. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  11831. */
  11832. start(delay?: number): void;
  11833. /**
  11834. * Stops the particle system.
  11835. * @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.
  11836. */
  11837. stop(stopSubEmitters?: boolean): void;
  11838. /**
  11839. * Remove all active particles
  11840. */
  11841. reset(): void;
  11842. /**
  11843. * @hidden (for internal use only)
  11844. */
  11845. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  11846. /**
  11847. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  11848. * Its lifetime will start back at 0.
  11849. */
  11850. recycleParticle: (particle: Particle) => void;
  11851. private _stopSubEmitters;
  11852. private _createParticle;
  11853. private _removeFromRoot;
  11854. private _emitFromParticle;
  11855. private _update;
  11856. /** @hidden */
  11857. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  11858. /** @hidden */
  11859. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  11860. /** @hidden */
  11861. private _getEffect;
  11862. /**
  11863. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  11864. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  11865. */
  11866. animate(preWarmOnly?: boolean): void;
  11867. private _appendParticleVertices;
  11868. /**
  11869. * Rebuilds the particle system.
  11870. */
  11871. rebuild(): void;
  11872. /**
  11873. * Is this system ready to be used/rendered
  11874. * @return true if the system is ready
  11875. */
  11876. isReady(): boolean;
  11877. private _render;
  11878. /**
  11879. * Renders the particle system in its current state.
  11880. * @returns the current number of particles
  11881. */
  11882. render(): number;
  11883. /**
  11884. * Disposes the particle system and free the associated resources
  11885. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  11886. */
  11887. dispose(disposeTexture?: boolean): void;
  11888. /**
  11889. * Clones the particle system.
  11890. * @param name The name of the cloned object
  11891. * @param newEmitter The new emitter to use
  11892. * @returns the cloned particle system
  11893. */
  11894. clone(name: string, newEmitter: any): ParticleSystem;
  11895. /**
  11896. * Serializes the particle system to a JSON object.
  11897. * @returns the JSON object
  11898. */
  11899. serialize(): any;
  11900. /** @hidden */
  11901. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  11902. /** @hidden */
  11903. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  11904. /**
  11905. * Parses a JSON object to create a particle system.
  11906. * @param parsedParticleSystem The JSON object to parse
  11907. * @param scene The scene to create the particle system in
  11908. * @param rootUrl The root url to use to load external dependencies like texture
  11909. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  11910. * @returns the Parsed particle system
  11911. */
  11912. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  11913. }
  11914. }
  11915. declare module BABYLON {
  11916. /**
  11917. * A particle represents one of the element emitted by a particle system.
  11918. * This is mainly define by its coordinates, direction, velocity and age.
  11919. */
  11920. export class Particle {
  11921. /**
  11922. * The particle system the particle belongs to.
  11923. */
  11924. particleSystem: ParticleSystem;
  11925. private static _Count;
  11926. /**
  11927. * Unique ID of the particle
  11928. */
  11929. id: number;
  11930. /**
  11931. * The world position of the particle in the scene.
  11932. */
  11933. position: Vector3;
  11934. /**
  11935. * The world direction of the particle in the scene.
  11936. */
  11937. direction: Vector3;
  11938. /**
  11939. * The color of the particle.
  11940. */
  11941. color: Color4;
  11942. /**
  11943. * The color change of the particle per step.
  11944. */
  11945. colorStep: Color4;
  11946. /**
  11947. * Defines how long will the life of the particle be.
  11948. */
  11949. lifeTime: number;
  11950. /**
  11951. * The current age of the particle.
  11952. */
  11953. age: number;
  11954. /**
  11955. * The current size of the particle.
  11956. */
  11957. size: number;
  11958. /**
  11959. * The current scale of the particle.
  11960. */
  11961. scale: Vector2;
  11962. /**
  11963. * The current angle of the particle.
  11964. */
  11965. angle: number;
  11966. /**
  11967. * Defines how fast is the angle changing.
  11968. */
  11969. angularSpeed: number;
  11970. /**
  11971. * Defines the cell index used by the particle to be rendered from a sprite.
  11972. */
  11973. cellIndex: number;
  11974. /**
  11975. * The information required to support color remapping
  11976. */
  11977. remapData: Vector4;
  11978. /** @hidden */
  11979. _randomCellOffset?: number;
  11980. /** @hidden */
  11981. _initialDirection: Nullable<Vector3>;
  11982. /** @hidden */
  11983. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  11984. /** @hidden */
  11985. _initialStartSpriteCellID: number;
  11986. /** @hidden */
  11987. _initialEndSpriteCellID: number;
  11988. /** @hidden */
  11989. _currentColorGradient: Nullable<ColorGradient>;
  11990. /** @hidden */
  11991. _currentColor1: Color4;
  11992. /** @hidden */
  11993. _currentColor2: Color4;
  11994. /** @hidden */
  11995. _currentSizeGradient: Nullable<FactorGradient>;
  11996. /** @hidden */
  11997. _currentSize1: number;
  11998. /** @hidden */
  11999. _currentSize2: number;
  12000. /** @hidden */
  12001. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12002. /** @hidden */
  12003. _currentAngularSpeed1: number;
  12004. /** @hidden */
  12005. _currentAngularSpeed2: number;
  12006. /** @hidden */
  12007. _currentVelocityGradient: Nullable<FactorGradient>;
  12008. /** @hidden */
  12009. _currentVelocity1: number;
  12010. /** @hidden */
  12011. _currentVelocity2: number;
  12012. /** @hidden */
  12013. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12014. /** @hidden */
  12015. _currentLimitVelocity1: number;
  12016. /** @hidden */
  12017. _currentLimitVelocity2: number;
  12018. /** @hidden */
  12019. _currentDragGradient: Nullable<FactorGradient>;
  12020. /** @hidden */
  12021. _currentDrag1: number;
  12022. /** @hidden */
  12023. _currentDrag2: number;
  12024. /** @hidden */
  12025. _randomNoiseCoordinates1: Vector3;
  12026. /** @hidden */
  12027. _randomNoiseCoordinates2: Vector3;
  12028. /**
  12029. * Creates a new instance Particle
  12030. * @param particleSystem the particle system the particle belongs to
  12031. */
  12032. constructor(
  12033. /**
  12034. * The particle system the particle belongs to.
  12035. */
  12036. particleSystem: ParticleSystem);
  12037. private updateCellInfoFromSystem;
  12038. /**
  12039. * Defines how the sprite cell index is updated for the particle
  12040. */
  12041. updateCellIndex(): void;
  12042. /** @hidden */
  12043. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12044. /** @hidden */
  12045. _inheritParticleInfoToSubEmitters(): void;
  12046. /** @hidden */
  12047. _reset(): void;
  12048. /**
  12049. * Copy the properties of particle to another one.
  12050. * @param other the particle to copy the information to.
  12051. */
  12052. copyTo(other: Particle): void;
  12053. }
  12054. }
  12055. declare module BABYLON {
  12056. /**
  12057. * Particle emitter represents a volume emitting particles.
  12058. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12059. */
  12060. export interface IParticleEmitterType {
  12061. /**
  12062. * Called by the particle System when the direction is computed for the created particle.
  12063. * @param worldMatrix is the world matrix of the particle system
  12064. * @param directionToUpdate is the direction vector to update with the result
  12065. * @param particle is the particle we are computed the direction for
  12066. */
  12067. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12068. /**
  12069. * Called by the particle System when the position is computed for the created particle.
  12070. * @param worldMatrix is the world matrix of the particle system
  12071. * @param positionToUpdate is the position vector to update with the result
  12072. * @param particle is the particle we are computed the position for
  12073. */
  12074. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12075. /**
  12076. * Clones the current emitter and returns a copy of it
  12077. * @returns the new emitter
  12078. */
  12079. clone(): IParticleEmitterType;
  12080. /**
  12081. * Called by the GPUParticleSystem to setup the update shader
  12082. * @param effect defines the update shader
  12083. */
  12084. applyToShader(effect: Effect): void;
  12085. /**
  12086. * Returns a string to use to update the GPU particles update shader
  12087. * @returns the effect defines string
  12088. */
  12089. getEffectDefines(): string;
  12090. /**
  12091. * Returns a string representing the class name
  12092. * @returns a string containing the class name
  12093. */
  12094. getClassName(): string;
  12095. /**
  12096. * Serializes the particle system to a JSON object.
  12097. * @returns the JSON object
  12098. */
  12099. serialize(): any;
  12100. /**
  12101. * Parse properties from a JSON object
  12102. * @param serializationObject defines the JSON object
  12103. * @param scene defines the hosting scene
  12104. */
  12105. parse(serializationObject: any, scene: Scene): void;
  12106. }
  12107. }
  12108. declare module BABYLON {
  12109. /**
  12110. * Particle emitter emitting particles from the inside of a box.
  12111. * It emits the particles randomly between 2 given directions.
  12112. */
  12113. export class BoxParticleEmitter implements IParticleEmitterType {
  12114. /**
  12115. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12116. */
  12117. direction1: Vector3;
  12118. /**
  12119. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12120. */
  12121. direction2: Vector3;
  12122. /**
  12123. * 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.
  12124. */
  12125. minEmitBox: Vector3;
  12126. /**
  12127. * 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.
  12128. */
  12129. maxEmitBox: Vector3;
  12130. /**
  12131. * Creates a new instance BoxParticleEmitter
  12132. */
  12133. constructor();
  12134. /**
  12135. * Called by the particle System when the direction is computed for the created particle.
  12136. * @param worldMatrix is the world matrix of the particle system
  12137. * @param directionToUpdate is the direction vector to update with the result
  12138. * @param particle is the particle we are computed the direction for
  12139. */
  12140. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12141. /**
  12142. * Called by the particle System when the position is computed for the created particle.
  12143. * @param worldMatrix is the world matrix of the particle system
  12144. * @param positionToUpdate is the position vector to update with the result
  12145. * @param particle is the particle we are computed the position for
  12146. */
  12147. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12148. /**
  12149. * Clones the current emitter and returns a copy of it
  12150. * @returns the new emitter
  12151. */
  12152. clone(): BoxParticleEmitter;
  12153. /**
  12154. * Called by the GPUParticleSystem to setup the update shader
  12155. * @param effect defines the update shader
  12156. */
  12157. applyToShader(effect: Effect): void;
  12158. /**
  12159. * Returns a string to use to update the GPU particles update shader
  12160. * @returns a string containng the defines string
  12161. */
  12162. getEffectDefines(): string;
  12163. /**
  12164. * Returns the string "BoxParticleEmitter"
  12165. * @returns a string containing the class name
  12166. */
  12167. getClassName(): string;
  12168. /**
  12169. * Serializes the particle system to a JSON object.
  12170. * @returns the JSON object
  12171. */
  12172. serialize(): any;
  12173. /**
  12174. * Parse properties from a JSON object
  12175. * @param serializationObject defines the JSON object
  12176. */
  12177. parse(serializationObject: any): void;
  12178. }
  12179. }
  12180. declare module BABYLON {
  12181. /**
  12182. * Particle emitter emitting particles from the inside of a cone.
  12183. * It emits the particles alongside the cone volume from the base to the particle.
  12184. * The emission direction might be randomized.
  12185. */
  12186. export class ConeParticleEmitter implements IParticleEmitterType {
  12187. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12188. directionRandomizer: number;
  12189. private _radius;
  12190. private _angle;
  12191. private _height;
  12192. /**
  12193. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  12194. */
  12195. radiusRange: number;
  12196. /**
  12197. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  12198. */
  12199. heightRange: number;
  12200. /**
  12201. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  12202. */
  12203. emitFromSpawnPointOnly: boolean;
  12204. /**
  12205. * Gets or sets the radius of the emission cone
  12206. */
  12207. get radius(): number;
  12208. set radius(value: number);
  12209. /**
  12210. * Gets or sets the angle of the emission cone
  12211. */
  12212. get angle(): number;
  12213. set angle(value: number);
  12214. private _buildHeight;
  12215. /**
  12216. * Creates a new instance ConeParticleEmitter
  12217. * @param radius the radius of the emission cone (1 by default)
  12218. * @param angle the cone base angle (PI by default)
  12219. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  12220. */
  12221. constructor(radius?: number, angle?: number,
  12222. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12223. directionRandomizer?: number);
  12224. /**
  12225. * Called by the particle System when the direction is computed for the created particle.
  12226. * @param worldMatrix is the world matrix of the particle system
  12227. * @param directionToUpdate is the direction vector to update with the result
  12228. * @param particle is the particle we are computed the direction for
  12229. */
  12230. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12231. /**
  12232. * Called by the particle System when the position is computed for the created particle.
  12233. * @param worldMatrix is the world matrix of the particle system
  12234. * @param positionToUpdate is the position vector to update with the result
  12235. * @param particle is the particle we are computed the position for
  12236. */
  12237. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12238. /**
  12239. * Clones the current emitter and returns a copy of it
  12240. * @returns the new emitter
  12241. */
  12242. clone(): ConeParticleEmitter;
  12243. /**
  12244. * Called by the GPUParticleSystem to setup the update shader
  12245. * @param effect defines the update shader
  12246. */
  12247. applyToShader(effect: Effect): void;
  12248. /**
  12249. * Returns a string to use to update the GPU particles update shader
  12250. * @returns a string containng the defines string
  12251. */
  12252. getEffectDefines(): string;
  12253. /**
  12254. * Returns the string "ConeParticleEmitter"
  12255. * @returns a string containing the class name
  12256. */
  12257. getClassName(): string;
  12258. /**
  12259. * Serializes the particle system to a JSON object.
  12260. * @returns the JSON object
  12261. */
  12262. serialize(): any;
  12263. /**
  12264. * Parse properties from a JSON object
  12265. * @param serializationObject defines the JSON object
  12266. */
  12267. parse(serializationObject: any): void;
  12268. }
  12269. }
  12270. declare module BABYLON {
  12271. /**
  12272. * Particle emitter emitting particles from the inside of a cylinder.
  12273. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  12274. */
  12275. export class CylinderParticleEmitter implements IParticleEmitterType {
  12276. /**
  12277. * The radius of the emission cylinder.
  12278. */
  12279. radius: number;
  12280. /**
  12281. * The height of the emission cylinder.
  12282. */
  12283. height: number;
  12284. /**
  12285. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12286. */
  12287. radiusRange: number;
  12288. /**
  12289. * How much to randomize the particle direction [0-1].
  12290. */
  12291. directionRandomizer: number;
  12292. /**
  12293. * Creates a new instance CylinderParticleEmitter
  12294. * @param radius the radius of the emission cylinder (1 by default)
  12295. * @param height the height of the emission cylinder (1 by default)
  12296. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12297. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12298. */
  12299. constructor(
  12300. /**
  12301. * The radius of the emission cylinder.
  12302. */
  12303. radius?: number,
  12304. /**
  12305. * The height of the emission cylinder.
  12306. */
  12307. height?: number,
  12308. /**
  12309. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12310. */
  12311. radiusRange?: number,
  12312. /**
  12313. * How much to randomize the particle direction [0-1].
  12314. */
  12315. directionRandomizer?: number);
  12316. /**
  12317. * Called by the particle System when the direction is computed for the created particle.
  12318. * @param worldMatrix is the world matrix of the particle system
  12319. * @param directionToUpdate is the direction vector to update with the result
  12320. * @param particle is the particle we are computed the direction for
  12321. */
  12322. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12323. /**
  12324. * Called by the particle System when the position is computed for the created particle.
  12325. * @param worldMatrix is the world matrix of the particle system
  12326. * @param positionToUpdate is the position vector to update with the result
  12327. * @param particle is the particle we are computed the position for
  12328. */
  12329. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12330. /**
  12331. * Clones the current emitter and returns a copy of it
  12332. * @returns the new emitter
  12333. */
  12334. clone(): CylinderParticleEmitter;
  12335. /**
  12336. * Called by the GPUParticleSystem to setup the update shader
  12337. * @param effect defines the update shader
  12338. */
  12339. applyToShader(effect: Effect): void;
  12340. /**
  12341. * Returns a string to use to update the GPU particles update shader
  12342. * @returns a string containng the defines string
  12343. */
  12344. getEffectDefines(): string;
  12345. /**
  12346. * Returns the string "CylinderParticleEmitter"
  12347. * @returns a string containing the class name
  12348. */
  12349. getClassName(): string;
  12350. /**
  12351. * Serializes the particle system to a JSON object.
  12352. * @returns the JSON object
  12353. */
  12354. serialize(): any;
  12355. /**
  12356. * Parse properties from a JSON object
  12357. * @param serializationObject defines the JSON object
  12358. */
  12359. parse(serializationObject: any): void;
  12360. }
  12361. /**
  12362. * Particle emitter emitting particles from the inside of a cylinder.
  12363. * It emits the particles randomly between two vectors.
  12364. */
  12365. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  12366. /**
  12367. * The min limit of the emission direction.
  12368. */
  12369. direction1: Vector3;
  12370. /**
  12371. * The max limit of the emission direction.
  12372. */
  12373. direction2: Vector3;
  12374. /**
  12375. * Creates a new instance CylinderDirectedParticleEmitter
  12376. * @param radius the radius of the emission cylinder (1 by default)
  12377. * @param height the height of the emission cylinder (1 by default)
  12378. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12379. * @param direction1 the min limit of the emission direction (up vector by default)
  12380. * @param direction2 the max limit of the emission direction (up vector by default)
  12381. */
  12382. constructor(radius?: number, height?: number, radiusRange?: number,
  12383. /**
  12384. * The min limit of the emission direction.
  12385. */
  12386. direction1?: Vector3,
  12387. /**
  12388. * The max limit of the emission direction.
  12389. */
  12390. direction2?: Vector3);
  12391. /**
  12392. * Called by the particle System when the direction is computed for the created particle.
  12393. * @param worldMatrix is the world matrix of the particle system
  12394. * @param directionToUpdate is the direction vector to update with the result
  12395. * @param particle is the particle we are computed the direction for
  12396. */
  12397. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12398. /**
  12399. * Clones the current emitter and returns a copy of it
  12400. * @returns the new emitter
  12401. */
  12402. clone(): CylinderDirectedParticleEmitter;
  12403. /**
  12404. * Called by the GPUParticleSystem to setup the update shader
  12405. * @param effect defines the update shader
  12406. */
  12407. applyToShader(effect: Effect): void;
  12408. /**
  12409. * Returns a string to use to update the GPU particles update shader
  12410. * @returns a string containng the defines string
  12411. */
  12412. getEffectDefines(): string;
  12413. /**
  12414. * Returns the string "CylinderDirectedParticleEmitter"
  12415. * @returns a string containing the class name
  12416. */
  12417. getClassName(): string;
  12418. /**
  12419. * Serializes the particle system to a JSON object.
  12420. * @returns the JSON object
  12421. */
  12422. serialize(): any;
  12423. /**
  12424. * Parse properties from a JSON object
  12425. * @param serializationObject defines the JSON object
  12426. */
  12427. parse(serializationObject: any): void;
  12428. }
  12429. }
  12430. declare module BABYLON {
  12431. /**
  12432. * Particle emitter emitting particles from the inside of a hemisphere.
  12433. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  12434. */
  12435. export class HemisphericParticleEmitter implements IParticleEmitterType {
  12436. /**
  12437. * The radius of the emission hemisphere.
  12438. */
  12439. radius: number;
  12440. /**
  12441. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12442. */
  12443. radiusRange: number;
  12444. /**
  12445. * How much to randomize the particle direction [0-1].
  12446. */
  12447. directionRandomizer: number;
  12448. /**
  12449. * Creates a new instance HemisphericParticleEmitter
  12450. * @param radius the radius of the emission hemisphere (1 by default)
  12451. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12452. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12453. */
  12454. constructor(
  12455. /**
  12456. * The radius of the emission hemisphere.
  12457. */
  12458. radius?: number,
  12459. /**
  12460. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12461. */
  12462. radiusRange?: number,
  12463. /**
  12464. * How much to randomize the particle direction [0-1].
  12465. */
  12466. directionRandomizer?: number);
  12467. /**
  12468. * Called by the particle System when the direction is computed for the created particle.
  12469. * @param worldMatrix is the world matrix of the particle system
  12470. * @param directionToUpdate is the direction vector to update with the result
  12471. * @param particle is the particle we are computed the direction for
  12472. */
  12473. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12474. /**
  12475. * Called by the particle System when the position is computed for the created particle.
  12476. * @param worldMatrix is the world matrix of the particle system
  12477. * @param positionToUpdate is the position vector to update with the result
  12478. * @param particle is the particle we are computed the position for
  12479. */
  12480. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12481. /**
  12482. * Clones the current emitter and returns a copy of it
  12483. * @returns the new emitter
  12484. */
  12485. clone(): HemisphericParticleEmitter;
  12486. /**
  12487. * Called by the GPUParticleSystem to setup the update shader
  12488. * @param effect defines the update shader
  12489. */
  12490. applyToShader(effect: Effect): void;
  12491. /**
  12492. * Returns a string to use to update the GPU particles update shader
  12493. * @returns a string containng the defines string
  12494. */
  12495. getEffectDefines(): string;
  12496. /**
  12497. * Returns the string "HemisphericParticleEmitter"
  12498. * @returns a string containing the class name
  12499. */
  12500. getClassName(): string;
  12501. /**
  12502. * Serializes the particle system to a JSON object.
  12503. * @returns the JSON object
  12504. */
  12505. serialize(): any;
  12506. /**
  12507. * Parse properties from a JSON object
  12508. * @param serializationObject defines the JSON object
  12509. */
  12510. parse(serializationObject: any): void;
  12511. }
  12512. }
  12513. declare module BABYLON {
  12514. /**
  12515. * Particle emitter emitting particles from a point.
  12516. * It emits the particles randomly between 2 given directions.
  12517. */
  12518. export class PointParticleEmitter implements IParticleEmitterType {
  12519. /**
  12520. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12521. */
  12522. direction1: Vector3;
  12523. /**
  12524. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12525. */
  12526. direction2: Vector3;
  12527. /**
  12528. * Creates a new instance PointParticleEmitter
  12529. */
  12530. constructor();
  12531. /**
  12532. * Called by the particle System when the direction is computed for the created particle.
  12533. * @param worldMatrix is the world matrix of the particle system
  12534. * @param directionToUpdate is the direction vector to update with the result
  12535. * @param particle is the particle we are computed the direction for
  12536. */
  12537. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12538. /**
  12539. * Called by the particle System when the position is computed for the created particle.
  12540. * @param worldMatrix is the world matrix of the particle system
  12541. * @param positionToUpdate is the position vector to update with the result
  12542. * @param particle is the particle we are computed the position for
  12543. */
  12544. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12545. /**
  12546. * Clones the current emitter and returns a copy of it
  12547. * @returns the new emitter
  12548. */
  12549. clone(): PointParticleEmitter;
  12550. /**
  12551. * Called by the GPUParticleSystem to setup the update shader
  12552. * @param effect defines the update shader
  12553. */
  12554. applyToShader(effect: Effect): void;
  12555. /**
  12556. * Returns a string to use to update the GPU particles update shader
  12557. * @returns a string containng the defines string
  12558. */
  12559. getEffectDefines(): string;
  12560. /**
  12561. * Returns the string "PointParticleEmitter"
  12562. * @returns a string containing the class name
  12563. */
  12564. getClassName(): string;
  12565. /**
  12566. * Serializes the particle system to a JSON object.
  12567. * @returns the JSON object
  12568. */
  12569. serialize(): any;
  12570. /**
  12571. * Parse properties from a JSON object
  12572. * @param serializationObject defines the JSON object
  12573. */
  12574. parse(serializationObject: any): void;
  12575. }
  12576. }
  12577. declare module BABYLON {
  12578. /**
  12579. * Particle emitter emitting particles from the inside of a sphere.
  12580. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  12581. */
  12582. export class SphereParticleEmitter implements IParticleEmitterType {
  12583. /**
  12584. * The radius of the emission sphere.
  12585. */
  12586. radius: number;
  12587. /**
  12588. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12589. */
  12590. radiusRange: number;
  12591. /**
  12592. * How much to randomize the particle direction [0-1].
  12593. */
  12594. directionRandomizer: number;
  12595. /**
  12596. * Creates a new instance SphereParticleEmitter
  12597. * @param radius the radius of the emission sphere (1 by default)
  12598. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12599. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12600. */
  12601. constructor(
  12602. /**
  12603. * The radius of the emission sphere.
  12604. */
  12605. radius?: number,
  12606. /**
  12607. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12608. */
  12609. radiusRange?: number,
  12610. /**
  12611. * How much to randomize the particle direction [0-1].
  12612. */
  12613. directionRandomizer?: number);
  12614. /**
  12615. * Called by the particle System when the direction is computed for the created particle.
  12616. * @param worldMatrix is the world matrix of the particle system
  12617. * @param directionToUpdate is the direction vector to update with the result
  12618. * @param particle is the particle we are computed the direction for
  12619. */
  12620. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12621. /**
  12622. * Called by the particle System when the position is computed for the created particle.
  12623. * @param worldMatrix is the world matrix of the particle system
  12624. * @param positionToUpdate is the position vector to update with the result
  12625. * @param particle is the particle we are computed the position for
  12626. */
  12627. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12628. /**
  12629. * Clones the current emitter and returns a copy of it
  12630. * @returns the new emitter
  12631. */
  12632. clone(): SphereParticleEmitter;
  12633. /**
  12634. * Called by the GPUParticleSystem to setup the update shader
  12635. * @param effect defines the update shader
  12636. */
  12637. applyToShader(effect: Effect): void;
  12638. /**
  12639. * Returns a string to use to update the GPU particles update shader
  12640. * @returns a string containng the defines string
  12641. */
  12642. getEffectDefines(): string;
  12643. /**
  12644. * Returns the string "SphereParticleEmitter"
  12645. * @returns a string containing the class name
  12646. */
  12647. getClassName(): string;
  12648. /**
  12649. * Serializes the particle system to a JSON object.
  12650. * @returns the JSON object
  12651. */
  12652. serialize(): any;
  12653. /**
  12654. * Parse properties from a JSON object
  12655. * @param serializationObject defines the JSON object
  12656. */
  12657. parse(serializationObject: any): void;
  12658. }
  12659. /**
  12660. * Particle emitter emitting particles from the inside of a sphere.
  12661. * It emits the particles randomly between two vectors.
  12662. */
  12663. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  12664. /**
  12665. * The min limit of the emission direction.
  12666. */
  12667. direction1: Vector3;
  12668. /**
  12669. * The max limit of the emission direction.
  12670. */
  12671. direction2: Vector3;
  12672. /**
  12673. * Creates a new instance SphereDirectedParticleEmitter
  12674. * @param radius the radius of the emission sphere (1 by default)
  12675. * @param direction1 the min limit of the emission direction (up vector by default)
  12676. * @param direction2 the max limit of the emission direction (up vector by default)
  12677. */
  12678. constructor(radius?: number,
  12679. /**
  12680. * The min limit of the emission direction.
  12681. */
  12682. direction1?: Vector3,
  12683. /**
  12684. * The max limit of the emission direction.
  12685. */
  12686. direction2?: Vector3);
  12687. /**
  12688. * Called by the particle System when the direction is computed for the created particle.
  12689. * @param worldMatrix is the world matrix of the particle system
  12690. * @param directionToUpdate is the direction vector to update with the result
  12691. * @param particle is the particle we are computed the direction for
  12692. */
  12693. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12694. /**
  12695. * Clones the current emitter and returns a copy of it
  12696. * @returns the new emitter
  12697. */
  12698. clone(): SphereDirectedParticleEmitter;
  12699. /**
  12700. * Called by the GPUParticleSystem to setup the update shader
  12701. * @param effect defines the update shader
  12702. */
  12703. applyToShader(effect: Effect): void;
  12704. /**
  12705. * Returns a string to use to update the GPU particles update shader
  12706. * @returns a string containng the defines string
  12707. */
  12708. getEffectDefines(): string;
  12709. /**
  12710. * Returns the string "SphereDirectedParticleEmitter"
  12711. * @returns a string containing the class name
  12712. */
  12713. getClassName(): string;
  12714. /**
  12715. * Serializes the particle system to a JSON object.
  12716. * @returns the JSON object
  12717. */
  12718. serialize(): any;
  12719. /**
  12720. * Parse properties from a JSON object
  12721. * @param serializationObject defines the JSON object
  12722. */
  12723. parse(serializationObject: any): void;
  12724. }
  12725. }
  12726. declare module BABYLON {
  12727. /**
  12728. * Particle emitter emitting particles from a custom list of positions.
  12729. */
  12730. export class CustomParticleEmitter implements IParticleEmitterType {
  12731. /**
  12732. * Gets or sets the position generator that will create the inital position of each particle.
  12733. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12734. */
  12735. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  12736. /**
  12737. * Gets or sets the destination generator that will create the final destination of each particle.
  12738. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  12739. */
  12740. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  12741. /**
  12742. * Creates a new instance CustomParticleEmitter
  12743. */
  12744. constructor();
  12745. /**
  12746. * Called by the particle System when the direction is computed for the created particle.
  12747. * @param worldMatrix is the world matrix of the particle system
  12748. * @param directionToUpdate is the direction vector to update with the result
  12749. * @param particle is the particle we are computed the direction for
  12750. */
  12751. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12752. /**
  12753. * Called by the particle System when the position is computed for the created particle.
  12754. * @param worldMatrix is the world matrix of the particle system
  12755. * @param positionToUpdate is the position vector to update with the result
  12756. * @param particle is the particle we are computed the position for
  12757. */
  12758. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12759. /**
  12760. * Clones the current emitter and returns a copy of it
  12761. * @returns the new emitter
  12762. */
  12763. clone(): CustomParticleEmitter;
  12764. /**
  12765. * Called by the GPUParticleSystem to setup the update shader
  12766. * @param effect defines the update shader
  12767. */
  12768. applyToShader(effect: Effect): void;
  12769. /**
  12770. * Returns a string to use to update the GPU particles update shader
  12771. * @returns a string containng the defines string
  12772. */
  12773. getEffectDefines(): string;
  12774. /**
  12775. * Returns the string "PointParticleEmitter"
  12776. * @returns a string containing the class name
  12777. */
  12778. getClassName(): string;
  12779. /**
  12780. * Serializes the particle system to a JSON object.
  12781. * @returns the JSON object
  12782. */
  12783. serialize(): any;
  12784. /**
  12785. * Parse properties from a JSON object
  12786. * @param serializationObject defines the JSON object
  12787. */
  12788. parse(serializationObject: any): void;
  12789. }
  12790. }
  12791. declare module BABYLON {
  12792. /**
  12793. * Particle emitter emitting particles from the inside of a box.
  12794. * It emits the particles randomly between 2 given directions.
  12795. */
  12796. export class MeshParticleEmitter implements IParticleEmitterType {
  12797. /** Defines the mesh to use as source */
  12798. mesh?: AbstractMesh | undefined;
  12799. private _indices;
  12800. private _positions;
  12801. private _normals;
  12802. private _storedNormal;
  12803. /**
  12804. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12805. */
  12806. direction1: Vector3;
  12807. /**
  12808. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12809. */
  12810. direction2: Vector3;
  12811. /**
  12812. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  12813. */
  12814. useMeshNormalsForDirection: boolean;
  12815. /**
  12816. * Creates a new instance MeshParticleEmitter
  12817. * @param mesh defines the mesh to use as source
  12818. */
  12819. constructor(
  12820. /** Defines the mesh to use as source */
  12821. mesh?: AbstractMesh | undefined);
  12822. /**
  12823. * Called by the particle System when the direction is computed for the created particle.
  12824. * @param worldMatrix is the world matrix of the particle system
  12825. * @param directionToUpdate is the direction vector to update with the result
  12826. * @param particle is the particle we are computed the direction for
  12827. */
  12828. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12829. /**
  12830. * Called by the particle System when the position is computed for the created particle.
  12831. * @param worldMatrix is the world matrix of the particle system
  12832. * @param positionToUpdate is the position vector to update with the result
  12833. * @param particle is the particle we are computed the position for
  12834. */
  12835. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12836. /**
  12837. * Clones the current emitter and returns a copy of it
  12838. * @returns the new emitter
  12839. */
  12840. clone(): MeshParticleEmitter;
  12841. /**
  12842. * Called by the GPUParticleSystem to setup the update shader
  12843. * @param effect defines the update shader
  12844. */
  12845. applyToShader(effect: Effect): void;
  12846. /**
  12847. * Returns a string to use to update the GPU particles update shader
  12848. * @returns a string containng the defines string
  12849. */
  12850. getEffectDefines(): string;
  12851. /**
  12852. * Returns the string "BoxParticleEmitter"
  12853. * @returns a string containing the class name
  12854. */
  12855. getClassName(): string;
  12856. /**
  12857. * Serializes the particle system to a JSON object.
  12858. * @returns the JSON object
  12859. */
  12860. serialize(): any;
  12861. /**
  12862. * Parse properties from a JSON object
  12863. * @param serializationObject defines the JSON object
  12864. * @param scene defines the hosting scene
  12865. */
  12866. parse(serializationObject: any, scene: Scene): void;
  12867. }
  12868. }
  12869. declare module BABYLON {
  12870. /**
  12871. * Interface representing a particle system in Babylon.js.
  12872. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  12873. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  12874. */
  12875. export interface IParticleSystem {
  12876. /**
  12877. * List of animations used by the particle system.
  12878. */
  12879. animations: Animation[];
  12880. /**
  12881. * The id of the Particle system.
  12882. */
  12883. id: string;
  12884. /**
  12885. * The name of the Particle system.
  12886. */
  12887. name: string;
  12888. /**
  12889. * The emitter represents the Mesh or position we are attaching the particle system to.
  12890. */
  12891. emitter: Nullable<AbstractMesh | Vector3>;
  12892. /**
  12893. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12894. */
  12895. isBillboardBased: boolean;
  12896. /**
  12897. * The rendering group used by the Particle system to chose when to render.
  12898. */
  12899. renderingGroupId: number;
  12900. /**
  12901. * The layer mask we are rendering the particles through.
  12902. */
  12903. layerMask: number;
  12904. /**
  12905. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12906. */
  12907. updateSpeed: number;
  12908. /**
  12909. * The amount of time the particle system is running (depends of the overall update speed).
  12910. */
  12911. targetStopDuration: number;
  12912. /**
  12913. * The texture used to render each particle. (this can be a spritesheet)
  12914. */
  12915. particleTexture: Nullable<Texture>;
  12916. /**
  12917. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  12918. */
  12919. blendMode: number;
  12920. /**
  12921. * Minimum life time of emitting particles.
  12922. */
  12923. minLifeTime: number;
  12924. /**
  12925. * Maximum life time of emitting particles.
  12926. */
  12927. maxLifeTime: number;
  12928. /**
  12929. * Minimum Size of emitting particles.
  12930. */
  12931. minSize: number;
  12932. /**
  12933. * Maximum Size of emitting particles.
  12934. */
  12935. maxSize: number;
  12936. /**
  12937. * Minimum scale of emitting particles on X axis.
  12938. */
  12939. minScaleX: number;
  12940. /**
  12941. * Maximum scale of emitting particles on X axis.
  12942. */
  12943. maxScaleX: number;
  12944. /**
  12945. * Minimum scale of emitting particles on Y axis.
  12946. */
  12947. minScaleY: number;
  12948. /**
  12949. * Maximum scale of emitting particles on Y axis.
  12950. */
  12951. maxScaleY: number;
  12952. /**
  12953. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  12954. */
  12955. color1: Color4;
  12956. /**
  12957. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  12958. */
  12959. color2: Color4;
  12960. /**
  12961. * Color the particle will have at the end of its lifetime.
  12962. */
  12963. colorDead: Color4;
  12964. /**
  12965. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  12966. */
  12967. emitRate: number;
  12968. /**
  12969. * You can use gravity if you want to give an orientation to your particles.
  12970. */
  12971. gravity: Vector3;
  12972. /**
  12973. * Minimum power of emitting particles.
  12974. */
  12975. minEmitPower: number;
  12976. /**
  12977. * Maximum power of emitting particles.
  12978. */
  12979. maxEmitPower: number;
  12980. /**
  12981. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12982. */
  12983. minAngularSpeed: number;
  12984. /**
  12985. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12986. */
  12987. maxAngularSpeed: number;
  12988. /**
  12989. * Gets or sets the minimal initial rotation in radians.
  12990. */
  12991. minInitialRotation: number;
  12992. /**
  12993. * Gets or sets the maximal initial rotation in radians.
  12994. */
  12995. maxInitialRotation: number;
  12996. /**
  12997. * The particle emitter type defines the emitter used by the particle system.
  12998. * It can be for example box, sphere, or cone...
  12999. */
  13000. particleEmitterType: Nullable<IParticleEmitterType>;
  13001. /**
  13002. * Defines the delay in milliseconds before starting the system (0 by default)
  13003. */
  13004. startDelay: number;
  13005. /**
  13006. * 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
  13007. */
  13008. preWarmCycles: number;
  13009. /**
  13010. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13011. */
  13012. preWarmStepOffset: number;
  13013. /**
  13014. * 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)
  13015. */
  13016. spriteCellChangeSpeed: number;
  13017. /**
  13018. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13019. */
  13020. startSpriteCellID: number;
  13021. /**
  13022. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13023. */
  13024. endSpriteCellID: number;
  13025. /**
  13026. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13027. */
  13028. spriteCellWidth: number;
  13029. /**
  13030. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13031. */
  13032. spriteCellHeight: number;
  13033. /**
  13034. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13035. */
  13036. spriteRandomStartCell: boolean;
  13037. /**
  13038. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13039. */
  13040. isAnimationSheetEnabled: boolean;
  13041. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13042. translationPivot: Vector2;
  13043. /**
  13044. * Gets or sets a texture used to add random noise to particle positions
  13045. */
  13046. noiseTexture: Nullable<BaseTexture>;
  13047. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13048. noiseStrength: Vector3;
  13049. /**
  13050. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13051. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13052. */
  13053. billboardMode: number;
  13054. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13055. limitVelocityDamping: number;
  13056. /**
  13057. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13058. */
  13059. beginAnimationOnStart: boolean;
  13060. /**
  13061. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13062. */
  13063. beginAnimationFrom: number;
  13064. /**
  13065. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13066. */
  13067. beginAnimationTo: number;
  13068. /**
  13069. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13070. */
  13071. beginAnimationLoop: boolean;
  13072. /**
  13073. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13074. */
  13075. disposeOnStop: boolean;
  13076. /**
  13077. * Gets the maximum number of particles active at the same time.
  13078. * @returns The max number of active particles.
  13079. */
  13080. getCapacity(): number;
  13081. /**
  13082. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13083. * @returns True if it has been started, otherwise false.
  13084. */
  13085. isStarted(): boolean;
  13086. /**
  13087. * Animates the particle system for this frame.
  13088. */
  13089. animate(): void;
  13090. /**
  13091. * Renders the particle system in its current state.
  13092. * @returns the current number of particles
  13093. */
  13094. render(): number;
  13095. /**
  13096. * Dispose the particle system and frees its associated resources.
  13097. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13098. */
  13099. dispose(disposeTexture?: boolean): void;
  13100. /**
  13101. * Clones the particle system.
  13102. * @param name The name of the cloned object
  13103. * @param newEmitter The new emitter to use
  13104. * @returns the cloned particle system
  13105. */
  13106. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  13107. /**
  13108. * Serializes the particle system to a JSON object.
  13109. * @returns the JSON object
  13110. */
  13111. serialize(): any;
  13112. /**
  13113. * Rebuild the particle system
  13114. */
  13115. rebuild(): void;
  13116. /**
  13117. * Starts the particle system and begins to emit
  13118. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  13119. */
  13120. start(delay?: number): void;
  13121. /**
  13122. * Stops the particle system.
  13123. */
  13124. stop(): void;
  13125. /**
  13126. * Remove all active particles
  13127. */
  13128. reset(): void;
  13129. /**
  13130. * Is this system ready to be used/rendered
  13131. * @return true if the system is ready
  13132. */
  13133. isReady(): boolean;
  13134. /**
  13135. * Adds a new color gradient
  13136. * @param gradient defines the gradient to use (between 0 and 1)
  13137. * @param color1 defines the color to affect to the specified gradient
  13138. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13139. * @returns the current particle system
  13140. */
  13141. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13142. /**
  13143. * Remove a specific color gradient
  13144. * @param gradient defines the gradient to remove
  13145. * @returns the current particle system
  13146. */
  13147. removeColorGradient(gradient: number): IParticleSystem;
  13148. /**
  13149. * Adds a new size gradient
  13150. * @param gradient defines the gradient to use (between 0 and 1)
  13151. * @param factor defines the size factor to affect to the specified gradient
  13152. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13153. * @returns the current particle system
  13154. */
  13155. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13156. /**
  13157. * Remove a specific size gradient
  13158. * @param gradient defines the gradient to remove
  13159. * @returns the current particle system
  13160. */
  13161. removeSizeGradient(gradient: number): IParticleSystem;
  13162. /**
  13163. * Gets the current list of color gradients.
  13164. * You must use addColorGradient and removeColorGradient to udpate this list
  13165. * @returns the list of color gradients
  13166. */
  13167. getColorGradients(): Nullable<Array<ColorGradient>>;
  13168. /**
  13169. * Gets the current list of size gradients.
  13170. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13171. * @returns the list of size gradients
  13172. */
  13173. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13174. /**
  13175. * Gets the current list of angular speed gradients.
  13176. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13177. * @returns the list of angular speed gradients
  13178. */
  13179. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13180. /**
  13181. * Adds a new angular speed gradient
  13182. * @param gradient defines the gradient to use (between 0 and 1)
  13183. * @param factor defines the angular speed to affect to the specified gradient
  13184. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13185. * @returns the current particle system
  13186. */
  13187. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13188. /**
  13189. * Remove a specific angular speed gradient
  13190. * @param gradient defines the gradient to remove
  13191. * @returns the current particle system
  13192. */
  13193. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13194. /**
  13195. * Gets the current list of velocity gradients.
  13196. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13197. * @returns the list of velocity gradients
  13198. */
  13199. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13200. /**
  13201. * Adds a new velocity gradient
  13202. * @param gradient defines the gradient to use (between 0 and 1)
  13203. * @param factor defines the velocity to affect to the specified gradient
  13204. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13205. * @returns the current particle system
  13206. */
  13207. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13208. /**
  13209. * Remove a specific velocity gradient
  13210. * @param gradient defines the gradient to remove
  13211. * @returns the current particle system
  13212. */
  13213. removeVelocityGradient(gradient: number): IParticleSystem;
  13214. /**
  13215. * Gets the current list of limit velocity gradients.
  13216. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13217. * @returns the list of limit velocity gradients
  13218. */
  13219. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13220. /**
  13221. * Adds a new limit velocity gradient
  13222. * @param gradient defines the gradient to use (between 0 and 1)
  13223. * @param factor defines the limit velocity to affect to the specified gradient
  13224. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13225. * @returns the current particle system
  13226. */
  13227. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13228. /**
  13229. * Remove a specific limit velocity gradient
  13230. * @param gradient defines the gradient to remove
  13231. * @returns the current particle system
  13232. */
  13233. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13234. /**
  13235. * Adds a new drag gradient
  13236. * @param gradient defines the gradient to use (between 0 and 1)
  13237. * @param factor defines the drag to affect to the specified gradient
  13238. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13239. * @returns the current particle system
  13240. */
  13241. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13242. /**
  13243. * Remove a specific drag gradient
  13244. * @param gradient defines the gradient to remove
  13245. * @returns the current particle system
  13246. */
  13247. removeDragGradient(gradient: number): IParticleSystem;
  13248. /**
  13249. * Gets the current list of drag gradients.
  13250. * You must use addDragGradient and removeDragGradient to udpate this list
  13251. * @returns the list of drag gradients
  13252. */
  13253. getDragGradients(): Nullable<Array<FactorGradient>>;
  13254. /**
  13255. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13256. * @param gradient defines the gradient to use (between 0 and 1)
  13257. * @param factor defines the emit rate to affect to the specified gradient
  13258. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13259. * @returns the current particle system
  13260. */
  13261. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13262. /**
  13263. * Remove a specific emit rate gradient
  13264. * @param gradient defines the gradient to remove
  13265. * @returns the current particle system
  13266. */
  13267. removeEmitRateGradient(gradient: number): IParticleSystem;
  13268. /**
  13269. * Gets the current list of emit rate gradients.
  13270. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13271. * @returns the list of emit rate gradients
  13272. */
  13273. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13274. /**
  13275. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13276. * @param gradient defines the gradient to use (between 0 and 1)
  13277. * @param factor defines the start size to affect to the specified gradient
  13278. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13279. * @returns the current particle system
  13280. */
  13281. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13282. /**
  13283. * Remove a specific start size gradient
  13284. * @param gradient defines the gradient to remove
  13285. * @returns the current particle system
  13286. */
  13287. removeStartSizeGradient(gradient: number): IParticleSystem;
  13288. /**
  13289. * Gets the current list of start size gradients.
  13290. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13291. * @returns the list of start size gradients
  13292. */
  13293. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13294. /**
  13295. * Adds a new life time gradient
  13296. * @param gradient defines the gradient to use (between 0 and 1)
  13297. * @param factor defines the life time factor to affect to the specified gradient
  13298. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13299. * @returns the current particle system
  13300. */
  13301. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13302. /**
  13303. * Remove a specific life time gradient
  13304. * @param gradient defines the gradient to remove
  13305. * @returns the current particle system
  13306. */
  13307. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13308. /**
  13309. * Gets the current list of life time gradients.
  13310. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13311. * @returns the list of life time gradients
  13312. */
  13313. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13314. /**
  13315. * Gets the current list of color gradients.
  13316. * You must use addColorGradient and removeColorGradient to udpate this list
  13317. * @returns the list of color gradients
  13318. */
  13319. getColorGradients(): Nullable<Array<ColorGradient>>;
  13320. /**
  13321. * Adds a new ramp gradient used to remap particle colors
  13322. * @param gradient defines the gradient to use (between 0 and 1)
  13323. * @param color defines the color to affect to the specified gradient
  13324. * @returns the current particle system
  13325. */
  13326. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  13327. /**
  13328. * Gets the current list of ramp gradients.
  13329. * You must use addRampGradient and removeRampGradient to udpate this list
  13330. * @returns the list of ramp gradients
  13331. */
  13332. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13333. /** Gets or sets a boolean indicating that ramp gradients must be used
  13334. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13335. */
  13336. useRampGradients: boolean;
  13337. /**
  13338. * Adds a new color remap gradient
  13339. * @param gradient defines the gradient to use (between 0 and 1)
  13340. * @param min defines the color remap minimal range
  13341. * @param max defines the color remap maximal range
  13342. * @returns the current particle system
  13343. */
  13344. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13345. /**
  13346. * Gets the current list of color remap gradients.
  13347. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13348. * @returns the list of color remap gradients
  13349. */
  13350. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13351. /**
  13352. * Adds a new alpha remap gradient
  13353. * @param gradient defines the gradient to use (between 0 and 1)
  13354. * @param min defines the alpha remap minimal range
  13355. * @param max defines the alpha remap maximal range
  13356. * @returns the current particle system
  13357. */
  13358. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13359. /**
  13360. * Gets the current list of alpha remap gradients.
  13361. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13362. * @returns the list of alpha remap gradients
  13363. */
  13364. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13365. /**
  13366. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13367. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13368. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13369. * @returns the emitter
  13370. */
  13371. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13372. /**
  13373. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13374. * @param radius The radius of the hemisphere to emit from
  13375. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13376. * @returns the emitter
  13377. */
  13378. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  13379. /**
  13380. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13381. * @param radius The radius of the sphere to emit from
  13382. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13383. * @returns the emitter
  13384. */
  13385. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  13386. /**
  13387. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13388. * @param radius The radius of the sphere to emit from
  13389. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13390. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13391. * @returns the emitter
  13392. */
  13393. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13394. /**
  13395. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13396. * @param radius The radius of the emission cylinder
  13397. * @param height The height of the emission cylinder
  13398. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13399. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13400. * @returns the emitter
  13401. */
  13402. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  13403. /**
  13404. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13405. * @param radius The radius of the cylinder to emit from
  13406. * @param height The height of the emission cylinder
  13407. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13408. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13409. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13410. * @returns the emitter
  13411. */
  13412. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13413. /**
  13414. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  13415. * @param radius The radius of the cone to emit from
  13416. * @param angle The base angle of the cone
  13417. * @returns the emitter
  13418. */
  13419. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  13420. /**
  13421. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13422. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13423. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13424. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13425. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13426. * @returns the emitter
  13427. */
  13428. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13429. /**
  13430. * Get hosting scene
  13431. * @returns the scene
  13432. */
  13433. getScene(): Scene;
  13434. }
  13435. }
  13436. declare module BABYLON {
  13437. /**
  13438. * 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.
  13439. * @see https://doc.babylonjs.com/how_to/transformnode
  13440. */
  13441. export class TransformNode extends Node {
  13442. /**
  13443. * Object will not rotate to face the camera
  13444. */
  13445. static BILLBOARDMODE_NONE: number;
  13446. /**
  13447. * Object will rotate to face the camera but only on the x axis
  13448. */
  13449. static BILLBOARDMODE_X: number;
  13450. /**
  13451. * Object will rotate to face the camera but only on the y axis
  13452. */
  13453. static BILLBOARDMODE_Y: number;
  13454. /**
  13455. * Object will rotate to face the camera but only on the z axis
  13456. */
  13457. static BILLBOARDMODE_Z: number;
  13458. /**
  13459. * Object will rotate to face the camera
  13460. */
  13461. static BILLBOARDMODE_ALL: number;
  13462. /**
  13463. * Object will rotate to face the camera's position instead of orientation
  13464. */
  13465. static BILLBOARDMODE_USE_POSITION: number;
  13466. private _forward;
  13467. private _forwardInverted;
  13468. private _up;
  13469. private _right;
  13470. private _rightInverted;
  13471. private _position;
  13472. private _rotation;
  13473. private _rotationQuaternion;
  13474. protected _scaling: Vector3;
  13475. protected _isDirty: boolean;
  13476. private _transformToBoneReferal;
  13477. private _isAbsoluteSynced;
  13478. private _billboardMode;
  13479. /**
  13480. * Gets or sets the billboard mode. Default is 0.
  13481. *
  13482. * | Value | Type | Description |
  13483. * | --- | --- | --- |
  13484. * | 0 | BILLBOARDMODE_NONE | |
  13485. * | 1 | BILLBOARDMODE_X | |
  13486. * | 2 | BILLBOARDMODE_Y | |
  13487. * | 4 | BILLBOARDMODE_Z | |
  13488. * | 7 | BILLBOARDMODE_ALL | |
  13489. *
  13490. */
  13491. get billboardMode(): number;
  13492. set billboardMode(value: number);
  13493. private _preserveParentRotationForBillboard;
  13494. /**
  13495. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13496. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13497. */
  13498. get preserveParentRotationForBillboard(): boolean;
  13499. set preserveParentRotationForBillboard(value: boolean);
  13500. /**
  13501. * 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
  13502. */
  13503. scalingDeterminant: number;
  13504. private _infiniteDistance;
  13505. /**
  13506. * Gets or sets the distance of the object to max, often used by skybox
  13507. */
  13508. get infiniteDistance(): boolean;
  13509. set infiniteDistance(value: boolean);
  13510. /**
  13511. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13512. * By default the system will update normals to compensate
  13513. */
  13514. ignoreNonUniformScaling: boolean;
  13515. /**
  13516. * 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
  13517. */
  13518. reIntegrateRotationIntoRotationQuaternion: boolean;
  13519. /** @hidden */
  13520. _poseMatrix: Nullable<Matrix>;
  13521. /** @hidden */
  13522. _localMatrix: Matrix;
  13523. private _usePivotMatrix;
  13524. private _absolutePosition;
  13525. private _absoluteScaling;
  13526. private _absoluteRotationQuaternion;
  13527. private _pivotMatrix;
  13528. private _pivotMatrixInverse;
  13529. protected _postMultiplyPivotMatrix: boolean;
  13530. protected _isWorldMatrixFrozen: boolean;
  13531. /** @hidden */
  13532. _indexInSceneTransformNodesArray: number;
  13533. /**
  13534. * An event triggered after the world matrix is updated
  13535. */
  13536. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13537. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13538. /**
  13539. * Gets a string identifying the name of the class
  13540. * @returns "TransformNode" string
  13541. */
  13542. getClassName(): string;
  13543. /**
  13544. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13545. */
  13546. get position(): Vector3;
  13547. set position(newPosition: Vector3);
  13548. /**
  13549. * 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)).
  13550. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13551. */
  13552. get rotation(): Vector3;
  13553. set rotation(newRotation: Vector3);
  13554. /**
  13555. * 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)).
  13556. */
  13557. get scaling(): Vector3;
  13558. set scaling(newScaling: Vector3);
  13559. /**
  13560. * 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).
  13561. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13562. */
  13563. get rotationQuaternion(): Nullable<Quaternion>;
  13564. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  13565. /**
  13566. * The forward direction of that transform in world space.
  13567. */
  13568. get forward(): Vector3;
  13569. /**
  13570. * The up direction of that transform in world space.
  13571. */
  13572. get up(): Vector3;
  13573. /**
  13574. * The right direction of that transform in world space.
  13575. */
  13576. get right(): Vector3;
  13577. /**
  13578. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13579. * @param matrix the matrix to copy the pose from
  13580. * @returns this TransformNode.
  13581. */
  13582. updatePoseMatrix(matrix: Matrix): TransformNode;
  13583. /**
  13584. * Returns the mesh Pose matrix.
  13585. * @returns the pose matrix
  13586. */
  13587. getPoseMatrix(): Matrix;
  13588. /** @hidden */
  13589. _isSynchronized(): boolean;
  13590. /** @hidden */
  13591. _initCache(): void;
  13592. /**
  13593. * Flag the transform node as dirty (Forcing it to update everything)
  13594. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13595. * @returns this transform node
  13596. */
  13597. markAsDirty(property: string): TransformNode;
  13598. /**
  13599. * Returns the current mesh absolute position.
  13600. * Returns a Vector3.
  13601. */
  13602. get absolutePosition(): Vector3;
  13603. /**
  13604. * Returns the current mesh absolute scaling.
  13605. * Returns a Vector3.
  13606. */
  13607. get absoluteScaling(): Vector3;
  13608. /**
  13609. * Returns the current mesh absolute rotation.
  13610. * Returns a Quaternion.
  13611. */
  13612. get absoluteRotationQuaternion(): Quaternion;
  13613. /**
  13614. * Sets a new matrix to apply before all other transformation
  13615. * @param matrix defines the transform matrix
  13616. * @returns the current TransformNode
  13617. */
  13618. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13619. /**
  13620. * Sets a new pivot matrix to the current node
  13621. * @param matrix defines the new pivot matrix to use
  13622. * @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
  13623. * @returns the current TransformNode
  13624. */
  13625. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13626. /**
  13627. * Returns the mesh pivot matrix.
  13628. * Default : Identity.
  13629. * @returns the matrix
  13630. */
  13631. getPivotMatrix(): Matrix;
  13632. /**
  13633. * Instantiate (when possible) or clone that node with its hierarchy
  13634. * @param newParent defines the new parent to use for the instance (or clone)
  13635. * @param options defines options to configure how copy is done
  13636. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  13637. * @returns an instance (or a clone) of the current node with its hiearchy
  13638. */
  13639. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  13640. doNotInstantiate: boolean;
  13641. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  13642. /**
  13643. * Prevents the World matrix to be computed any longer
  13644. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13645. * @returns the TransformNode.
  13646. */
  13647. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13648. /**
  13649. * Allows back the World matrix computation.
  13650. * @returns the TransformNode.
  13651. */
  13652. unfreezeWorldMatrix(): this;
  13653. /**
  13654. * True if the World matrix has been frozen.
  13655. */
  13656. get isWorldMatrixFrozen(): boolean;
  13657. /**
  13658. * Retuns the mesh absolute position in the World.
  13659. * @returns a Vector3.
  13660. */
  13661. getAbsolutePosition(): Vector3;
  13662. /**
  13663. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13664. * @param absolutePosition the absolute position to set
  13665. * @returns the TransformNode.
  13666. */
  13667. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13668. /**
  13669. * Sets the mesh position in its local space.
  13670. * @param vector3 the position to set in localspace
  13671. * @returns the TransformNode.
  13672. */
  13673. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13674. /**
  13675. * Returns the mesh position in the local space from the current World matrix values.
  13676. * @returns a new Vector3.
  13677. */
  13678. getPositionExpressedInLocalSpace(): Vector3;
  13679. /**
  13680. * Translates the mesh along the passed Vector3 in its local space.
  13681. * @param vector3 the distance to translate in localspace
  13682. * @returns the TransformNode.
  13683. */
  13684. locallyTranslate(vector3: Vector3): TransformNode;
  13685. private static _lookAtVectorCache;
  13686. /**
  13687. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13688. * @param targetPoint the position (must be in same space as current mesh) to look at
  13689. * @param yawCor optional yaw (y-axis) correction in radians
  13690. * @param pitchCor optional pitch (x-axis) correction in radians
  13691. * @param rollCor optional roll (z-axis) correction in radians
  13692. * @param space the choosen space of the target
  13693. * @returns the TransformNode.
  13694. */
  13695. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13696. /**
  13697. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13698. * This Vector3 is expressed in the World space.
  13699. * @param localAxis axis to rotate
  13700. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13701. */
  13702. getDirection(localAxis: Vector3): Vector3;
  13703. /**
  13704. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13705. * localAxis is expressed in the mesh local space.
  13706. * result is computed in the Wordl space from the mesh World matrix.
  13707. * @param localAxis axis to rotate
  13708. * @param result the resulting transformnode
  13709. * @returns this TransformNode.
  13710. */
  13711. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13712. /**
  13713. * Sets this transform node rotation to the given local axis.
  13714. * @param localAxis the axis in local space
  13715. * @param yawCor optional yaw (y-axis) correction in radians
  13716. * @param pitchCor optional pitch (x-axis) correction in radians
  13717. * @param rollCor optional roll (z-axis) correction in radians
  13718. * @returns this TransformNode
  13719. */
  13720. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  13721. /**
  13722. * Sets a new pivot point to the current node
  13723. * @param point defines the new pivot point to use
  13724. * @param space defines if the point is in world or local space (local by default)
  13725. * @returns the current TransformNode
  13726. */
  13727. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  13728. /**
  13729. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  13730. * @returns the pivot point
  13731. */
  13732. getPivotPoint(): Vector3;
  13733. /**
  13734. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  13735. * @param result the vector3 to store the result
  13736. * @returns this TransformNode.
  13737. */
  13738. getPivotPointToRef(result: Vector3): TransformNode;
  13739. /**
  13740. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  13741. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  13742. */
  13743. getAbsolutePivotPoint(): Vector3;
  13744. /**
  13745. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  13746. * @param result vector3 to store the result
  13747. * @returns this TransformNode.
  13748. */
  13749. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  13750. /**
  13751. * Defines the passed node as the parent of the current node.
  13752. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  13753. * @see https://doc.babylonjs.com/how_to/parenting
  13754. * @param node the node ot set as the parent
  13755. * @returns this TransformNode.
  13756. */
  13757. setParent(node: Nullable<Node>): TransformNode;
  13758. private _nonUniformScaling;
  13759. /**
  13760. * True if the scaling property of this object is non uniform eg. (1,2,1)
  13761. */
  13762. get nonUniformScaling(): boolean;
  13763. /** @hidden */
  13764. _updateNonUniformScalingState(value: boolean): boolean;
  13765. /**
  13766. * Attach the current TransformNode to another TransformNode associated with a bone
  13767. * @param bone Bone affecting the TransformNode
  13768. * @param affectedTransformNode TransformNode associated with the bone
  13769. * @returns this object
  13770. */
  13771. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  13772. /**
  13773. * Detach the transform node if its associated with a bone
  13774. * @returns this object
  13775. */
  13776. detachFromBone(): TransformNode;
  13777. private static _rotationAxisCache;
  13778. /**
  13779. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  13780. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13781. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13782. * The passed axis is also normalized.
  13783. * @param axis the axis to rotate around
  13784. * @param amount the amount to rotate in radians
  13785. * @param space Space to rotate in (Default: local)
  13786. * @returns the TransformNode.
  13787. */
  13788. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13789. /**
  13790. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  13791. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13792. * The passed axis is also normalized. .
  13793. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  13794. * @param point the point to rotate around
  13795. * @param axis the axis to rotate around
  13796. * @param amount the amount to rotate in radians
  13797. * @returns the TransformNode
  13798. */
  13799. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  13800. /**
  13801. * Translates the mesh along the axis vector for the passed distance in the given space.
  13802. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13803. * @param axis the axis to translate in
  13804. * @param distance the distance to translate
  13805. * @param space Space to rotate in (Default: local)
  13806. * @returns the TransformNode.
  13807. */
  13808. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  13809. /**
  13810. * Adds a rotation step to the mesh current rotation.
  13811. * x, y, z are Euler angles expressed in radians.
  13812. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  13813. * This means this rotation is made in the mesh local space only.
  13814. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  13815. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  13816. * ```javascript
  13817. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  13818. * ```
  13819. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  13820. * 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.
  13821. * @param x Rotation to add
  13822. * @param y Rotation to add
  13823. * @param z Rotation to add
  13824. * @returns the TransformNode.
  13825. */
  13826. addRotation(x: number, y: number, z: number): TransformNode;
  13827. /**
  13828. * @hidden
  13829. */
  13830. protected _getEffectiveParent(): Nullable<Node>;
  13831. /**
  13832. * Computes the world matrix of the node
  13833. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13834. * @returns the world matrix
  13835. */
  13836. computeWorldMatrix(force?: boolean): Matrix;
  13837. /**
  13838. * Resets this nodeTransform's local matrix to Matrix.Identity().
  13839. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  13840. */
  13841. resetLocalMatrix(independentOfChildren?: boolean): void;
  13842. protected _afterComputeWorldMatrix(): void;
  13843. /**
  13844. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  13845. * @param func callback function to add
  13846. *
  13847. * @returns the TransformNode.
  13848. */
  13849. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  13850. /**
  13851. * Removes a registered callback function.
  13852. * @param func callback function to remove
  13853. * @returns the TransformNode.
  13854. */
  13855. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  13856. /**
  13857. * Gets the position of the current mesh in camera space
  13858. * @param camera defines the camera to use
  13859. * @returns a position
  13860. */
  13861. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  13862. /**
  13863. * Returns the distance from the mesh to the active camera
  13864. * @param camera defines the camera to use
  13865. * @returns the distance
  13866. */
  13867. getDistanceToCamera(camera?: Nullable<Camera>): number;
  13868. /**
  13869. * Clone the current transform node
  13870. * @param name Name of the new clone
  13871. * @param newParent New parent for the clone
  13872. * @param doNotCloneChildren Do not clone children hierarchy
  13873. * @returns the new transform node
  13874. */
  13875. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  13876. /**
  13877. * Serializes the objects information.
  13878. * @param currentSerializationObject defines the object to serialize in
  13879. * @returns the serialized object
  13880. */
  13881. serialize(currentSerializationObject?: any): any;
  13882. /**
  13883. * Returns a new TransformNode object parsed from the source provided.
  13884. * @param parsedTransformNode is the source.
  13885. * @param scene the scne the object belongs to
  13886. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  13887. * @returns a new TransformNode object parsed from the source provided.
  13888. */
  13889. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  13890. /**
  13891. * Get all child-transformNodes of this node
  13892. * @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
  13893. * @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
  13894. * @returns an array of TransformNode
  13895. */
  13896. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  13897. /**
  13898. * Releases resources associated with this transform node.
  13899. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  13900. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  13901. */
  13902. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  13903. /**
  13904. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  13905. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  13906. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  13907. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  13908. * @returns the current mesh
  13909. */
  13910. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  13911. private _syncAbsoluteScalingAndRotation;
  13912. }
  13913. }
  13914. declare module BABYLON {
  13915. /**
  13916. * Class used to override all child animations of a given target
  13917. */
  13918. export class AnimationPropertiesOverride {
  13919. /**
  13920. * Gets or sets a value indicating if animation blending must be used
  13921. */
  13922. enableBlending: boolean;
  13923. /**
  13924. * Gets or sets the blending speed to use when enableBlending is true
  13925. */
  13926. blendingSpeed: number;
  13927. /**
  13928. * Gets or sets the default loop mode to use
  13929. */
  13930. loopMode: number;
  13931. }
  13932. }
  13933. declare module BABYLON {
  13934. /**
  13935. * Class used to store bone information
  13936. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13937. */
  13938. export class Bone extends Node {
  13939. /**
  13940. * defines the bone name
  13941. */
  13942. name: string;
  13943. private static _tmpVecs;
  13944. private static _tmpQuat;
  13945. private static _tmpMats;
  13946. /**
  13947. * Gets the list of child bones
  13948. */
  13949. children: Bone[];
  13950. /** Gets the animations associated with this bone */
  13951. animations: Animation[];
  13952. /**
  13953. * Gets or sets bone length
  13954. */
  13955. length: number;
  13956. /**
  13957. * @hidden Internal only
  13958. * Set this value to map this bone to a different index in the transform matrices
  13959. * Set this value to -1 to exclude the bone from the transform matrices
  13960. */
  13961. _index: Nullable<number>;
  13962. private _skeleton;
  13963. private _localMatrix;
  13964. private _restPose;
  13965. private _baseMatrix;
  13966. private _absoluteTransform;
  13967. private _invertedAbsoluteTransform;
  13968. private _parent;
  13969. private _scalingDeterminant;
  13970. private _worldTransform;
  13971. private _localScaling;
  13972. private _localRotation;
  13973. private _localPosition;
  13974. private _needToDecompose;
  13975. private _needToCompose;
  13976. /** @hidden */
  13977. _linkedTransformNode: Nullable<TransformNode>;
  13978. /** @hidden */
  13979. _waitingTransformNodeId: Nullable<string>;
  13980. /** @hidden */
  13981. get _matrix(): Matrix;
  13982. /** @hidden */
  13983. set _matrix(value: Matrix);
  13984. /**
  13985. * Create a new bone
  13986. * @param name defines the bone name
  13987. * @param skeleton defines the parent skeleton
  13988. * @param parentBone defines the parent (can be null if the bone is the root)
  13989. * @param localMatrix defines the local matrix
  13990. * @param restPose defines the rest pose matrix
  13991. * @param baseMatrix defines the base matrix
  13992. * @param index defines index of the bone in the hiearchy
  13993. */
  13994. constructor(
  13995. /**
  13996. * defines the bone name
  13997. */
  13998. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13999. /**
  14000. * Gets the current object class name.
  14001. * @return the class name
  14002. */
  14003. getClassName(): string;
  14004. /**
  14005. * Gets the parent skeleton
  14006. * @returns a skeleton
  14007. */
  14008. getSkeleton(): Skeleton;
  14009. /**
  14010. * Gets parent bone
  14011. * @returns a bone or null if the bone is the root of the bone hierarchy
  14012. */
  14013. getParent(): Nullable<Bone>;
  14014. /**
  14015. * Returns an array containing the root bones
  14016. * @returns an array containing the root bones
  14017. */
  14018. getChildren(): Array<Bone>;
  14019. /**
  14020. * Gets the node index in matrix array generated for rendering
  14021. * @returns the node index
  14022. */
  14023. getIndex(): number;
  14024. /**
  14025. * Sets the parent bone
  14026. * @param parent defines the parent (can be null if the bone is the root)
  14027. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14028. */
  14029. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14030. /**
  14031. * Gets the local matrix
  14032. * @returns a matrix
  14033. */
  14034. getLocalMatrix(): Matrix;
  14035. /**
  14036. * Gets the base matrix (initial matrix which remains unchanged)
  14037. * @returns a matrix
  14038. */
  14039. getBaseMatrix(): Matrix;
  14040. /**
  14041. * Gets the rest pose matrix
  14042. * @returns a matrix
  14043. */
  14044. getRestPose(): Matrix;
  14045. /**
  14046. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14047. */
  14048. getWorldMatrix(): Matrix;
  14049. /**
  14050. * Sets the local matrix to rest pose matrix
  14051. */
  14052. returnToRest(): void;
  14053. /**
  14054. * Gets the inverse of the absolute transform matrix.
  14055. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14056. * @returns a matrix
  14057. */
  14058. getInvertedAbsoluteTransform(): Matrix;
  14059. /**
  14060. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14061. * @returns a matrix
  14062. */
  14063. getAbsoluteTransform(): Matrix;
  14064. /**
  14065. * Links with the given transform node.
  14066. * The local matrix of this bone is copied from the transform node every frame.
  14067. * @param transformNode defines the transform node to link to
  14068. */
  14069. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14070. /**
  14071. * Gets the node used to drive the bone's transformation
  14072. * @returns a transform node or null
  14073. */
  14074. getTransformNode(): Nullable<TransformNode>;
  14075. /** Gets or sets current position (in local space) */
  14076. get position(): Vector3;
  14077. set position(newPosition: Vector3);
  14078. /** Gets or sets current rotation (in local space) */
  14079. get rotation(): Vector3;
  14080. set rotation(newRotation: Vector3);
  14081. /** Gets or sets current rotation quaternion (in local space) */
  14082. get rotationQuaternion(): Quaternion;
  14083. set rotationQuaternion(newRotation: Quaternion);
  14084. /** Gets or sets current scaling (in local space) */
  14085. get scaling(): Vector3;
  14086. set scaling(newScaling: Vector3);
  14087. /**
  14088. * Gets the animation properties override
  14089. */
  14090. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14091. private _decompose;
  14092. private _compose;
  14093. /**
  14094. * Update the base and local matrices
  14095. * @param matrix defines the new base or local matrix
  14096. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14097. * @param updateLocalMatrix defines if the local matrix should be updated
  14098. */
  14099. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14100. /** @hidden */
  14101. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14102. /**
  14103. * Flag the bone as dirty (Forcing it to update everything)
  14104. */
  14105. markAsDirty(): void;
  14106. /** @hidden */
  14107. _markAsDirtyAndCompose(): void;
  14108. private _markAsDirtyAndDecompose;
  14109. /**
  14110. * Translate the bone in local or world space
  14111. * @param vec The amount to translate the bone
  14112. * @param space The space that the translation is in
  14113. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14114. */
  14115. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14116. /**
  14117. * Set the postion of the bone in local or world space
  14118. * @param position The position to set the bone
  14119. * @param space The space that the position is in
  14120. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14121. */
  14122. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14123. /**
  14124. * Set the absolute position of the bone (world space)
  14125. * @param position The position to set the bone
  14126. * @param mesh The mesh that this bone is attached to
  14127. */
  14128. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14129. /**
  14130. * Scale the bone on the x, y and z axes (in local space)
  14131. * @param x The amount to scale the bone on the x axis
  14132. * @param y The amount to scale the bone on the y axis
  14133. * @param z The amount to scale the bone on the z axis
  14134. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14135. */
  14136. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14137. /**
  14138. * Set the bone scaling in local space
  14139. * @param scale defines the scaling vector
  14140. */
  14141. setScale(scale: Vector3): void;
  14142. /**
  14143. * Gets the current scaling in local space
  14144. * @returns the current scaling vector
  14145. */
  14146. getScale(): Vector3;
  14147. /**
  14148. * Gets the current scaling in local space and stores it in a target vector
  14149. * @param result defines the target vector
  14150. */
  14151. getScaleToRef(result: Vector3): void;
  14152. /**
  14153. * Set the yaw, pitch, and roll of the bone in local or world space
  14154. * @param yaw The rotation of the bone on the y axis
  14155. * @param pitch The rotation of the bone on the x axis
  14156. * @param roll The rotation of the bone on the z axis
  14157. * @param space The space that the axes of rotation are in
  14158. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14159. */
  14160. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14161. /**
  14162. * Add a rotation to the bone on an axis in local or world space
  14163. * @param axis The axis to rotate the bone on
  14164. * @param amount The amount to rotate the bone
  14165. * @param space The space that the axis is in
  14166. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14167. */
  14168. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14169. /**
  14170. * Set the rotation of the bone to a particular axis angle in local or world space
  14171. * @param axis The axis to rotate the bone on
  14172. * @param angle The angle that the bone should be rotated to
  14173. * @param space The space that the axis is in
  14174. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14175. */
  14176. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14177. /**
  14178. * Set the euler rotation of the bone in local of world space
  14179. * @param rotation The euler rotation that the bone should be set to
  14180. * @param space The space that the rotation is in
  14181. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14182. */
  14183. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14184. /**
  14185. * Set the quaternion rotation of the bone in local of world space
  14186. * @param quat The quaternion rotation that the bone should be set to
  14187. * @param space The space that the rotation is in
  14188. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14189. */
  14190. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14191. /**
  14192. * Set the rotation matrix of the bone in local of world space
  14193. * @param rotMat The rotation matrix that the bone should be set to
  14194. * @param space The space that the rotation is in
  14195. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14196. */
  14197. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14198. private _rotateWithMatrix;
  14199. private _getNegativeRotationToRef;
  14200. /**
  14201. * Get the position of the bone in local or world space
  14202. * @param space The space that the returned position is in
  14203. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14204. * @returns The position of the bone
  14205. */
  14206. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14207. /**
  14208. * Copy the position of the bone to a vector3 in local or world space
  14209. * @param space The space that the returned position is in
  14210. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14211. * @param result The vector3 to copy the position to
  14212. */
  14213. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14214. /**
  14215. * Get the absolute position of the bone (world space)
  14216. * @param mesh The mesh that this bone is attached to
  14217. * @returns The absolute position of the bone
  14218. */
  14219. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14220. /**
  14221. * Copy the absolute position of the bone (world space) to the result param
  14222. * @param mesh The mesh that this bone is attached to
  14223. * @param result The vector3 to copy the absolute position to
  14224. */
  14225. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14226. /**
  14227. * Compute the absolute transforms of this bone and its children
  14228. */
  14229. computeAbsoluteTransforms(): void;
  14230. /**
  14231. * Get the world direction from an axis that is in the local space of the bone
  14232. * @param localAxis The local direction that is used to compute the world direction
  14233. * @param mesh The mesh that this bone is attached to
  14234. * @returns The world direction
  14235. */
  14236. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14237. /**
  14238. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14239. * @param localAxis The local direction that is used to compute the world direction
  14240. * @param mesh The mesh that this bone is attached to
  14241. * @param result The vector3 that the world direction will be copied to
  14242. */
  14243. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14244. /**
  14245. * Get the euler rotation of the bone in local or world space
  14246. * @param space The space that the rotation should be in
  14247. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14248. * @returns The euler rotation
  14249. */
  14250. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14251. /**
  14252. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14253. * @param space The space that the rotation should be in
  14254. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14255. * @param result The vector3 that the rotation should be copied to
  14256. */
  14257. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14258. /**
  14259. * Get the quaternion rotation of the bone in either local or world space
  14260. * @param space The space that the rotation should be in
  14261. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14262. * @returns The quaternion rotation
  14263. */
  14264. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14265. /**
  14266. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14267. * @param space The space that the rotation should be in
  14268. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14269. * @param result The quaternion that the rotation should be copied to
  14270. */
  14271. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14272. /**
  14273. * Get the rotation matrix of the bone in local or world space
  14274. * @param space The space that the rotation should be in
  14275. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14276. * @returns The rotation matrix
  14277. */
  14278. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14279. /**
  14280. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14281. * @param space The space that the rotation should be in
  14282. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14283. * @param result The quaternion that the rotation should be copied to
  14284. */
  14285. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14286. /**
  14287. * Get the world position of a point that is in the local space of the bone
  14288. * @param position The local position
  14289. * @param mesh The mesh that this bone is attached to
  14290. * @returns The world position
  14291. */
  14292. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14293. /**
  14294. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14295. * @param position The local position
  14296. * @param mesh The mesh that this bone is attached to
  14297. * @param result The vector3 that the world position should be copied to
  14298. */
  14299. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14300. /**
  14301. * Get the local position of a point that is in world space
  14302. * @param position The world position
  14303. * @param mesh The mesh that this bone is attached to
  14304. * @returns The local position
  14305. */
  14306. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14307. /**
  14308. * Get the local position of a point that is in world space and copy it to the result param
  14309. * @param position The world position
  14310. * @param mesh The mesh that this bone is attached to
  14311. * @param result The vector3 that the local position should be copied to
  14312. */
  14313. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14314. }
  14315. }
  14316. declare module BABYLON {
  14317. /**
  14318. * Defines a runtime animation
  14319. */
  14320. export class RuntimeAnimation {
  14321. private _events;
  14322. /**
  14323. * The current frame of the runtime animation
  14324. */
  14325. private _currentFrame;
  14326. /**
  14327. * The animation used by the runtime animation
  14328. */
  14329. private _animation;
  14330. /**
  14331. * The target of the runtime animation
  14332. */
  14333. private _target;
  14334. /**
  14335. * The initiating animatable
  14336. */
  14337. private _host;
  14338. /**
  14339. * The original value of the runtime animation
  14340. */
  14341. private _originalValue;
  14342. /**
  14343. * The original blend value of the runtime animation
  14344. */
  14345. private _originalBlendValue;
  14346. /**
  14347. * The offsets cache of the runtime animation
  14348. */
  14349. private _offsetsCache;
  14350. /**
  14351. * The high limits cache of the runtime animation
  14352. */
  14353. private _highLimitsCache;
  14354. /**
  14355. * Specifies if the runtime animation has been stopped
  14356. */
  14357. private _stopped;
  14358. /**
  14359. * The blending factor of the runtime animation
  14360. */
  14361. private _blendingFactor;
  14362. /**
  14363. * The BabylonJS scene
  14364. */
  14365. private _scene;
  14366. /**
  14367. * The current value of the runtime animation
  14368. */
  14369. private _currentValue;
  14370. /** @hidden */
  14371. _animationState: _IAnimationState;
  14372. /**
  14373. * The active target of the runtime animation
  14374. */
  14375. private _activeTargets;
  14376. private _currentActiveTarget;
  14377. private _directTarget;
  14378. /**
  14379. * The target path of the runtime animation
  14380. */
  14381. private _targetPath;
  14382. /**
  14383. * The weight of the runtime animation
  14384. */
  14385. private _weight;
  14386. /**
  14387. * The ratio offset of the runtime animation
  14388. */
  14389. private _ratioOffset;
  14390. /**
  14391. * The previous delay of the runtime animation
  14392. */
  14393. private _previousDelay;
  14394. /**
  14395. * The previous ratio of the runtime animation
  14396. */
  14397. private _previousRatio;
  14398. private _enableBlending;
  14399. private _keys;
  14400. private _minFrame;
  14401. private _maxFrame;
  14402. private _minValue;
  14403. private _maxValue;
  14404. private _targetIsArray;
  14405. /**
  14406. * Gets the current frame of the runtime animation
  14407. */
  14408. get currentFrame(): number;
  14409. /**
  14410. * Gets the weight of the runtime animation
  14411. */
  14412. get weight(): number;
  14413. /**
  14414. * Gets the current value of the runtime animation
  14415. */
  14416. get currentValue(): any;
  14417. /**
  14418. * Gets the target path of the runtime animation
  14419. */
  14420. get targetPath(): string;
  14421. /**
  14422. * Gets the actual target of the runtime animation
  14423. */
  14424. get target(): any;
  14425. /** @hidden */
  14426. _onLoop: () => void;
  14427. /**
  14428. * Create a new RuntimeAnimation object
  14429. * @param target defines the target of the animation
  14430. * @param animation defines the source animation object
  14431. * @param scene defines the hosting scene
  14432. * @param host defines the initiating Animatable
  14433. */
  14434. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  14435. private _preparePath;
  14436. /**
  14437. * Gets the animation from the runtime animation
  14438. */
  14439. get animation(): Animation;
  14440. /**
  14441. * Resets the runtime animation to the beginning
  14442. * @param restoreOriginal defines whether to restore the target property to the original value
  14443. */
  14444. reset(restoreOriginal?: boolean): void;
  14445. /**
  14446. * Specifies if the runtime animation is stopped
  14447. * @returns Boolean specifying if the runtime animation is stopped
  14448. */
  14449. isStopped(): boolean;
  14450. /**
  14451. * Disposes of the runtime animation
  14452. */
  14453. dispose(): void;
  14454. /**
  14455. * Apply the interpolated value to the target
  14456. * @param currentValue defines the value computed by the animation
  14457. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  14458. */
  14459. setValue(currentValue: any, weight: number): void;
  14460. private _getOriginalValues;
  14461. private _setValue;
  14462. /**
  14463. * Gets the loop pmode of the runtime animation
  14464. * @returns Loop Mode
  14465. */
  14466. private _getCorrectLoopMode;
  14467. /**
  14468. * Move the current animation to a given frame
  14469. * @param frame defines the frame to move to
  14470. */
  14471. goToFrame(frame: number): void;
  14472. /**
  14473. * @hidden Internal use only
  14474. */
  14475. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  14476. /**
  14477. * Execute the current animation
  14478. * @param delay defines the delay to add to the current frame
  14479. * @param from defines the lower bound of the animation range
  14480. * @param to defines the upper bound of the animation range
  14481. * @param loop defines if the current animation must loop
  14482. * @param speedRatio defines the current speed ratio
  14483. * @param weight defines the weight of the animation (default is -1 so no weight)
  14484. * @param onLoop optional callback called when animation loops
  14485. * @returns a boolean indicating if the animation is running
  14486. */
  14487. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  14488. }
  14489. }
  14490. declare module BABYLON {
  14491. /**
  14492. * Class used to store an actual running animation
  14493. */
  14494. export class Animatable {
  14495. /** defines the target object */
  14496. target: any;
  14497. /** defines the starting frame number (default is 0) */
  14498. fromFrame: number;
  14499. /** defines the ending frame number (default is 100) */
  14500. toFrame: number;
  14501. /** defines if the animation must loop (default is false) */
  14502. loopAnimation: boolean;
  14503. /** defines a callback to call when animation ends if it is not looping */
  14504. onAnimationEnd?: (() => void) | null | undefined;
  14505. /** defines a callback to call when animation loops */
  14506. onAnimationLoop?: (() => void) | null | undefined;
  14507. private _localDelayOffset;
  14508. private _pausedDelay;
  14509. private _runtimeAnimations;
  14510. private _paused;
  14511. private _scene;
  14512. private _speedRatio;
  14513. private _weight;
  14514. private _syncRoot;
  14515. /**
  14516. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  14517. * This will only apply for non looping animation (default is true)
  14518. */
  14519. disposeOnEnd: boolean;
  14520. /**
  14521. * Gets a boolean indicating if the animation has started
  14522. */
  14523. animationStarted: boolean;
  14524. /**
  14525. * Observer raised when the animation ends
  14526. */
  14527. onAnimationEndObservable: Observable<Animatable>;
  14528. /**
  14529. * Observer raised when the animation loops
  14530. */
  14531. onAnimationLoopObservable: Observable<Animatable>;
  14532. /**
  14533. * Gets the root Animatable used to synchronize and normalize animations
  14534. */
  14535. get syncRoot(): Nullable<Animatable>;
  14536. /**
  14537. * Gets the current frame of the first RuntimeAnimation
  14538. * Used to synchronize Animatables
  14539. */
  14540. get masterFrame(): number;
  14541. /**
  14542. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  14543. */
  14544. get weight(): number;
  14545. set weight(value: number);
  14546. /**
  14547. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  14548. */
  14549. get speedRatio(): number;
  14550. set speedRatio(value: number);
  14551. /**
  14552. * Creates a new Animatable
  14553. * @param scene defines the hosting scene
  14554. * @param target defines the target object
  14555. * @param fromFrame defines the starting frame number (default is 0)
  14556. * @param toFrame defines the ending frame number (default is 100)
  14557. * @param loopAnimation defines if the animation must loop (default is false)
  14558. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  14559. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  14560. * @param animations defines a group of animation to add to the new Animatable
  14561. * @param onAnimationLoop defines a callback to call when animation loops
  14562. */
  14563. constructor(scene: Scene,
  14564. /** defines the target object */
  14565. target: any,
  14566. /** defines the starting frame number (default is 0) */
  14567. fromFrame?: number,
  14568. /** defines the ending frame number (default is 100) */
  14569. toFrame?: number,
  14570. /** defines if the animation must loop (default is false) */
  14571. loopAnimation?: boolean, speedRatio?: number,
  14572. /** defines a callback to call when animation ends if it is not looping */
  14573. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  14574. /** defines a callback to call when animation loops */
  14575. onAnimationLoop?: (() => void) | null | undefined);
  14576. /**
  14577. * Synchronize and normalize current Animatable with a source Animatable
  14578. * This is useful when using animation weights and when animations are not of the same length
  14579. * @param root defines the root Animatable to synchronize with
  14580. * @returns the current Animatable
  14581. */
  14582. syncWith(root: Animatable): Animatable;
  14583. /**
  14584. * Gets the list of runtime animations
  14585. * @returns an array of RuntimeAnimation
  14586. */
  14587. getAnimations(): RuntimeAnimation[];
  14588. /**
  14589. * Adds more animations to the current animatable
  14590. * @param target defines the target of the animations
  14591. * @param animations defines the new animations to add
  14592. */
  14593. appendAnimations(target: any, animations: Animation[]): void;
  14594. /**
  14595. * Gets the source animation for a specific property
  14596. * @param property defines the propertyu to look for
  14597. * @returns null or the source animation for the given property
  14598. */
  14599. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  14600. /**
  14601. * Gets the runtime animation for a specific property
  14602. * @param property defines the propertyu to look for
  14603. * @returns null or the runtime animation for the given property
  14604. */
  14605. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  14606. /**
  14607. * Resets the animatable to its original state
  14608. */
  14609. reset(): void;
  14610. /**
  14611. * Allows the animatable to blend with current running animations
  14612. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14613. * @param blendingSpeed defines the blending speed to use
  14614. */
  14615. enableBlending(blendingSpeed: number): void;
  14616. /**
  14617. * Disable animation blending
  14618. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14619. */
  14620. disableBlending(): void;
  14621. /**
  14622. * Jump directly to a given frame
  14623. * @param frame defines the frame to jump to
  14624. */
  14625. goToFrame(frame: number): void;
  14626. /**
  14627. * Pause the animation
  14628. */
  14629. pause(): void;
  14630. /**
  14631. * Restart the animation
  14632. */
  14633. restart(): void;
  14634. private _raiseOnAnimationEnd;
  14635. /**
  14636. * Stop and delete the current animation
  14637. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  14638. * @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)
  14639. */
  14640. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  14641. /**
  14642. * Wait asynchronously for the animation to end
  14643. * @returns a promise which will be fullfilled when the animation ends
  14644. */
  14645. waitAsync(): Promise<Animatable>;
  14646. /** @hidden */
  14647. _animate(delay: number): boolean;
  14648. }
  14649. interface Scene {
  14650. /** @hidden */
  14651. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  14652. /** @hidden */
  14653. _processLateAnimationBindingsForMatrices(holder: {
  14654. totalWeight: number;
  14655. animations: RuntimeAnimation[];
  14656. originalValue: Matrix;
  14657. }): any;
  14658. /** @hidden */
  14659. _processLateAnimationBindingsForQuaternions(holder: {
  14660. totalWeight: number;
  14661. animations: RuntimeAnimation[];
  14662. originalValue: Quaternion;
  14663. }, refQuaternion: Quaternion): Quaternion;
  14664. /** @hidden */
  14665. _processLateAnimationBindings(): void;
  14666. /**
  14667. * Will start the animation sequence of a given target
  14668. * @param target defines the target
  14669. * @param from defines from which frame should animation start
  14670. * @param to defines until which frame should animation run.
  14671. * @param weight defines the weight to apply to the animation (1.0 by default)
  14672. * @param loop defines if the animation loops
  14673. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14674. * @param onAnimationEnd defines the function to be executed when the animation ends
  14675. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14676. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14677. * @param onAnimationLoop defines the callback to call when an animation loops
  14678. * @returns the animatable object created for this animation
  14679. */
  14680. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  14681. /**
  14682. * Will start the animation sequence of a given target
  14683. * @param target defines the target
  14684. * @param from defines from which frame should animation start
  14685. * @param to defines until which frame should animation run.
  14686. * @param loop defines if the animation loops
  14687. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14688. * @param onAnimationEnd defines the function to be executed when the animation ends
  14689. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14690. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14691. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  14692. * @param onAnimationLoop defines the callback to call when an animation loops
  14693. * @returns the animatable object created for this animation
  14694. */
  14695. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  14696. /**
  14697. * Will start the animation sequence of a given target and its hierarchy
  14698. * @param target defines the target
  14699. * @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.
  14700. * @param from defines from which frame should animation start
  14701. * @param to defines until which frame should animation run.
  14702. * @param loop defines if the animation loops
  14703. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  14704. * @param onAnimationEnd defines the function to be executed when the animation ends
  14705. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  14706. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  14707. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  14708. * @param onAnimationLoop defines the callback to call when an animation loops
  14709. * @returns the list of created animatables
  14710. */
  14711. 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[];
  14712. /**
  14713. * Begin a new animation on a given node
  14714. * @param target defines the target where the animation will take place
  14715. * @param animations defines the list of animations to start
  14716. * @param from defines the initial value
  14717. * @param to defines the final value
  14718. * @param loop defines if you want animation to loop (off by default)
  14719. * @param speedRatio defines the speed ratio to apply to all animations
  14720. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  14721. * @param onAnimationLoop defines the callback to call when an animation loops
  14722. * @returns the list of created animatables
  14723. */
  14724. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  14725. /**
  14726. * Begin a new animation on a given node and its hierarchy
  14727. * @param target defines the root node where the animation will take place
  14728. * @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.
  14729. * @param animations defines the list of animations to start
  14730. * @param from defines the initial value
  14731. * @param to defines the final value
  14732. * @param loop defines if you want animation to loop (off by default)
  14733. * @param speedRatio defines the speed ratio to apply to all animations
  14734. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  14735. * @param onAnimationLoop defines the callback to call when an animation loops
  14736. * @returns the list of animatables created for all nodes
  14737. */
  14738. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  14739. /**
  14740. * Gets the animatable associated with a specific target
  14741. * @param target defines the target of the animatable
  14742. * @returns the required animatable if found
  14743. */
  14744. getAnimatableByTarget(target: any): Nullable<Animatable>;
  14745. /**
  14746. * Gets all animatables associated with a given target
  14747. * @param target defines the target to look animatables for
  14748. * @returns an array of Animatables
  14749. */
  14750. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  14751. /**
  14752. * Stops and removes all animations that have been applied to the scene
  14753. */
  14754. stopAllAnimations(): void;
  14755. /**
  14756. * Gets the current delta time used by animation engine
  14757. */
  14758. deltaTime: number;
  14759. }
  14760. interface Bone {
  14761. /**
  14762. * Copy an animation range from another bone
  14763. * @param source defines the source bone
  14764. * @param rangeName defines the range name to copy
  14765. * @param frameOffset defines the frame offset
  14766. * @param rescaleAsRequired defines if rescaling must be applied if required
  14767. * @param skelDimensionsRatio defines the scaling ratio
  14768. * @returns true if operation was successful
  14769. */
  14770. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  14771. }
  14772. }
  14773. declare module BABYLON {
  14774. /**
  14775. * Class used to handle skinning animations
  14776. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14777. */
  14778. export class Skeleton implements IAnimatable {
  14779. /** defines the skeleton name */
  14780. name: string;
  14781. /** defines the skeleton Id */
  14782. id: string;
  14783. /**
  14784. * Defines the list of child bones
  14785. */
  14786. bones: Bone[];
  14787. /**
  14788. * Defines an estimate of the dimension of the skeleton at rest
  14789. */
  14790. dimensionsAtRest: Vector3;
  14791. /**
  14792. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  14793. */
  14794. needInitialSkinMatrix: boolean;
  14795. /**
  14796. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  14797. */
  14798. overrideMesh: Nullable<AbstractMesh>;
  14799. /**
  14800. * Gets the list of animations attached to this skeleton
  14801. */
  14802. animations: Array<Animation>;
  14803. private _scene;
  14804. private _isDirty;
  14805. private _transformMatrices;
  14806. private _transformMatrixTexture;
  14807. private _meshesWithPoseMatrix;
  14808. private _animatables;
  14809. private _identity;
  14810. private _synchronizedWithMesh;
  14811. private _ranges;
  14812. private _lastAbsoluteTransformsUpdateId;
  14813. private _canUseTextureForBones;
  14814. private _uniqueId;
  14815. /** @hidden */
  14816. _numBonesWithLinkedTransformNode: number;
  14817. /** @hidden */
  14818. _hasWaitingData: Nullable<boolean>;
  14819. /**
  14820. * Specifies if the skeleton should be serialized
  14821. */
  14822. doNotSerialize: boolean;
  14823. private _useTextureToStoreBoneMatrices;
  14824. /**
  14825. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  14826. * Please note that this option is not available if the hardware does not support it
  14827. */
  14828. get useTextureToStoreBoneMatrices(): boolean;
  14829. set useTextureToStoreBoneMatrices(value: boolean);
  14830. private _animationPropertiesOverride;
  14831. /**
  14832. * Gets or sets the animation properties override
  14833. */
  14834. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14835. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  14836. /**
  14837. * List of inspectable custom properties (used by the Inspector)
  14838. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  14839. */
  14840. inspectableCustomProperties: IInspectable[];
  14841. /**
  14842. * An observable triggered before computing the skeleton's matrices
  14843. */
  14844. onBeforeComputeObservable: Observable<Skeleton>;
  14845. /**
  14846. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  14847. */
  14848. get isUsingTextureForMatrices(): boolean;
  14849. /**
  14850. * Gets the unique ID of this skeleton
  14851. */
  14852. get uniqueId(): number;
  14853. /**
  14854. * Creates a new skeleton
  14855. * @param name defines the skeleton name
  14856. * @param id defines the skeleton Id
  14857. * @param scene defines the hosting scene
  14858. */
  14859. constructor(
  14860. /** defines the skeleton name */
  14861. name: string,
  14862. /** defines the skeleton Id */
  14863. id: string, scene: Scene);
  14864. /**
  14865. * Gets the current object class name.
  14866. * @return the class name
  14867. */
  14868. getClassName(): string;
  14869. /**
  14870. * Returns an array containing the root bones
  14871. * @returns an array containing the root bones
  14872. */
  14873. getChildren(): Array<Bone>;
  14874. /**
  14875. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  14876. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  14877. * @returns a Float32Array containing matrices data
  14878. */
  14879. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  14880. /**
  14881. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  14882. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  14883. * @returns a raw texture containing the data
  14884. */
  14885. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  14886. /**
  14887. * Gets the current hosting scene
  14888. * @returns a scene object
  14889. */
  14890. getScene(): Scene;
  14891. /**
  14892. * Gets a string representing the current skeleton data
  14893. * @param fullDetails defines a boolean indicating if we want a verbose version
  14894. * @returns a string representing the current skeleton data
  14895. */
  14896. toString(fullDetails?: boolean): string;
  14897. /**
  14898. * Get bone's index searching by name
  14899. * @param name defines bone's name to search for
  14900. * @return the indice of the bone. Returns -1 if not found
  14901. */
  14902. getBoneIndexByName(name: string): number;
  14903. /**
  14904. * Creater a new animation range
  14905. * @param name defines the name of the range
  14906. * @param from defines the start key
  14907. * @param to defines the end key
  14908. */
  14909. createAnimationRange(name: string, from: number, to: number): void;
  14910. /**
  14911. * Delete a specific animation range
  14912. * @param name defines the name of the range
  14913. * @param deleteFrames defines if frames must be removed as well
  14914. */
  14915. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  14916. /**
  14917. * Gets a specific animation range
  14918. * @param name defines the name of the range to look for
  14919. * @returns the requested animation range or null if not found
  14920. */
  14921. getAnimationRange(name: string): Nullable<AnimationRange>;
  14922. /**
  14923. * Gets the list of all animation ranges defined on this skeleton
  14924. * @returns an array
  14925. */
  14926. getAnimationRanges(): Nullable<AnimationRange>[];
  14927. /**
  14928. * Copy animation range from a source skeleton.
  14929. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  14930. * @param source defines the source skeleton
  14931. * @param name defines the name of the range to copy
  14932. * @param rescaleAsRequired defines if rescaling must be applied if required
  14933. * @returns true if operation was successful
  14934. */
  14935. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  14936. /**
  14937. * Forces the skeleton to go to rest pose
  14938. */
  14939. returnToRest(): void;
  14940. private _getHighestAnimationFrame;
  14941. /**
  14942. * Begin a specific animation range
  14943. * @param name defines the name of the range to start
  14944. * @param loop defines if looping must be turned on (false by default)
  14945. * @param speedRatio defines the speed ratio to apply (1 by default)
  14946. * @param onAnimationEnd defines a callback which will be called when animation will end
  14947. * @returns a new animatable
  14948. */
  14949. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  14950. /** @hidden */
  14951. _markAsDirty(): void;
  14952. /** @hidden */
  14953. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  14954. /** @hidden */
  14955. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  14956. private _computeTransformMatrices;
  14957. /**
  14958. * Build all resources required to render a skeleton
  14959. */
  14960. prepare(): void;
  14961. /**
  14962. * Gets the list of animatables currently running for this skeleton
  14963. * @returns an array of animatables
  14964. */
  14965. getAnimatables(): IAnimatable[];
  14966. /**
  14967. * Clone the current skeleton
  14968. * @param name defines the name of the new skeleton
  14969. * @param id defines the id of the new skeleton
  14970. * @returns the new skeleton
  14971. */
  14972. clone(name: string, id?: string): Skeleton;
  14973. /**
  14974. * Enable animation blending for this skeleton
  14975. * @param blendingSpeed defines the blending speed to apply
  14976. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14977. */
  14978. enableBlending(blendingSpeed?: number): void;
  14979. /**
  14980. * Releases all resources associated with the current skeleton
  14981. */
  14982. dispose(): void;
  14983. /**
  14984. * Serialize the skeleton in a JSON object
  14985. * @returns a JSON object
  14986. */
  14987. serialize(): any;
  14988. /**
  14989. * Creates a new skeleton from serialized data
  14990. * @param parsedSkeleton defines the serialized data
  14991. * @param scene defines the hosting scene
  14992. * @returns a new skeleton
  14993. */
  14994. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  14995. /**
  14996. * Compute all node absolute transforms
  14997. * @param forceUpdate defines if computation must be done even if cache is up to date
  14998. */
  14999. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  15000. /**
  15001. * Gets the root pose matrix
  15002. * @returns a matrix
  15003. */
  15004. getPoseMatrix(): Nullable<Matrix>;
  15005. /**
  15006. * Sorts bones per internal index
  15007. */
  15008. sortBones(): void;
  15009. private _sortBones;
  15010. }
  15011. }
  15012. declare module BABYLON {
  15013. /**
  15014. * Creates an instance based on a source mesh.
  15015. */
  15016. export class InstancedMesh extends AbstractMesh {
  15017. private _sourceMesh;
  15018. private _currentLOD;
  15019. /** @hidden */
  15020. _indexInSourceMeshInstanceArray: number;
  15021. constructor(name: string, source: Mesh);
  15022. /**
  15023. * Returns the string "InstancedMesh".
  15024. */
  15025. getClassName(): string;
  15026. /** Gets the list of lights affecting that mesh */
  15027. get lightSources(): Light[];
  15028. _resyncLightSources(): void;
  15029. _resyncLightSource(light: Light): void;
  15030. _removeLightSource(light: Light, dispose: boolean): void;
  15031. /**
  15032. * If the source mesh receives shadows
  15033. */
  15034. get receiveShadows(): boolean;
  15035. /**
  15036. * The material of the source mesh
  15037. */
  15038. get material(): Nullable<Material>;
  15039. /**
  15040. * Visibility of the source mesh
  15041. */
  15042. get visibility(): number;
  15043. /**
  15044. * Skeleton of the source mesh
  15045. */
  15046. get skeleton(): Nullable<Skeleton>;
  15047. /**
  15048. * Rendering ground id of the source mesh
  15049. */
  15050. get renderingGroupId(): number;
  15051. set renderingGroupId(value: number);
  15052. /**
  15053. * Returns the total number of vertices (integer).
  15054. */
  15055. getTotalVertices(): number;
  15056. /**
  15057. * Returns a positive integer : the total number of indices in this mesh geometry.
  15058. * @returns the numner of indices or zero if the mesh has no geometry.
  15059. */
  15060. getTotalIndices(): number;
  15061. /**
  15062. * The source mesh of the instance
  15063. */
  15064. get sourceMesh(): Mesh;
  15065. /**
  15066. * Is this node ready to be used/rendered
  15067. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15068. * @return {boolean} is it ready
  15069. */
  15070. isReady(completeCheck?: boolean): boolean;
  15071. /**
  15072. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15073. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15074. * @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.
  15075. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15076. */
  15077. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15078. /**
  15079. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15080. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15081. * The `data` are either a numeric array either a Float32Array.
  15082. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15083. * 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).
  15084. * Note that a new underlying VertexBuffer object is created each call.
  15085. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15086. *
  15087. * Possible `kind` values :
  15088. * - VertexBuffer.PositionKind
  15089. * - VertexBuffer.UVKind
  15090. * - VertexBuffer.UV2Kind
  15091. * - VertexBuffer.UV3Kind
  15092. * - VertexBuffer.UV4Kind
  15093. * - VertexBuffer.UV5Kind
  15094. * - VertexBuffer.UV6Kind
  15095. * - VertexBuffer.ColorKind
  15096. * - VertexBuffer.MatricesIndicesKind
  15097. * - VertexBuffer.MatricesIndicesExtraKind
  15098. * - VertexBuffer.MatricesWeightsKind
  15099. * - VertexBuffer.MatricesWeightsExtraKind
  15100. *
  15101. * Returns the Mesh.
  15102. */
  15103. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  15104. /**
  15105. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15106. * If the mesh has no geometry, it is simply returned as it is.
  15107. * The `data` are either a numeric array either a Float32Array.
  15108. * No new underlying VertexBuffer object is created.
  15109. * 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.
  15110. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15111. *
  15112. * Possible `kind` values :
  15113. * - VertexBuffer.PositionKind
  15114. * - VertexBuffer.UVKind
  15115. * - VertexBuffer.UV2Kind
  15116. * - VertexBuffer.UV3Kind
  15117. * - VertexBuffer.UV4Kind
  15118. * - VertexBuffer.UV5Kind
  15119. * - VertexBuffer.UV6Kind
  15120. * - VertexBuffer.ColorKind
  15121. * - VertexBuffer.MatricesIndicesKind
  15122. * - VertexBuffer.MatricesIndicesExtraKind
  15123. * - VertexBuffer.MatricesWeightsKind
  15124. * - VertexBuffer.MatricesWeightsExtraKind
  15125. *
  15126. * Returns the Mesh.
  15127. */
  15128. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15129. /**
  15130. * Sets the mesh indices.
  15131. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15132. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15133. * This method creates a new index buffer each call.
  15134. * Returns the Mesh.
  15135. */
  15136. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15137. /**
  15138. * Boolean : True if the mesh owns the requested kind of data.
  15139. */
  15140. isVerticesDataPresent(kind: string): boolean;
  15141. /**
  15142. * Returns an array of indices (IndicesArray).
  15143. */
  15144. getIndices(): Nullable<IndicesArray>;
  15145. get _positions(): Nullable<Vector3[]>;
  15146. /**
  15147. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15148. * This means the mesh underlying bounding box and sphere are recomputed.
  15149. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  15150. * @returns the current mesh
  15151. */
  15152. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  15153. /** @hidden */
  15154. _preActivate(): InstancedMesh;
  15155. /** @hidden */
  15156. _activate(renderId: number, intermediateRendering: boolean): boolean;
  15157. /** @hidden */
  15158. _postActivate(): void;
  15159. getWorldMatrix(): Matrix;
  15160. get isAnInstance(): boolean;
  15161. /**
  15162. * Returns the current associated LOD AbstractMesh.
  15163. */
  15164. getLOD(camera: Camera): AbstractMesh;
  15165. /** @hidden */
  15166. _syncSubMeshes(): InstancedMesh;
  15167. /** @hidden */
  15168. _generatePointsArray(): boolean;
  15169. /**
  15170. * Creates a new InstancedMesh from the current mesh.
  15171. * - name (string) : the cloned mesh name
  15172. * - newParent (optional Node) : the optional Node to parent the clone to.
  15173. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15174. *
  15175. * Returns the clone.
  15176. */
  15177. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  15178. /**
  15179. * Disposes the InstancedMesh.
  15180. * Returns nothing.
  15181. */
  15182. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15183. }
  15184. interface Mesh {
  15185. /**
  15186. * Register a custom buffer that will be instanced
  15187. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15188. * @param kind defines the buffer kind
  15189. * @param stride defines the stride in floats
  15190. */
  15191. registerInstancedBuffer(kind: string, stride: number): void;
  15192. /** @hidden */
  15193. _userInstancedBuffersStorage: {
  15194. data: {
  15195. [key: string]: Float32Array;
  15196. };
  15197. sizes: {
  15198. [key: string]: number;
  15199. };
  15200. vertexBuffers: {
  15201. [key: string]: Nullable<VertexBuffer>;
  15202. };
  15203. strides: {
  15204. [key: string]: number;
  15205. };
  15206. };
  15207. }
  15208. interface AbstractMesh {
  15209. /**
  15210. * Object used to store instanced buffers defined by user
  15211. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15212. */
  15213. instancedBuffers: {
  15214. [key: string]: any;
  15215. };
  15216. }
  15217. }
  15218. declare module BABYLON {
  15219. /**
  15220. * Defines the options associated with the creation of a shader material.
  15221. */
  15222. export interface IShaderMaterialOptions {
  15223. /**
  15224. * Does the material work in alpha blend mode
  15225. */
  15226. needAlphaBlending: boolean;
  15227. /**
  15228. * Does the material work in alpha test mode
  15229. */
  15230. needAlphaTesting: boolean;
  15231. /**
  15232. * The list of attribute names used in the shader
  15233. */
  15234. attributes: string[];
  15235. /**
  15236. * The list of unifrom names used in the shader
  15237. */
  15238. uniforms: string[];
  15239. /**
  15240. * The list of UBO names used in the shader
  15241. */
  15242. uniformBuffers: string[];
  15243. /**
  15244. * The list of sampler names used in the shader
  15245. */
  15246. samplers: string[];
  15247. /**
  15248. * The list of defines used in the shader
  15249. */
  15250. defines: string[];
  15251. }
  15252. /**
  15253. * 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.
  15254. *
  15255. * This returned material effects how the mesh will look based on the code in the shaders.
  15256. *
  15257. * @see http://doc.babylonjs.com/how_to/shader_material
  15258. */
  15259. export class ShaderMaterial extends Material {
  15260. private _shaderPath;
  15261. private _options;
  15262. private _textures;
  15263. private _textureArrays;
  15264. private _floats;
  15265. private _ints;
  15266. private _floatsArrays;
  15267. private _colors3;
  15268. private _colors3Arrays;
  15269. private _colors4;
  15270. private _colors4Arrays;
  15271. private _vectors2;
  15272. private _vectors3;
  15273. private _vectors4;
  15274. private _matrices;
  15275. private _matrixArrays;
  15276. private _matrices3x3;
  15277. private _matrices2x2;
  15278. private _vectors2Arrays;
  15279. private _vectors3Arrays;
  15280. private _vectors4Arrays;
  15281. private _cachedWorldViewMatrix;
  15282. private _cachedWorldViewProjectionMatrix;
  15283. private _renderId;
  15284. private _multiview;
  15285. /**
  15286. * Instantiate a new shader material.
  15287. * 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.
  15288. * This returned material effects how the mesh will look based on the code in the shaders.
  15289. * @see http://doc.babylonjs.com/how_to/shader_material
  15290. * @param name Define the name of the material in the scene
  15291. * @param scene Define the scene the material belongs to
  15292. * @param shaderPath Defines the route to the shader code in one of three ways:
  15293. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  15294. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  15295. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  15296. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  15297. * @param options Define the options used to create the shader
  15298. */
  15299. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  15300. /**
  15301. * Gets the shader path used to define the shader code
  15302. * It can be modified to trigger a new compilation
  15303. */
  15304. get shaderPath(): any;
  15305. /**
  15306. * Sets the shader path used to define the shader code
  15307. * It can be modified to trigger a new compilation
  15308. */
  15309. set shaderPath(shaderPath: any);
  15310. /**
  15311. * Gets the options used to compile the shader.
  15312. * They can be modified to trigger a new compilation
  15313. */
  15314. get options(): IShaderMaterialOptions;
  15315. /**
  15316. * Gets the current class name of the material e.g. "ShaderMaterial"
  15317. * Mainly use in serialization.
  15318. * @returns the class name
  15319. */
  15320. getClassName(): string;
  15321. /**
  15322. * Specifies if the material will require alpha blending
  15323. * @returns a boolean specifying if alpha blending is needed
  15324. */
  15325. needAlphaBlending(): boolean;
  15326. /**
  15327. * Specifies if this material should be rendered in alpha test mode
  15328. * @returns a boolean specifying if an alpha test is needed.
  15329. */
  15330. needAlphaTesting(): boolean;
  15331. private _checkUniform;
  15332. /**
  15333. * Set a texture in the shader.
  15334. * @param name Define the name of the uniform samplers as defined in the shader
  15335. * @param texture Define the texture to bind to this sampler
  15336. * @return the material itself allowing "fluent" like uniform updates
  15337. */
  15338. setTexture(name: string, texture: Texture): ShaderMaterial;
  15339. /**
  15340. * Set a texture array in the shader.
  15341. * @param name Define the name of the uniform sampler array as defined in the shader
  15342. * @param textures Define the list of textures to bind to this sampler
  15343. * @return the material itself allowing "fluent" like uniform updates
  15344. */
  15345. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  15346. /**
  15347. * Set a float in the shader.
  15348. * @param name Define the name of the uniform as defined in the shader
  15349. * @param value Define the value to give to the uniform
  15350. * @return the material itself allowing "fluent" like uniform updates
  15351. */
  15352. setFloat(name: string, value: number): ShaderMaterial;
  15353. /**
  15354. * Set a int in the shader.
  15355. * @param name Define the name of the uniform as defined in the shader
  15356. * @param value Define the value to give to the uniform
  15357. * @return the material itself allowing "fluent" like uniform updates
  15358. */
  15359. setInt(name: string, value: number): ShaderMaterial;
  15360. /**
  15361. * Set an array of floats in the shader.
  15362. * @param name Define the name of the uniform as defined in the shader
  15363. * @param value Define the value to give to the uniform
  15364. * @return the material itself allowing "fluent" like uniform updates
  15365. */
  15366. setFloats(name: string, value: number[]): ShaderMaterial;
  15367. /**
  15368. * Set a vec3 in the shader from a Color3.
  15369. * @param name Define the name of the uniform as defined in the shader
  15370. * @param value Define the value to give to the uniform
  15371. * @return the material itself allowing "fluent" like uniform updates
  15372. */
  15373. setColor3(name: string, value: Color3): ShaderMaterial;
  15374. /**
  15375. * Set a vec3 array in the shader from a Color3 array.
  15376. * @param name Define the name of the uniform as defined in the shader
  15377. * @param value Define the value to give to the uniform
  15378. * @return the material itself allowing "fluent" like uniform updates
  15379. */
  15380. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  15381. /**
  15382. * Set a vec4 in the shader from a Color4.
  15383. * @param name Define the name of the uniform as defined in the shader
  15384. * @param value Define the value to give to the uniform
  15385. * @return the material itself allowing "fluent" like uniform updates
  15386. */
  15387. setColor4(name: string, value: Color4): ShaderMaterial;
  15388. /**
  15389. * Set a vec4 array in the shader from a Color4 array.
  15390. * @param name Define the name of the uniform as defined in the shader
  15391. * @param value Define the value to give to the uniform
  15392. * @return the material itself allowing "fluent" like uniform updates
  15393. */
  15394. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  15395. /**
  15396. * Set a vec2 in the shader from a Vector2.
  15397. * @param name Define the name of the uniform as defined in the shader
  15398. * @param value Define the value to give to the uniform
  15399. * @return the material itself allowing "fluent" like uniform updates
  15400. */
  15401. setVector2(name: string, value: Vector2): ShaderMaterial;
  15402. /**
  15403. * Set a vec3 in the shader from a Vector3.
  15404. * @param name Define the name of the uniform as defined in the shader
  15405. * @param value Define the value to give to the uniform
  15406. * @return the material itself allowing "fluent" like uniform updates
  15407. */
  15408. setVector3(name: string, value: Vector3): ShaderMaterial;
  15409. /**
  15410. * Set a vec4 in the shader from a Vector4.
  15411. * @param name Define the name of the uniform as defined in the shader
  15412. * @param value Define the value to give to the uniform
  15413. * @return the material itself allowing "fluent" like uniform updates
  15414. */
  15415. setVector4(name: string, value: Vector4): ShaderMaterial;
  15416. /**
  15417. * Set a mat4 in the shader from a Matrix.
  15418. * @param name Define the name of the uniform as defined in the shader
  15419. * @param value Define the value to give to the uniform
  15420. * @return the material itself allowing "fluent" like uniform updates
  15421. */
  15422. setMatrix(name: string, value: Matrix): ShaderMaterial;
  15423. /**
  15424. * Set a float32Array in the shader from a matrix array.
  15425. * @param name Define the name of the uniform as defined in the shader
  15426. * @param value Define the value to give to the uniform
  15427. * @return the material itself allowing "fluent" like uniform updates
  15428. */
  15429. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  15430. /**
  15431. * Set a mat3 in the shader from a Float32Array.
  15432. * @param name Define the name of the uniform as defined in the shader
  15433. * @param value Define the value to give to the uniform
  15434. * @return the material itself allowing "fluent" like uniform updates
  15435. */
  15436. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  15437. /**
  15438. * Set a mat2 in the shader from a Float32Array.
  15439. * @param name Define the name of the uniform as defined in the shader
  15440. * @param value Define the value to give to the uniform
  15441. * @return the material itself allowing "fluent" like uniform updates
  15442. */
  15443. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  15444. /**
  15445. * Set a vec2 array in the shader from a number array.
  15446. * @param name Define the name of the uniform as defined in the shader
  15447. * @param value Define the value to give to the uniform
  15448. * @return the material itself allowing "fluent" like uniform updates
  15449. */
  15450. setArray2(name: string, value: number[]): ShaderMaterial;
  15451. /**
  15452. * Set a vec3 array in the shader from a number array.
  15453. * @param name Define the name of the uniform as defined in the shader
  15454. * @param value Define the value to give to the uniform
  15455. * @return the material itself allowing "fluent" like uniform updates
  15456. */
  15457. setArray3(name: string, value: number[]): ShaderMaterial;
  15458. /**
  15459. * Set a vec4 array in the shader from a number array.
  15460. * @param name Define the name of the uniform as defined in the shader
  15461. * @param value Define the value to give to the uniform
  15462. * @return the material itself allowing "fluent" like uniform updates
  15463. */
  15464. setArray4(name: string, value: number[]): ShaderMaterial;
  15465. private _checkCache;
  15466. /**
  15467. * Specifies that the submesh is ready to be used
  15468. * @param mesh defines the mesh to check
  15469. * @param subMesh defines which submesh to check
  15470. * @param useInstances specifies that instances should be used
  15471. * @returns a boolean indicating that the submesh is ready or not
  15472. */
  15473. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  15474. /**
  15475. * Checks if the material is ready to render the requested mesh
  15476. * @param mesh Define the mesh to render
  15477. * @param useInstances Define whether or not the material is used with instances
  15478. * @returns true if ready, otherwise false
  15479. */
  15480. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  15481. /**
  15482. * Binds the world matrix to the material
  15483. * @param world defines the world transformation matrix
  15484. */
  15485. bindOnlyWorldMatrix(world: Matrix): void;
  15486. /**
  15487. * Binds the material to the mesh
  15488. * @param world defines the world transformation matrix
  15489. * @param mesh defines the mesh to bind the material to
  15490. */
  15491. bind(world: Matrix, mesh?: Mesh): void;
  15492. /**
  15493. * Gets the active textures from the material
  15494. * @returns an array of textures
  15495. */
  15496. getActiveTextures(): BaseTexture[];
  15497. /**
  15498. * Specifies if the material uses a texture
  15499. * @param texture defines the texture to check against the material
  15500. * @returns a boolean specifying if the material uses the texture
  15501. */
  15502. hasTexture(texture: BaseTexture): boolean;
  15503. /**
  15504. * Makes a duplicate of the material, and gives it a new name
  15505. * @param name defines the new name for the duplicated material
  15506. * @returns the cloned material
  15507. */
  15508. clone(name: string): ShaderMaterial;
  15509. /**
  15510. * Disposes the material
  15511. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  15512. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  15513. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  15514. */
  15515. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  15516. /**
  15517. * Serializes this material in a JSON representation
  15518. * @returns the serialized material object
  15519. */
  15520. serialize(): any;
  15521. /**
  15522. * Creates a shader material from parsed shader material data
  15523. * @param source defines the JSON represnetation of the material
  15524. * @param scene defines the hosting scene
  15525. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  15526. * @returns a new material
  15527. */
  15528. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  15529. }
  15530. }
  15531. declare module BABYLON {
  15532. /** @hidden */
  15533. export var colorPixelShader: {
  15534. name: string;
  15535. shader: string;
  15536. };
  15537. }
  15538. declare module BABYLON {
  15539. /** @hidden */
  15540. export var colorVertexShader: {
  15541. name: string;
  15542. shader: string;
  15543. };
  15544. }
  15545. declare module BABYLON {
  15546. /**
  15547. * Line mesh
  15548. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  15549. */
  15550. export class LinesMesh extends Mesh {
  15551. /**
  15552. * If vertex color should be applied to the mesh
  15553. */
  15554. readonly useVertexColor?: boolean | undefined;
  15555. /**
  15556. * If vertex alpha should be applied to the mesh
  15557. */
  15558. readonly useVertexAlpha?: boolean | undefined;
  15559. /**
  15560. * Color of the line (Default: White)
  15561. */
  15562. color: Color3;
  15563. /**
  15564. * Alpha of the line (Default: 1)
  15565. */
  15566. alpha: number;
  15567. /**
  15568. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15569. * This margin is expressed in world space coordinates, so its value may vary.
  15570. * Default value is 0.1
  15571. */
  15572. intersectionThreshold: number;
  15573. private _colorShader;
  15574. private color4;
  15575. /**
  15576. * Creates a new LinesMesh
  15577. * @param name defines the name
  15578. * @param scene defines the hosting scene
  15579. * @param parent defines the parent mesh if any
  15580. * @param source defines the optional source LinesMesh used to clone data from
  15581. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  15582. * When false, achieved by calling a clone(), also passing False.
  15583. * This will make creation of children, recursive.
  15584. * @param useVertexColor defines if this LinesMesh supports vertex color
  15585. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  15586. */
  15587. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  15588. /**
  15589. * If vertex color should be applied to the mesh
  15590. */
  15591. useVertexColor?: boolean | undefined,
  15592. /**
  15593. * If vertex alpha should be applied to the mesh
  15594. */
  15595. useVertexAlpha?: boolean | undefined);
  15596. private _addClipPlaneDefine;
  15597. private _removeClipPlaneDefine;
  15598. isReady(): boolean;
  15599. /**
  15600. * Returns the string "LineMesh"
  15601. */
  15602. getClassName(): string;
  15603. /**
  15604. * @hidden
  15605. */
  15606. get material(): Material;
  15607. /**
  15608. * @hidden
  15609. */
  15610. set material(value: Material);
  15611. /**
  15612. * @hidden
  15613. */
  15614. get checkCollisions(): boolean;
  15615. /** @hidden */
  15616. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  15617. /** @hidden */
  15618. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  15619. /**
  15620. * Disposes of the line mesh
  15621. * @param doNotRecurse If children should be disposed
  15622. */
  15623. dispose(doNotRecurse?: boolean): void;
  15624. /**
  15625. * Returns a new LineMesh object cloned from the current one.
  15626. */
  15627. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  15628. /**
  15629. * Creates a new InstancedLinesMesh object from the mesh model.
  15630. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  15631. * @param name defines the name of the new instance
  15632. * @returns a new InstancedLinesMesh
  15633. */
  15634. createInstance(name: string): InstancedLinesMesh;
  15635. }
  15636. /**
  15637. * Creates an instance based on a source LinesMesh
  15638. */
  15639. export class InstancedLinesMesh extends InstancedMesh {
  15640. /**
  15641. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15642. * This margin is expressed in world space coordinates, so its value may vary.
  15643. * Initilized with the intersectionThreshold value of the source LinesMesh
  15644. */
  15645. intersectionThreshold: number;
  15646. constructor(name: string, source: LinesMesh);
  15647. /**
  15648. * Returns the string "InstancedLinesMesh".
  15649. */
  15650. getClassName(): string;
  15651. }
  15652. }
  15653. declare module BABYLON {
  15654. /** @hidden */
  15655. export var linePixelShader: {
  15656. name: string;
  15657. shader: string;
  15658. };
  15659. }
  15660. declare module BABYLON {
  15661. /** @hidden */
  15662. export var lineVertexShader: {
  15663. name: string;
  15664. shader: string;
  15665. };
  15666. }
  15667. declare module BABYLON {
  15668. interface AbstractMesh {
  15669. /**
  15670. * Gets the edgesRenderer associated with the mesh
  15671. */
  15672. edgesRenderer: Nullable<EdgesRenderer>;
  15673. }
  15674. interface LinesMesh {
  15675. /**
  15676. * Enables the edge rendering mode on the mesh.
  15677. * This mode makes the mesh edges visible
  15678. * @param epsilon defines the maximal distance between two angles to detect a face
  15679. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15680. * @returns the currentAbstractMesh
  15681. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15682. */
  15683. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  15684. }
  15685. interface InstancedLinesMesh {
  15686. /**
  15687. * Enables the edge rendering mode on the mesh.
  15688. * This mode makes the mesh edges visible
  15689. * @param epsilon defines the maximal distance between two angles to detect a face
  15690. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  15691. * @returns the current InstancedLinesMesh
  15692. * @see https://www.babylonjs-playground.com/#19O9TU#0
  15693. */
  15694. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  15695. }
  15696. /**
  15697. * Defines the minimum contract an Edges renderer should follow.
  15698. */
  15699. export interface IEdgesRenderer extends IDisposable {
  15700. /**
  15701. * Gets or sets a boolean indicating if the edgesRenderer is active
  15702. */
  15703. isEnabled: boolean;
  15704. /**
  15705. * Renders the edges of the attached mesh,
  15706. */
  15707. render(): void;
  15708. /**
  15709. * Checks wether or not the edges renderer is ready to render.
  15710. * @return true if ready, otherwise false.
  15711. */
  15712. isReady(): boolean;
  15713. }
  15714. /**
  15715. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  15716. */
  15717. export class EdgesRenderer implements IEdgesRenderer {
  15718. /**
  15719. * Define the size of the edges with an orthographic camera
  15720. */
  15721. edgesWidthScalerForOrthographic: number;
  15722. /**
  15723. * Define the size of the edges with a perspective camera
  15724. */
  15725. edgesWidthScalerForPerspective: number;
  15726. protected _source: AbstractMesh;
  15727. protected _linesPositions: number[];
  15728. protected _linesNormals: number[];
  15729. protected _linesIndices: number[];
  15730. protected _epsilon: number;
  15731. protected _indicesCount: number;
  15732. protected _lineShader: ShaderMaterial;
  15733. protected _ib: DataBuffer;
  15734. protected _buffers: {
  15735. [key: string]: Nullable<VertexBuffer>;
  15736. };
  15737. protected _checkVerticesInsteadOfIndices: boolean;
  15738. private _meshRebuildObserver;
  15739. private _meshDisposeObserver;
  15740. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  15741. isEnabled: boolean;
  15742. /**
  15743. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  15744. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  15745. * @param source Mesh used to create edges
  15746. * @param epsilon sum of angles in adjacency to check for edge
  15747. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  15748. * @param generateEdgesLines - should generate Lines or only prepare resources.
  15749. */
  15750. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  15751. protected _prepareRessources(): void;
  15752. /** @hidden */
  15753. _rebuild(): void;
  15754. /**
  15755. * Releases the required resources for the edges renderer
  15756. */
  15757. dispose(): void;
  15758. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  15759. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  15760. /**
  15761. * Checks if the pair of p0 and p1 is en edge
  15762. * @param faceIndex
  15763. * @param edge
  15764. * @param faceNormals
  15765. * @param p0
  15766. * @param p1
  15767. * @private
  15768. */
  15769. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  15770. /**
  15771. * push line into the position, normal and index buffer
  15772. * @protected
  15773. */
  15774. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  15775. /**
  15776. * Generates lines edges from adjacencjes
  15777. * @private
  15778. */
  15779. _generateEdgesLines(): void;
  15780. /**
  15781. * Checks wether or not the edges renderer is ready to render.
  15782. * @return true if ready, otherwise false.
  15783. */
  15784. isReady(): boolean;
  15785. /**
  15786. * Renders the edges of the attached mesh,
  15787. */
  15788. render(): void;
  15789. }
  15790. /**
  15791. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  15792. */
  15793. export class LineEdgesRenderer extends EdgesRenderer {
  15794. /**
  15795. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  15796. * @param source LineMesh used to generate edges
  15797. * @param epsilon not important (specified angle for edge detection)
  15798. * @param checkVerticesInsteadOfIndices not important for LineMesh
  15799. */
  15800. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  15801. /**
  15802. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  15803. */
  15804. _generateEdgesLines(): void;
  15805. }
  15806. }
  15807. declare module BABYLON {
  15808. /**
  15809. * This represents the object necessary to create a rendering group.
  15810. * This is exclusively used and created by the rendering manager.
  15811. * To modify the behavior, you use the available helpers in your scene or meshes.
  15812. * @hidden
  15813. */
  15814. export class RenderingGroup {
  15815. index: number;
  15816. private static _zeroVector;
  15817. private _scene;
  15818. private _opaqueSubMeshes;
  15819. private _transparentSubMeshes;
  15820. private _alphaTestSubMeshes;
  15821. private _depthOnlySubMeshes;
  15822. private _particleSystems;
  15823. private _spriteManagers;
  15824. private _opaqueSortCompareFn;
  15825. private _alphaTestSortCompareFn;
  15826. private _transparentSortCompareFn;
  15827. private _renderOpaque;
  15828. private _renderAlphaTest;
  15829. private _renderTransparent;
  15830. /** @hidden */
  15831. _edgesRenderers: SmartArray<IEdgesRenderer>;
  15832. onBeforeTransparentRendering: () => void;
  15833. /**
  15834. * Set the opaque sort comparison function.
  15835. * If null the sub meshes will be render in the order they were created
  15836. */
  15837. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  15838. /**
  15839. * Set the alpha test sort comparison function.
  15840. * If null the sub meshes will be render in the order they were created
  15841. */
  15842. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  15843. /**
  15844. * Set the transparent sort comparison function.
  15845. * If null the sub meshes will be render in the order they were created
  15846. */
  15847. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  15848. /**
  15849. * Creates a new rendering group.
  15850. * @param index The rendering group index
  15851. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  15852. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  15853. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  15854. */
  15855. 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>);
  15856. /**
  15857. * Render all the sub meshes contained in the group.
  15858. * @param customRenderFunction Used to override the default render behaviour of the group.
  15859. * @returns true if rendered some submeshes.
  15860. */
  15861. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  15862. /**
  15863. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  15864. * @param subMeshes The submeshes to render
  15865. */
  15866. private renderOpaqueSorted;
  15867. /**
  15868. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  15869. * @param subMeshes The submeshes to render
  15870. */
  15871. private renderAlphaTestSorted;
  15872. /**
  15873. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  15874. * @param subMeshes The submeshes to render
  15875. */
  15876. private renderTransparentSorted;
  15877. /**
  15878. * Renders the submeshes in a specified order.
  15879. * @param subMeshes The submeshes to sort before render
  15880. * @param sortCompareFn The comparison function use to sort
  15881. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  15882. * @param transparent Specifies to activate blending if true
  15883. */
  15884. private static renderSorted;
  15885. /**
  15886. * Renders the submeshes in the order they were dispatched (no sort applied).
  15887. * @param subMeshes The submeshes to render
  15888. */
  15889. private static renderUnsorted;
  15890. /**
  15891. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  15892. * are rendered back to front if in the same alpha index.
  15893. *
  15894. * @param a The first submesh
  15895. * @param b The second submesh
  15896. * @returns The result of the comparison
  15897. */
  15898. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  15899. /**
  15900. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  15901. * are rendered back to front.
  15902. *
  15903. * @param a The first submesh
  15904. * @param b The second submesh
  15905. * @returns The result of the comparison
  15906. */
  15907. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  15908. /**
  15909. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  15910. * are rendered front to back (prevent overdraw).
  15911. *
  15912. * @param a The first submesh
  15913. * @param b The second submesh
  15914. * @returns The result of the comparison
  15915. */
  15916. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  15917. /**
  15918. * Resets the different lists of submeshes to prepare a new frame.
  15919. */
  15920. prepare(): void;
  15921. dispose(): void;
  15922. /**
  15923. * Inserts the submesh in its correct queue depending on its material.
  15924. * @param subMesh The submesh to dispatch
  15925. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  15926. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  15927. */
  15928. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  15929. dispatchSprites(spriteManager: ISpriteManager): void;
  15930. dispatchParticles(particleSystem: IParticleSystem): void;
  15931. private _renderParticles;
  15932. private _renderSprites;
  15933. }
  15934. }
  15935. declare module BABYLON {
  15936. /**
  15937. * Interface describing the different options available in the rendering manager
  15938. * regarding Auto Clear between groups.
  15939. */
  15940. export interface IRenderingManagerAutoClearSetup {
  15941. /**
  15942. * Defines whether or not autoclear is enable.
  15943. */
  15944. autoClear: boolean;
  15945. /**
  15946. * Defines whether or not to autoclear the depth buffer.
  15947. */
  15948. depth: boolean;
  15949. /**
  15950. * Defines whether or not to autoclear the stencil buffer.
  15951. */
  15952. stencil: boolean;
  15953. }
  15954. /**
  15955. * This class is used by the onRenderingGroupObservable
  15956. */
  15957. export class RenderingGroupInfo {
  15958. /**
  15959. * The Scene that being rendered
  15960. */
  15961. scene: Scene;
  15962. /**
  15963. * The camera currently used for the rendering pass
  15964. */
  15965. camera: Nullable<Camera>;
  15966. /**
  15967. * The ID of the renderingGroup being processed
  15968. */
  15969. renderingGroupId: number;
  15970. }
  15971. /**
  15972. * This is the manager responsible of all the rendering for meshes sprites and particles.
  15973. * It is enable to manage the different groups as well as the different necessary sort functions.
  15974. * This should not be used directly aside of the few static configurations
  15975. */
  15976. export class RenderingManager {
  15977. /**
  15978. * The max id used for rendering groups (not included)
  15979. */
  15980. static MAX_RENDERINGGROUPS: number;
  15981. /**
  15982. * The min id used for rendering groups (included)
  15983. */
  15984. static MIN_RENDERINGGROUPS: number;
  15985. /**
  15986. * Used to globally prevent autoclearing scenes.
  15987. */
  15988. static AUTOCLEAR: boolean;
  15989. /**
  15990. * @hidden
  15991. */
  15992. _useSceneAutoClearSetup: boolean;
  15993. private _scene;
  15994. private _renderingGroups;
  15995. private _depthStencilBufferAlreadyCleaned;
  15996. private _autoClearDepthStencil;
  15997. private _customOpaqueSortCompareFn;
  15998. private _customAlphaTestSortCompareFn;
  15999. private _customTransparentSortCompareFn;
  16000. private _renderingGroupInfo;
  16001. /**
  16002. * Instantiates a new rendering group for a particular scene
  16003. * @param scene Defines the scene the groups belongs to
  16004. */
  16005. constructor(scene: Scene);
  16006. private _clearDepthStencilBuffer;
  16007. /**
  16008. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16009. * @hidden
  16010. */
  16011. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16012. /**
  16013. * Resets the different information of the group to prepare a new frame
  16014. * @hidden
  16015. */
  16016. reset(): void;
  16017. /**
  16018. * Dispose and release the group and its associated resources.
  16019. * @hidden
  16020. */
  16021. dispose(): void;
  16022. /**
  16023. * Clear the info related to rendering groups preventing retention points during dispose.
  16024. */
  16025. freeRenderingGroups(): void;
  16026. private _prepareRenderingGroup;
  16027. /**
  16028. * Add a sprite manager to the rendering manager in order to render it this frame.
  16029. * @param spriteManager Define the sprite manager to render
  16030. */
  16031. dispatchSprites(spriteManager: ISpriteManager): void;
  16032. /**
  16033. * Add a particle system to the rendering manager in order to render it this frame.
  16034. * @param particleSystem Define the particle system to render
  16035. */
  16036. dispatchParticles(particleSystem: IParticleSystem): void;
  16037. /**
  16038. * Add a submesh to the manager in order to render it this frame
  16039. * @param subMesh The submesh to dispatch
  16040. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16041. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16042. */
  16043. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16044. /**
  16045. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16046. * This allowed control for front to back rendering or reversly depending of the special needs.
  16047. *
  16048. * @param renderingGroupId The rendering group id corresponding to its index
  16049. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16050. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16051. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16052. */
  16053. 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;
  16054. /**
  16055. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16056. *
  16057. * @param renderingGroupId The rendering group id corresponding to its index
  16058. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16059. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16060. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16061. */
  16062. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16063. /**
  16064. * Gets the current auto clear configuration for one rendering group of the rendering
  16065. * manager.
  16066. * @param index the rendering group index to get the information for
  16067. * @returns The auto clear setup for the requested rendering group
  16068. */
  16069. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16070. }
  16071. }
  16072. declare module BABYLON {
  16073. /**
  16074. * Defines the options associated with the creation of a custom shader for a shadow generator.
  16075. */
  16076. export interface ICustomShaderOptions {
  16077. /**
  16078. * Gets or sets the custom shader name to use
  16079. */
  16080. shaderName: string;
  16081. /**
  16082. * The list of attribute names used in the shader
  16083. */
  16084. attributes?: string[];
  16085. /**
  16086. * The list of unifrom names used in the shader
  16087. */
  16088. uniforms?: string[];
  16089. /**
  16090. * The list of sampler names used in the shader
  16091. */
  16092. samplers?: string[];
  16093. /**
  16094. * The list of defines used in the shader
  16095. */
  16096. defines?: string[];
  16097. }
  16098. /**
  16099. * Interface to implement to create a shadow generator compatible with BJS.
  16100. */
  16101. export interface IShadowGenerator {
  16102. /**
  16103. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16104. * @returns The render target texture if present otherwise, null
  16105. */
  16106. getShadowMap(): Nullable<RenderTargetTexture>;
  16107. /**
  16108. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16109. * @param subMesh The submesh we want to render in the shadow map
  16110. * @param useInstances Defines wether will draw in the map using instances
  16111. * @returns true if ready otherwise, false
  16112. */
  16113. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16114. /**
  16115. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16116. * @param defines Defines of the material we want to update
  16117. * @param lightIndex Index of the light in the enabled light list of the material
  16118. */
  16119. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  16120. /**
  16121. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16122. * defined in the generator but impacting the effect).
  16123. * It implies the unifroms available on the materials are the standard BJS ones.
  16124. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16125. * @param effect The effect we are binfing the information for
  16126. */
  16127. bindShadowLight(lightIndex: string, effect: Effect): void;
  16128. /**
  16129. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16130. * (eq to shadow prjection matrix * light transform matrix)
  16131. * @returns The transform matrix used to create the shadow map
  16132. */
  16133. getTransformMatrix(): Matrix;
  16134. /**
  16135. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16136. * Cube and 2D textures for instance.
  16137. */
  16138. recreateShadowMap(): void;
  16139. /**
  16140. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16141. * @param onCompiled Callback triggered at the and of the effects compilation
  16142. * @param options Sets of optional options forcing the compilation with different modes
  16143. */
  16144. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16145. useInstances: boolean;
  16146. }>): void;
  16147. /**
  16148. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16149. * @param options Sets of optional options forcing the compilation with different modes
  16150. * @returns A promise that resolves when the compilation completes
  16151. */
  16152. forceCompilationAsync(options?: Partial<{
  16153. useInstances: boolean;
  16154. }>): Promise<void>;
  16155. /**
  16156. * Serializes the shadow generator setup to a json object.
  16157. * @returns The serialized JSON object
  16158. */
  16159. serialize(): any;
  16160. /**
  16161. * Disposes the Shadow map and related Textures and effects.
  16162. */
  16163. dispose(): void;
  16164. }
  16165. /**
  16166. * Default implementation IShadowGenerator.
  16167. * This is the main object responsible of generating shadows in the framework.
  16168. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  16169. */
  16170. export class ShadowGenerator implements IShadowGenerator {
  16171. /**
  16172. * Name of the shadow generator class
  16173. */
  16174. static CLASSNAME: string;
  16175. /**
  16176. * Shadow generator mode None: no filtering applied.
  16177. */
  16178. static readonly FILTER_NONE: number;
  16179. /**
  16180. * Shadow generator mode ESM: Exponential Shadow Mapping.
  16181. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16182. */
  16183. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  16184. /**
  16185. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  16186. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  16187. */
  16188. static readonly FILTER_POISSONSAMPLING: number;
  16189. /**
  16190. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  16191. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16192. */
  16193. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  16194. /**
  16195. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  16196. * edge artifacts on steep falloff.
  16197. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16198. */
  16199. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  16200. /**
  16201. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  16202. * edge artifacts on steep falloff.
  16203. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16204. */
  16205. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  16206. /**
  16207. * Shadow generator mode PCF: Percentage Closer Filtering
  16208. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16209. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  16210. */
  16211. static readonly FILTER_PCF: number;
  16212. /**
  16213. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  16214. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16215. * Contact Hardening
  16216. */
  16217. static readonly FILTER_PCSS: number;
  16218. /**
  16219. * Reserved for PCF and PCSS
  16220. * Highest Quality.
  16221. *
  16222. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  16223. *
  16224. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  16225. */
  16226. static readonly QUALITY_HIGH: number;
  16227. /**
  16228. * Reserved for PCF and PCSS
  16229. * Good tradeoff for quality/perf cross devices
  16230. *
  16231. * Execute PCF on a 3*3 kernel.
  16232. *
  16233. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  16234. */
  16235. static readonly QUALITY_MEDIUM: number;
  16236. /**
  16237. * Reserved for PCF and PCSS
  16238. * The lowest quality but the fastest.
  16239. *
  16240. * Execute PCF on a 1*1 kernel.
  16241. *
  16242. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  16243. */
  16244. static readonly QUALITY_LOW: number;
  16245. /** Gets or sets the custom shader name to use */
  16246. customShaderOptions: ICustomShaderOptions;
  16247. /**
  16248. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  16249. */
  16250. onBeforeShadowMapRenderObservable: Observable<Effect>;
  16251. /**
  16252. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  16253. */
  16254. onAfterShadowMapRenderObservable: Observable<Effect>;
  16255. /**
  16256. * Observable triggered before a mesh is rendered in the shadow map.
  16257. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  16258. */
  16259. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  16260. /**
  16261. * Observable triggered after a mesh is rendered in the shadow map.
  16262. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  16263. */
  16264. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  16265. protected _bias: number;
  16266. /**
  16267. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  16268. */
  16269. get bias(): number;
  16270. /**
  16271. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  16272. */
  16273. set bias(bias: number);
  16274. protected _normalBias: number;
  16275. /**
  16276. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16277. */
  16278. get normalBias(): number;
  16279. /**
  16280. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16281. */
  16282. set normalBias(normalBias: number);
  16283. protected _blurBoxOffset: number;
  16284. /**
  16285. * Gets the blur box offset: offset applied during the blur pass.
  16286. * Only useful if useKernelBlur = false
  16287. */
  16288. get blurBoxOffset(): number;
  16289. /**
  16290. * Sets the blur box offset: offset applied during the blur pass.
  16291. * Only useful if useKernelBlur = false
  16292. */
  16293. set blurBoxOffset(value: number);
  16294. protected _blurScale: number;
  16295. /**
  16296. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  16297. * 2 means half of the size.
  16298. */
  16299. get blurScale(): number;
  16300. /**
  16301. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  16302. * 2 means half of the size.
  16303. */
  16304. set blurScale(value: number);
  16305. protected _blurKernel: number;
  16306. /**
  16307. * Gets the blur kernel: kernel size of the blur pass.
  16308. * Only useful if useKernelBlur = true
  16309. */
  16310. get blurKernel(): number;
  16311. /**
  16312. * Sets the blur kernel: kernel size of the blur pass.
  16313. * Only useful if useKernelBlur = true
  16314. */
  16315. set blurKernel(value: number);
  16316. protected _useKernelBlur: boolean;
  16317. /**
  16318. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  16319. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16320. */
  16321. get useKernelBlur(): boolean;
  16322. /**
  16323. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  16324. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16325. */
  16326. set useKernelBlur(value: boolean);
  16327. protected _depthScale: number;
  16328. /**
  16329. * Gets the depth scale used in ESM mode.
  16330. */
  16331. get depthScale(): number;
  16332. /**
  16333. * Sets the depth scale used in ESM mode.
  16334. * This can override the scale stored on the light.
  16335. */
  16336. set depthScale(value: number);
  16337. protected _validateFilter(filter: number): number;
  16338. protected _filter: number;
  16339. /**
  16340. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  16341. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16342. */
  16343. get filter(): number;
  16344. /**
  16345. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  16346. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16347. */
  16348. set filter(value: number);
  16349. /**
  16350. * Gets if the current filter is set to Poisson Sampling.
  16351. */
  16352. get usePoissonSampling(): boolean;
  16353. /**
  16354. * Sets the current filter to Poisson Sampling.
  16355. */
  16356. set usePoissonSampling(value: boolean);
  16357. /**
  16358. * Gets if the current filter is set to ESM.
  16359. */
  16360. get useExponentialShadowMap(): boolean;
  16361. /**
  16362. * Sets the current filter is to ESM.
  16363. */
  16364. set useExponentialShadowMap(value: boolean);
  16365. /**
  16366. * Gets if the current filter is set to filtered ESM.
  16367. */
  16368. get useBlurExponentialShadowMap(): boolean;
  16369. /**
  16370. * Gets if the current filter is set to filtered ESM.
  16371. */
  16372. set useBlurExponentialShadowMap(value: boolean);
  16373. /**
  16374. * Gets if the current filter is set to "close ESM" (using the inverse of the
  16375. * exponential to prevent steep falloff artifacts).
  16376. */
  16377. get useCloseExponentialShadowMap(): boolean;
  16378. /**
  16379. * Sets the current filter to "close ESM" (using the inverse of the
  16380. * exponential to prevent steep falloff artifacts).
  16381. */
  16382. set useCloseExponentialShadowMap(value: boolean);
  16383. /**
  16384. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  16385. * exponential to prevent steep falloff artifacts).
  16386. */
  16387. get useBlurCloseExponentialShadowMap(): boolean;
  16388. /**
  16389. * Sets the current filter to filtered "close ESM" (using the inverse of the
  16390. * exponential to prevent steep falloff artifacts).
  16391. */
  16392. set useBlurCloseExponentialShadowMap(value: boolean);
  16393. /**
  16394. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  16395. */
  16396. get usePercentageCloserFiltering(): boolean;
  16397. /**
  16398. * Sets the current filter to "PCF" (percentage closer filtering).
  16399. */
  16400. set usePercentageCloserFiltering(value: boolean);
  16401. protected _filteringQuality: number;
  16402. /**
  16403. * Gets the PCF or PCSS Quality.
  16404. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16405. */
  16406. get filteringQuality(): number;
  16407. /**
  16408. * Sets the PCF or PCSS Quality.
  16409. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16410. */
  16411. set filteringQuality(filteringQuality: number);
  16412. /**
  16413. * Gets if the current filter is set to "PCSS" (contact hardening).
  16414. */
  16415. get useContactHardeningShadow(): boolean;
  16416. /**
  16417. * Sets the current filter to "PCSS" (contact hardening).
  16418. */
  16419. set useContactHardeningShadow(value: boolean);
  16420. protected _contactHardeningLightSizeUVRatio: number;
  16421. /**
  16422. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16423. * Using a ratio helps keeping shape stability independently of the map size.
  16424. *
  16425. * It does not account for the light projection as it was having too much
  16426. * instability during the light setup or during light position changes.
  16427. *
  16428. * Only valid if useContactHardeningShadow is true.
  16429. */
  16430. get contactHardeningLightSizeUVRatio(): number;
  16431. /**
  16432. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16433. * Using a ratio helps keeping shape stability independently of the map size.
  16434. *
  16435. * It does not account for the light projection as it was having too much
  16436. * instability during the light setup or during light position changes.
  16437. *
  16438. * Only valid if useContactHardeningShadow is true.
  16439. */
  16440. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  16441. protected _darkness: number;
  16442. /** Gets or sets the actual darkness of a shadow */
  16443. get darkness(): number;
  16444. set darkness(value: number);
  16445. /**
  16446. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  16447. * 0 means strongest and 1 would means no shadow.
  16448. * @returns the darkness.
  16449. */
  16450. getDarkness(): number;
  16451. /**
  16452. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  16453. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  16454. * @returns the shadow generator allowing fluent coding.
  16455. */
  16456. setDarkness(darkness: number): ShadowGenerator;
  16457. protected _transparencyShadow: boolean;
  16458. /** Gets or sets the ability to have transparent shadow */
  16459. get transparencyShadow(): boolean;
  16460. set transparencyShadow(value: boolean);
  16461. /**
  16462. * Sets the ability to have transparent shadow (boolean).
  16463. * @param transparent True if transparent else False
  16464. * @returns the shadow generator allowing fluent coding
  16465. */
  16466. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  16467. protected _shadowMap: Nullable<RenderTargetTexture>;
  16468. protected _shadowMap2: Nullable<RenderTargetTexture>;
  16469. /**
  16470. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16471. * @returns The render target texture if present otherwise, null
  16472. */
  16473. getShadowMap(): Nullable<RenderTargetTexture>;
  16474. /**
  16475. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  16476. * @returns The render target texture if the shadow map is present otherwise, null
  16477. */
  16478. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  16479. /**
  16480. * Gets the class name of that object
  16481. * @returns "ShadowGenerator"
  16482. */
  16483. getClassName(): string;
  16484. /**
  16485. * Helper function to add a mesh and its descendants to the list of shadow casters.
  16486. * @param mesh Mesh to add
  16487. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  16488. * @returns the Shadow Generator itself
  16489. */
  16490. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16491. /**
  16492. * Helper function to remove a mesh and its descendants from the list of shadow casters
  16493. * @param mesh Mesh to remove
  16494. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  16495. * @returns the Shadow Generator itself
  16496. */
  16497. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16498. /**
  16499. * Controls the extent to which the shadows fade out at the edge of the frustum
  16500. */
  16501. frustumEdgeFalloff: number;
  16502. protected _light: IShadowLight;
  16503. /**
  16504. * Returns the associated light object.
  16505. * @returns the light generating the shadow
  16506. */
  16507. getLight(): IShadowLight;
  16508. /**
  16509. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  16510. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  16511. * It might on the other hand introduce peter panning.
  16512. */
  16513. forceBackFacesOnly: boolean;
  16514. protected _scene: Scene;
  16515. protected _lightDirection: Vector3;
  16516. protected _effect: Effect;
  16517. protected _viewMatrix: Matrix;
  16518. protected _projectionMatrix: Matrix;
  16519. protected _transformMatrix: Matrix;
  16520. protected _cachedPosition: Vector3;
  16521. protected _cachedDirection: Vector3;
  16522. protected _cachedDefines: string;
  16523. protected _currentRenderID: number;
  16524. protected _boxBlurPostprocess: Nullable<PostProcess>;
  16525. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  16526. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  16527. protected _blurPostProcesses: PostProcess[];
  16528. protected _mapSize: number;
  16529. protected _currentFaceIndex: number;
  16530. protected _currentFaceIndexCache: number;
  16531. protected _textureType: number;
  16532. protected _defaultTextureMatrix: Matrix;
  16533. protected _storedUniqueId: Nullable<number>;
  16534. /** @hidden */
  16535. static _SceneComponentInitialization: (scene: Scene) => void;
  16536. /**
  16537. * Creates a ShadowGenerator object.
  16538. * A ShadowGenerator is the required tool to use the shadows.
  16539. * Each light casting shadows needs to use its own ShadowGenerator.
  16540. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  16541. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  16542. * @param light The light object generating the shadows.
  16543. * @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.
  16544. */
  16545. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  16546. protected _initializeGenerator(): void;
  16547. protected _createTargetRenderTexture(): void;
  16548. protected _initializeShadowMap(): void;
  16549. protected _initializeBlurRTTAndPostProcesses(): void;
  16550. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  16551. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  16552. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  16553. protected _applyFilterValues(): void;
  16554. /**
  16555. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16556. * @param onCompiled Callback triggered at the and of the effects compilation
  16557. * @param options Sets of optional options forcing the compilation with different modes
  16558. */
  16559. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16560. useInstances: boolean;
  16561. }>): void;
  16562. /**
  16563. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16564. * @param options Sets of optional options forcing the compilation with different modes
  16565. * @returns A promise that resolves when the compilation completes
  16566. */
  16567. forceCompilationAsync(options?: Partial<{
  16568. useInstances: boolean;
  16569. }>): Promise<void>;
  16570. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  16571. /**
  16572. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16573. * @param subMesh The submesh we want to render in the shadow map
  16574. * @param useInstances Defines wether will draw in the map using instances
  16575. * @returns true if ready otherwise, false
  16576. */
  16577. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16578. /**
  16579. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16580. * @param defines Defines of the material we want to update
  16581. * @param lightIndex Index of the light in the enabled light list of the material
  16582. */
  16583. prepareDefines(defines: any, lightIndex: number): void;
  16584. /**
  16585. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16586. * defined in the generator but impacting the effect).
  16587. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16588. * @param effect The effect we are binfing the information for
  16589. */
  16590. bindShadowLight(lightIndex: string, effect: Effect): void;
  16591. /**
  16592. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16593. * (eq to shadow prjection matrix * light transform matrix)
  16594. * @returns The transform matrix used to create the shadow map
  16595. */
  16596. getTransformMatrix(): Matrix;
  16597. /**
  16598. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16599. * Cube and 2D textures for instance.
  16600. */
  16601. recreateShadowMap(): void;
  16602. protected _disposeBlurPostProcesses(): void;
  16603. protected _disposeRTTandPostProcesses(): void;
  16604. /**
  16605. * Disposes the ShadowGenerator.
  16606. * Returns nothing.
  16607. */
  16608. dispose(): void;
  16609. /**
  16610. * Serializes the shadow generator setup to a json object.
  16611. * @returns The serialized JSON object
  16612. */
  16613. serialize(): any;
  16614. /**
  16615. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  16616. * @param parsedShadowGenerator The JSON object to parse
  16617. * @param scene The scene to create the shadow map for
  16618. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  16619. * @returns The parsed shadow generator
  16620. */
  16621. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  16622. }
  16623. }
  16624. declare module BABYLON {
  16625. /**
  16626. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  16627. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  16628. * 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.
  16629. */
  16630. export abstract class Light extends Node {
  16631. /**
  16632. * Falloff Default: light is falling off following the material specification:
  16633. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  16634. */
  16635. static readonly FALLOFF_DEFAULT: number;
  16636. /**
  16637. * Falloff Physical: light is falling off following the inverse squared distance law.
  16638. */
  16639. static readonly FALLOFF_PHYSICAL: number;
  16640. /**
  16641. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  16642. * to enhance interoperability with other engines.
  16643. */
  16644. static readonly FALLOFF_GLTF: number;
  16645. /**
  16646. * Falloff Standard: light is falling off like in the standard material
  16647. * to enhance interoperability with other materials.
  16648. */
  16649. static readonly FALLOFF_STANDARD: number;
  16650. /**
  16651. * If every light affecting the material is in this lightmapMode,
  16652. * material.lightmapTexture adds or multiplies
  16653. * (depends on material.useLightmapAsShadowmap)
  16654. * after every other light calculations.
  16655. */
  16656. static readonly LIGHTMAP_DEFAULT: number;
  16657. /**
  16658. * material.lightmapTexture as only diffuse lighting from this light
  16659. * adds only specular lighting from this light
  16660. * adds dynamic shadows
  16661. */
  16662. static readonly LIGHTMAP_SPECULAR: number;
  16663. /**
  16664. * material.lightmapTexture as only lighting
  16665. * no light calculation from this light
  16666. * only adds dynamic shadows from this light
  16667. */
  16668. static readonly LIGHTMAP_SHADOWSONLY: number;
  16669. /**
  16670. * Each light type uses the default quantity according to its type:
  16671. * point/spot lights use luminous intensity
  16672. * directional lights use illuminance
  16673. */
  16674. static readonly INTENSITYMODE_AUTOMATIC: number;
  16675. /**
  16676. * lumen (lm)
  16677. */
  16678. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  16679. /**
  16680. * candela (lm/sr)
  16681. */
  16682. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  16683. /**
  16684. * lux (lm/m^2)
  16685. */
  16686. static readonly INTENSITYMODE_ILLUMINANCE: number;
  16687. /**
  16688. * nit (cd/m^2)
  16689. */
  16690. static readonly INTENSITYMODE_LUMINANCE: number;
  16691. /**
  16692. * Light type const id of the point light.
  16693. */
  16694. static readonly LIGHTTYPEID_POINTLIGHT: number;
  16695. /**
  16696. * Light type const id of the directional light.
  16697. */
  16698. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  16699. /**
  16700. * Light type const id of the spot light.
  16701. */
  16702. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  16703. /**
  16704. * Light type const id of the hemispheric light.
  16705. */
  16706. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  16707. /**
  16708. * Diffuse gives the basic color to an object.
  16709. */
  16710. diffuse: Color3;
  16711. /**
  16712. * Specular produces a highlight color on an object.
  16713. * Note: This is note affecting PBR materials.
  16714. */
  16715. specular: Color3;
  16716. /**
  16717. * Defines the falloff type for this light. This lets overrriding how punctual light are
  16718. * falling off base on range or angle.
  16719. * This can be set to any values in Light.FALLOFF_x.
  16720. *
  16721. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  16722. * other types of materials.
  16723. */
  16724. falloffType: number;
  16725. /**
  16726. * Strength of the light.
  16727. * Note: By default it is define in the framework own unit.
  16728. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  16729. */
  16730. intensity: number;
  16731. private _range;
  16732. protected _inverseSquaredRange: number;
  16733. /**
  16734. * Defines how far from the source the light is impacting in scene units.
  16735. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  16736. */
  16737. get range(): number;
  16738. /**
  16739. * Defines how far from the source the light is impacting in scene units.
  16740. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  16741. */
  16742. set range(value: number);
  16743. /**
  16744. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  16745. * of light.
  16746. */
  16747. private _photometricScale;
  16748. private _intensityMode;
  16749. /**
  16750. * Gets the photometric scale used to interpret the intensity.
  16751. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  16752. */
  16753. get intensityMode(): number;
  16754. /**
  16755. * Sets the photometric scale used to interpret the intensity.
  16756. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  16757. */
  16758. set intensityMode(value: number);
  16759. private _radius;
  16760. /**
  16761. * Gets the light radius used by PBR Materials to simulate soft area lights.
  16762. */
  16763. get radius(): number;
  16764. /**
  16765. * sets the light radius used by PBR Materials to simulate soft area lights.
  16766. */
  16767. set radius(value: number);
  16768. private _renderPriority;
  16769. /**
  16770. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  16771. * exceeding the number allowed of the materials.
  16772. */
  16773. renderPriority: number;
  16774. private _shadowEnabled;
  16775. /**
  16776. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  16777. * the current shadow generator.
  16778. */
  16779. get shadowEnabled(): boolean;
  16780. /**
  16781. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  16782. * the current shadow generator.
  16783. */
  16784. set shadowEnabled(value: boolean);
  16785. private _includedOnlyMeshes;
  16786. /**
  16787. * Gets the only meshes impacted by this light.
  16788. */
  16789. get includedOnlyMeshes(): AbstractMesh[];
  16790. /**
  16791. * Sets the only meshes impacted by this light.
  16792. */
  16793. set includedOnlyMeshes(value: AbstractMesh[]);
  16794. private _excludedMeshes;
  16795. /**
  16796. * Gets the meshes not impacted by this light.
  16797. */
  16798. get excludedMeshes(): AbstractMesh[];
  16799. /**
  16800. * Sets the meshes not impacted by this light.
  16801. */
  16802. set excludedMeshes(value: AbstractMesh[]);
  16803. private _excludeWithLayerMask;
  16804. /**
  16805. * Gets the layer id use to find what meshes are not impacted by the light.
  16806. * Inactive if 0
  16807. */
  16808. get excludeWithLayerMask(): number;
  16809. /**
  16810. * Sets the layer id use to find what meshes are not impacted by the light.
  16811. * Inactive if 0
  16812. */
  16813. set excludeWithLayerMask(value: number);
  16814. private _includeOnlyWithLayerMask;
  16815. /**
  16816. * Gets the layer id use to find what meshes are impacted by the light.
  16817. * Inactive if 0
  16818. */
  16819. get includeOnlyWithLayerMask(): number;
  16820. /**
  16821. * Sets the layer id use to find what meshes are impacted by the light.
  16822. * Inactive if 0
  16823. */
  16824. set includeOnlyWithLayerMask(value: number);
  16825. private _lightmapMode;
  16826. /**
  16827. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  16828. */
  16829. get lightmapMode(): number;
  16830. /**
  16831. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  16832. */
  16833. set lightmapMode(value: number);
  16834. /**
  16835. * Shadow generator associted to the light.
  16836. * @hidden Internal use only.
  16837. */
  16838. _shadowGenerator: Nullable<IShadowGenerator>;
  16839. /**
  16840. * @hidden Internal use only.
  16841. */
  16842. _excludedMeshesIds: string[];
  16843. /**
  16844. * @hidden Internal use only.
  16845. */
  16846. _includedOnlyMeshesIds: string[];
  16847. /**
  16848. * The current light unifom buffer.
  16849. * @hidden Internal use only.
  16850. */
  16851. _uniformBuffer: UniformBuffer;
  16852. /** @hidden */
  16853. _renderId: number;
  16854. /**
  16855. * Creates a Light object in the scene.
  16856. * Documentation : https://doc.babylonjs.com/babylon101/lights
  16857. * @param name The firendly name of the light
  16858. * @param scene The scene the light belongs too
  16859. */
  16860. constructor(name: string, scene: Scene);
  16861. protected abstract _buildUniformLayout(): void;
  16862. /**
  16863. * Sets the passed Effect "effect" with the Light information.
  16864. * @param effect The effect to update
  16865. * @param lightIndex The index of the light in the effect to update
  16866. * @returns The light
  16867. */
  16868. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  16869. /**
  16870. * Sets the passed Effect "effect" with the Light textures.
  16871. * @param effect The effect to update
  16872. * @param lightIndex The index of the light in the effect to update
  16873. * @returns The light
  16874. */
  16875. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  16876. /**
  16877. * Binds the lights information from the scene to the effect for the given mesh.
  16878. * @param lightIndex Light index
  16879. * @param scene The scene where the light belongs to
  16880. * @param effect The effect we are binding the data to
  16881. * @param useSpecular Defines if specular is supported
  16882. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  16883. */
  16884. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  16885. /**
  16886. * Sets the passed Effect "effect" with the Light information.
  16887. * @param effect The effect to update
  16888. * @param lightDataUniformName The uniform used to store light data (position or direction)
  16889. * @returns The light
  16890. */
  16891. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  16892. /**
  16893. * Returns the string "Light".
  16894. * @returns the class name
  16895. */
  16896. getClassName(): string;
  16897. /** @hidden */
  16898. readonly _isLight: boolean;
  16899. /**
  16900. * Converts the light information to a readable string for debug purpose.
  16901. * @param fullDetails Supports for multiple levels of logging within scene loading
  16902. * @returns the human readable light info
  16903. */
  16904. toString(fullDetails?: boolean): string;
  16905. /** @hidden */
  16906. protected _syncParentEnabledState(): void;
  16907. /**
  16908. * Set the enabled state of this node.
  16909. * @param value - the new enabled state
  16910. */
  16911. setEnabled(value: boolean): void;
  16912. /**
  16913. * Returns the Light associated shadow generator if any.
  16914. * @return the associated shadow generator.
  16915. */
  16916. getShadowGenerator(): Nullable<IShadowGenerator>;
  16917. /**
  16918. * Returns a Vector3, the absolute light position in the World.
  16919. * @returns the world space position of the light
  16920. */
  16921. getAbsolutePosition(): Vector3;
  16922. /**
  16923. * Specifies if the light will affect the passed mesh.
  16924. * @param mesh The mesh to test against the light
  16925. * @return true the mesh is affected otherwise, false.
  16926. */
  16927. canAffectMesh(mesh: AbstractMesh): boolean;
  16928. /**
  16929. * Sort function to order lights for rendering.
  16930. * @param a First Light object to compare to second.
  16931. * @param b Second Light object to compare first.
  16932. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  16933. */
  16934. static CompareLightsPriority(a: Light, b: Light): number;
  16935. /**
  16936. * Releases resources associated with this node.
  16937. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  16938. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  16939. */
  16940. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16941. /**
  16942. * Returns the light type ID (integer).
  16943. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  16944. */
  16945. getTypeID(): number;
  16946. /**
  16947. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  16948. * @returns the scaled intensity in intensity mode unit
  16949. */
  16950. getScaledIntensity(): number;
  16951. /**
  16952. * Returns a new Light object, named "name", from the current one.
  16953. * @param name The name of the cloned light
  16954. * @returns the new created light
  16955. */
  16956. clone(name: string): Nullable<Light>;
  16957. /**
  16958. * Serializes the current light into a Serialization object.
  16959. * @returns the serialized object.
  16960. */
  16961. serialize(): any;
  16962. /**
  16963. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  16964. * This new light is named "name" and added to the passed scene.
  16965. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  16966. * @param name The friendly name of the light
  16967. * @param scene The scene the new light will belong to
  16968. * @returns the constructor function
  16969. */
  16970. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  16971. /**
  16972. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  16973. * @param parsedLight The JSON representation of the light
  16974. * @param scene The scene to create the parsed light in
  16975. * @returns the created light after parsing
  16976. */
  16977. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  16978. private _hookArrayForExcluded;
  16979. private _hookArrayForIncludedOnly;
  16980. private _resyncMeshes;
  16981. /**
  16982. * Forces the meshes to update their light related information in their rendering used effects
  16983. * @hidden Internal Use Only
  16984. */
  16985. _markMeshesAsLightDirty(): void;
  16986. /**
  16987. * Recomputes the cached photometric scale if needed.
  16988. */
  16989. private _computePhotometricScale;
  16990. /**
  16991. * Returns the Photometric Scale according to the light type and intensity mode.
  16992. */
  16993. private _getPhotometricScale;
  16994. /**
  16995. * Reorder the light in the scene according to their defined priority.
  16996. * @hidden Internal Use Only
  16997. */
  16998. _reorderLightsInScene(): void;
  16999. /**
  17000. * Prepares the list of defines specific to the light type.
  17001. * @param defines the list of defines
  17002. * @param lightIndex defines the index of the light for the effect
  17003. */
  17004. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17005. }
  17006. }
  17007. declare module BABYLON {
  17008. /**
  17009. * Interface used to define Action
  17010. */
  17011. export interface IAction {
  17012. /**
  17013. * Trigger for the action
  17014. */
  17015. trigger: number;
  17016. /** Options of the trigger */
  17017. triggerOptions: any;
  17018. /**
  17019. * Gets the trigger parameters
  17020. * @returns the trigger parameters
  17021. */
  17022. getTriggerParameter(): any;
  17023. /**
  17024. * Internal only - executes current action event
  17025. * @hidden
  17026. */
  17027. _executeCurrent(evt?: ActionEvent): void;
  17028. /**
  17029. * Serialize placeholder for child classes
  17030. * @param parent of child
  17031. * @returns the serialized object
  17032. */
  17033. serialize(parent: any): any;
  17034. /**
  17035. * Internal only
  17036. * @hidden
  17037. */
  17038. _prepare(): void;
  17039. /**
  17040. * Internal only - manager for action
  17041. * @hidden
  17042. */
  17043. _actionManager: AbstractActionManager;
  17044. /**
  17045. * Adds action to chain of actions, may be a DoNothingAction
  17046. * @param action defines the next action to execute
  17047. * @returns The action passed in
  17048. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17049. */
  17050. then(action: IAction): IAction;
  17051. }
  17052. /**
  17053. * The action to be carried out following a trigger
  17054. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  17055. */
  17056. export class Action implements IAction {
  17057. /** the trigger, with or without parameters, for the action */
  17058. triggerOptions: any;
  17059. /**
  17060. * Trigger for the action
  17061. */
  17062. trigger: number;
  17063. /**
  17064. * Internal only - manager for action
  17065. * @hidden
  17066. */
  17067. _actionManager: ActionManager;
  17068. private _nextActiveAction;
  17069. private _child;
  17070. private _condition?;
  17071. private _triggerParameter;
  17072. /**
  17073. * An event triggered prior to action being executed.
  17074. */
  17075. onBeforeExecuteObservable: Observable<Action>;
  17076. /**
  17077. * Creates a new Action
  17078. * @param triggerOptions the trigger, with or without parameters, for the action
  17079. * @param condition an optional determinant of action
  17080. */
  17081. constructor(
  17082. /** the trigger, with or without parameters, for the action */
  17083. triggerOptions: any, condition?: Condition);
  17084. /**
  17085. * Internal only
  17086. * @hidden
  17087. */
  17088. _prepare(): void;
  17089. /**
  17090. * Gets the trigger parameters
  17091. * @returns the trigger parameters
  17092. */
  17093. getTriggerParameter(): any;
  17094. /**
  17095. * Internal only - executes current action event
  17096. * @hidden
  17097. */
  17098. _executeCurrent(evt?: ActionEvent): void;
  17099. /**
  17100. * Execute placeholder for child classes
  17101. * @param evt optional action event
  17102. */
  17103. execute(evt?: ActionEvent): void;
  17104. /**
  17105. * Skips to next active action
  17106. */
  17107. skipToNextActiveAction(): void;
  17108. /**
  17109. * Adds action to chain of actions, may be a DoNothingAction
  17110. * @param action defines the next action to execute
  17111. * @returns The action passed in
  17112. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17113. */
  17114. then(action: Action): Action;
  17115. /**
  17116. * Internal only
  17117. * @hidden
  17118. */
  17119. _getProperty(propertyPath: string): string;
  17120. /**
  17121. * Internal only
  17122. * @hidden
  17123. */
  17124. _getEffectiveTarget(target: any, propertyPath: string): any;
  17125. /**
  17126. * Serialize placeholder for child classes
  17127. * @param parent of child
  17128. * @returns the serialized object
  17129. */
  17130. serialize(parent: any): any;
  17131. /**
  17132. * Internal only called by serialize
  17133. * @hidden
  17134. */
  17135. protected _serialize(serializedAction: any, parent?: any): any;
  17136. /**
  17137. * Internal only
  17138. * @hidden
  17139. */
  17140. static _SerializeValueAsString: (value: any) => string;
  17141. /**
  17142. * Internal only
  17143. * @hidden
  17144. */
  17145. static _GetTargetProperty: (target: Node | Scene) => {
  17146. name: string;
  17147. targetType: string;
  17148. value: string;
  17149. };
  17150. }
  17151. }
  17152. declare module BABYLON {
  17153. /**
  17154. * A Condition applied to an Action
  17155. */
  17156. export class Condition {
  17157. /**
  17158. * Internal only - manager for action
  17159. * @hidden
  17160. */
  17161. _actionManager: ActionManager;
  17162. /**
  17163. * Internal only
  17164. * @hidden
  17165. */
  17166. _evaluationId: number;
  17167. /**
  17168. * Internal only
  17169. * @hidden
  17170. */
  17171. _currentResult: boolean;
  17172. /**
  17173. * Creates a new Condition
  17174. * @param actionManager the manager of the action the condition is applied to
  17175. */
  17176. constructor(actionManager: ActionManager);
  17177. /**
  17178. * Check if the current condition is valid
  17179. * @returns a boolean
  17180. */
  17181. isValid(): boolean;
  17182. /**
  17183. * Internal only
  17184. * @hidden
  17185. */
  17186. _getProperty(propertyPath: string): string;
  17187. /**
  17188. * Internal only
  17189. * @hidden
  17190. */
  17191. _getEffectiveTarget(target: any, propertyPath: string): any;
  17192. /**
  17193. * Serialize placeholder for child classes
  17194. * @returns the serialized object
  17195. */
  17196. serialize(): any;
  17197. /**
  17198. * Internal only
  17199. * @hidden
  17200. */
  17201. protected _serialize(serializedCondition: any): any;
  17202. }
  17203. /**
  17204. * Defines specific conditional operators as extensions of Condition
  17205. */
  17206. export class ValueCondition extends Condition {
  17207. /** path to specify the property of the target the conditional operator uses */
  17208. propertyPath: string;
  17209. /** the value compared by the conditional operator against the current value of the property */
  17210. value: any;
  17211. /** the conditional operator, default ValueCondition.IsEqual */
  17212. operator: number;
  17213. /**
  17214. * Internal only
  17215. * @hidden
  17216. */
  17217. private static _IsEqual;
  17218. /**
  17219. * Internal only
  17220. * @hidden
  17221. */
  17222. private static _IsDifferent;
  17223. /**
  17224. * Internal only
  17225. * @hidden
  17226. */
  17227. private static _IsGreater;
  17228. /**
  17229. * Internal only
  17230. * @hidden
  17231. */
  17232. private static _IsLesser;
  17233. /**
  17234. * returns the number for IsEqual
  17235. */
  17236. static get IsEqual(): number;
  17237. /**
  17238. * Returns the number for IsDifferent
  17239. */
  17240. static get IsDifferent(): number;
  17241. /**
  17242. * Returns the number for IsGreater
  17243. */
  17244. static get IsGreater(): number;
  17245. /**
  17246. * Returns the number for IsLesser
  17247. */
  17248. static get IsLesser(): number;
  17249. /**
  17250. * Internal only The action manager for the condition
  17251. * @hidden
  17252. */
  17253. _actionManager: ActionManager;
  17254. /**
  17255. * Internal only
  17256. * @hidden
  17257. */
  17258. private _target;
  17259. /**
  17260. * Internal only
  17261. * @hidden
  17262. */
  17263. private _effectiveTarget;
  17264. /**
  17265. * Internal only
  17266. * @hidden
  17267. */
  17268. private _property;
  17269. /**
  17270. * Creates a new ValueCondition
  17271. * @param actionManager manager for the action the condition applies to
  17272. * @param target for the action
  17273. * @param propertyPath path to specify the property of the target the conditional operator uses
  17274. * @param value the value compared by the conditional operator against the current value of the property
  17275. * @param operator the conditional operator, default ValueCondition.IsEqual
  17276. */
  17277. constructor(actionManager: ActionManager, target: any,
  17278. /** path to specify the property of the target the conditional operator uses */
  17279. propertyPath: string,
  17280. /** the value compared by the conditional operator against the current value of the property */
  17281. value: any,
  17282. /** the conditional operator, default ValueCondition.IsEqual */
  17283. operator?: number);
  17284. /**
  17285. * Compares the given value with the property value for the specified conditional operator
  17286. * @returns the result of the comparison
  17287. */
  17288. isValid(): boolean;
  17289. /**
  17290. * Serialize the ValueCondition into a JSON compatible object
  17291. * @returns serialization object
  17292. */
  17293. serialize(): any;
  17294. /**
  17295. * Gets the name of the conditional operator for the ValueCondition
  17296. * @param operator the conditional operator
  17297. * @returns the name
  17298. */
  17299. static GetOperatorName(operator: number): string;
  17300. }
  17301. /**
  17302. * Defines a predicate condition as an extension of Condition
  17303. */
  17304. export class PredicateCondition extends Condition {
  17305. /** defines the predicate function used to validate the condition */
  17306. predicate: () => boolean;
  17307. /**
  17308. * Internal only - manager for action
  17309. * @hidden
  17310. */
  17311. _actionManager: ActionManager;
  17312. /**
  17313. * Creates a new PredicateCondition
  17314. * @param actionManager manager for the action the condition applies to
  17315. * @param predicate defines the predicate function used to validate the condition
  17316. */
  17317. constructor(actionManager: ActionManager,
  17318. /** defines the predicate function used to validate the condition */
  17319. predicate: () => boolean);
  17320. /**
  17321. * @returns the validity of the predicate condition
  17322. */
  17323. isValid(): boolean;
  17324. }
  17325. /**
  17326. * Defines a state condition as an extension of Condition
  17327. */
  17328. export class StateCondition extends Condition {
  17329. /** Value to compare with target state */
  17330. value: string;
  17331. /**
  17332. * Internal only - manager for action
  17333. * @hidden
  17334. */
  17335. _actionManager: ActionManager;
  17336. /**
  17337. * Internal only
  17338. * @hidden
  17339. */
  17340. private _target;
  17341. /**
  17342. * Creates a new StateCondition
  17343. * @param actionManager manager for the action the condition applies to
  17344. * @param target of the condition
  17345. * @param value to compare with target state
  17346. */
  17347. constructor(actionManager: ActionManager, target: any,
  17348. /** Value to compare with target state */
  17349. value: string);
  17350. /**
  17351. * Gets a boolean indicating if the current condition is met
  17352. * @returns the validity of the state
  17353. */
  17354. isValid(): boolean;
  17355. /**
  17356. * Serialize the StateCondition into a JSON compatible object
  17357. * @returns serialization object
  17358. */
  17359. serialize(): any;
  17360. }
  17361. }
  17362. declare module BABYLON {
  17363. /**
  17364. * This defines an action responsible to toggle a boolean once triggered.
  17365. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17366. */
  17367. export class SwitchBooleanAction extends Action {
  17368. /**
  17369. * The path to the boolean property in the target object
  17370. */
  17371. propertyPath: string;
  17372. private _target;
  17373. private _effectiveTarget;
  17374. private _property;
  17375. /**
  17376. * Instantiate the action
  17377. * @param triggerOptions defines the trigger options
  17378. * @param target defines the object containing the boolean
  17379. * @param propertyPath defines the path to the boolean property in the target object
  17380. * @param condition defines the trigger related conditions
  17381. */
  17382. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  17383. /** @hidden */
  17384. _prepare(): void;
  17385. /**
  17386. * Execute the action toggle the boolean value.
  17387. */
  17388. execute(): void;
  17389. /**
  17390. * Serializes the actions and its related information.
  17391. * @param parent defines the object to serialize in
  17392. * @returns the serialized object
  17393. */
  17394. serialize(parent: any): any;
  17395. }
  17396. /**
  17397. * This defines an action responsible to set a the state field of the target
  17398. * to a desired value once triggered.
  17399. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17400. */
  17401. export class SetStateAction extends Action {
  17402. /**
  17403. * The value to store in the state field.
  17404. */
  17405. value: string;
  17406. private _target;
  17407. /**
  17408. * Instantiate the action
  17409. * @param triggerOptions defines the trigger options
  17410. * @param target defines the object containing the state property
  17411. * @param value defines the value to store in the state field
  17412. * @param condition defines the trigger related conditions
  17413. */
  17414. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  17415. /**
  17416. * Execute the action and store the value on the target state property.
  17417. */
  17418. execute(): void;
  17419. /**
  17420. * Serializes the actions and its related information.
  17421. * @param parent defines the object to serialize in
  17422. * @returns the serialized object
  17423. */
  17424. serialize(parent: any): any;
  17425. }
  17426. /**
  17427. * This defines an action responsible to set a property of the target
  17428. * to a desired value once triggered.
  17429. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17430. */
  17431. export class SetValueAction extends Action {
  17432. /**
  17433. * The path of the property to set in the target.
  17434. */
  17435. propertyPath: string;
  17436. /**
  17437. * The value to set in the property
  17438. */
  17439. value: any;
  17440. private _target;
  17441. private _effectiveTarget;
  17442. private _property;
  17443. /**
  17444. * Instantiate the action
  17445. * @param triggerOptions defines the trigger options
  17446. * @param target defines the object containing the property
  17447. * @param propertyPath defines the path of the property to set in the target
  17448. * @param value defines the value to set in the property
  17449. * @param condition defines the trigger related conditions
  17450. */
  17451. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17452. /** @hidden */
  17453. _prepare(): void;
  17454. /**
  17455. * Execute the action and set the targetted property to the desired value.
  17456. */
  17457. execute(): void;
  17458. /**
  17459. * Serializes the actions and its related information.
  17460. * @param parent defines the object to serialize in
  17461. * @returns the serialized object
  17462. */
  17463. serialize(parent: any): any;
  17464. }
  17465. /**
  17466. * This defines an action responsible to increment the target value
  17467. * to a desired value once triggered.
  17468. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17469. */
  17470. export class IncrementValueAction extends Action {
  17471. /**
  17472. * The path of the property to increment in the target.
  17473. */
  17474. propertyPath: string;
  17475. /**
  17476. * The value we should increment the property by.
  17477. */
  17478. value: any;
  17479. private _target;
  17480. private _effectiveTarget;
  17481. private _property;
  17482. /**
  17483. * Instantiate the action
  17484. * @param triggerOptions defines the trigger options
  17485. * @param target defines the object containing the property
  17486. * @param propertyPath defines the path of the property to increment in the target
  17487. * @param value defines the value value we should increment the property by
  17488. * @param condition defines the trigger related conditions
  17489. */
  17490. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17491. /** @hidden */
  17492. _prepare(): void;
  17493. /**
  17494. * Execute the action and increment the target of the value amount.
  17495. */
  17496. execute(): void;
  17497. /**
  17498. * Serializes the actions and its related information.
  17499. * @param parent defines the object to serialize in
  17500. * @returns the serialized object
  17501. */
  17502. serialize(parent: any): any;
  17503. }
  17504. /**
  17505. * This defines an action responsible to start an animation once triggered.
  17506. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17507. */
  17508. export class PlayAnimationAction extends Action {
  17509. /**
  17510. * Where the animation should start (animation frame)
  17511. */
  17512. from: number;
  17513. /**
  17514. * Where the animation should stop (animation frame)
  17515. */
  17516. to: number;
  17517. /**
  17518. * Define if the animation should loop or stop after the first play.
  17519. */
  17520. loop?: boolean;
  17521. private _target;
  17522. /**
  17523. * Instantiate the action
  17524. * @param triggerOptions defines the trigger options
  17525. * @param target defines the target animation or animation name
  17526. * @param from defines from where the animation should start (animation frame)
  17527. * @param end defines where the animation should stop (animation frame)
  17528. * @param loop defines if the animation should loop or stop after the first play
  17529. * @param condition defines the trigger related conditions
  17530. */
  17531. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  17532. /** @hidden */
  17533. _prepare(): void;
  17534. /**
  17535. * Execute the action and play the animation.
  17536. */
  17537. execute(): void;
  17538. /**
  17539. * Serializes the actions and its related information.
  17540. * @param parent defines the object to serialize in
  17541. * @returns the serialized object
  17542. */
  17543. serialize(parent: any): any;
  17544. }
  17545. /**
  17546. * This defines an action responsible to stop an animation once triggered.
  17547. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17548. */
  17549. export class StopAnimationAction extends Action {
  17550. private _target;
  17551. /**
  17552. * Instantiate the action
  17553. * @param triggerOptions defines the trigger options
  17554. * @param target defines the target animation or animation name
  17555. * @param condition defines the trigger related conditions
  17556. */
  17557. constructor(triggerOptions: any, target: any, condition?: Condition);
  17558. /** @hidden */
  17559. _prepare(): void;
  17560. /**
  17561. * Execute the action and stop the animation.
  17562. */
  17563. execute(): void;
  17564. /**
  17565. * Serializes the actions and its related information.
  17566. * @param parent defines the object to serialize in
  17567. * @returns the serialized object
  17568. */
  17569. serialize(parent: any): any;
  17570. }
  17571. /**
  17572. * This defines an action responsible that does nothing once triggered.
  17573. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17574. */
  17575. export class DoNothingAction extends Action {
  17576. /**
  17577. * Instantiate the action
  17578. * @param triggerOptions defines the trigger options
  17579. * @param condition defines the trigger related conditions
  17580. */
  17581. constructor(triggerOptions?: any, condition?: Condition);
  17582. /**
  17583. * Execute the action and do nothing.
  17584. */
  17585. execute(): void;
  17586. /**
  17587. * Serializes the actions and its related information.
  17588. * @param parent defines the object to serialize in
  17589. * @returns the serialized object
  17590. */
  17591. serialize(parent: any): any;
  17592. }
  17593. /**
  17594. * This defines an action responsible to trigger several actions once triggered.
  17595. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17596. */
  17597. export class CombineAction extends Action {
  17598. /**
  17599. * The list of aggregated animations to run.
  17600. */
  17601. children: Action[];
  17602. /**
  17603. * Instantiate the action
  17604. * @param triggerOptions defines the trigger options
  17605. * @param children defines the list of aggregated animations to run
  17606. * @param condition defines the trigger related conditions
  17607. */
  17608. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  17609. /** @hidden */
  17610. _prepare(): void;
  17611. /**
  17612. * Execute the action and executes all the aggregated actions.
  17613. */
  17614. execute(evt: ActionEvent): void;
  17615. /**
  17616. * Serializes the actions and its related information.
  17617. * @param parent defines the object to serialize in
  17618. * @returns the serialized object
  17619. */
  17620. serialize(parent: any): any;
  17621. }
  17622. /**
  17623. * This defines an action responsible to run code (external event) once triggered.
  17624. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17625. */
  17626. export class ExecuteCodeAction extends Action {
  17627. /**
  17628. * The callback function to run.
  17629. */
  17630. func: (evt: ActionEvent) => void;
  17631. /**
  17632. * Instantiate the action
  17633. * @param triggerOptions defines the trigger options
  17634. * @param func defines the callback function to run
  17635. * @param condition defines the trigger related conditions
  17636. */
  17637. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  17638. /**
  17639. * Execute the action and run the attached code.
  17640. */
  17641. execute(evt: ActionEvent): void;
  17642. }
  17643. /**
  17644. * This defines an action responsible to set the parent property of the target once triggered.
  17645. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17646. */
  17647. export class SetParentAction extends Action {
  17648. private _parent;
  17649. private _target;
  17650. /**
  17651. * Instantiate the action
  17652. * @param triggerOptions defines the trigger options
  17653. * @param target defines the target containing the parent property
  17654. * @param parent defines from where the animation should start (animation frame)
  17655. * @param condition defines the trigger related conditions
  17656. */
  17657. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  17658. /** @hidden */
  17659. _prepare(): void;
  17660. /**
  17661. * Execute the action and set the parent property.
  17662. */
  17663. execute(): void;
  17664. /**
  17665. * Serializes the actions and its related information.
  17666. * @param parent defines the object to serialize in
  17667. * @returns the serialized object
  17668. */
  17669. serialize(parent: any): any;
  17670. }
  17671. }
  17672. declare module BABYLON {
  17673. /**
  17674. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  17675. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  17676. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17677. */
  17678. export class ActionManager extends AbstractActionManager {
  17679. /**
  17680. * Nothing
  17681. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17682. */
  17683. static readonly NothingTrigger: number;
  17684. /**
  17685. * On pick
  17686. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17687. */
  17688. static readonly OnPickTrigger: number;
  17689. /**
  17690. * On left pick
  17691. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17692. */
  17693. static readonly OnLeftPickTrigger: number;
  17694. /**
  17695. * On right pick
  17696. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17697. */
  17698. static readonly OnRightPickTrigger: number;
  17699. /**
  17700. * On center pick
  17701. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17702. */
  17703. static readonly OnCenterPickTrigger: number;
  17704. /**
  17705. * On pick down
  17706. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17707. */
  17708. static readonly OnPickDownTrigger: number;
  17709. /**
  17710. * On double pick
  17711. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17712. */
  17713. static readonly OnDoublePickTrigger: number;
  17714. /**
  17715. * On pick up
  17716. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17717. */
  17718. static readonly OnPickUpTrigger: number;
  17719. /**
  17720. * On pick out.
  17721. * This trigger will only be raised if you also declared a OnPickDown
  17722. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17723. */
  17724. static readonly OnPickOutTrigger: number;
  17725. /**
  17726. * On long press
  17727. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17728. */
  17729. static readonly OnLongPressTrigger: number;
  17730. /**
  17731. * On pointer over
  17732. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17733. */
  17734. static readonly OnPointerOverTrigger: number;
  17735. /**
  17736. * On pointer out
  17737. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17738. */
  17739. static readonly OnPointerOutTrigger: number;
  17740. /**
  17741. * On every frame
  17742. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17743. */
  17744. static readonly OnEveryFrameTrigger: number;
  17745. /**
  17746. * On intersection enter
  17747. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17748. */
  17749. static readonly OnIntersectionEnterTrigger: number;
  17750. /**
  17751. * On intersection exit
  17752. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17753. */
  17754. static readonly OnIntersectionExitTrigger: number;
  17755. /**
  17756. * On key down
  17757. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17758. */
  17759. static readonly OnKeyDownTrigger: number;
  17760. /**
  17761. * On key up
  17762. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  17763. */
  17764. static readonly OnKeyUpTrigger: number;
  17765. private _scene;
  17766. /**
  17767. * Creates a new action manager
  17768. * @param scene defines the hosting scene
  17769. */
  17770. constructor(scene: Scene);
  17771. /**
  17772. * Releases all associated resources
  17773. */
  17774. dispose(): void;
  17775. /**
  17776. * Gets hosting scene
  17777. * @returns the hosting scene
  17778. */
  17779. getScene(): Scene;
  17780. /**
  17781. * Does this action manager handles actions of any of the given triggers
  17782. * @param triggers defines the triggers to be tested
  17783. * @return a boolean indicating whether one (or more) of the triggers is handled
  17784. */
  17785. hasSpecificTriggers(triggers: number[]): boolean;
  17786. /**
  17787. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  17788. * speed.
  17789. * @param triggerA defines the trigger to be tested
  17790. * @param triggerB defines the trigger to be tested
  17791. * @return a boolean indicating whether one (or more) of the triggers is handled
  17792. */
  17793. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  17794. /**
  17795. * Does this action manager handles actions of a given trigger
  17796. * @param trigger defines the trigger to be tested
  17797. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  17798. * @return whether the trigger is handled
  17799. */
  17800. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  17801. /**
  17802. * Does this action manager has pointer triggers
  17803. */
  17804. get hasPointerTriggers(): boolean;
  17805. /**
  17806. * Does this action manager has pick triggers
  17807. */
  17808. get hasPickTriggers(): boolean;
  17809. /**
  17810. * Registers an action to this action manager
  17811. * @param action defines the action to be registered
  17812. * @return the action amended (prepared) after registration
  17813. */
  17814. registerAction(action: IAction): Nullable<IAction>;
  17815. /**
  17816. * Unregisters an action to this action manager
  17817. * @param action defines the action to be unregistered
  17818. * @return a boolean indicating whether the action has been unregistered
  17819. */
  17820. unregisterAction(action: IAction): Boolean;
  17821. /**
  17822. * Process a specific trigger
  17823. * @param trigger defines the trigger to process
  17824. * @param evt defines the event details to be processed
  17825. */
  17826. processTrigger(trigger: number, evt?: IActionEvent): void;
  17827. /** @hidden */
  17828. _getEffectiveTarget(target: any, propertyPath: string): any;
  17829. /** @hidden */
  17830. _getProperty(propertyPath: string): string;
  17831. /**
  17832. * Serialize this manager to a JSON object
  17833. * @param name defines the property name to store this manager
  17834. * @returns a JSON representation of this manager
  17835. */
  17836. serialize(name: string): any;
  17837. /**
  17838. * Creates a new ActionManager from a JSON data
  17839. * @param parsedActions defines the JSON data to read from
  17840. * @param object defines the hosting mesh
  17841. * @param scene defines the hosting scene
  17842. */
  17843. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  17844. /**
  17845. * Get a trigger name by index
  17846. * @param trigger defines the trigger index
  17847. * @returns a trigger name
  17848. */
  17849. static GetTriggerName(trigger: number): string;
  17850. }
  17851. }
  17852. declare module BABYLON {
  17853. /**
  17854. * Class used to represent a sprite
  17855. * @see http://doc.babylonjs.com/babylon101/sprites
  17856. */
  17857. export class Sprite {
  17858. /** defines the name */
  17859. name: string;
  17860. /** Gets or sets the current world position */
  17861. position: Vector3;
  17862. /** Gets or sets the main color */
  17863. color: Color4;
  17864. /** Gets or sets the width */
  17865. width: number;
  17866. /** Gets or sets the height */
  17867. height: number;
  17868. /** Gets or sets rotation angle */
  17869. angle: number;
  17870. /** Gets or sets the cell index in the sprite sheet */
  17871. cellIndex: number;
  17872. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  17873. cellRef: string;
  17874. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  17875. invertU: number;
  17876. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  17877. invertV: number;
  17878. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  17879. disposeWhenFinishedAnimating: boolean;
  17880. /** Gets the list of attached animations */
  17881. animations: Animation[];
  17882. /** Gets or sets a boolean indicating if the sprite can be picked */
  17883. isPickable: boolean;
  17884. /**
  17885. * Gets or sets the associated action manager
  17886. */
  17887. actionManager: Nullable<ActionManager>;
  17888. private _animationStarted;
  17889. private _loopAnimation;
  17890. private _fromIndex;
  17891. private _toIndex;
  17892. private _delay;
  17893. private _direction;
  17894. private _manager;
  17895. private _time;
  17896. private _onAnimationEnd;
  17897. /**
  17898. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  17899. */
  17900. isVisible: boolean;
  17901. /**
  17902. * Gets or sets the sprite size
  17903. */
  17904. get size(): number;
  17905. set size(value: number);
  17906. /**
  17907. * Creates a new Sprite
  17908. * @param name defines the name
  17909. * @param manager defines the manager
  17910. */
  17911. constructor(
  17912. /** defines the name */
  17913. name: string, manager: ISpriteManager);
  17914. /**
  17915. * Starts an animation
  17916. * @param from defines the initial key
  17917. * @param to defines the end key
  17918. * @param loop defines if the animation must loop
  17919. * @param delay defines the start delay (in ms)
  17920. * @param onAnimationEnd defines a callback to call when animation ends
  17921. */
  17922. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  17923. /** Stops current animation (if any) */
  17924. stopAnimation(): void;
  17925. /** @hidden */
  17926. _animate(deltaTime: number): void;
  17927. /** Release associated resources */
  17928. dispose(): void;
  17929. }
  17930. }
  17931. declare module BABYLON {
  17932. /**
  17933. * Information about the result of picking within a scene
  17934. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  17935. */
  17936. export class PickingInfo {
  17937. /** @hidden */
  17938. _pickingUnavailable: boolean;
  17939. /**
  17940. * If the pick collided with an object
  17941. */
  17942. hit: boolean;
  17943. /**
  17944. * Distance away where the pick collided
  17945. */
  17946. distance: number;
  17947. /**
  17948. * The location of pick collision
  17949. */
  17950. pickedPoint: Nullable<Vector3>;
  17951. /**
  17952. * The mesh corresponding the the pick collision
  17953. */
  17954. pickedMesh: Nullable<AbstractMesh>;
  17955. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  17956. bu: number;
  17957. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  17958. bv: number;
  17959. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  17960. faceId: number;
  17961. /** Id of the the submesh that was picked */
  17962. subMeshId: number;
  17963. /** If a sprite was picked, this will be the sprite the pick collided with */
  17964. pickedSprite: Nullable<Sprite>;
  17965. /**
  17966. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  17967. */
  17968. originMesh: Nullable<AbstractMesh>;
  17969. /**
  17970. * The ray that was used to perform the picking.
  17971. */
  17972. ray: Nullable<Ray>;
  17973. /**
  17974. * Gets the normal correspodning to the face the pick collided with
  17975. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  17976. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  17977. * @returns The normal correspodning to the face the pick collided with
  17978. */
  17979. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  17980. /**
  17981. * Gets the texture coordinates of where the pick occured
  17982. * @returns the vector containing the coordnates of the texture
  17983. */
  17984. getTextureCoordinates(): Nullable<Vector2>;
  17985. }
  17986. }
  17987. declare module BABYLON {
  17988. /**
  17989. * Gather the list of pointer event types as constants.
  17990. */
  17991. export class PointerEventTypes {
  17992. /**
  17993. * 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.
  17994. */
  17995. static readonly POINTERDOWN: number;
  17996. /**
  17997. * The pointerup event is fired when a pointer is no longer active.
  17998. */
  17999. static readonly POINTERUP: number;
  18000. /**
  18001. * The pointermove event is fired when a pointer changes coordinates.
  18002. */
  18003. static readonly POINTERMOVE: number;
  18004. /**
  18005. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18006. */
  18007. static readonly POINTERWHEEL: number;
  18008. /**
  18009. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18010. */
  18011. static readonly POINTERPICK: number;
  18012. /**
  18013. * The pointertap event is fired when a the object has been touched and released without drag.
  18014. */
  18015. static readonly POINTERTAP: number;
  18016. /**
  18017. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18018. */
  18019. static readonly POINTERDOUBLETAP: number;
  18020. }
  18021. /**
  18022. * Base class of pointer info types.
  18023. */
  18024. export class PointerInfoBase {
  18025. /**
  18026. * Defines the type of event (PointerEventTypes)
  18027. */
  18028. type: number;
  18029. /**
  18030. * Defines the related dom event
  18031. */
  18032. event: PointerEvent | MouseWheelEvent;
  18033. /**
  18034. * Instantiates the base class of pointers info.
  18035. * @param type Defines the type of event (PointerEventTypes)
  18036. * @param event Defines the related dom event
  18037. */
  18038. constructor(
  18039. /**
  18040. * Defines the type of event (PointerEventTypes)
  18041. */
  18042. type: number,
  18043. /**
  18044. * Defines the related dom event
  18045. */
  18046. event: PointerEvent | MouseWheelEvent);
  18047. }
  18048. /**
  18049. * This class is used to store pointer related info for the onPrePointerObservable event.
  18050. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18051. */
  18052. export class PointerInfoPre extends PointerInfoBase {
  18053. /**
  18054. * Ray from a pointer if availible (eg. 6dof controller)
  18055. */
  18056. ray: Nullable<Ray>;
  18057. /**
  18058. * Defines the local position of the pointer on the canvas.
  18059. */
  18060. localPosition: Vector2;
  18061. /**
  18062. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18063. */
  18064. skipOnPointerObservable: boolean;
  18065. /**
  18066. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18067. * @param type Defines the type of event (PointerEventTypes)
  18068. * @param event Defines the related dom event
  18069. * @param localX Defines the local x coordinates of the pointer when the event occured
  18070. * @param localY Defines the local y coordinates of the pointer when the event occured
  18071. */
  18072. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18073. }
  18074. /**
  18075. * This type contains all the data related to a pointer event in Babylon.js.
  18076. * 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.
  18077. */
  18078. export class PointerInfo extends PointerInfoBase {
  18079. /**
  18080. * Defines the picking info associated to the info (if any)\
  18081. */
  18082. pickInfo: Nullable<PickingInfo>;
  18083. /**
  18084. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18085. * @param type Defines the type of event (PointerEventTypes)
  18086. * @param event Defines the related dom event
  18087. * @param pickInfo Defines the picking info associated to the info (if any)\
  18088. */
  18089. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18090. /**
  18091. * Defines the picking info associated to the info (if any)\
  18092. */
  18093. pickInfo: Nullable<PickingInfo>);
  18094. }
  18095. /**
  18096. * Data relating to a touch event on the screen.
  18097. */
  18098. export interface PointerTouch {
  18099. /**
  18100. * X coordinate of touch.
  18101. */
  18102. x: number;
  18103. /**
  18104. * Y coordinate of touch.
  18105. */
  18106. y: number;
  18107. /**
  18108. * Id of touch. Unique for each finger.
  18109. */
  18110. pointerId: number;
  18111. /**
  18112. * Event type passed from DOM.
  18113. */
  18114. type: any;
  18115. }
  18116. }
  18117. declare module BABYLON {
  18118. /**
  18119. * Manage the mouse inputs to control the movement of a free camera.
  18120. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18121. */
  18122. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18123. /**
  18124. * Define if touch is enabled in the mouse input
  18125. */
  18126. touchEnabled: boolean;
  18127. /**
  18128. * Defines the camera the input is attached to.
  18129. */
  18130. camera: FreeCamera;
  18131. /**
  18132. * Defines the buttons associated with the input to handle camera move.
  18133. */
  18134. buttons: number[];
  18135. /**
  18136. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18137. */
  18138. angularSensibility: number;
  18139. private _pointerInput;
  18140. private _onMouseMove;
  18141. private _observer;
  18142. private previousPosition;
  18143. /**
  18144. * Observable for when a pointer move event occurs containing the move offset
  18145. */
  18146. onPointerMovedObservable: Observable<{
  18147. offsetX: number;
  18148. offsetY: number;
  18149. }>;
  18150. /**
  18151. * @hidden
  18152. * If the camera should be rotated automatically based on pointer movement
  18153. */
  18154. _allowCameraRotation: boolean;
  18155. /**
  18156. * Manage the mouse inputs to control the movement of a free camera.
  18157. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18158. * @param touchEnabled Defines if touch is enabled or not
  18159. */
  18160. constructor(
  18161. /**
  18162. * Define if touch is enabled in the mouse input
  18163. */
  18164. touchEnabled?: boolean);
  18165. /**
  18166. * Attach the input controls to a specific dom element to get the input from.
  18167. * @param element Defines the element the controls should be listened from
  18168. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18169. */
  18170. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18171. /**
  18172. * Called on JS contextmenu event.
  18173. * Override this method to provide functionality.
  18174. */
  18175. protected onContextMenu(evt: PointerEvent): void;
  18176. /**
  18177. * Detach the current controls from the specified dom element.
  18178. * @param element Defines the element to stop listening the inputs from
  18179. */
  18180. detachControl(element: Nullable<HTMLElement>): void;
  18181. /**
  18182. * Gets the class name of the current intput.
  18183. * @returns the class name
  18184. */
  18185. getClassName(): string;
  18186. /**
  18187. * Get the friendly name associated with the input class.
  18188. * @returns the input friendly name
  18189. */
  18190. getSimpleName(): string;
  18191. }
  18192. }
  18193. declare module BABYLON {
  18194. /**
  18195. * Manage the touch inputs to control the movement of a free camera.
  18196. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18197. */
  18198. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18199. /**
  18200. * Defines the camera the input is attached to.
  18201. */
  18202. camera: FreeCamera;
  18203. /**
  18204. * Defines the touch sensibility for rotation.
  18205. * The higher the faster.
  18206. */
  18207. touchAngularSensibility: number;
  18208. /**
  18209. * Defines the touch sensibility for move.
  18210. * The higher the faster.
  18211. */
  18212. touchMoveSensibility: number;
  18213. private _offsetX;
  18214. private _offsetY;
  18215. private _pointerPressed;
  18216. private _pointerInput;
  18217. private _observer;
  18218. private _onLostFocus;
  18219. /**
  18220. * Attach the input controls to a specific dom element to get the input from.
  18221. * @param element Defines the element the controls should be listened from
  18222. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18223. */
  18224. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18225. /**
  18226. * Detach the current controls from the specified dom element.
  18227. * @param element Defines the element to stop listening the inputs from
  18228. */
  18229. detachControl(element: Nullable<HTMLElement>): void;
  18230. /**
  18231. * Update the current camera state depending on the inputs that have been used this frame.
  18232. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18233. */
  18234. checkInputs(): void;
  18235. /**
  18236. * Gets the class name of the current intput.
  18237. * @returns the class name
  18238. */
  18239. getClassName(): string;
  18240. /**
  18241. * Get the friendly name associated with the input class.
  18242. * @returns the input friendly name
  18243. */
  18244. getSimpleName(): string;
  18245. }
  18246. }
  18247. declare module BABYLON {
  18248. /**
  18249. * Default Inputs manager for the FreeCamera.
  18250. * It groups all the default supported inputs for ease of use.
  18251. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18252. */
  18253. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18254. /**
  18255. * @hidden
  18256. */
  18257. _mouseInput: Nullable<FreeCameraMouseInput>;
  18258. /**
  18259. * Instantiates a new FreeCameraInputsManager.
  18260. * @param camera Defines the camera the inputs belong to
  18261. */
  18262. constructor(camera: FreeCamera);
  18263. /**
  18264. * Add keyboard input support to the input manager.
  18265. * @returns the current input manager
  18266. */
  18267. addKeyboard(): FreeCameraInputsManager;
  18268. /**
  18269. * Add mouse input support to the input manager.
  18270. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18271. * @returns the current input manager
  18272. */
  18273. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18274. /**
  18275. * Removes the mouse input support from the manager
  18276. * @returns the current input manager
  18277. */
  18278. removeMouse(): FreeCameraInputsManager;
  18279. /**
  18280. * Add touch input support to the input manager.
  18281. * @returns the current input manager
  18282. */
  18283. addTouch(): FreeCameraInputsManager;
  18284. /**
  18285. * Remove all attached input methods from a camera
  18286. */
  18287. clear(): void;
  18288. }
  18289. }
  18290. declare module BABYLON {
  18291. /**
  18292. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18293. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18294. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18295. */
  18296. export class FreeCamera extends TargetCamera {
  18297. /**
  18298. * Define the collision ellipsoid of the camera.
  18299. * This is helpful to simulate a camera body like the player body around the camera
  18300. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18301. */
  18302. ellipsoid: Vector3;
  18303. /**
  18304. * Define an offset for the position of the ellipsoid around the camera.
  18305. * This can be helpful to determine the center of the body near the gravity center of the body
  18306. * instead of its head.
  18307. */
  18308. ellipsoidOffset: Vector3;
  18309. /**
  18310. * Enable or disable collisions of the camera with the rest of the scene objects.
  18311. */
  18312. checkCollisions: boolean;
  18313. /**
  18314. * Enable or disable gravity on the camera.
  18315. */
  18316. applyGravity: boolean;
  18317. /**
  18318. * Define the input manager associated to the camera.
  18319. */
  18320. inputs: FreeCameraInputsManager;
  18321. /**
  18322. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18323. * Higher values reduce sensitivity.
  18324. */
  18325. get angularSensibility(): number;
  18326. /**
  18327. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18328. * Higher values reduce sensitivity.
  18329. */
  18330. set angularSensibility(value: number);
  18331. /**
  18332. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18333. */
  18334. get keysUp(): number[];
  18335. set keysUp(value: number[]);
  18336. /**
  18337. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18338. */
  18339. get keysDown(): number[];
  18340. set keysDown(value: number[]);
  18341. /**
  18342. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18343. */
  18344. get keysLeft(): number[];
  18345. set keysLeft(value: number[]);
  18346. /**
  18347. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18348. */
  18349. get keysRight(): number[];
  18350. set keysRight(value: number[]);
  18351. /**
  18352. * Event raised when the camera collide with a mesh in the scene.
  18353. */
  18354. onCollide: (collidedMesh: AbstractMesh) => void;
  18355. private _collider;
  18356. private _needMoveForGravity;
  18357. private _oldPosition;
  18358. private _diffPosition;
  18359. private _newPosition;
  18360. /** @hidden */
  18361. _localDirection: Vector3;
  18362. /** @hidden */
  18363. _transformedDirection: Vector3;
  18364. /**
  18365. * Instantiates a Free Camera.
  18366. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18367. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18368. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18369. * @param name Define the name of the camera in the scene
  18370. * @param position Define the start position of the camera in the scene
  18371. * @param scene Define the scene the camera belongs to
  18372. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18373. */
  18374. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18375. /**
  18376. * Attached controls to the current camera.
  18377. * @param element Defines the element the controls should be listened from
  18378. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18379. */
  18380. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18381. /**
  18382. * Detach the current controls from the camera.
  18383. * The camera will stop reacting to inputs.
  18384. * @param element Defines the element to stop listening the inputs from
  18385. */
  18386. detachControl(element: HTMLElement): void;
  18387. private _collisionMask;
  18388. /**
  18389. * Define a collision mask to limit the list of object the camera can collide with
  18390. */
  18391. get collisionMask(): number;
  18392. set collisionMask(mask: number);
  18393. /** @hidden */
  18394. _collideWithWorld(displacement: Vector3): void;
  18395. private _onCollisionPositionChange;
  18396. /** @hidden */
  18397. _checkInputs(): void;
  18398. /** @hidden */
  18399. _decideIfNeedsToMove(): boolean;
  18400. /** @hidden */
  18401. _updatePosition(): void;
  18402. /**
  18403. * Destroy the camera and release the current resources hold by it.
  18404. */
  18405. dispose(): void;
  18406. /**
  18407. * Gets the current object class name.
  18408. * @return the class name
  18409. */
  18410. getClassName(): string;
  18411. }
  18412. }
  18413. declare module BABYLON {
  18414. /**
  18415. * Represents a gamepad control stick position
  18416. */
  18417. export class StickValues {
  18418. /**
  18419. * The x component of the control stick
  18420. */
  18421. x: number;
  18422. /**
  18423. * The y component of the control stick
  18424. */
  18425. y: number;
  18426. /**
  18427. * Initializes the gamepad x and y control stick values
  18428. * @param x The x component of the gamepad control stick value
  18429. * @param y The y component of the gamepad control stick value
  18430. */
  18431. constructor(
  18432. /**
  18433. * The x component of the control stick
  18434. */
  18435. x: number,
  18436. /**
  18437. * The y component of the control stick
  18438. */
  18439. y: number);
  18440. }
  18441. /**
  18442. * An interface which manages callbacks for gamepad button changes
  18443. */
  18444. export interface GamepadButtonChanges {
  18445. /**
  18446. * Called when a gamepad has been changed
  18447. */
  18448. changed: boolean;
  18449. /**
  18450. * Called when a gamepad press event has been triggered
  18451. */
  18452. pressChanged: boolean;
  18453. /**
  18454. * Called when a touch event has been triggered
  18455. */
  18456. touchChanged: boolean;
  18457. /**
  18458. * Called when a value has changed
  18459. */
  18460. valueChanged: boolean;
  18461. }
  18462. /**
  18463. * Represents a gamepad
  18464. */
  18465. export class Gamepad {
  18466. /**
  18467. * The id of the gamepad
  18468. */
  18469. id: string;
  18470. /**
  18471. * The index of the gamepad
  18472. */
  18473. index: number;
  18474. /**
  18475. * The browser gamepad
  18476. */
  18477. browserGamepad: any;
  18478. /**
  18479. * Specifies what type of gamepad this represents
  18480. */
  18481. type: number;
  18482. private _leftStick;
  18483. private _rightStick;
  18484. /** @hidden */
  18485. _isConnected: boolean;
  18486. private _leftStickAxisX;
  18487. private _leftStickAxisY;
  18488. private _rightStickAxisX;
  18489. private _rightStickAxisY;
  18490. /**
  18491. * Triggered when the left control stick has been changed
  18492. */
  18493. private _onleftstickchanged;
  18494. /**
  18495. * Triggered when the right control stick has been changed
  18496. */
  18497. private _onrightstickchanged;
  18498. /**
  18499. * Represents a gamepad controller
  18500. */
  18501. static GAMEPAD: number;
  18502. /**
  18503. * Represents a generic controller
  18504. */
  18505. static GENERIC: number;
  18506. /**
  18507. * Represents an XBox controller
  18508. */
  18509. static XBOX: number;
  18510. /**
  18511. * Represents a pose-enabled controller
  18512. */
  18513. static POSE_ENABLED: number;
  18514. /**
  18515. * Represents an Dual Shock controller
  18516. */
  18517. static DUALSHOCK: number;
  18518. /**
  18519. * Specifies whether the left control stick should be Y-inverted
  18520. */
  18521. protected _invertLeftStickY: boolean;
  18522. /**
  18523. * Specifies if the gamepad has been connected
  18524. */
  18525. get isConnected(): boolean;
  18526. /**
  18527. * Initializes the gamepad
  18528. * @param id The id of the gamepad
  18529. * @param index The index of the gamepad
  18530. * @param browserGamepad The browser gamepad
  18531. * @param leftStickX The x component of the left joystick
  18532. * @param leftStickY The y component of the left joystick
  18533. * @param rightStickX The x component of the right joystick
  18534. * @param rightStickY The y component of the right joystick
  18535. */
  18536. constructor(
  18537. /**
  18538. * The id of the gamepad
  18539. */
  18540. id: string,
  18541. /**
  18542. * The index of the gamepad
  18543. */
  18544. index: number,
  18545. /**
  18546. * The browser gamepad
  18547. */
  18548. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  18549. /**
  18550. * Callback triggered when the left joystick has changed
  18551. * @param callback
  18552. */
  18553. onleftstickchanged(callback: (values: StickValues) => void): void;
  18554. /**
  18555. * Callback triggered when the right joystick has changed
  18556. * @param callback
  18557. */
  18558. onrightstickchanged(callback: (values: StickValues) => void): void;
  18559. /**
  18560. * Gets the left joystick
  18561. */
  18562. get leftStick(): StickValues;
  18563. /**
  18564. * Sets the left joystick values
  18565. */
  18566. set leftStick(newValues: StickValues);
  18567. /**
  18568. * Gets the right joystick
  18569. */
  18570. get rightStick(): StickValues;
  18571. /**
  18572. * Sets the right joystick value
  18573. */
  18574. set rightStick(newValues: StickValues);
  18575. /**
  18576. * Updates the gamepad joystick positions
  18577. */
  18578. update(): void;
  18579. /**
  18580. * Disposes the gamepad
  18581. */
  18582. dispose(): void;
  18583. }
  18584. /**
  18585. * Represents a generic gamepad
  18586. */
  18587. export class GenericPad extends Gamepad {
  18588. private _buttons;
  18589. private _onbuttondown;
  18590. private _onbuttonup;
  18591. /**
  18592. * Observable triggered when a button has been pressed
  18593. */
  18594. onButtonDownObservable: Observable<number>;
  18595. /**
  18596. * Observable triggered when a button has been released
  18597. */
  18598. onButtonUpObservable: Observable<number>;
  18599. /**
  18600. * Callback triggered when a button has been pressed
  18601. * @param callback Called when a button has been pressed
  18602. */
  18603. onbuttondown(callback: (buttonPressed: number) => void): void;
  18604. /**
  18605. * Callback triggered when a button has been released
  18606. * @param callback Called when a button has been released
  18607. */
  18608. onbuttonup(callback: (buttonReleased: number) => void): void;
  18609. /**
  18610. * Initializes the generic gamepad
  18611. * @param id The id of the generic gamepad
  18612. * @param index The index of the generic gamepad
  18613. * @param browserGamepad The browser gamepad
  18614. */
  18615. constructor(id: string, index: number, browserGamepad: any);
  18616. private _setButtonValue;
  18617. /**
  18618. * Updates the generic gamepad
  18619. */
  18620. update(): void;
  18621. /**
  18622. * Disposes the generic gamepad
  18623. */
  18624. dispose(): void;
  18625. }
  18626. }
  18627. declare module BABYLON {
  18628. /**
  18629. * Defines the types of pose enabled controllers that are supported
  18630. */
  18631. export enum PoseEnabledControllerType {
  18632. /**
  18633. * HTC Vive
  18634. */
  18635. VIVE = 0,
  18636. /**
  18637. * Oculus Rift
  18638. */
  18639. OCULUS = 1,
  18640. /**
  18641. * Windows mixed reality
  18642. */
  18643. WINDOWS = 2,
  18644. /**
  18645. * Samsung gear VR
  18646. */
  18647. GEAR_VR = 3,
  18648. /**
  18649. * Google Daydream
  18650. */
  18651. DAYDREAM = 4,
  18652. /**
  18653. * Generic
  18654. */
  18655. GENERIC = 5
  18656. }
  18657. /**
  18658. * Defines the MutableGamepadButton interface for the state of a gamepad button
  18659. */
  18660. export interface MutableGamepadButton {
  18661. /**
  18662. * Value of the button/trigger
  18663. */
  18664. value: number;
  18665. /**
  18666. * If the button/trigger is currently touched
  18667. */
  18668. touched: boolean;
  18669. /**
  18670. * If the button/trigger is currently pressed
  18671. */
  18672. pressed: boolean;
  18673. }
  18674. /**
  18675. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  18676. * @hidden
  18677. */
  18678. export interface ExtendedGamepadButton extends GamepadButton {
  18679. /**
  18680. * If the button/trigger is currently pressed
  18681. */
  18682. readonly pressed: boolean;
  18683. /**
  18684. * If the button/trigger is currently touched
  18685. */
  18686. readonly touched: boolean;
  18687. /**
  18688. * Value of the button/trigger
  18689. */
  18690. readonly value: number;
  18691. }
  18692. /** @hidden */
  18693. export interface _GamePadFactory {
  18694. /**
  18695. * Returns whether or not the current gamepad can be created for this type of controller.
  18696. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  18697. * @returns true if it can be created, otherwise false
  18698. */
  18699. canCreate(gamepadInfo: any): boolean;
  18700. /**
  18701. * Creates a new instance of the Gamepad.
  18702. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  18703. * @returns the new gamepad instance
  18704. */
  18705. create(gamepadInfo: any): Gamepad;
  18706. }
  18707. /**
  18708. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  18709. */
  18710. export class PoseEnabledControllerHelper {
  18711. /** @hidden */
  18712. static _ControllerFactories: _GamePadFactory[];
  18713. /** @hidden */
  18714. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  18715. /**
  18716. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  18717. * @param vrGamepad the gamepad to initialized
  18718. * @returns a vr controller of the type the gamepad identified as
  18719. */
  18720. static InitiateController(vrGamepad: any): Gamepad;
  18721. }
  18722. /**
  18723. * Defines the PoseEnabledController object that contains state of a vr capable controller
  18724. */
  18725. export class PoseEnabledController extends Gamepad implements PoseControlled {
  18726. /**
  18727. * If the controller is used in a webXR session
  18728. */
  18729. isXR: boolean;
  18730. private _deviceRoomPosition;
  18731. private _deviceRoomRotationQuaternion;
  18732. /**
  18733. * The device position in babylon space
  18734. */
  18735. devicePosition: Vector3;
  18736. /**
  18737. * The device rotation in babylon space
  18738. */
  18739. deviceRotationQuaternion: Quaternion;
  18740. /**
  18741. * The scale factor of the device in babylon space
  18742. */
  18743. deviceScaleFactor: number;
  18744. /**
  18745. * (Likely devicePosition should be used instead) The device position in its room space
  18746. */
  18747. position: Vector3;
  18748. /**
  18749. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  18750. */
  18751. rotationQuaternion: Quaternion;
  18752. /**
  18753. * The type of controller (Eg. Windows mixed reality)
  18754. */
  18755. controllerType: PoseEnabledControllerType;
  18756. protected _calculatedPosition: Vector3;
  18757. private _calculatedRotation;
  18758. /**
  18759. * The raw pose from the device
  18760. */
  18761. rawPose: DevicePose;
  18762. private _trackPosition;
  18763. private _maxRotationDistFromHeadset;
  18764. private _draggedRoomRotation;
  18765. /**
  18766. * @hidden
  18767. */
  18768. _disableTrackPosition(fixedPosition: Vector3): void;
  18769. /**
  18770. * Internal, the mesh attached to the controller
  18771. * @hidden
  18772. */
  18773. _mesh: Nullable<AbstractMesh>;
  18774. private _poseControlledCamera;
  18775. private _leftHandSystemQuaternion;
  18776. /**
  18777. * Internal, matrix used to convert room space to babylon space
  18778. * @hidden
  18779. */
  18780. _deviceToWorld: Matrix;
  18781. /**
  18782. * Node to be used when casting a ray from the controller
  18783. * @hidden
  18784. */
  18785. _pointingPoseNode: Nullable<TransformNode>;
  18786. /**
  18787. * Name of the child mesh that can be used to cast a ray from the controller
  18788. */
  18789. static readonly POINTING_POSE: string;
  18790. /**
  18791. * Creates a new PoseEnabledController from a gamepad
  18792. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  18793. */
  18794. constructor(browserGamepad: any);
  18795. private _workingMatrix;
  18796. /**
  18797. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  18798. */
  18799. update(): void;
  18800. /**
  18801. * Updates only the pose device and mesh without doing any button event checking
  18802. */
  18803. protected _updatePoseAndMesh(): void;
  18804. /**
  18805. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  18806. * @param poseData raw pose fromthe device
  18807. */
  18808. updateFromDevice(poseData: DevicePose): void;
  18809. /**
  18810. * @hidden
  18811. */
  18812. _meshAttachedObservable: Observable<AbstractMesh>;
  18813. /**
  18814. * Attaches a mesh to the controller
  18815. * @param mesh the mesh to be attached
  18816. */
  18817. attachToMesh(mesh: AbstractMesh): void;
  18818. /**
  18819. * Attaches the controllers mesh to a camera
  18820. * @param camera the camera the mesh should be attached to
  18821. */
  18822. attachToPoseControlledCamera(camera: TargetCamera): void;
  18823. /**
  18824. * Disposes of the controller
  18825. */
  18826. dispose(): void;
  18827. /**
  18828. * The mesh that is attached to the controller
  18829. */
  18830. get mesh(): Nullable<AbstractMesh>;
  18831. /**
  18832. * Gets the ray of the controller in the direction the controller is pointing
  18833. * @param length the length the resulting ray should be
  18834. * @returns a ray in the direction the controller is pointing
  18835. */
  18836. getForwardRay(length?: number): Ray;
  18837. }
  18838. }
  18839. declare module BABYLON {
  18840. /**
  18841. * Defines the WebVRController object that represents controllers tracked in 3D space
  18842. */
  18843. export abstract class WebVRController extends PoseEnabledController {
  18844. /**
  18845. * Internal, the default controller model for the controller
  18846. */
  18847. protected _defaultModel: Nullable<AbstractMesh>;
  18848. /**
  18849. * Fired when the trigger state has changed
  18850. */
  18851. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  18852. /**
  18853. * Fired when the main button state has changed
  18854. */
  18855. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  18856. /**
  18857. * Fired when the secondary button state has changed
  18858. */
  18859. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  18860. /**
  18861. * Fired when the pad state has changed
  18862. */
  18863. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  18864. /**
  18865. * Fired when controllers stick values have changed
  18866. */
  18867. onPadValuesChangedObservable: Observable<StickValues>;
  18868. /**
  18869. * Array of button availible on the controller
  18870. */
  18871. protected _buttons: Array<MutableGamepadButton>;
  18872. private _onButtonStateChange;
  18873. /**
  18874. * Fired when a controller button's state has changed
  18875. * @param callback the callback containing the button that was modified
  18876. */
  18877. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  18878. /**
  18879. * X and Y axis corresponding to the controllers joystick
  18880. */
  18881. pad: StickValues;
  18882. /**
  18883. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  18884. */
  18885. hand: string;
  18886. /**
  18887. * The default controller model for the controller
  18888. */
  18889. get defaultModel(): Nullable<AbstractMesh>;
  18890. /**
  18891. * Creates a new WebVRController from a gamepad
  18892. * @param vrGamepad the gamepad that the WebVRController should be created from
  18893. */
  18894. constructor(vrGamepad: any);
  18895. /**
  18896. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  18897. */
  18898. update(): void;
  18899. /**
  18900. * Function to be called when a button is modified
  18901. */
  18902. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  18903. /**
  18904. * Loads a mesh and attaches it to the controller
  18905. * @param scene the scene the mesh should be added to
  18906. * @param meshLoaded callback for when the mesh has been loaded
  18907. */
  18908. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  18909. private _setButtonValue;
  18910. private _changes;
  18911. private _checkChanges;
  18912. /**
  18913. * Disposes of th webVRCOntroller
  18914. */
  18915. dispose(): void;
  18916. }
  18917. }
  18918. declare module BABYLON {
  18919. /**
  18920. * The HemisphericLight simulates the ambient environment light,
  18921. * so the passed direction is the light reflection direction, not the incoming direction.
  18922. */
  18923. export class HemisphericLight extends Light {
  18924. /**
  18925. * The groundColor is the light in the opposite direction to the one specified during creation.
  18926. * 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.
  18927. */
  18928. groundColor: Color3;
  18929. /**
  18930. * The light reflection direction, not the incoming direction.
  18931. */
  18932. direction: Vector3;
  18933. /**
  18934. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  18935. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  18936. * The HemisphericLight can't cast shadows.
  18937. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18938. * @param name The friendly name of the light
  18939. * @param direction The direction of the light reflection
  18940. * @param scene The scene the light belongs to
  18941. */
  18942. constructor(name: string, direction: Vector3, scene: Scene);
  18943. protected _buildUniformLayout(): void;
  18944. /**
  18945. * Returns the string "HemisphericLight".
  18946. * @return The class name
  18947. */
  18948. getClassName(): string;
  18949. /**
  18950. * Sets the HemisphericLight direction towards the passed target (Vector3).
  18951. * Returns the updated direction.
  18952. * @param target The target the direction should point to
  18953. * @return The computed direction
  18954. */
  18955. setDirectionToTarget(target: Vector3): Vector3;
  18956. /**
  18957. * Returns the shadow generator associated to the light.
  18958. * @returns Always null for hemispheric lights because it does not support shadows.
  18959. */
  18960. getShadowGenerator(): Nullable<IShadowGenerator>;
  18961. /**
  18962. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  18963. * @param effect The effect to update
  18964. * @param lightIndex The index of the light in the effect to update
  18965. * @returns The hemispheric light
  18966. */
  18967. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  18968. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  18969. /**
  18970. * Computes the world matrix of the node
  18971. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  18972. * @param useWasUpdatedFlag defines a reserved property
  18973. * @returns the world matrix
  18974. */
  18975. computeWorldMatrix(): Matrix;
  18976. /**
  18977. * Returns the integer 3.
  18978. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18979. */
  18980. getTypeID(): number;
  18981. /**
  18982. * Prepares the list of defines specific to the light type.
  18983. * @param defines the list of defines
  18984. * @param lightIndex defines the index of the light for the effect
  18985. */
  18986. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18987. }
  18988. }
  18989. declare module BABYLON {
  18990. /** @hidden */
  18991. export var vrMultiviewToSingleviewPixelShader: {
  18992. name: string;
  18993. shader: string;
  18994. };
  18995. }
  18996. declare module BABYLON {
  18997. /**
  18998. * Renders to multiple views with a single draw call
  18999. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19000. */
  19001. export class MultiviewRenderTarget extends RenderTargetTexture {
  19002. /**
  19003. * Creates a multiview render target
  19004. * @param scene scene used with the render target
  19005. * @param size the size of the render target (used for each view)
  19006. */
  19007. constructor(scene: Scene, size?: number | {
  19008. width: number;
  19009. height: number;
  19010. } | {
  19011. ratio: number;
  19012. });
  19013. /**
  19014. * @hidden
  19015. * @param faceIndex the face index, if its a cube texture
  19016. */
  19017. _bindFrameBuffer(faceIndex?: number): void;
  19018. /**
  19019. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19020. * @returns the view count
  19021. */
  19022. getViewCount(): number;
  19023. }
  19024. }
  19025. declare module BABYLON {
  19026. /**
  19027. * Represents a camera frustum
  19028. */
  19029. export class Frustum {
  19030. /**
  19031. * Gets the planes representing the frustum
  19032. * @param transform matrix to be applied to the returned planes
  19033. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  19034. */
  19035. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  19036. /**
  19037. * Gets the near frustum plane transformed by the transform matrix
  19038. * @param transform transformation matrix to be applied to the resulting frustum plane
  19039. * @param frustumPlane the resuling frustum plane
  19040. */
  19041. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19042. /**
  19043. * Gets the far frustum plane transformed by the transform matrix
  19044. * @param transform transformation matrix to be applied to the resulting frustum plane
  19045. * @param frustumPlane the resuling frustum plane
  19046. */
  19047. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19048. /**
  19049. * Gets the left frustum plane transformed by the transform matrix
  19050. * @param transform transformation matrix to be applied to the resulting frustum plane
  19051. * @param frustumPlane the resuling frustum plane
  19052. */
  19053. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19054. /**
  19055. * Gets the right frustum plane transformed by the transform matrix
  19056. * @param transform transformation matrix to be applied to the resulting frustum plane
  19057. * @param frustumPlane the resuling frustum plane
  19058. */
  19059. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19060. /**
  19061. * Gets the top frustum plane transformed by the transform matrix
  19062. * @param transform transformation matrix to be applied to the resulting frustum plane
  19063. * @param frustumPlane the resuling frustum plane
  19064. */
  19065. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19066. /**
  19067. * Gets the bottom frustum plane transformed by the transform matrix
  19068. * @param transform transformation matrix to be applied to the resulting frustum plane
  19069. * @param frustumPlane the resuling frustum plane
  19070. */
  19071. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19072. /**
  19073. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  19074. * @param transform transformation matrix to be applied to the resulting frustum planes
  19075. * @param frustumPlanes the resuling frustum planes
  19076. */
  19077. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  19078. }
  19079. }
  19080. declare module BABYLON {
  19081. interface Engine {
  19082. /**
  19083. * Creates a new multiview render target
  19084. * @param width defines the width of the texture
  19085. * @param height defines the height of the texture
  19086. * @returns the created multiview texture
  19087. */
  19088. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19089. /**
  19090. * Binds a multiview framebuffer to be drawn to
  19091. * @param multiviewTexture texture to bind
  19092. */
  19093. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19094. }
  19095. interface Camera {
  19096. /**
  19097. * @hidden
  19098. * 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)
  19099. */
  19100. _useMultiviewToSingleView: boolean;
  19101. /**
  19102. * @hidden
  19103. * 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)
  19104. */
  19105. _multiviewTexture: Nullable<RenderTargetTexture>;
  19106. /**
  19107. * @hidden
  19108. * ensures the multiview texture of the camera exists and has the specified width/height
  19109. * @param width height to set on the multiview texture
  19110. * @param height width to set on the multiview texture
  19111. */
  19112. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19113. }
  19114. interface Scene {
  19115. /** @hidden */
  19116. _transformMatrixR: Matrix;
  19117. /** @hidden */
  19118. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19119. /** @hidden */
  19120. _createMultiviewUbo(): void;
  19121. /** @hidden */
  19122. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19123. /** @hidden */
  19124. _renderMultiviewToSingleView(camera: Camera): void;
  19125. }
  19126. }
  19127. declare module BABYLON {
  19128. /**
  19129. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19130. * This will not be used for webXR as it supports displaying texture arrays directly
  19131. */
  19132. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19133. /**
  19134. * Initializes a VRMultiviewToSingleview
  19135. * @param name name of the post process
  19136. * @param camera camera to be applied to
  19137. * @param scaleFactor scaling factor to the size of the output texture
  19138. */
  19139. constructor(name: string, camera: Camera, scaleFactor: number);
  19140. }
  19141. }
  19142. declare module BABYLON {
  19143. /**
  19144. * Interface used to define additional presentation attributes
  19145. */
  19146. export interface IVRPresentationAttributes {
  19147. /**
  19148. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19149. */
  19150. highRefreshRate: boolean;
  19151. /**
  19152. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19153. */
  19154. foveationLevel: number;
  19155. }
  19156. interface Engine {
  19157. /** @hidden */
  19158. _vrDisplay: any;
  19159. /** @hidden */
  19160. _vrSupported: boolean;
  19161. /** @hidden */
  19162. _oldSize: Size;
  19163. /** @hidden */
  19164. _oldHardwareScaleFactor: number;
  19165. /** @hidden */
  19166. _vrExclusivePointerMode: boolean;
  19167. /** @hidden */
  19168. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19169. /** @hidden */
  19170. _onVRDisplayPointerRestricted: () => void;
  19171. /** @hidden */
  19172. _onVRDisplayPointerUnrestricted: () => void;
  19173. /** @hidden */
  19174. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19175. /** @hidden */
  19176. _onVrDisplayDisconnect: Nullable<() => void>;
  19177. /** @hidden */
  19178. _onVrDisplayPresentChange: Nullable<() => void>;
  19179. /**
  19180. * Observable signaled when VR display mode changes
  19181. */
  19182. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19183. /**
  19184. * Observable signaled when VR request present is complete
  19185. */
  19186. onVRRequestPresentComplete: Observable<boolean>;
  19187. /**
  19188. * Observable signaled when VR request present starts
  19189. */
  19190. onVRRequestPresentStart: Observable<Engine>;
  19191. /**
  19192. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19193. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19194. */
  19195. isInVRExclusivePointerMode: boolean;
  19196. /**
  19197. * Gets a boolean indicating if a webVR device was detected
  19198. * @returns true if a webVR device was detected
  19199. */
  19200. isVRDevicePresent(): boolean;
  19201. /**
  19202. * Gets the current webVR device
  19203. * @returns the current webVR device (or null)
  19204. */
  19205. getVRDevice(): any;
  19206. /**
  19207. * Initializes a webVR display and starts listening to display change events
  19208. * The onVRDisplayChangedObservable will be notified upon these changes
  19209. * @returns A promise containing a VRDisplay and if vr is supported
  19210. */
  19211. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19212. /** @hidden */
  19213. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19214. /**
  19215. * Gets or sets the presentation attributes used to configure VR rendering
  19216. */
  19217. vrPresentationAttributes?: IVRPresentationAttributes;
  19218. /**
  19219. * Call this function to switch to webVR mode
  19220. * Will do nothing if webVR is not supported or if there is no webVR device
  19221. * @param options the webvr options provided to the camera. mainly used for multiview
  19222. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19223. */
  19224. enableVR(options: WebVROptions): void;
  19225. /** @hidden */
  19226. _onVRFullScreenTriggered(): void;
  19227. }
  19228. }
  19229. declare module BABYLON {
  19230. /**
  19231. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19232. * IMPORTANT!! The data is right-hand data.
  19233. * @export
  19234. * @interface DevicePose
  19235. */
  19236. export interface DevicePose {
  19237. /**
  19238. * The position of the device, values in array are [x,y,z].
  19239. */
  19240. readonly position: Nullable<Float32Array>;
  19241. /**
  19242. * The linearVelocity of the device, values in array are [x,y,z].
  19243. */
  19244. readonly linearVelocity: Nullable<Float32Array>;
  19245. /**
  19246. * The linearAcceleration of the device, values in array are [x,y,z].
  19247. */
  19248. readonly linearAcceleration: Nullable<Float32Array>;
  19249. /**
  19250. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19251. */
  19252. readonly orientation: Nullable<Float32Array>;
  19253. /**
  19254. * The angularVelocity of the device, values in array are [x,y,z].
  19255. */
  19256. readonly angularVelocity: Nullable<Float32Array>;
  19257. /**
  19258. * The angularAcceleration of the device, values in array are [x,y,z].
  19259. */
  19260. readonly angularAcceleration: Nullable<Float32Array>;
  19261. }
  19262. /**
  19263. * Interface representing a pose controlled object in Babylon.
  19264. * A pose controlled object has both regular pose values as well as pose values
  19265. * from an external device such as a VR head mounted display
  19266. */
  19267. export interface PoseControlled {
  19268. /**
  19269. * The position of the object in babylon space.
  19270. */
  19271. position: Vector3;
  19272. /**
  19273. * The rotation quaternion of the object in babylon space.
  19274. */
  19275. rotationQuaternion: Quaternion;
  19276. /**
  19277. * The position of the device in babylon space.
  19278. */
  19279. devicePosition?: Vector3;
  19280. /**
  19281. * The rotation quaternion of the device in babylon space.
  19282. */
  19283. deviceRotationQuaternion: Quaternion;
  19284. /**
  19285. * The raw pose coming from the device.
  19286. */
  19287. rawPose: Nullable<DevicePose>;
  19288. /**
  19289. * The scale of the device to be used when translating from device space to babylon space.
  19290. */
  19291. deviceScaleFactor: number;
  19292. /**
  19293. * Updates the poseControlled values based on the input device pose.
  19294. * @param poseData the pose data to update the object with
  19295. */
  19296. updateFromDevice(poseData: DevicePose): void;
  19297. }
  19298. /**
  19299. * Set of options to customize the webVRCamera
  19300. */
  19301. export interface WebVROptions {
  19302. /**
  19303. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19304. */
  19305. trackPosition?: boolean;
  19306. /**
  19307. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19308. */
  19309. positionScale?: number;
  19310. /**
  19311. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19312. */
  19313. displayName?: string;
  19314. /**
  19315. * Should the native controller meshes be initialized. (default: true)
  19316. */
  19317. controllerMeshes?: boolean;
  19318. /**
  19319. * Creating a default HemiLight only on controllers. (default: true)
  19320. */
  19321. defaultLightingOnControllers?: boolean;
  19322. /**
  19323. * If you don't want to use the default VR button of the helper. (default: false)
  19324. */
  19325. useCustomVRButton?: boolean;
  19326. /**
  19327. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19328. */
  19329. customVRButton?: HTMLButtonElement;
  19330. /**
  19331. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19332. */
  19333. rayLength?: number;
  19334. /**
  19335. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19336. */
  19337. defaultHeight?: number;
  19338. /**
  19339. * If multiview should be used if availible (default: false)
  19340. */
  19341. useMultiview?: boolean;
  19342. }
  19343. /**
  19344. * This represents a WebVR camera.
  19345. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19346. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19347. */
  19348. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19349. private webVROptions;
  19350. /**
  19351. * @hidden
  19352. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19353. */
  19354. _vrDevice: any;
  19355. /**
  19356. * The rawPose of the vrDevice.
  19357. */
  19358. rawPose: Nullable<DevicePose>;
  19359. private _onVREnabled;
  19360. private _specsVersion;
  19361. private _attached;
  19362. private _frameData;
  19363. protected _descendants: Array<Node>;
  19364. private _deviceRoomPosition;
  19365. /** @hidden */
  19366. _deviceRoomRotationQuaternion: Quaternion;
  19367. private _standingMatrix;
  19368. /**
  19369. * Represents device position in babylon space.
  19370. */
  19371. devicePosition: Vector3;
  19372. /**
  19373. * Represents device rotation in babylon space.
  19374. */
  19375. deviceRotationQuaternion: Quaternion;
  19376. /**
  19377. * The scale of the device to be used when translating from device space to babylon space.
  19378. */
  19379. deviceScaleFactor: number;
  19380. private _deviceToWorld;
  19381. private _worldToDevice;
  19382. /**
  19383. * References to the webVR controllers for the vrDevice.
  19384. */
  19385. controllers: Array<WebVRController>;
  19386. /**
  19387. * Emits an event when a controller is attached.
  19388. */
  19389. onControllersAttachedObservable: Observable<WebVRController[]>;
  19390. /**
  19391. * Emits an event when a controller's mesh has been loaded;
  19392. */
  19393. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19394. /**
  19395. * Emits an event when the HMD's pose has been updated.
  19396. */
  19397. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19398. private _poseSet;
  19399. /**
  19400. * If the rig cameras be used as parent instead of this camera.
  19401. */
  19402. rigParenting: boolean;
  19403. private _lightOnControllers;
  19404. private _defaultHeight?;
  19405. /**
  19406. * Instantiates a WebVRFreeCamera.
  19407. * @param name The name of the WebVRFreeCamera
  19408. * @param position The starting anchor position for the camera
  19409. * @param scene The scene the camera belongs to
  19410. * @param webVROptions a set of customizable options for the webVRCamera
  19411. */
  19412. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19413. /**
  19414. * Gets the device distance from the ground in meters.
  19415. * @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.
  19416. */
  19417. deviceDistanceToRoomGround(): number;
  19418. /**
  19419. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19420. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19421. */
  19422. useStandingMatrix(callback?: (bool: boolean) => void): void;
  19423. /**
  19424. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19425. * @returns A promise with a boolean set to if the standing matrix is supported.
  19426. */
  19427. useStandingMatrixAsync(): Promise<boolean>;
  19428. /**
  19429. * Disposes the camera
  19430. */
  19431. dispose(): void;
  19432. /**
  19433. * Gets a vrController by name.
  19434. * @param name The name of the controller to retreive
  19435. * @returns the controller matching the name specified or null if not found
  19436. */
  19437. getControllerByName(name: string): Nullable<WebVRController>;
  19438. private _leftController;
  19439. /**
  19440. * The controller corresponding to the users left hand.
  19441. */
  19442. get leftController(): Nullable<WebVRController>;
  19443. private _rightController;
  19444. /**
  19445. * The controller corresponding to the users right hand.
  19446. */
  19447. get rightController(): Nullable<WebVRController>;
  19448. /**
  19449. * Casts a ray forward from the vrCamera's gaze.
  19450. * @param length Length of the ray (default: 100)
  19451. * @returns the ray corresponding to the gaze
  19452. */
  19453. getForwardRay(length?: number): Ray;
  19454. /**
  19455. * @hidden
  19456. * Updates the camera based on device's frame data
  19457. */
  19458. _checkInputs(): void;
  19459. /**
  19460. * Updates the poseControlled values based on the input device pose.
  19461. * @param poseData Pose coming from the device
  19462. */
  19463. updateFromDevice(poseData: DevicePose): void;
  19464. private _htmlElementAttached;
  19465. private _detachIfAttached;
  19466. /**
  19467. * WebVR's attach control will start broadcasting frames to the device.
  19468. * Note that in certain browsers (chrome for example) this function must be called
  19469. * within a user-interaction callback. Example:
  19470. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  19471. *
  19472. * @param element html element to attach the vrDevice to
  19473. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  19474. */
  19475. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19476. /**
  19477. * Detaches the camera from the html element and disables VR
  19478. *
  19479. * @param element html element to detach from
  19480. */
  19481. detachControl(element: HTMLElement): void;
  19482. /**
  19483. * @returns the name of this class
  19484. */
  19485. getClassName(): string;
  19486. /**
  19487. * Calls resetPose on the vrDisplay
  19488. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  19489. */
  19490. resetToCurrentRotation(): void;
  19491. /**
  19492. * @hidden
  19493. * Updates the rig cameras (left and right eye)
  19494. */
  19495. _updateRigCameras(): void;
  19496. private _workingVector;
  19497. private _oneVector;
  19498. private _workingMatrix;
  19499. private updateCacheCalled;
  19500. private _correctPositionIfNotTrackPosition;
  19501. /**
  19502. * @hidden
  19503. * Updates the cached values of the camera
  19504. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  19505. */
  19506. _updateCache(ignoreParentClass?: boolean): void;
  19507. /**
  19508. * @hidden
  19509. * Get current device position in babylon world
  19510. */
  19511. _computeDevicePosition(): void;
  19512. /**
  19513. * Updates the current device position and rotation in the babylon world
  19514. */
  19515. update(): void;
  19516. /**
  19517. * @hidden
  19518. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  19519. * @returns an identity matrix
  19520. */
  19521. _getViewMatrix(): Matrix;
  19522. private _tmpMatrix;
  19523. /**
  19524. * This function is called by the two RIG cameras.
  19525. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  19526. * @hidden
  19527. */
  19528. _getWebVRViewMatrix(): Matrix;
  19529. /** @hidden */
  19530. _getWebVRProjectionMatrix(): Matrix;
  19531. private _onGamepadConnectedObserver;
  19532. private _onGamepadDisconnectedObserver;
  19533. private _updateCacheWhenTrackingDisabledObserver;
  19534. /**
  19535. * Initializes the controllers and their meshes
  19536. */
  19537. initControllers(): void;
  19538. }
  19539. }
  19540. declare module BABYLON {
  19541. /**
  19542. * Size options for a post process
  19543. */
  19544. export type PostProcessOptions = {
  19545. width: number;
  19546. height: number;
  19547. };
  19548. /**
  19549. * PostProcess can be used to apply a shader to a texture after it has been rendered
  19550. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  19551. */
  19552. export class PostProcess {
  19553. /** Name of the PostProcess. */
  19554. name: string;
  19555. /**
  19556. * Gets or sets the unique id of the post process
  19557. */
  19558. uniqueId: number;
  19559. /**
  19560. * Width of the texture to apply the post process on
  19561. */
  19562. width: number;
  19563. /**
  19564. * Height of the texture to apply the post process on
  19565. */
  19566. height: number;
  19567. /**
  19568. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  19569. * @hidden
  19570. */
  19571. _outputTexture: Nullable<InternalTexture>;
  19572. /**
  19573. * Sampling mode used by the shader
  19574. * See https://doc.babylonjs.com/classes/3.1/texture
  19575. */
  19576. renderTargetSamplingMode: number;
  19577. /**
  19578. * Clear color to use when screen clearing
  19579. */
  19580. clearColor: Color4;
  19581. /**
  19582. * If the buffer needs to be cleared before applying the post process. (default: true)
  19583. * Should be set to false if shader will overwrite all previous pixels.
  19584. */
  19585. autoClear: boolean;
  19586. /**
  19587. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  19588. */
  19589. alphaMode: number;
  19590. /**
  19591. * Sets the setAlphaBlendConstants of the babylon engine
  19592. */
  19593. alphaConstants: Color4;
  19594. /**
  19595. * Animations to be used for the post processing
  19596. */
  19597. animations: Animation[];
  19598. /**
  19599. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  19600. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  19601. */
  19602. enablePixelPerfectMode: boolean;
  19603. /**
  19604. * Force the postprocess to be applied without taking in account viewport
  19605. */
  19606. forceFullscreenViewport: boolean;
  19607. /**
  19608. * List of inspectable custom properties (used by the Inspector)
  19609. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19610. */
  19611. inspectableCustomProperties: IInspectable[];
  19612. /**
  19613. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  19614. *
  19615. * | Value | Type | Description |
  19616. * | ----- | ----------------------------------- | ----------- |
  19617. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  19618. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  19619. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  19620. *
  19621. */
  19622. scaleMode: number;
  19623. /**
  19624. * Force textures to be a power of two (default: false)
  19625. */
  19626. alwaysForcePOT: boolean;
  19627. private _samples;
  19628. /**
  19629. * Number of sample textures (default: 1)
  19630. */
  19631. get samples(): number;
  19632. set samples(n: number);
  19633. /**
  19634. * Modify the scale of the post process to be the same as the viewport (default: false)
  19635. */
  19636. adaptScaleToCurrentViewport: boolean;
  19637. private _camera;
  19638. private _scene;
  19639. private _engine;
  19640. private _options;
  19641. private _reusable;
  19642. private _textureType;
  19643. private _textureFormat;
  19644. /**
  19645. * Smart array of input and output textures for the post process.
  19646. * @hidden
  19647. */
  19648. _textures: SmartArray<InternalTexture>;
  19649. /**
  19650. * The index in _textures that corresponds to the output texture.
  19651. * @hidden
  19652. */
  19653. _currentRenderTextureInd: number;
  19654. private _effect;
  19655. private _samplers;
  19656. private _fragmentUrl;
  19657. private _vertexUrl;
  19658. private _parameters;
  19659. private _scaleRatio;
  19660. protected _indexParameters: any;
  19661. private _shareOutputWithPostProcess;
  19662. private _texelSize;
  19663. private _forcedOutputTexture;
  19664. /**
  19665. * Returns the fragment url or shader name used in the post process.
  19666. * @returns the fragment url or name in the shader store.
  19667. */
  19668. getEffectName(): string;
  19669. /**
  19670. * An event triggered when the postprocess is activated.
  19671. */
  19672. onActivateObservable: Observable<Camera>;
  19673. private _onActivateObserver;
  19674. /**
  19675. * A function that is added to the onActivateObservable
  19676. */
  19677. set onActivate(callback: Nullable<(camera: Camera) => void>);
  19678. /**
  19679. * An event triggered when the postprocess changes its size.
  19680. */
  19681. onSizeChangedObservable: Observable<PostProcess>;
  19682. private _onSizeChangedObserver;
  19683. /**
  19684. * A function that is added to the onSizeChangedObservable
  19685. */
  19686. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  19687. /**
  19688. * An event triggered when the postprocess applies its effect.
  19689. */
  19690. onApplyObservable: Observable<Effect>;
  19691. private _onApplyObserver;
  19692. /**
  19693. * A function that is added to the onApplyObservable
  19694. */
  19695. set onApply(callback: (effect: Effect) => void);
  19696. /**
  19697. * An event triggered before rendering the postprocess
  19698. */
  19699. onBeforeRenderObservable: Observable<Effect>;
  19700. private _onBeforeRenderObserver;
  19701. /**
  19702. * A function that is added to the onBeforeRenderObservable
  19703. */
  19704. set onBeforeRender(callback: (effect: Effect) => void);
  19705. /**
  19706. * An event triggered after rendering the postprocess
  19707. */
  19708. onAfterRenderObservable: Observable<Effect>;
  19709. private _onAfterRenderObserver;
  19710. /**
  19711. * A function that is added to the onAfterRenderObservable
  19712. */
  19713. set onAfterRender(callback: (efect: Effect) => void);
  19714. /**
  19715. * 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
  19716. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  19717. */
  19718. get inputTexture(): InternalTexture;
  19719. set inputTexture(value: InternalTexture);
  19720. /**
  19721. * Gets the camera which post process is applied to.
  19722. * @returns The camera the post process is applied to.
  19723. */
  19724. getCamera(): Camera;
  19725. /**
  19726. * Gets the texel size of the postprocess.
  19727. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  19728. */
  19729. get texelSize(): Vector2;
  19730. /**
  19731. * Creates a new instance PostProcess
  19732. * @param name The name of the PostProcess.
  19733. * @param fragmentUrl The url of the fragment shader to be used.
  19734. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  19735. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  19736. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  19737. * @param camera The camera to apply the render pass to.
  19738. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19739. * @param engine The engine which the post process will be applied. (default: current engine)
  19740. * @param reusable If the post process can be reused on the same frame. (default: false)
  19741. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  19742. * @param textureType Type of textures used when performing the post process. (default: 0)
  19743. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  19744. * @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
  19745. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  19746. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  19747. */
  19748. constructor(
  19749. /** Name of the PostProcess. */
  19750. 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);
  19751. /**
  19752. * Gets a string idenfifying the name of the class
  19753. * @returns "PostProcess" string
  19754. */
  19755. getClassName(): string;
  19756. /**
  19757. * Gets the engine which this post process belongs to.
  19758. * @returns The engine the post process was enabled with.
  19759. */
  19760. getEngine(): Engine;
  19761. /**
  19762. * The effect that is created when initializing the post process.
  19763. * @returns The created effect corresponding the the postprocess.
  19764. */
  19765. getEffect(): Effect;
  19766. /**
  19767. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  19768. * @param postProcess The post process to share the output with.
  19769. * @returns This post process.
  19770. */
  19771. shareOutputWith(postProcess: PostProcess): PostProcess;
  19772. /**
  19773. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  19774. * This should be called if the post process that shares output with this post process is disabled/disposed.
  19775. */
  19776. useOwnOutput(): void;
  19777. /**
  19778. * Updates the effect with the current post process compile time values and recompiles the shader.
  19779. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  19780. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  19781. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  19782. * @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
  19783. * @param onCompiled Called when the shader has been compiled.
  19784. * @param onError Called if there is an error when compiling a shader.
  19785. */
  19786. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  19787. /**
  19788. * The post process is reusable if it can be used multiple times within one frame.
  19789. * @returns If the post process is reusable
  19790. */
  19791. isReusable(): boolean;
  19792. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  19793. markTextureDirty(): void;
  19794. /**
  19795. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  19796. * 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.
  19797. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  19798. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  19799. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  19800. * @returns The target texture that was bound to be written to.
  19801. */
  19802. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  19803. /**
  19804. * If the post process is supported.
  19805. */
  19806. get isSupported(): boolean;
  19807. /**
  19808. * The aspect ratio of the output texture.
  19809. */
  19810. get aspectRatio(): number;
  19811. /**
  19812. * Get a value indicating if the post-process is ready to be used
  19813. * @returns true if the post-process is ready (shader is compiled)
  19814. */
  19815. isReady(): boolean;
  19816. /**
  19817. * Binds all textures and uniforms to the shader, this will be run on every pass.
  19818. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  19819. */
  19820. apply(): Nullable<Effect>;
  19821. private _disposeTextures;
  19822. /**
  19823. * Disposes the post process.
  19824. * @param camera The camera to dispose the post process on.
  19825. */
  19826. dispose(camera?: Camera): void;
  19827. }
  19828. }
  19829. declare module BABYLON {
  19830. /** @hidden */
  19831. export var kernelBlurVaryingDeclaration: {
  19832. name: string;
  19833. shader: string;
  19834. };
  19835. }
  19836. declare module BABYLON {
  19837. /** @hidden */
  19838. export var kernelBlurFragment: {
  19839. name: string;
  19840. shader: string;
  19841. };
  19842. }
  19843. declare module BABYLON {
  19844. /** @hidden */
  19845. export var kernelBlurFragment2: {
  19846. name: string;
  19847. shader: string;
  19848. };
  19849. }
  19850. declare module BABYLON {
  19851. /** @hidden */
  19852. export var kernelBlurPixelShader: {
  19853. name: string;
  19854. shader: string;
  19855. };
  19856. }
  19857. declare module BABYLON {
  19858. /** @hidden */
  19859. export var kernelBlurVertex: {
  19860. name: string;
  19861. shader: string;
  19862. };
  19863. }
  19864. declare module BABYLON {
  19865. /** @hidden */
  19866. export var kernelBlurVertexShader: {
  19867. name: string;
  19868. shader: string;
  19869. };
  19870. }
  19871. declare module BABYLON {
  19872. /**
  19873. * The Blur Post Process which blurs an image based on a kernel and direction.
  19874. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  19875. */
  19876. export class BlurPostProcess extends PostProcess {
  19877. /** The direction in which to blur the image. */
  19878. direction: Vector2;
  19879. private blockCompilation;
  19880. protected _kernel: number;
  19881. protected _idealKernel: number;
  19882. protected _packedFloat: boolean;
  19883. private _staticDefines;
  19884. /**
  19885. * Sets the length in pixels of the blur sample region
  19886. */
  19887. set kernel(v: number);
  19888. /**
  19889. * Gets the length in pixels of the blur sample region
  19890. */
  19891. get kernel(): number;
  19892. /**
  19893. * Sets wether or not the blur needs to unpack/repack floats
  19894. */
  19895. set packedFloat(v: boolean);
  19896. /**
  19897. * Gets wether or not the blur is unpacking/repacking floats
  19898. */
  19899. get packedFloat(): boolean;
  19900. /**
  19901. * Creates a new instance BlurPostProcess
  19902. * @param name The name of the effect.
  19903. * @param direction The direction in which to blur the image.
  19904. * @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.
  19905. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  19906. * @param camera The camera to apply the render pass to.
  19907. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19908. * @param engine The engine which the post process will be applied. (default: current engine)
  19909. * @param reusable If the post process can be reused on the same frame. (default: false)
  19910. * @param textureType Type of textures used when performing the post process. (default: 0)
  19911. * @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)
  19912. */
  19913. constructor(name: string,
  19914. /** The direction in which to blur the image. */
  19915. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  19916. /**
  19917. * Updates the effect with the current post process compile time values and recompiles the shader.
  19918. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  19919. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  19920. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  19921. * @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
  19922. * @param onCompiled Called when the shader has been compiled.
  19923. * @param onError Called if there is an error when compiling a shader.
  19924. */
  19925. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  19926. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  19927. /**
  19928. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  19929. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  19930. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  19931. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  19932. * The gaps between physical kernels are compensated for in the weighting of the samples
  19933. * @param idealKernel Ideal blur kernel.
  19934. * @return Nearest best kernel.
  19935. */
  19936. protected _nearestBestKernel(idealKernel: number): number;
  19937. /**
  19938. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  19939. * @param x The point on the Gaussian distribution to sample.
  19940. * @return the value of the Gaussian function at x.
  19941. */
  19942. protected _gaussianWeight(x: number): number;
  19943. /**
  19944. * Generates a string that can be used as a floating point number in GLSL.
  19945. * @param x Value to print.
  19946. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  19947. * @return GLSL float string.
  19948. */
  19949. protected _glslFloat(x: number, decimalFigures?: number): string;
  19950. }
  19951. }
  19952. declare module BABYLON {
  19953. /**
  19954. * Mirror texture can be used to simulate the view from a mirror in a scene.
  19955. * It will dynamically be rendered every frame to adapt to the camera point of view.
  19956. * You can then easily use it as a reflectionTexture on a flat surface.
  19957. * In case the surface is not a plane, please consider relying on reflection probes.
  19958. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  19959. */
  19960. export class MirrorTexture extends RenderTargetTexture {
  19961. private scene;
  19962. /**
  19963. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  19964. * 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.
  19965. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  19966. */
  19967. mirrorPlane: Plane;
  19968. /**
  19969. * Define the blur ratio used to blur the reflection if needed.
  19970. */
  19971. set blurRatio(value: number);
  19972. get blurRatio(): number;
  19973. /**
  19974. * Define the adaptive blur kernel used to blur the reflection if needed.
  19975. * This will autocompute the closest best match for the `blurKernel`
  19976. */
  19977. set adaptiveBlurKernel(value: number);
  19978. /**
  19979. * Define the blur kernel used to blur the reflection if needed.
  19980. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  19981. */
  19982. set blurKernel(value: number);
  19983. /**
  19984. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  19985. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  19986. */
  19987. set blurKernelX(value: number);
  19988. get blurKernelX(): number;
  19989. /**
  19990. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  19991. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  19992. */
  19993. set blurKernelY(value: number);
  19994. get blurKernelY(): number;
  19995. private _autoComputeBlurKernel;
  19996. protected _onRatioRescale(): void;
  19997. private _updateGammaSpace;
  19998. private _imageProcessingConfigChangeObserver;
  19999. private _transformMatrix;
  20000. private _mirrorMatrix;
  20001. private _savedViewMatrix;
  20002. private _blurX;
  20003. private _blurY;
  20004. private _adaptiveBlurKernel;
  20005. private _blurKernelX;
  20006. private _blurKernelY;
  20007. private _blurRatio;
  20008. /**
  20009. * Instantiates a Mirror Texture.
  20010. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20011. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20012. * You can then easily use it as a reflectionTexture on a flat surface.
  20013. * In case the surface is not a plane, please consider relying on reflection probes.
  20014. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20015. * @param name
  20016. * @param size
  20017. * @param scene
  20018. * @param generateMipMaps
  20019. * @param type
  20020. * @param samplingMode
  20021. * @param generateDepthBuffer
  20022. */
  20023. constructor(name: string, size: number | {
  20024. width: number;
  20025. height: number;
  20026. } | {
  20027. ratio: number;
  20028. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  20029. private _preparePostProcesses;
  20030. /**
  20031. * Clone the mirror texture.
  20032. * @returns the cloned texture
  20033. */
  20034. clone(): MirrorTexture;
  20035. /**
  20036. * Serialize the texture to a JSON representation you could use in Parse later on
  20037. * @returns the serialized JSON representation
  20038. */
  20039. serialize(): any;
  20040. /**
  20041. * Dispose the texture and release its associated resources.
  20042. */
  20043. dispose(): void;
  20044. }
  20045. }
  20046. declare module BABYLON {
  20047. /**
  20048. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20049. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20050. */
  20051. export class Texture extends BaseTexture {
  20052. /**
  20053. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  20054. */
  20055. static SerializeBuffers: boolean;
  20056. /** @hidden */
  20057. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  20058. /** @hidden */
  20059. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  20060. /** @hidden */
  20061. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  20062. /** nearest is mag = nearest and min = nearest and mip = linear */
  20063. static readonly NEAREST_SAMPLINGMODE: number;
  20064. /** nearest is mag = nearest and min = nearest and mip = linear */
  20065. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  20066. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20067. static readonly BILINEAR_SAMPLINGMODE: number;
  20068. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20069. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  20070. /** Trilinear is mag = linear and min = linear and mip = linear */
  20071. static readonly TRILINEAR_SAMPLINGMODE: number;
  20072. /** Trilinear is mag = linear and min = linear and mip = linear */
  20073. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  20074. /** mag = nearest and min = nearest and mip = nearest */
  20075. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  20076. /** mag = nearest and min = linear and mip = nearest */
  20077. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  20078. /** mag = nearest and min = linear and mip = linear */
  20079. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  20080. /** mag = nearest and min = linear and mip = none */
  20081. static readonly NEAREST_LINEAR: number;
  20082. /** mag = nearest and min = nearest and mip = none */
  20083. static readonly NEAREST_NEAREST: number;
  20084. /** mag = linear and min = nearest and mip = nearest */
  20085. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  20086. /** mag = linear and min = nearest and mip = linear */
  20087. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  20088. /** mag = linear and min = linear and mip = none */
  20089. static readonly LINEAR_LINEAR: number;
  20090. /** mag = linear and min = nearest and mip = none */
  20091. static readonly LINEAR_NEAREST: number;
  20092. /** Explicit coordinates mode */
  20093. static readonly EXPLICIT_MODE: number;
  20094. /** Spherical coordinates mode */
  20095. static readonly SPHERICAL_MODE: number;
  20096. /** Planar coordinates mode */
  20097. static readonly PLANAR_MODE: number;
  20098. /** Cubic coordinates mode */
  20099. static readonly CUBIC_MODE: number;
  20100. /** Projection coordinates mode */
  20101. static readonly PROJECTION_MODE: number;
  20102. /** Inverse Cubic coordinates mode */
  20103. static readonly SKYBOX_MODE: number;
  20104. /** Inverse Cubic coordinates mode */
  20105. static readonly INVCUBIC_MODE: number;
  20106. /** Equirectangular coordinates mode */
  20107. static readonly EQUIRECTANGULAR_MODE: number;
  20108. /** Equirectangular Fixed coordinates mode */
  20109. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  20110. /** Equirectangular Fixed Mirrored coordinates mode */
  20111. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  20112. /** Texture is not repeating outside of 0..1 UVs */
  20113. static readonly CLAMP_ADDRESSMODE: number;
  20114. /** Texture is repeating outside of 0..1 UVs */
  20115. static readonly WRAP_ADDRESSMODE: number;
  20116. /** Texture is repeating and mirrored */
  20117. static readonly MIRROR_ADDRESSMODE: number;
  20118. /**
  20119. * 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
  20120. */
  20121. static UseSerializedUrlIfAny: boolean;
  20122. /**
  20123. * Define the url of the texture.
  20124. */
  20125. url: Nullable<string>;
  20126. /**
  20127. * Define an offset on the texture to offset the u coordinates of the UVs
  20128. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20129. */
  20130. uOffset: number;
  20131. /**
  20132. * Define an offset on the texture to offset the v coordinates of the UVs
  20133. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20134. */
  20135. vOffset: number;
  20136. /**
  20137. * Define an offset on the texture to scale the u coordinates of the UVs
  20138. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20139. */
  20140. uScale: number;
  20141. /**
  20142. * Define an offset on the texture to scale the v coordinates of the UVs
  20143. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20144. */
  20145. vScale: number;
  20146. /**
  20147. * Define an offset on the texture to rotate around the u coordinates of the UVs
  20148. * @see http://doc.babylonjs.com/how_to/more_materials
  20149. */
  20150. uAng: number;
  20151. /**
  20152. * Define an offset on the texture to rotate around the v coordinates of the UVs
  20153. * @see http://doc.babylonjs.com/how_to/more_materials
  20154. */
  20155. vAng: number;
  20156. /**
  20157. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  20158. * @see http://doc.babylonjs.com/how_to/more_materials
  20159. */
  20160. wAng: number;
  20161. /**
  20162. * Defines the center of rotation (U)
  20163. */
  20164. uRotationCenter: number;
  20165. /**
  20166. * Defines the center of rotation (V)
  20167. */
  20168. vRotationCenter: number;
  20169. /**
  20170. * Defines the center of rotation (W)
  20171. */
  20172. wRotationCenter: number;
  20173. /**
  20174. * Are mip maps generated for this texture or not.
  20175. */
  20176. get noMipmap(): boolean;
  20177. /**
  20178. * List of inspectable custom properties (used by the Inspector)
  20179. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20180. */
  20181. inspectableCustomProperties: Nullable<IInspectable[]>;
  20182. private _noMipmap;
  20183. /** @hidden */
  20184. _invertY: boolean;
  20185. private _rowGenerationMatrix;
  20186. private _cachedTextureMatrix;
  20187. private _projectionModeMatrix;
  20188. private _t0;
  20189. private _t1;
  20190. private _t2;
  20191. private _cachedUOffset;
  20192. private _cachedVOffset;
  20193. private _cachedUScale;
  20194. private _cachedVScale;
  20195. private _cachedUAng;
  20196. private _cachedVAng;
  20197. private _cachedWAng;
  20198. private _cachedProjectionMatrixId;
  20199. private _cachedCoordinatesMode;
  20200. /** @hidden */
  20201. protected _initialSamplingMode: number;
  20202. /** @hidden */
  20203. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  20204. private _deleteBuffer;
  20205. protected _format: Nullable<number>;
  20206. private _delayedOnLoad;
  20207. private _delayedOnError;
  20208. private _mimeType?;
  20209. /**
  20210. * Observable triggered once the texture has been loaded.
  20211. */
  20212. onLoadObservable: Observable<Texture>;
  20213. protected _isBlocking: boolean;
  20214. /**
  20215. * Is the texture preventing material to render while loading.
  20216. * If false, a default texture will be used instead of the loading one during the preparation step.
  20217. */
  20218. set isBlocking(value: boolean);
  20219. get isBlocking(): boolean;
  20220. /**
  20221. * Get the current sampling mode associated with the texture.
  20222. */
  20223. get samplingMode(): number;
  20224. /**
  20225. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  20226. */
  20227. get invertY(): boolean;
  20228. /**
  20229. * Instantiates a new texture.
  20230. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20231. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20232. * @param url defines the url of the picture to load as a texture
  20233. * @param scene defines the scene or engine the texture will belong to
  20234. * @param noMipmap defines if the texture will require mip maps or not
  20235. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  20236. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20237. * @param onLoad defines a callback triggered when the texture has been loaded
  20238. * @param onError defines a callback triggered when an error occurred during the loading session
  20239. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  20240. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  20241. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20242. * @param mimeType defines an optional mime type information
  20243. */
  20244. 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);
  20245. /**
  20246. * Update the url (and optional buffer) of this texture if url was null during construction.
  20247. * @param url the url of the texture
  20248. * @param buffer the buffer of the texture (defaults to null)
  20249. * @param onLoad callback called when the texture is loaded (defaults to null)
  20250. */
  20251. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  20252. /**
  20253. * Finish the loading sequence of a texture flagged as delayed load.
  20254. * @hidden
  20255. */
  20256. delayLoad(): void;
  20257. private _prepareRowForTextureGeneration;
  20258. /**
  20259. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  20260. * @returns the transform matrix of the texture.
  20261. */
  20262. getTextureMatrix(uBase?: number): Matrix;
  20263. /**
  20264. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  20265. * @returns The reflection texture transform
  20266. */
  20267. getReflectionTextureMatrix(): Matrix;
  20268. /**
  20269. * Clones the texture.
  20270. * @returns the cloned texture
  20271. */
  20272. clone(): Texture;
  20273. /**
  20274. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20275. * @returns The JSON representation of the texture
  20276. */
  20277. serialize(): any;
  20278. /**
  20279. * Get the current class name of the texture useful for serialization or dynamic coding.
  20280. * @returns "Texture"
  20281. */
  20282. getClassName(): string;
  20283. /**
  20284. * Dispose the texture and release its associated resources.
  20285. */
  20286. dispose(): void;
  20287. /**
  20288. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  20289. * @param parsedTexture Define the JSON representation of the texture
  20290. * @param scene Define the scene the parsed texture should be instantiated in
  20291. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  20292. * @returns The parsed texture if successful
  20293. */
  20294. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  20295. /**
  20296. * Creates a texture from its base 64 representation.
  20297. * @param data Define the base64 payload without the data: prefix
  20298. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20299. * @param scene Define the scene the texture should belong to
  20300. * @param noMipmap Forces the texture to not create mip map information if true
  20301. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20302. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20303. * @param onLoad define a callback triggered when the texture has been loaded
  20304. * @param onError define a callback triggered when an error occurred during the loading session
  20305. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20306. * @returns the created texture
  20307. */
  20308. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  20309. /**
  20310. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  20311. * @param data Define the base64 payload without the data: prefix
  20312. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20313. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  20314. * @param scene Define the scene the texture should belong to
  20315. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  20316. * @param noMipmap Forces the texture to not create mip map information if true
  20317. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20318. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20319. * @param onLoad define a callback triggered when the texture has been loaded
  20320. * @param onError define a callback triggered when an error occurred during the loading session
  20321. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20322. * @returns the created texture
  20323. */
  20324. 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;
  20325. }
  20326. }
  20327. declare module BABYLON {
  20328. /**
  20329. * PostProcessManager is used to manage one or more post processes or post process pipelines
  20330. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20331. */
  20332. export class PostProcessManager {
  20333. private _scene;
  20334. private _indexBuffer;
  20335. private _vertexBuffers;
  20336. /**
  20337. * Creates a new instance PostProcess
  20338. * @param scene The scene that the post process is associated with.
  20339. */
  20340. constructor(scene: Scene);
  20341. private _prepareBuffers;
  20342. private _buildIndexBuffer;
  20343. /**
  20344. * Rebuilds the vertex buffers of the manager.
  20345. * @hidden
  20346. */
  20347. _rebuild(): void;
  20348. /**
  20349. * Prepares a frame to be run through a post process.
  20350. * @param sourceTexture The input texture to the post procesess. (default: null)
  20351. * @param postProcesses An array of post processes to be run. (default: null)
  20352. * @returns True if the post processes were able to be run.
  20353. * @hidden
  20354. */
  20355. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  20356. /**
  20357. * Manually render a set of post processes to a texture.
  20358. * @param postProcesses An array of post processes to be run.
  20359. * @param targetTexture The target texture to render to.
  20360. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  20361. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  20362. * @param lodLevel defines which lod of the texture to render to
  20363. */
  20364. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  20365. /**
  20366. * Finalize the result of the output of the postprocesses.
  20367. * @param doNotPresent If true the result will not be displayed to the screen.
  20368. * @param targetTexture The target texture to render to.
  20369. * @param faceIndex The index of the face to bind the target texture to.
  20370. * @param postProcesses The array of post processes to render.
  20371. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  20372. * @hidden
  20373. */
  20374. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  20375. /**
  20376. * Disposes of the post process manager.
  20377. */
  20378. dispose(): void;
  20379. }
  20380. }
  20381. declare module BABYLON {
  20382. /**
  20383. * This Helps creating a texture that will be created from a camera in your scene.
  20384. * It is basically a dynamic texture that could be used to create special effects for instance.
  20385. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20386. */
  20387. export class RenderTargetTexture extends Texture {
  20388. isCube: boolean;
  20389. /**
  20390. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20391. */
  20392. static readonly REFRESHRATE_RENDER_ONCE: number;
  20393. /**
  20394. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20395. */
  20396. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20397. /**
  20398. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20399. * the central point of your effect and can save a lot of performances.
  20400. */
  20401. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20402. /**
  20403. * Use this predicate to dynamically define the list of mesh you want to render.
  20404. * If set, the renderList property will be overwritten.
  20405. */
  20406. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20407. private _renderList;
  20408. /**
  20409. * Use this list to define the list of mesh you want to render.
  20410. */
  20411. get renderList(): Nullable<Array<AbstractMesh>>;
  20412. set renderList(value: Nullable<Array<AbstractMesh>>);
  20413. /**
  20414. * Use this function to overload the renderList array at rendering time.
  20415. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  20416. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  20417. * the cube (if the RTT is a cube, else layerOrFace=0).
  20418. * The renderList passed to the function is the current render list (the one that will be used if the function returns null)
  20419. */
  20420. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>) => Nullable<Array<AbstractMesh>>;
  20421. private _hookArray;
  20422. /**
  20423. * Define if particles should be rendered in your texture.
  20424. */
  20425. renderParticles: boolean;
  20426. /**
  20427. * Define if sprites should be rendered in your texture.
  20428. */
  20429. renderSprites: boolean;
  20430. /**
  20431. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20432. */
  20433. coordinatesMode: number;
  20434. /**
  20435. * Define the camera used to render the texture.
  20436. */
  20437. activeCamera: Nullable<Camera>;
  20438. /**
  20439. * Override the render function of the texture with your own one.
  20440. */
  20441. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20442. /**
  20443. * Define if camera post processes should be use while rendering the texture.
  20444. */
  20445. useCameraPostProcesses: boolean;
  20446. /**
  20447. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20448. */
  20449. ignoreCameraViewport: boolean;
  20450. private _postProcessManager;
  20451. private _postProcesses;
  20452. private _resizeObserver;
  20453. /**
  20454. * An event triggered when the texture is unbind.
  20455. */
  20456. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20457. /**
  20458. * An event triggered when the texture is unbind.
  20459. */
  20460. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20461. private _onAfterUnbindObserver;
  20462. /**
  20463. * Set a after unbind callback in the texture.
  20464. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20465. */
  20466. set onAfterUnbind(callback: () => void);
  20467. /**
  20468. * An event triggered before rendering the texture
  20469. */
  20470. onBeforeRenderObservable: Observable<number>;
  20471. private _onBeforeRenderObserver;
  20472. /**
  20473. * Set a before render callback in the texture.
  20474. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20475. */
  20476. set onBeforeRender(callback: (faceIndex: number) => void);
  20477. /**
  20478. * An event triggered after rendering the texture
  20479. */
  20480. onAfterRenderObservable: Observable<number>;
  20481. private _onAfterRenderObserver;
  20482. /**
  20483. * Set a after render callback in the texture.
  20484. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20485. */
  20486. set onAfterRender(callback: (faceIndex: number) => void);
  20487. /**
  20488. * An event triggered after the texture clear
  20489. */
  20490. onClearObservable: Observable<Engine>;
  20491. private _onClearObserver;
  20492. /**
  20493. * Set a clear callback in the texture.
  20494. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20495. */
  20496. set onClear(callback: (Engine: Engine) => void);
  20497. /**
  20498. * An event triggered when the texture is resized.
  20499. */
  20500. onResizeObservable: Observable<RenderTargetTexture>;
  20501. /**
  20502. * Define the clear color of the Render Target if it should be different from the scene.
  20503. */
  20504. clearColor: Color4;
  20505. protected _size: number | {
  20506. width: number;
  20507. height: number;
  20508. layers?: number;
  20509. };
  20510. protected _initialSizeParameter: number | {
  20511. width: number;
  20512. height: number;
  20513. } | {
  20514. ratio: number;
  20515. };
  20516. protected _sizeRatio: Nullable<number>;
  20517. /** @hidden */
  20518. _generateMipMaps: boolean;
  20519. protected _renderingManager: RenderingManager;
  20520. /** @hidden */
  20521. _waitingRenderList: string[];
  20522. protected _doNotChangeAspectRatio: boolean;
  20523. protected _currentRefreshId: number;
  20524. protected _refreshRate: number;
  20525. protected _textureMatrix: Matrix;
  20526. protected _samples: number;
  20527. protected _renderTargetOptions: RenderTargetCreationOptions;
  20528. /**
  20529. * Gets render target creation options that were used.
  20530. */
  20531. get renderTargetOptions(): RenderTargetCreationOptions;
  20532. protected _engine: Engine;
  20533. protected _onRatioRescale(): void;
  20534. /**
  20535. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20536. * It must define where the camera used to render the texture is set
  20537. */
  20538. boundingBoxPosition: Vector3;
  20539. private _boundingBoxSize;
  20540. /**
  20541. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20542. * When defined, the cubemap will switch to local mode
  20543. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20544. * @example https://www.babylonjs-playground.com/#RNASML
  20545. */
  20546. set boundingBoxSize(value: Vector3);
  20547. get boundingBoxSize(): Vector3;
  20548. /**
  20549. * In case the RTT has been created with a depth texture, get the associated
  20550. * depth texture.
  20551. * Otherwise, return null.
  20552. */
  20553. get depthStencilTexture(): Nullable<InternalTexture>;
  20554. /**
  20555. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20556. * or used a shadow, depth texture...
  20557. * @param name The friendly name of the texture
  20558. * @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)
  20559. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20560. * @param generateMipMaps True if mip maps need to be generated after render.
  20561. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20562. * @param type The type of the buffer in the RTT (int, half float, float...)
  20563. * @param isCube True if a cube texture needs to be created
  20564. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20565. * @param generateDepthBuffer True to generate a depth buffer
  20566. * @param generateStencilBuffer True to generate a stencil buffer
  20567. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20568. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20569. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20570. */
  20571. constructor(name: string, size: number | {
  20572. width: number;
  20573. height: number;
  20574. layers?: number;
  20575. } | {
  20576. ratio: number;
  20577. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20578. /**
  20579. * Creates a depth stencil texture.
  20580. * This is only available in WebGL 2 or with the depth texture extension available.
  20581. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20582. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20583. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20584. */
  20585. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20586. private _processSizeParameter;
  20587. /**
  20588. * Define the number of samples to use in case of MSAA.
  20589. * It defaults to one meaning no MSAA has been enabled.
  20590. */
  20591. get samples(): number;
  20592. set samples(value: number);
  20593. /**
  20594. * Resets the refresh counter of the texture and start bak from scratch.
  20595. * Could be useful to regenerate the texture if it is setup to render only once.
  20596. */
  20597. resetRefreshCounter(): void;
  20598. /**
  20599. * Define the refresh rate of the texture or the rendering frequency.
  20600. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20601. */
  20602. get refreshRate(): number;
  20603. set refreshRate(value: number);
  20604. /**
  20605. * Adds a post process to the render target rendering passes.
  20606. * @param postProcess define the post process to add
  20607. */
  20608. addPostProcess(postProcess: PostProcess): void;
  20609. /**
  20610. * Clear all the post processes attached to the render target
  20611. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20612. */
  20613. clearPostProcesses(dispose?: boolean): void;
  20614. /**
  20615. * Remove one of the post process from the list of attached post processes to the texture
  20616. * @param postProcess define the post process to remove from the list
  20617. */
  20618. removePostProcess(postProcess: PostProcess): void;
  20619. /** @hidden */
  20620. _shouldRender(): boolean;
  20621. /**
  20622. * Gets the actual render size of the texture.
  20623. * @returns the width of the render size
  20624. */
  20625. getRenderSize(): number;
  20626. /**
  20627. * Gets the actual render width of the texture.
  20628. * @returns the width of the render size
  20629. */
  20630. getRenderWidth(): number;
  20631. /**
  20632. * Gets the actual render height of the texture.
  20633. * @returns the height of the render size
  20634. */
  20635. getRenderHeight(): number;
  20636. /**
  20637. * Gets the actual number of layers of the texture.
  20638. * @returns the number of layers
  20639. */
  20640. getRenderLayers(): number;
  20641. /**
  20642. * Get if the texture can be rescaled or not.
  20643. */
  20644. get canRescale(): boolean;
  20645. /**
  20646. * Resize the texture using a ratio.
  20647. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20648. */
  20649. scale(ratio: number): void;
  20650. /**
  20651. * Get the texture reflection matrix used to rotate/transform the reflection.
  20652. * @returns the reflection matrix
  20653. */
  20654. getReflectionTextureMatrix(): Matrix;
  20655. /**
  20656. * Resize the texture to a new desired size.
  20657. * Be carrefull as it will recreate all the data in the new texture.
  20658. * @param size Define the new size. It can be:
  20659. * - a number for squared texture,
  20660. * - an object containing { width: number, height: number }
  20661. * - or an object containing a ratio { ratio: number }
  20662. */
  20663. resize(size: number | {
  20664. width: number;
  20665. height: number;
  20666. } | {
  20667. ratio: number;
  20668. }): void;
  20669. private _defaultRenderListPrepared;
  20670. /**
  20671. * Renders all the objects from the render list into the texture.
  20672. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20673. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20674. */
  20675. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20676. private _bestReflectionRenderTargetDimension;
  20677. private _prepareRenderingManager;
  20678. /**
  20679. * @hidden
  20680. * @param faceIndex face index to bind to if this is a cubetexture
  20681. * @param layer defines the index of the texture to bind in the array
  20682. */
  20683. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  20684. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20685. private renderToTarget;
  20686. /**
  20687. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20688. * This allowed control for front to back rendering or reversly depending of the special needs.
  20689. *
  20690. * @param renderingGroupId The rendering group id corresponding to its index
  20691. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20692. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20693. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20694. */
  20695. 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;
  20696. /**
  20697. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20698. *
  20699. * @param renderingGroupId The rendering group id corresponding to its index
  20700. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20701. */
  20702. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20703. /**
  20704. * Clones the texture.
  20705. * @returns the cloned texture
  20706. */
  20707. clone(): RenderTargetTexture;
  20708. /**
  20709. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20710. * @returns The JSON representation of the texture
  20711. */
  20712. serialize(): any;
  20713. /**
  20714. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20715. */
  20716. disposeFramebufferObjects(): void;
  20717. /**
  20718. * Dispose the texture and release its associated resources.
  20719. */
  20720. dispose(): void;
  20721. /** @hidden */
  20722. _rebuild(): void;
  20723. /**
  20724. * Clear the info related to rendering groups preventing retention point in material dispose.
  20725. */
  20726. freeRenderingGroups(): void;
  20727. /**
  20728. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20729. * @returns the view count
  20730. */
  20731. getViewCount(): number;
  20732. }
  20733. }
  20734. declare module BABYLON {
  20735. /**
  20736. * Options for compiling materials.
  20737. */
  20738. export interface IMaterialCompilationOptions {
  20739. /**
  20740. * Defines whether clip planes are enabled.
  20741. */
  20742. clipPlane: boolean;
  20743. /**
  20744. * Defines whether instances are enabled.
  20745. */
  20746. useInstances: boolean;
  20747. }
  20748. /**
  20749. * Base class for the main features of a material in Babylon.js
  20750. */
  20751. export class Material implements IAnimatable {
  20752. /**
  20753. * Returns the triangle fill mode
  20754. */
  20755. static readonly TriangleFillMode: number;
  20756. /**
  20757. * Returns the wireframe mode
  20758. */
  20759. static readonly WireFrameFillMode: number;
  20760. /**
  20761. * Returns the point fill mode
  20762. */
  20763. static readonly PointFillMode: number;
  20764. /**
  20765. * Returns the point list draw mode
  20766. */
  20767. static readonly PointListDrawMode: number;
  20768. /**
  20769. * Returns the line list draw mode
  20770. */
  20771. static readonly LineListDrawMode: number;
  20772. /**
  20773. * Returns the line loop draw mode
  20774. */
  20775. static readonly LineLoopDrawMode: number;
  20776. /**
  20777. * Returns the line strip draw mode
  20778. */
  20779. static readonly LineStripDrawMode: number;
  20780. /**
  20781. * Returns the triangle strip draw mode
  20782. */
  20783. static readonly TriangleStripDrawMode: number;
  20784. /**
  20785. * Returns the triangle fan draw mode
  20786. */
  20787. static readonly TriangleFanDrawMode: number;
  20788. /**
  20789. * Stores the clock-wise side orientation
  20790. */
  20791. static readonly ClockWiseSideOrientation: number;
  20792. /**
  20793. * Stores the counter clock-wise side orientation
  20794. */
  20795. static readonly CounterClockWiseSideOrientation: number;
  20796. /**
  20797. * The dirty texture flag value
  20798. */
  20799. static readonly TextureDirtyFlag: number;
  20800. /**
  20801. * The dirty light flag value
  20802. */
  20803. static readonly LightDirtyFlag: number;
  20804. /**
  20805. * The dirty fresnel flag value
  20806. */
  20807. static readonly FresnelDirtyFlag: number;
  20808. /**
  20809. * The dirty attribute flag value
  20810. */
  20811. static readonly AttributesDirtyFlag: number;
  20812. /**
  20813. * The dirty misc flag value
  20814. */
  20815. static readonly MiscDirtyFlag: number;
  20816. /**
  20817. * The all dirty flag value
  20818. */
  20819. static readonly AllDirtyFlag: number;
  20820. /**
  20821. * The ID of the material
  20822. */
  20823. id: string;
  20824. /**
  20825. * Gets or sets the unique id of the material
  20826. */
  20827. uniqueId: number;
  20828. /**
  20829. * The name of the material
  20830. */
  20831. name: string;
  20832. /**
  20833. * Gets or sets user defined metadata
  20834. */
  20835. metadata: any;
  20836. /**
  20837. * For internal use only. Please do not use.
  20838. */
  20839. reservedDataStore: any;
  20840. /**
  20841. * Specifies if the ready state should be checked on each call
  20842. */
  20843. checkReadyOnEveryCall: boolean;
  20844. /**
  20845. * Specifies if the ready state should be checked once
  20846. */
  20847. checkReadyOnlyOnce: boolean;
  20848. /**
  20849. * The state of the material
  20850. */
  20851. state: string;
  20852. /**
  20853. * The alpha value of the material
  20854. */
  20855. protected _alpha: number;
  20856. /**
  20857. * List of inspectable custom properties (used by the Inspector)
  20858. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20859. */
  20860. inspectableCustomProperties: IInspectable[];
  20861. /**
  20862. * Sets the alpha value of the material
  20863. */
  20864. set alpha(value: number);
  20865. /**
  20866. * Gets the alpha value of the material
  20867. */
  20868. get alpha(): number;
  20869. /**
  20870. * Specifies if back face culling is enabled
  20871. */
  20872. protected _backFaceCulling: boolean;
  20873. /**
  20874. * Sets the back-face culling state
  20875. */
  20876. set backFaceCulling(value: boolean);
  20877. /**
  20878. * Gets the back-face culling state
  20879. */
  20880. get backFaceCulling(): boolean;
  20881. /**
  20882. * Stores the value for side orientation
  20883. */
  20884. sideOrientation: number;
  20885. /**
  20886. * Callback triggered when the material is compiled
  20887. */
  20888. onCompiled: Nullable<(effect: Effect) => void>;
  20889. /**
  20890. * Callback triggered when an error occurs
  20891. */
  20892. onError: Nullable<(effect: Effect, errors: string) => void>;
  20893. /**
  20894. * Callback triggered to get the render target textures
  20895. */
  20896. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20897. /**
  20898. * Gets a boolean indicating that current material needs to register RTT
  20899. */
  20900. get hasRenderTargetTextures(): boolean;
  20901. /**
  20902. * Specifies if the material should be serialized
  20903. */
  20904. doNotSerialize: boolean;
  20905. /**
  20906. * @hidden
  20907. */
  20908. _storeEffectOnSubMeshes: boolean;
  20909. /**
  20910. * Stores the animations for the material
  20911. */
  20912. animations: Nullable<Array<Animation>>;
  20913. /**
  20914. * An event triggered when the material is disposed
  20915. */
  20916. onDisposeObservable: Observable<Material>;
  20917. /**
  20918. * An observer which watches for dispose events
  20919. */
  20920. private _onDisposeObserver;
  20921. private _onUnBindObservable;
  20922. /**
  20923. * Called during a dispose event
  20924. */
  20925. set onDispose(callback: () => void);
  20926. private _onBindObservable;
  20927. /**
  20928. * An event triggered when the material is bound
  20929. */
  20930. get onBindObservable(): Observable<AbstractMesh>;
  20931. /**
  20932. * An observer which watches for bind events
  20933. */
  20934. private _onBindObserver;
  20935. /**
  20936. * Called during a bind event
  20937. */
  20938. set onBind(callback: (Mesh: AbstractMesh) => void);
  20939. /**
  20940. * An event triggered when the material is unbound
  20941. */
  20942. get onUnBindObservable(): Observable<Material>;
  20943. /**
  20944. * Stores the value of the alpha mode
  20945. */
  20946. private _alphaMode;
  20947. /**
  20948. * Sets the value of the alpha mode.
  20949. *
  20950. * | Value | Type | Description |
  20951. * | --- | --- | --- |
  20952. * | 0 | ALPHA_DISABLE | |
  20953. * | 1 | ALPHA_ADD | |
  20954. * | 2 | ALPHA_COMBINE | |
  20955. * | 3 | ALPHA_SUBTRACT | |
  20956. * | 4 | ALPHA_MULTIPLY | |
  20957. * | 5 | ALPHA_MAXIMIZED | |
  20958. * | 6 | ALPHA_ONEONE | |
  20959. * | 7 | ALPHA_PREMULTIPLIED | |
  20960. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20961. * | 9 | ALPHA_INTERPOLATE | |
  20962. * | 10 | ALPHA_SCREENMODE | |
  20963. *
  20964. */
  20965. set alphaMode(value: number);
  20966. /**
  20967. * Gets the value of the alpha mode
  20968. */
  20969. get alphaMode(): number;
  20970. /**
  20971. * Stores the state of the need depth pre-pass value
  20972. */
  20973. private _needDepthPrePass;
  20974. /**
  20975. * Sets the need depth pre-pass value
  20976. */
  20977. set needDepthPrePass(value: boolean);
  20978. /**
  20979. * Gets the depth pre-pass value
  20980. */
  20981. get needDepthPrePass(): boolean;
  20982. /**
  20983. * Specifies if depth writing should be disabled
  20984. */
  20985. disableDepthWrite: boolean;
  20986. /**
  20987. * Specifies if depth writing should be forced
  20988. */
  20989. forceDepthWrite: boolean;
  20990. /**
  20991. * Specifies the depth function that should be used. 0 means the default engine function
  20992. */
  20993. depthFunction: number;
  20994. /**
  20995. * Specifies if there should be a separate pass for culling
  20996. */
  20997. separateCullingPass: boolean;
  20998. /**
  20999. * Stores the state specifing if fog should be enabled
  21000. */
  21001. private _fogEnabled;
  21002. /**
  21003. * Sets the state for enabling fog
  21004. */
  21005. set fogEnabled(value: boolean);
  21006. /**
  21007. * Gets the value of the fog enabled state
  21008. */
  21009. get fogEnabled(): boolean;
  21010. /**
  21011. * Stores the size of points
  21012. */
  21013. pointSize: number;
  21014. /**
  21015. * Stores the z offset value
  21016. */
  21017. zOffset: number;
  21018. /**
  21019. * Gets a value specifying if wireframe mode is enabled
  21020. */
  21021. get wireframe(): boolean;
  21022. /**
  21023. * Sets the state of wireframe mode
  21024. */
  21025. set wireframe(value: boolean);
  21026. /**
  21027. * Gets the value specifying if point clouds are enabled
  21028. */
  21029. get pointsCloud(): boolean;
  21030. /**
  21031. * Sets the state of point cloud mode
  21032. */
  21033. set pointsCloud(value: boolean);
  21034. /**
  21035. * Gets the material fill mode
  21036. */
  21037. get fillMode(): number;
  21038. /**
  21039. * Sets the material fill mode
  21040. */
  21041. set fillMode(value: number);
  21042. /**
  21043. * @hidden
  21044. * Stores the effects for the material
  21045. */
  21046. _effect: Nullable<Effect>;
  21047. /**
  21048. * Specifies if uniform buffers should be used
  21049. */
  21050. private _useUBO;
  21051. /**
  21052. * Stores a reference to the scene
  21053. */
  21054. private _scene;
  21055. /**
  21056. * Stores the fill mode state
  21057. */
  21058. private _fillMode;
  21059. /**
  21060. * Specifies if the depth write state should be cached
  21061. */
  21062. private _cachedDepthWriteState;
  21063. /**
  21064. * Specifies if the depth function state should be cached
  21065. */
  21066. private _cachedDepthFunctionState;
  21067. /**
  21068. * Stores the uniform buffer
  21069. */
  21070. protected _uniformBuffer: UniformBuffer;
  21071. /** @hidden */
  21072. _indexInSceneMaterialArray: number;
  21073. /** @hidden */
  21074. meshMap: Nullable<{
  21075. [id: string]: AbstractMesh | undefined;
  21076. }>;
  21077. /**
  21078. * Creates a material instance
  21079. * @param name defines the name of the material
  21080. * @param scene defines the scene to reference
  21081. * @param doNotAdd specifies if the material should be added to the scene
  21082. */
  21083. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21084. /**
  21085. * Returns a string representation of the current material
  21086. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21087. * @returns a string with material information
  21088. */
  21089. toString(fullDetails?: boolean): string;
  21090. /**
  21091. * Gets the class name of the material
  21092. * @returns a string with the class name of the material
  21093. */
  21094. getClassName(): string;
  21095. /**
  21096. * Specifies if updates for the material been locked
  21097. */
  21098. get isFrozen(): boolean;
  21099. /**
  21100. * Locks updates for the material
  21101. */
  21102. freeze(): void;
  21103. /**
  21104. * Unlocks updates for the material
  21105. */
  21106. unfreeze(): void;
  21107. /**
  21108. * Specifies if the material is ready to be used
  21109. * @param mesh defines the mesh to check
  21110. * @param useInstances specifies if instances should be used
  21111. * @returns a boolean indicating if the material is ready to be used
  21112. */
  21113. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21114. /**
  21115. * Specifies that the submesh is ready to be used
  21116. * @param mesh defines the mesh to check
  21117. * @param subMesh defines which submesh to check
  21118. * @param useInstances specifies that instances should be used
  21119. * @returns a boolean indicating that the submesh is ready or not
  21120. */
  21121. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21122. /**
  21123. * Returns the material effect
  21124. * @returns the effect associated with the material
  21125. */
  21126. getEffect(): Nullable<Effect>;
  21127. /**
  21128. * Returns the current scene
  21129. * @returns a Scene
  21130. */
  21131. getScene(): Scene;
  21132. /**
  21133. * Specifies if the material will require alpha blending
  21134. * @returns a boolean specifying if alpha blending is needed
  21135. */
  21136. needAlphaBlending(): boolean;
  21137. /**
  21138. * Specifies if the mesh will require alpha blending
  21139. * @param mesh defines the mesh to check
  21140. * @returns a boolean specifying if alpha blending is needed for the mesh
  21141. */
  21142. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21143. /**
  21144. * Specifies if this material should be rendered in alpha test mode
  21145. * @returns a boolean specifying if an alpha test is needed.
  21146. */
  21147. needAlphaTesting(): boolean;
  21148. /**
  21149. * Gets the texture used for the alpha test
  21150. * @returns the texture to use for alpha testing
  21151. */
  21152. getAlphaTestTexture(): Nullable<BaseTexture>;
  21153. /**
  21154. * Marks the material to indicate that it needs to be re-calculated
  21155. */
  21156. markDirty(): void;
  21157. /** @hidden */
  21158. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21159. /**
  21160. * Binds the material to the mesh
  21161. * @param world defines the world transformation matrix
  21162. * @param mesh defines the mesh to bind the material to
  21163. */
  21164. bind(world: Matrix, mesh?: Mesh): void;
  21165. /**
  21166. * Binds the submesh to the material
  21167. * @param world defines the world transformation matrix
  21168. * @param mesh defines the mesh containing the submesh
  21169. * @param subMesh defines the submesh to bind the material to
  21170. */
  21171. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21172. /**
  21173. * Binds the world matrix to the material
  21174. * @param world defines the world transformation matrix
  21175. */
  21176. bindOnlyWorldMatrix(world: Matrix): void;
  21177. /**
  21178. * Binds the scene's uniform buffer to the effect.
  21179. * @param effect defines the effect to bind to the scene uniform buffer
  21180. * @param sceneUbo defines the uniform buffer storing scene data
  21181. */
  21182. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21183. /**
  21184. * Binds the view matrix to the effect
  21185. * @param effect defines the effect to bind the view matrix to
  21186. */
  21187. bindView(effect: Effect): void;
  21188. /**
  21189. * Binds the view projection matrix to the effect
  21190. * @param effect defines the effect to bind the view projection matrix to
  21191. */
  21192. bindViewProjection(effect: Effect): void;
  21193. /**
  21194. * Specifies if material alpha testing should be turned on for the mesh
  21195. * @param mesh defines the mesh to check
  21196. */
  21197. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21198. /**
  21199. * Processes to execute after binding the material to a mesh
  21200. * @param mesh defines the rendered mesh
  21201. */
  21202. protected _afterBind(mesh?: Mesh): void;
  21203. /**
  21204. * Unbinds the material from the mesh
  21205. */
  21206. unbind(): void;
  21207. /**
  21208. * Gets the active textures from the material
  21209. * @returns an array of textures
  21210. */
  21211. getActiveTextures(): BaseTexture[];
  21212. /**
  21213. * Specifies if the material uses a texture
  21214. * @param texture defines the texture to check against the material
  21215. * @returns a boolean specifying if the material uses the texture
  21216. */
  21217. hasTexture(texture: BaseTexture): boolean;
  21218. /**
  21219. * Makes a duplicate of the material, and gives it a new name
  21220. * @param name defines the new name for the duplicated material
  21221. * @returns the cloned material
  21222. */
  21223. clone(name: string): Nullable<Material>;
  21224. /**
  21225. * Gets the meshes bound to the material
  21226. * @returns an array of meshes bound to the material
  21227. */
  21228. getBindedMeshes(): AbstractMesh[];
  21229. /**
  21230. * Force shader compilation
  21231. * @param mesh defines the mesh associated with this material
  21232. * @param onCompiled defines a function to execute once the material is compiled
  21233. * @param options defines the options to configure the compilation
  21234. * @param onError defines a function to execute if the material fails compiling
  21235. */
  21236. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21237. /**
  21238. * Force shader compilation
  21239. * @param mesh defines the mesh that will use this material
  21240. * @param options defines additional options for compiling the shaders
  21241. * @returns a promise that resolves when the compilation completes
  21242. */
  21243. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21244. private static readonly _AllDirtyCallBack;
  21245. private static readonly _ImageProcessingDirtyCallBack;
  21246. private static readonly _TextureDirtyCallBack;
  21247. private static readonly _FresnelDirtyCallBack;
  21248. private static readonly _MiscDirtyCallBack;
  21249. private static readonly _LightsDirtyCallBack;
  21250. private static readonly _AttributeDirtyCallBack;
  21251. private static _FresnelAndMiscDirtyCallBack;
  21252. private static _TextureAndMiscDirtyCallBack;
  21253. private static readonly _DirtyCallbackArray;
  21254. private static readonly _RunDirtyCallBacks;
  21255. /**
  21256. * Marks a define in the material to indicate that it needs to be re-computed
  21257. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21258. */
  21259. markAsDirty(flag: number): void;
  21260. /**
  21261. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21262. * @param func defines a function which checks material defines against the submeshes
  21263. */
  21264. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21265. /**
  21266. * Indicates that we need to re-calculated for all submeshes
  21267. */
  21268. protected _markAllSubMeshesAsAllDirty(): void;
  21269. /**
  21270. * Indicates that image processing needs to be re-calculated for all submeshes
  21271. */
  21272. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21273. /**
  21274. * Indicates that textures need to be re-calculated for all submeshes
  21275. */
  21276. protected _markAllSubMeshesAsTexturesDirty(): void;
  21277. /**
  21278. * Indicates that fresnel needs to be re-calculated for all submeshes
  21279. */
  21280. protected _markAllSubMeshesAsFresnelDirty(): void;
  21281. /**
  21282. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21283. */
  21284. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21285. /**
  21286. * Indicates that lights need to be re-calculated for all submeshes
  21287. */
  21288. protected _markAllSubMeshesAsLightsDirty(): void;
  21289. /**
  21290. * Indicates that attributes need to be re-calculated for all submeshes
  21291. */
  21292. protected _markAllSubMeshesAsAttributesDirty(): void;
  21293. /**
  21294. * Indicates that misc needs to be re-calculated for all submeshes
  21295. */
  21296. protected _markAllSubMeshesAsMiscDirty(): void;
  21297. /**
  21298. * Indicates that textures and misc need to be re-calculated for all submeshes
  21299. */
  21300. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21301. /**
  21302. * Disposes the material
  21303. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21304. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21305. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21306. */
  21307. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21308. /** @hidden */
  21309. private releaseVertexArrayObject;
  21310. /**
  21311. * Serializes this material
  21312. * @returns the serialized material object
  21313. */
  21314. serialize(): any;
  21315. /**
  21316. * Creates a material from parsed material data
  21317. * @param parsedMaterial defines parsed material data
  21318. * @param scene defines the hosting scene
  21319. * @param rootUrl defines the root URL to use to load textures
  21320. * @returns a new material
  21321. */
  21322. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21323. }
  21324. }
  21325. declare module BABYLON {
  21326. /**
  21327. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21328. * separate meshes. This can be use to improve performances.
  21329. * @see http://doc.babylonjs.com/how_to/multi_materials
  21330. */
  21331. export class MultiMaterial extends Material {
  21332. private _subMaterials;
  21333. /**
  21334. * Gets or Sets the list of Materials used within the multi material.
  21335. * They need to be ordered according to the submeshes order in the associated mesh
  21336. */
  21337. get subMaterials(): Nullable<Material>[];
  21338. set subMaterials(value: Nullable<Material>[]);
  21339. /**
  21340. * Function used to align with Node.getChildren()
  21341. * @returns the list of Materials used within the multi material
  21342. */
  21343. getChildren(): Nullable<Material>[];
  21344. /**
  21345. * Instantiates a new Multi Material
  21346. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21347. * separate meshes. This can be use to improve performances.
  21348. * @see http://doc.babylonjs.com/how_to/multi_materials
  21349. * @param name Define the name in the scene
  21350. * @param scene Define the scene the material belongs to
  21351. */
  21352. constructor(name: string, scene: Scene);
  21353. private _hookArray;
  21354. /**
  21355. * Get one of the submaterial by its index in the submaterials array
  21356. * @param index The index to look the sub material at
  21357. * @returns The Material if the index has been defined
  21358. */
  21359. getSubMaterial(index: number): Nullable<Material>;
  21360. /**
  21361. * Get the list of active textures for the whole sub materials list.
  21362. * @returns All the textures that will be used during the rendering
  21363. */
  21364. getActiveTextures(): BaseTexture[];
  21365. /**
  21366. * Gets the current class name of the material e.g. "MultiMaterial"
  21367. * Mainly use in serialization.
  21368. * @returns the class name
  21369. */
  21370. getClassName(): string;
  21371. /**
  21372. * Checks if the material is ready to render the requested sub mesh
  21373. * @param mesh Define the mesh the submesh belongs to
  21374. * @param subMesh Define the sub mesh to look readyness for
  21375. * @param useInstances Define whether or not the material is used with instances
  21376. * @returns true if ready, otherwise false
  21377. */
  21378. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21379. /**
  21380. * Clones the current material and its related sub materials
  21381. * @param name Define the name of the newly cloned material
  21382. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21383. * @returns the cloned material
  21384. */
  21385. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21386. /**
  21387. * Serializes the materials into a JSON representation.
  21388. * @returns the JSON representation
  21389. */
  21390. serialize(): any;
  21391. /**
  21392. * Dispose the material and release its associated resources
  21393. * @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)
  21394. * @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)
  21395. * @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)
  21396. */
  21397. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21398. /**
  21399. * Creates a MultiMaterial from parsed MultiMaterial data.
  21400. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21401. * @param scene defines the hosting scene
  21402. * @returns a new MultiMaterial
  21403. */
  21404. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21405. }
  21406. }
  21407. declare module BABYLON {
  21408. /**
  21409. * Base class for submeshes
  21410. */
  21411. export class BaseSubMesh {
  21412. /** @hidden */
  21413. _materialDefines: Nullable<MaterialDefines>;
  21414. /** @hidden */
  21415. _materialEffect: Nullable<Effect>;
  21416. /**
  21417. * Gets material defines used by the effect associated to the sub mesh
  21418. */
  21419. get materialDefines(): Nullable<MaterialDefines>;
  21420. /**
  21421. * Sets material defines used by the effect associated to the sub mesh
  21422. */
  21423. set materialDefines(defines: Nullable<MaterialDefines>);
  21424. /**
  21425. * Gets associated effect
  21426. */
  21427. get effect(): Nullable<Effect>;
  21428. /**
  21429. * Sets associated effect (effect used to render this submesh)
  21430. * @param effect defines the effect to associate with
  21431. * @param defines defines the set of defines used to compile this effect
  21432. */
  21433. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21434. }
  21435. /**
  21436. * Defines a subdivision inside a mesh
  21437. */
  21438. export class SubMesh extends BaseSubMesh implements ICullable {
  21439. /** the material index to use */
  21440. materialIndex: number;
  21441. /** vertex index start */
  21442. verticesStart: number;
  21443. /** vertices count */
  21444. verticesCount: number;
  21445. /** index start */
  21446. indexStart: number;
  21447. /** indices count */
  21448. indexCount: number;
  21449. /** @hidden */
  21450. _linesIndexCount: number;
  21451. private _mesh;
  21452. private _renderingMesh;
  21453. private _boundingInfo;
  21454. private _linesIndexBuffer;
  21455. /** @hidden */
  21456. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21457. /** @hidden */
  21458. _trianglePlanes: Plane[];
  21459. /** @hidden */
  21460. _lastColliderTransformMatrix: Nullable<Matrix>;
  21461. /** @hidden */
  21462. _renderId: number;
  21463. /** @hidden */
  21464. _alphaIndex: number;
  21465. /** @hidden */
  21466. _distanceToCamera: number;
  21467. /** @hidden */
  21468. _id: number;
  21469. private _currentMaterial;
  21470. /**
  21471. * Add a new submesh to a mesh
  21472. * @param materialIndex defines the material index to use
  21473. * @param verticesStart defines vertex index start
  21474. * @param verticesCount defines vertices count
  21475. * @param indexStart defines index start
  21476. * @param indexCount defines indices count
  21477. * @param mesh defines the parent mesh
  21478. * @param renderingMesh defines an optional rendering mesh
  21479. * @param createBoundingBox defines if bounding box should be created for this submesh
  21480. * @returns the new submesh
  21481. */
  21482. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21483. /**
  21484. * Creates a new submesh
  21485. * @param materialIndex defines the material index to use
  21486. * @param verticesStart defines vertex index start
  21487. * @param verticesCount defines vertices count
  21488. * @param indexStart defines index start
  21489. * @param indexCount defines indices count
  21490. * @param mesh defines the parent mesh
  21491. * @param renderingMesh defines an optional rendering mesh
  21492. * @param createBoundingBox defines if bounding box should be created for this submesh
  21493. */
  21494. constructor(
  21495. /** the material index to use */
  21496. materialIndex: number,
  21497. /** vertex index start */
  21498. verticesStart: number,
  21499. /** vertices count */
  21500. verticesCount: number,
  21501. /** index start */
  21502. indexStart: number,
  21503. /** indices count */
  21504. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21505. /**
  21506. * Returns true if this submesh covers the entire parent mesh
  21507. * @ignorenaming
  21508. */
  21509. get IsGlobal(): boolean;
  21510. /**
  21511. * Returns the submesh BoudingInfo object
  21512. * @returns current bounding info (or mesh's one if the submesh is global)
  21513. */
  21514. getBoundingInfo(): BoundingInfo;
  21515. /**
  21516. * Sets the submesh BoundingInfo
  21517. * @param boundingInfo defines the new bounding info to use
  21518. * @returns the SubMesh
  21519. */
  21520. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21521. /**
  21522. * Returns the mesh of the current submesh
  21523. * @return the parent mesh
  21524. */
  21525. getMesh(): AbstractMesh;
  21526. /**
  21527. * Returns the rendering mesh of the submesh
  21528. * @returns the rendering mesh (could be different from parent mesh)
  21529. */
  21530. getRenderingMesh(): Mesh;
  21531. /**
  21532. * Returns the submesh material
  21533. * @returns null or the current material
  21534. */
  21535. getMaterial(): Nullable<Material>;
  21536. /**
  21537. * Sets a new updated BoundingInfo object to the submesh
  21538. * @param data defines an optional position array to use to determine the bounding info
  21539. * @returns the SubMesh
  21540. */
  21541. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21542. /** @hidden */
  21543. _checkCollision(collider: Collider): boolean;
  21544. /**
  21545. * Updates the submesh BoundingInfo
  21546. * @param world defines the world matrix to use to update the bounding info
  21547. * @returns the submesh
  21548. */
  21549. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21550. /**
  21551. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21552. * @param frustumPlanes defines the frustum planes
  21553. * @returns true if the submesh is intersecting with the frustum
  21554. */
  21555. isInFrustum(frustumPlanes: Plane[]): boolean;
  21556. /**
  21557. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21558. * @param frustumPlanes defines the frustum planes
  21559. * @returns true if the submesh is inside the frustum
  21560. */
  21561. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21562. /**
  21563. * Renders the submesh
  21564. * @param enableAlphaMode defines if alpha needs to be used
  21565. * @returns the submesh
  21566. */
  21567. render(enableAlphaMode: boolean): SubMesh;
  21568. /**
  21569. * @hidden
  21570. */
  21571. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21572. /**
  21573. * Checks if the submesh intersects with a ray
  21574. * @param ray defines the ray to test
  21575. * @returns true is the passed ray intersects the submesh bounding box
  21576. */
  21577. canIntersects(ray: Ray): boolean;
  21578. /**
  21579. * Intersects current submesh with a ray
  21580. * @param ray defines the ray to test
  21581. * @param positions defines mesh's positions array
  21582. * @param indices defines mesh's indices array
  21583. * @param fastCheck defines if only bounding info should be used
  21584. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21585. * @returns intersection info or null if no intersection
  21586. */
  21587. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21588. /** @hidden */
  21589. private _intersectLines;
  21590. /** @hidden */
  21591. private _intersectUnIndexedLines;
  21592. /** @hidden */
  21593. private _intersectTriangles;
  21594. /** @hidden */
  21595. private _intersectUnIndexedTriangles;
  21596. /** @hidden */
  21597. _rebuild(): void;
  21598. /**
  21599. * Creates a new submesh from the passed mesh
  21600. * @param newMesh defines the new hosting mesh
  21601. * @param newRenderingMesh defines an optional rendering mesh
  21602. * @returns the new submesh
  21603. */
  21604. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21605. /**
  21606. * Release associated resources
  21607. */
  21608. dispose(): void;
  21609. /**
  21610. * Gets the class name
  21611. * @returns the string "SubMesh".
  21612. */
  21613. getClassName(): string;
  21614. /**
  21615. * Creates a new submesh from indices data
  21616. * @param materialIndex the index of the main mesh material
  21617. * @param startIndex the index where to start the copy in the mesh indices array
  21618. * @param indexCount the number of indices to copy then from the startIndex
  21619. * @param mesh the main mesh to create the submesh from
  21620. * @param renderingMesh the optional rendering mesh
  21621. * @returns a new submesh
  21622. */
  21623. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21624. }
  21625. }
  21626. declare module BABYLON {
  21627. /**
  21628. * Class used to represent data loading progression
  21629. */
  21630. export class SceneLoaderFlags {
  21631. private static _ForceFullSceneLoadingForIncremental;
  21632. private static _ShowLoadingScreen;
  21633. private static _CleanBoneMatrixWeights;
  21634. private static _loggingLevel;
  21635. /**
  21636. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21637. */
  21638. static get ForceFullSceneLoadingForIncremental(): boolean;
  21639. static set ForceFullSceneLoadingForIncremental(value: boolean);
  21640. /**
  21641. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21642. */
  21643. static get ShowLoadingScreen(): boolean;
  21644. static set ShowLoadingScreen(value: boolean);
  21645. /**
  21646. * Defines the current logging level (while loading the scene)
  21647. * @ignorenaming
  21648. */
  21649. static get loggingLevel(): number;
  21650. static set loggingLevel(value: number);
  21651. /**
  21652. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21653. */
  21654. static get CleanBoneMatrixWeights(): boolean;
  21655. static set CleanBoneMatrixWeights(value: boolean);
  21656. }
  21657. }
  21658. declare module BABYLON {
  21659. /**
  21660. * Class used to store geometry data (vertex buffers + index buffer)
  21661. */
  21662. export class Geometry implements IGetSetVerticesData {
  21663. /**
  21664. * Gets or sets the ID of the geometry
  21665. */
  21666. id: string;
  21667. /**
  21668. * Gets or sets the unique ID of the geometry
  21669. */
  21670. uniqueId: number;
  21671. /**
  21672. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21673. */
  21674. delayLoadState: number;
  21675. /**
  21676. * Gets the file containing the data to load when running in delay load state
  21677. */
  21678. delayLoadingFile: Nullable<string>;
  21679. /**
  21680. * Callback called when the geometry is updated
  21681. */
  21682. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21683. private _scene;
  21684. private _engine;
  21685. private _meshes;
  21686. private _totalVertices;
  21687. /** @hidden */
  21688. _indices: IndicesArray;
  21689. /** @hidden */
  21690. _vertexBuffers: {
  21691. [key: string]: VertexBuffer;
  21692. };
  21693. private _isDisposed;
  21694. private _extend;
  21695. private _boundingBias;
  21696. /** @hidden */
  21697. _delayInfo: Array<string>;
  21698. private _indexBuffer;
  21699. private _indexBufferIsUpdatable;
  21700. /** @hidden */
  21701. _boundingInfo: Nullable<BoundingInfo>;
  21702. /** @hidden */
  21703. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21704. /** @hidden */
  21705. _softwareSkinningFrameId: number;
  21706. private _vertexArrayObjects;
  21707. private _updatable;
  21708. /** @hidden */
  21709. _positions: Nullable<Vector3[]>;
  21710. /**
  21711. * 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
  21712. */
  21713. get boundingBias(): Vector2;
  21714. /**
  21715. * 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
  21716. */
  21717. set boundingBias(value: Vector2);
  21718. /**
  21719. * Static function used to attach a new empty geometry to a mesh
  21720. * @param mesh defines the mesh to attach the geometry to
  21721. * @returns the new Geometry
  21722. */
  21723. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21724. /**
  21725. * Creates a new geometry
  21726. * @param id defines the unique ID
  21727. * @param scene defines the hosting scene
  21728. * @param vertexData defines the VertexData used to get geometry data
  21729. * @param updatable defines if geometry must be updatable (false by default)
  21730. * @param mesh defines the mesh that will be associated with the geometry
  21731. */
  21732. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21733. /**
  21734. * Gets the current extend of the geometry
  21735. */
  21736. get extend(): {
  21737. minimum: Vector3;
  21738. maximum: Vector3;
  21739. };
  21740. /**
  21741. * Gets the hosting scene
  21742. * @returns the hosting Scene
  21743. */
  21744. getScene(): Scene;
  21745. /**
  21746. * Gets the hosting engine
  21747. * @returns the hosting Engine
  21748. */
  21749. getEngine(): Engine;
  21750. /**
  21751. * Defines if the geometry is ready to use
  21752. * @returns true if the geometry is ready to be used
  21753. */
  21754. isReady(): boolean;
  21755. /**
  21756. * Gets a value indicating that the geometry should not be serialized
  21757. */
  21758. get doNotSerialize(): boolean;
  21759. /** @hidden */
  21760. _rebuild(): void;
  21761. /**
  21762. * Affects all geometry data in one call
  21763. * @param vertexData defines the geometry data
  21764. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21765. */
  21766. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21767. /**
  21768. * Set specific vertex data
  21769. * @param kind defines the data kind (Position, normal, etc...)
  21770. * @param data defines the vertex data to use
  21771. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21772. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21773. */
  21774. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21775. /**
  21776. * Removes a specific vertex data
  21777. * @param kind defines the data kind (Position, normal, etc...)
  21778. */
  21779. removeVerticesData(kind: string): void;
  21780. /**
  21781. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21782. * @param buffer defines the vertex buffer to use
  21783. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21784. */
  21785. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21786. /**
  21787. * Update a specific vertex buffer
  21788. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21789. * It will do nothing if the buffer is not updatable
  21790. * @param kind defines the data kind (Position, normal, etc...)
  21791. * @param data defines the data to use
  21792. * @param offset defines the offset in the target buffer where to store the data
  21793. * @param useBytes set to true if the offset is in bytes
  21794. */
  21795. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21796. /**
  21797. * Update a specific vertex buffer
  21798. * This function will create a new buffer if the current one is not updatable
  21799. * @param kind defines the data kind (Position, normal, etc...)
  21800. * @param data defines the data to use
  21801. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21802. */
  21803. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21804. private _updateBoundingInfo;
  21805. /** @hidden */
  21806. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21807. /**
  21808. * Gets total number of vertices
  21809. * @returns the total number of vertices
  21810. */
  21811. getTotalVertices(): number;
  21812. /**
  21813. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21814. * @param kind defines the data kind (Position, normal, etc...)
  21815. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21816. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21817. * @returns a float array containing vertex data
  21818. */
  21819. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21820. /**
  21821. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21822. * @param kind defines the data kind (Position, normal, etc...)
  21823. * @returns true if the vertex buffer with the specified kind is updatable
  21824. */
  21825. isVertexBufferUpdatable(kind: string): boolean;
  21826. /**
  21827. * Gets a specific vertex buffer
  21828. * @param kind defines the data kind (Position, normal, etc...)
  21829. * @returns a VertexBuffer
  21830. */
  21831. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21832. /**
  21833. * Returns all vertex buffers
  21834. * @return an object holding all vertex buffers indexed by kind
  21835. */
  21836. getVertexBuffers(): Nullable<{
  21837. [key: string]: VertexBuffer;
  21838. }>;
  21839. /**
  21840. * Gets a boolean indicating if specific vertex buffer is present
  21841. * @param kind defines the data kind (Position, normal, etc...)
  21842. * @returns true if data is present
  21843. */
  21844. isVerticesDataPresent(kind: string): boolean;
  21845. /**
  21846. * Gets a list of all attached data kinds (Position, normal, etc...)
  21847. * @returns a list of string containing all kinds
  21848. */
  21849. getVerticesDataKinds(): string[];
  21850. /**
  21851. * Update index buffer
  21852. * @param indices defines the indices to store in the index buffer
  21853. * @param offset defines the offset in the target buffer where to store the data
  21854. * @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)
  21855. */
  21856. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21857. /**
  21858. * Creates a new index buffer
  21859. * @param indices defines the indices to store in the index buffer
  21860. * @param totalVertices defines the total number of vertices (could be null)
  21861. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21862. */
  21863. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21864. /**
  21865. * Return the total number of indices
  21866. * @returns the total number of indices
  21867. */
  21868. getTotalIndices(): number;
  21869. /**
  21870. * Gets the index buffer array
  21871. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21872. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21873. * @returns the index buffer array
  21874. */
  21875. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21876. /**
  21877. * Gets the index buffer
  21878. * @return the index buffer
  21879. */
  21880. getIndexBuffer(): Nullable<DataBuffer>;
  21881. /** @hidden */
  21882. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21883. /**
  21884. * Release the associated resources for a specific mesh
  21885. * @param mesh defines the source mesh
  21886. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21887. */
  21888. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21889. /**
  21890. * Apply current geometry to a given mesh
  21891. * @param mesh defines the mesh to apply geometry to
  21892. */
  21893. applyToMesh(mesh: Mesh): void;
  21894. private _updateExtend;
  21895. private _applyToMesh;
  21896. private notifyUpdate;
  21897. /**
  21898. * Load the geometry if it was flagged as delay loaded
  21899. * @param scene defines the hosting scene
  21900. * @param onLoaded defines a callback called when the geometry is loaded
  21901. */
  21902. load(scene: Scene, onLoaded?: () => void): void;
  21903. private _queueLoad;
  21904. /**
  21905. * Invert the geometry to move from a right handed system to a left handed one.
  21906. */
  21907. toLeftHanded(): void;
  21908. /** @hidden */
  21909. _resetPointsArrayCache(): void;
  21910. /** @hidden */
  21911. _generatePointsArray(): boolean;
  21912. /**
  21913. * Gets a value indicating if the geometry is disposed
  21914. * @returns true if the geometry was disposed
  21915. */
  21916. isDisposed(): boolean;
  21917. private _disposeVertexArrayObjects;
  21918. /**
  21919. * Free all associated resources
  21920. */
  21921. dispose(): void;
  21922. /**
  21923. * Clone the current geometry into a new geometry
  21924. * @param id defines the unique ID of the new geometry
  21925. * @returns a new geometry object
  21926. */
  21927. copy(id: string): Geometry;
  21928. /**
  21929. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21930. * @return a JSON representation of the current geometry data (without the vertices data)
  21931. */
  21932. serialize(): any;
  21933. private toNumberArray;
  21934. /**
  21935. * Serialize all vertices data into a JSON oject
  21936. * @returns a JSON representation of the current geometry data
  21937. */
  21938. serializeVerticeData(): any;
  21939. /**
  21940. * Extracts a clone of a mesh geometry
  21941. * @param mesh defines the source mesh
  21942. * @param id defines the unique ID of the new geometry object
  21943. * @returns the new geometry object
  21944. */
  21945. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21946. /**
  21947. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21948. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21949. * Be aware Math.random() could cause collisions, but:
  21950. * "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"
  21951. * @returns a string containing a new GUID
  21952. */
  21953. static RandomId(): string;
  21954. /** @hidden */
  21955. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21956. private static _CleanMatricesWeights;
  21957. /**
  21958. * Create a new geometry from persisted data (Using .babylon file format)
  21959. * @param parsedVertexData defines the persisted data
  21960. * @param scene defines the hosting scene
  21961. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21962. * @returns the new geometry object
  21963. */
  21964. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21965. }
  21966. }
  21967. declare module BABYLON {
  21968. /**
  21969. * Define an interface for all classes that will get and set the data on vertices
  21970. */
  21971. export interface IGetSetVerticesData {
  21972. /**
  21973. * Gets a boolean indicating if specific vertex data is present
  21974. * @param kind defines the vertex data kind to use
  21975. * @returns true is data kind is present
  21976. */
  21977. isVerticesDataPresent(kind: string): boolean;
  21978. /**
  21979. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21980. * @param kind defines the data kind (Position, normal, etc...)
  21981. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21982. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21983. * @returns a float array containing vertex data
  21984. */
  21985. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21986. /**
  21987. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21988. * @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.
  21989. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21990. * @returns the indices array or an empty array if the mesh has no geometry
  21991. */
  21992. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21993. /**
  21994. * Set specific vertex data
  21995. * @param kind defines the data kind (Position, normal, etc...)
  21996. * @param data defines the vertex data to use
  21997. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21998. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21999. */
  22000. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22001. /**
  22002. * Update a specific associated vertex buffer
  22003. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22004. * - VertexBuffer.PositionKind
  22005. * - VertexBuffer.UVKind
  22006. * - VertexBuffer.UV2Kind
  22007. * - VertexBuffer.UV3Kind
  22008. * - VertexBuffer.UV4Kind
  22009. * - VertexBuffer.UV5Kind
  22010. * - VertexBuffer.UV6Kind
  22011. * - VertexBuffer.ColorKind
  22012. * - VertexBuffer.MatricesIndicesKind
  22013. * - VertexBuffer.MatricesIndicesExtraKind
  22014. * - VertexBuffer.MatricesWeightsKind
  22015. * - VertexBuffer.MatricesWeightsExtraKind
  22016. * @param data defines the data source
  22017. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22018. * @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)
  22019. */
  22020. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22021. /**
  22022. * Creates a new index buffer
  22023. * @param indices defines the indices to store in the index buffer
  22024. * @param totalVertices defines the total number of vertices (could be null)
  22025. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22026. */
  22027. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22028. }
  22029. /**
  22030. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22031. */
  22032. export class VertexData {
  22033. /**
  22034. * Mesh side orientation : usually the external or front surface
  22035. */
  22036. static readonly FRONTSIDE: number;
  22037. /**
  22038. * Mesh side orientation : usually the internal or back surface
  22039. */
  22040. static readonly BACKSIDE: number;
  22041. /**
  22042. * Mesh side orientation : both internal and external or front and back surfaces
  22043. */
  22044. static readonly DOUBLESIDE: number;
  22045. /**
  22046. * Mesh side orientation : by default, `FRONTSIDE`
  22047. */
  22048. static readonly DEFAULTSIDE: number;
  22049. /**
  22050. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22051. */
  22052. positions: Nullable<FloatArray>;
  22053. /**
  22054. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22055. */
  22056. normals: Nullable<FloatArray>;
  22057. /**
  22058. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22059. */
  22060. tangents: Nullable<FloatArray>;
  22061. /**
  22062. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22063. */
  22064. uvs: Nullable<FloatArray>;
  22065. /**
  22066. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22067. */
  22068. uvs2: Nullable<FloatArray>;
  22069. /**
  22070. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22071. */
  22072. uvs3: Nullable<FloatArray>;
  22073. /**
  22074. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22075. */
  22076. uvs4: Nullable<FloatArray>;
  22077. /**
  22078. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22079. */
  22080. uvs5: Nullable<FloatArray>;
  22081. /**
  22082. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22083. */
  22084. uvs6: Nullable<FloatArray>;
  22085. /**
  22086. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22087. */
  22088. colors: Nullable<FloatArray>;
  22089. /**
  22090. * 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).
  22091. */
  22092. matricesIndices: Nullable<FloatArray>;
  22093. /**
  22094. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22095. */
  22096. matricesWeights: Nullable<FloatArray>;
  22097. /**
  22098. * An array extending the number of possible indices
  22099. */
  22100. matricesIndicesExtra: Nullable<FloatArray>;
  22101. /**
  22102. * An array extending the number of possible weights when the number of indices is extended
  22103. */
  22104. matricesWeightsExtra: Nullable<FloatArray>;
  22105. /**
  22106. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22107. */
  22108. indices: Nullable<IndicesArray>;
  22109. /**
  22110. * Uses the passed data array to set the set the values for the specified kind of data
  22111. * @param data a linear array of floating numbers
  22112. * @param kind the type of data that is being set, eg positions, colors etc
  22113. */
  22114. set(data: FloatArray, kind: string): void;
  22115. /**
  22116. * Associates the vertexData to the passed Mesh.
  22117. * Sets it as updatable or not (default `false`)
  22118. * @param mesh the mesh the vertexData is applied to
  22119. * @param updatable when used and having the value true allows new data to update the vertexData
  22120. * @returns the VertexData
  22121. */
  22122. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22123. /**
  22124. * Associates the vertexData to the passed Geometry.
  22125. * Sets it as updatable or not (default `false`)
  22126. * @param geometry the geometry the vertexData is applied to
  22127. * @param updatable when used and having the value true allows new data to update the vertexData
  22128. * @returns VertexData
  22129. */
  22130. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22131. /**
  22132. * Updates the associated mesh
  22133. * @param mesh the mesh to be updated
  22134. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22135. * @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
  22136. * @returns VertexData
  22137. */
  22138. updateMesh(mesh: Mesh): VertexData;
  22139. /**
  22140. * Updates the associated geometry
  22141. * @param geometry the geometry to be updated
  22142. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22143. * @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
  22144. * @returns VertexData.
  22145. */
  22146. updateGeometry(geometry: Geometry): VertexData;
  22147. private _applyTo;
  22148. private _update;
  22149. /**
  22150. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22151. * @param matrix the transforming matrix
  22152. * @returns the VertexData
  22153. */
  22154. transform(matrix: Matrix): VertexData;
  22155. /**
  22156. * Merges the passed VertexData into the current one
  22157. * @param other the VertexData to be merged into the current one
  22158. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22159. * @returns the modified VertexData
  22160. */
  22161. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22162. private _mergeElement;
  22163. private _validate;
  22164. /**
  22165. * Serializes the VertexData
  22166. * @returns a serialized object
  22167. */
  22168. serialize(): any;
  22169. /**
  22170. * Extracts the vertexData from a mesh
  22171. * @param mesh the mesh from which to extract the VertexData
  22172. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22173. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22174. * @returns the object VertexData associated to the passed mesh
  22175. */
  22176. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22177. /**
  22178. * Extracts the vertexData from the geometry
  22179. * @param geometry the geometry from which to extract the VertexData
  22180. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22181. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22182. * @returns the object VertexData associated to the passed mesh
  22183. */
  22184. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22185. private static _ExtractFrom;
  22186. /**
  22187. * Creates the VertexData for a Ribbon
  22188. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22189. * * pathArray array of paths, each of which an array of successive Vector3
  22190. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22191. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22192. * * 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
  22193. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22194. * * 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)
  22195. * * 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)
  22196. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22197. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22198. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22199. * @returns the VertexData of the ribbon
  22200. */
  22201. static CreateRibbon(options: {
  22202. pathArray: Vector3[][];
  22203. closeArray?: boolean;
  22204. closePath?: boolean;
  22205. offset?: number;
  22206. sideOrientation?: number;
  22207. frontUVs?: Vector4;
  22208. backUVs?: Vector4;
  22209. invertUV?: boolean;
  22210. uvs?: Vector2[];
  22211. colors?: Color4[];
  22212. }): VertexData;
  22213. /**
  22214. * Creates the VertexData for a box
  22215. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22216. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22217. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22218. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22219. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22220. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22221. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22222. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22223. * * 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)
  22224. * * 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)
  22225. * @returns the VertexData of the box
  22226. */
  22227. static CreateBox(options: {
  22228. size?: number;
  22229. width?: number;
  22230. height?: number;
  22231. depth?: number;
  22232. faceUV?: Vector4[];
  22233. faceColors?: Color4[];
  22234. sideOrientation?: number;
  22235. frontUVs?: Vector4;
  22236. backUVs?: Vector4;
  22237. }): VertexData;
  22238. /**
  22239. * Creates the VertexData for a tiled box
  22240. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22241. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22242. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22243. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22244. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22245. * @returns the VertexData of the box
  22246. */
  22247. static CreateTiledBox(options: {
  22248. pattern?: number;
  22249. width?: number;
  22250. height?: number;
  22251. depth?: number;
  22252. tileSize?: number;
  22253. tileWidth?: number;
  22254. tileHeight?: number;
  22255. alignHorizontal?: number;
  22256. alignVertical?: number;
  22257. faceUV?: Vector4[];
  22258. faceColors?: Color4[];
  22259. sideOrientation?: number;
  22260. }): VertexData;
  22261. /**
  22262. * Creates the VertexData for a tiled plane
  22263. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22264. * * pattern a limited pattern arrangement depending on the number
  22265. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22266. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22267. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22268. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22269. * * 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)
  22270. * * 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)
  22271. * @returns the VertexData of the tiled plane
  22272. */
  22273. static CreateTiledPlane(options: {
  22274. pattern?: number;
  22275. tileSize?: number;
  22276. tileWidth?: number;
  22277. tileHeight?: number;
  22278. size?: number;
  22279. width?: number;
  22280. height?: number;
  22281. alignHorizontal?: number;
  22282. alignVertical?: number;
  22283. sideOrientation?: number;
  22284. frontUVs?: Vector4;
  22285. backUVs?: Vector4;
  22286. }): VertexData;
  22287. /**
  22288. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22289. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22290. * * segments sets the number of horizontal strips optional, default 32
  22291. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22292. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22293. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22294. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22295. * * 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
  22296. * * 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
  22297. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22298. * * 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)
  22299. * * 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)
  22300. * @returns the VertexData of the ellipsoid
  22301. */
  22302. static CreateSphere(options: {
  22303. segments?: number;
  22304. diameter?: number;
  22305. diameterX?: number;
  22306. diameterY?: number;
  22307. diameterZ?: number;
  22308. arc?: number;
  22309. slice?: number;
  22310. sideOrientation?: number;
  22311. frontUVs?: Vector4;
  22312. backUVs?: Vector4;
  22313. }): VertexData;
  22314. /**
  22315. * Creates the VertexData for a cylinder, cone or prism
  22316. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22317. * * height sets the height (y direction) of the cylinder, optional, default 2
  22318. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22319. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22320. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22321. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22322. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22323. * * 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
  22324. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22325. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22326. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22327. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22328. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22329. * * 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)
  22330. * * 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)
  22331. * @returns the VertexData of the cylinder, cone or prism
  22332. */
  22333. static CreateCylinder(options: {
  22334. height?: number;
  22335. diameterTop?: number;
  22336. diameterBottom?: number;
  22337. diameter?: number;
  22338. tessellation?: number;
  22339. subdivisions?: number;
  22340. arc?: number;
  22341. faceColors?: Color4[];
  22342. faceUV?: Vector4[];
  22343. hasRings?: boolean;
  22344. enclose?: boolean;
  22345. sideOrientation?: number;
  22346. frontUVs?: Vector4;
  22347. backUVs?: Vector4;
  22348. }): VertexData;
  22349. /**
  22350. * Creates the VertexData for a torus
  22351. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22352. * * diameter the diameter of the torus, optional default 1
  22353. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22354. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22355. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22356. * * 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)
  22357. * * 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)
  22358. * @returns the VertexData of the torus
  22359. */
  22360. static CreateTorus(options: {
  22361. diameter?: number;
  22362. thickness?: number;
  22363. tessellation?: number;
  22364. sideOrientation?: number;
  22365. frontUVs?: Vector4;
  22366. backUVs?: Vector4;
  22367. }): VertexData;
  22368. /**
  22369. * Creates the VertexData of the LineSystem
  22370. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22371. * - lines an array of lines, each line being an array of successive Vector3
  22372. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22373. * @returns the VertexData of the LineSystem
  22374. */
  22375. static CreateLineSystem(options: {
  22376. lines: Vector3[][];
  22377. colors?: Nullable<Color4[][]>;
  22378. }): VertexData;
  22379. /**
  22380. * Create the VertexData for a DashedLines
  22381. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22382. * - points an array successive Vector3
  22383. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22384. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22385. * - dashNb the intended total number of dashes, optional, default 200
  22386. * @returns the VertexData for the DashedLines
  22387. */
  22388. static CreateDashedLines(options: {
  22389. points: Vector3[];
  22390. dashSize?: number;
  22391. gapSize?: number;
  22392. dashNb?: number;
  22393. }): VertexData;
  22394. /**
  22395. * Creates the VertexData for a Ground
  22396. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22397. * - width the width (x direction) of the ground, optional, default 1
  22398. * - height the height (z direction) of the ground, optional, default 1
  22399. * - subdivisions the number of subdivisions per side, optional, default 1
  22400. * @returns the VertexData of the Ground
  22401. */
  22402. static CreateGround(options: {
  22403. width?: number;
  22404. height?: number;
  22405. subdivisions?: number;
  22406. subdivisionsX?: number;
  22407. subdivisionsY?: number;
  22408. }): VertexData;
  22409. /**
  22410. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22411. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22412. * * xmin the ground minimum X coordinate, optional, default -1
  22413. * * zmin the ground minimum Z coordinate, optional, default -1
  22414. * * xmax the ground maximum X coordinate, optional, default 1
  22415. * * zmax the ground maximum Z coordinate, optional, default 1
  22416. * * 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}
  22417. * * 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}
  22418. * @returns the VertexData of the TiledGround
  22419. */
  22420. static CreateTiledGround(options: {
  22421. xmin: number;
  22422. zmin: number;
  22423. xmax: number;
  22424. zmax: number;
  22425. subdivisions?: {
  22426. w: number;
  22427. h: number;
  22428. };
  22429. precision?: {
  22430. w: number;
  22431. h: number;
  22432. };
  22433. }): VertexData;
  22434. /**
  22435. * Creates the VertexData of the Ground designed from a heightmap
  22436. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22437. * * width the width (x direction) of the ground
  22438. * * height the height (z direction) of the ground
  22439. * * subdivisions the number of subdivisions per side
  22440. * * minHeight the minimum altitude on the ground, optional, default 0
  22441. * * maxHeight the maximum altitude on the ground, optional default 1
  22442. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22443. * * buffer the array holding the image color data
  22444. * * bufferWidth the width of image
  22445. * * bufferHeight the height of image
  22446. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22447. * @returns the VertexData of the Ground designed from a heightmap
  22448. */
  22449. static CreateGroundFromHeightMap(options: {
  22450. width: number;
  22451. height: number;
  22452. subdivisions: number;
  22453. minHeight: number;
  22454. maxHeight: number;
  22455. colorFilter: Color3;
  22456. buffer: Uint8Array;
  22457. bufferWidth: number;
  22458. bufferHeight: number;
  22459. alphaFilter: number;
  22460. }): VertexData;
  22461. /**
  22462. * Creates the VertexData for a Plane
  22463. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22464. * * size sets the width and height of the plane to the value of size, optional default 1
  22465. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22466. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22467. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22468. * * 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)
  22469. * * 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)
  22470. * @returns the VertexData of the box
  22471. */
  22472. static CreatePlane(options: {
  22473. size?: number;
  22474. width?: number;
  22475. height?: number;
  22476. sideOrientation?: number;
  22477. frontUVs?: Vector4;
  22478. backUVs?: Vector4;
  22479. }): VertexData;
  22480. /**
  22481. * Creates the VertexData of the Disc or regular Polygon
  22482. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22483. * * radius the radius of the disc, optional default 0.5
  22484. * * tessellation the number of polygon sides, optional, default 64
  22485. * * 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
  22486. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22487. * * 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)
  22488. * * 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)
  22489. * @returns the VertexData of the box
  22490. */
  22491. static CreateDisc(options: {
  22492. radius?: number;
  22493. tessellation?: number;
  22494. arc?: number;
  22495. sideOrientation?: number;
  22496. frontUVs?: Vector4;
  22497. backUVs?: Vector4;
  22498. }): VertexData;
  22499. /**
  22500. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22501. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22502. * @param polygon a mesh built from polygonTriangulation.build()
  22503. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22504. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22505. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22506. * @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)
  22507. * @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)
  22508. * @returns the VertexData of the Polygon
  22509. */
  22510. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22511. /**
  22512. * Creates the VertexData of the IcoSphere
  22513. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22514. * * radius the radius of the IcoSphere, optional default 1
  22515. * * radiusX allows stretching in the x direction, optional, default radius
  22516. * * radiusY allows stretching in the y direction, optional, default radius
  22517. * * radiusZ allows stretching in the z direction, optional, default radius
  22518. * * flat when true creates a flat shaded mesh, optional, default true
  22519. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22520. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22521. * * 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)
  22522. * * 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)
  22523. * @returns the VertexData of the IcoSphere
  22524. */
  22525. static CreateIcoSphere(options: {
  22526. radius?: number;
  22527. radiusX?: number;
  22528. radiusY?: number;
  22529. radiusZ?: number;
  22530. flat?: boolean;
  22531. subdivisions?: number;
  22532. sideOrientation?: number;
  22533. frontUVs?: Vector4;
  22534. backUVs?: Vector4;
  22535. }): VertexData;
  22536. /**
  22537. * Creates the VertexData for a Polyhedron
  22538. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22539. * * type provided types are:
  22540. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22541. * * 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)
  22542. * * size the size of the IcoSphere, optional default 1
  22543. * * sizeX allows stretching in the x direction, optional, default size
  22544. * * sizeY allows stretching in the y direction, optional, default size
  22545. * * sizeZ allows stretching in the z direction, optional, default size
  22546. * * 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
  22547. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22548. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22549. * * flat when true creates a flat shaded mesh, optional, default true
  22550. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22551. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22552. * * 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)
  22553. * * 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)
  22554. * @returns the VertexData of the Polyhedron
  22555. */
  22556. static CreatePolyhedron(options: {
  22557. type?: number;
  22558. size?: number;
  22559. sizeX?: number;
  22560. sizeY?: number;
  22561. sizeZ?: number;
  22562. custom?: any;
  22563. faceUV?: Vector4[];
  22564. faceColors?: Color4[];
  22565. flat?: boolean;
  22566. sideOrientation?: number;
  22567. frontUVs?: Vector4;
  22568. backUVs?: Vector4;
  22569. }): VertexData;
  22570. /**
  22571. * Creates the VertexData for a TorusKnot
  22572. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22573. * * radius the radius of the torus knot, optional, default 2
  22574. * * tube the thickness of the tube, optional, default 0.5
  22575. * * radialSegments the number of sides on each tube segments, optional, default 32
  22576. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22577. * * p the number of windings around the z axis, optional, default 2
  22578. * * q the number of windings around the x axis, optional, default 3
  22579. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22580. * * 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)
  22581. * * 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)
  22582. * @returns the VertexData of the Torus Knot
  22583. */
  22584. static CreateTorusKnot(options: {
  22585. radius?: number;
  22586. tube?: number;
  22587. radialSegments?: number;
  22588. tubularSegments?: number;
  22589. p?: number;
  22590. q?: number;
  22591. sideOrientation?: number;
  22592. frontUVs?: Vector4;
  22593. backUVs?: Vector4;
  22594. }): VertexData;
  22595. /**
  22596. * Compute normals for given positions and indices
  22597. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22598. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22599. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22600. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22601. * * facetNormals : optional array of facet normals (vector3)
  22602. * * facetPositions : optional array of facet positions (vector3)
  22603. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22604. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22605. * * bInfo : optional bounding info, required for facetPartitioning computation
  22606. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22607. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22608. * * useRightHandedSystem: optional boolean to for right handed system computation
  22609. * * depthSort : optional boolean to enable the facet depth sort computation
  22610. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22611. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22612. */
  22613. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22614. facetNormals?: any;
  22615. facetPositions?: any;
  22616. facetPartitioning?: any;
  22617. ratio?: number;
  22618. bInfo?: any;
  22619. bbSize?: Vector3;
  22620. subDiv?: any;
  22621. useRightHandedSystem?: boolean;
  22622. depthSort?: boolean;
  22623. distanceTo?: Vector3;
  22624. depthSortedFacets?: any;
  22625. }): void;
  22626. /** @hidden */
  22627. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22628. /**
  22629. * Applies VertexData created from the imported parameters to the geometry
  22630. * @param parsedVertexData the parsed data from an imported file
  22631. * @param geometry the geometry to apply the VertexData to
  22632. */
  22633. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22634. }
  22635. }
  22636. declare module BABYLON {
  22637. /**
  22638. * Defines a target to use with MorphTargetManager
  22639. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22640. */
  22641. export class MorphTarget implements IAnimatable {
  22642. /** defines the name of the target */
  22643. name: string;
  22644. /**
  22645. * Gets or sets the list of animations
  22646. */
  22647. animations: Animation[];
  22648. private _scene;
  22649. private _positions;
  22650. private _normals;
  22651. private _tangents;
  22652. private _uvs;
  22653. private _influence;
  22654. private _uniqueId;
  22655. /**
  22656. * Observable raised when the influence changes
  22657. */
  22658. onInfluenceChanged: Observable<boolean>;
  22659. /** @hidden */
  22660. _onDataLayoutChanged: Observable<void>;
  22661. /**
  22662. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22663. */
  22664. get influence(): number;
  22665. set influence(influence: number);
  22666. /**
  22667. * Gets or sets the id of the morph Target
  22668. */
  22669. id: string;
  22670. private _animationPropertiesOverride;
  22671. /**
  22672. * Gets or sets the animation properties override
  22673. */
  22674. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  22675. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  22676. /**
  22677. * Creates a new MorphTarget
  22678. * @param name defines the name of the target
  22679. * @param influence defines the influence to use
  22680. * @param scene defines the scene the morphtarget belongs to
  22681. */
  22682. constructor(
  22683. /** defines the name of the target */
  22684. name: string, influence?: number, scene?: Nullable<Scene>);
  22685. /**
  22686. * Gets the unique ID of this manager
  22687. */
  22688. get uniqueId(): number;
  22689. /**
  22690. * Gets a boolean defining if the target contains position data
  22691. */
  22692. get hasPositions(): boolean;
  22693. /**
  22694. * Gets a boolean defining if the target contains normal data
  22695. */
  22696. get hasNormals(): boolean;
  22697. /**
  22698. * Gets a boolean defining if the target contains tangent data
  22699. */
  22700. get hasTangents(): boolean;
  22701. /**
  22702. * Gets a boolean defining if the target contains texture coordinates data
  22703. */
  22704. get hasUVs(): boolean;
  22705. /**
  22706. * Affects position data to this target
  22707. * @param data defines the position data to use
  22708. */
  22709. setPositions(data: Nullable<FloatArray>): void;
  22710. /**
  22711. * Gets the position data stored in this target
  22712. * @returns a FloatArray containing the position data (or null if not present)
  22713. */
  22714. getPositions(): Nullable<FloatArray>;
  22715. /**
  22716. * Affects normal data to this target
  22717. * @param data defines the normal data to use
  22718. */
  22719. setNormals(data: Nullable<FloatArray>): void;
  22720. /**
  22721. * Gets the normal data stored in this target
  22722. * @returns a FloatArray containing the normal data (or null if not present)
  22723. */
  22724. getNormals(): Nullable<FloatArray>;
  22725. /**
  22726. * Affects tangent data to this target
  22727. * @param data defines the tangent data to use
  22728. */
  22729. setTangents(data: Nullable<FloatArray>): void;
  22730. /**
  22731. * Gets the tangent data stored in this target
  22732. * @returns a FloatArray containing the tangent data (or null if not present)
  22733. */
  22734. getTangents(): Nullable<FloatArray>;
  22735. /**
  22736. * Affects texture coordinates data to this target
  22737. * @param data defines the texture coordinates data to use
  22738. */
  22739. setUVs(data: Nullable<FloatArray>): void;
  22740. /**
  22741. * Gets the texture coordinates data stored in this target
  22742. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22743. */
  22744. getUVs(): Nullable<FloatArray>;
  22745. /**
  22746. * Clone the current target
  22747. * @returns a new MorphTarget
  22748. */
  22749. clone(): MorphTarget;
  22750. /**
  22751. * Serializes the current target into a Serialization object
  22752. * @returns the serialized object
  22753. */
  22754. serialize(): any;
  22755. /**
  22756. * Returns the string "MorphTarget"
  22757. * @returns "MorphTarget"
  22758. */
  22759. getClassName(): string;
  22760. /**
  22761. * Creates a new target from serialized data
  22762. * @param serializationObject defines the serialized data to use
  22763. * @returns a new MorphTarget
  22764. */
  22765. static Parse(serializationObject: any): MorphTarget;
  22766. /**
  22767. * Creates a MorphTarget from mesh data
  22768. * @param mesh defines the source mesh
  22769. * @param name defines the name to use for the new target
  22770. * @param influence defines the influence to attach to the target
  22771. * @returns a new MorphTarget
  22772. */
  22773. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22774. }
  22775. }
  22776. declare module BABYLON {
  22777. /**
  22778. * This class is used to deform meshes using morphing between different targets
  22779. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22780. */
  22781. export class MorphTargetManager {
  22782. private _targets;
  22783. private _targetInfluenceChangedObservers;
  22784. private _targetDataLayoutChangedObservers;
  22785. private _activeTargets;
  22786. private _scene;
  22787. private _influences;
  22788. private _supportsNormals;
  22789. private _supportsTangents;
  22790. private _supportsUVs;
  22791. private _vertexCount;
  22792. private _uniqueId;
  22793. private _tempInfluences;
  22794. /**
  22795. * Gets or sets a boolean indicating if normals must be morphed
  22796. */
  22797. enableNormalMorphing: boolean;
  22798. /**
  22799. * Gets or sets a boolean indicating if tangents must be morphed
  22800. */
  22801. enableTangentMorphing: boolean;
  22802. /**
  22803. * Gets or sets a boolean indicating if UV must be morphed
  22804. */
  22805. enableUVMorphing: boolean;
  22806. /**
  22807. * Creates a new MorphTargetManager
  22808. * @param scene defines the current scene
  22809. */
  22810. constructor(scene?: Nullable<Scene>);
  22811. /**
  22812. * Gets the unique ID of this manager
  22813. */
  22814. get uniqueId(): number;
  22815. /**
  22816. * Gets the number of vertices handled by this manager
  22817. */
  22818. get vertexCount(): number;
  22819. /**
  22820. * Gets a boolean indicating if this manager supports morphing of normals
  22821. */
  22822. get supportsNormals(): boolean;
  22823. /**
  22824. * Gets a boolean indicating if this manager supports morphing of tangents
  22825. */
  22826. get supportsTangents(): boolean;
  22827. /**
  22828. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22829. */
  22830. get supportsUVs(): boolean;
  22831. /**
  22832. * Gets the number of targets stored in this manager
  22833. */
  22834. get numTargets(): number;
  22835. /**
  22836. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22837. */
  22838. get numInfluencers(): number;
  22839. /**
  22840. * Gets the list of influences (one per target)
  22841. */
  22842. get influences(): Float32Array;
  22843. /**
  22844. * Gets the active target at specified index. An active target is a target with an influence > 0
  22845. * @param index defines the index to check
  22846. * @returns the requested target
  22847. */
  22848. getActiveTarget(index: number): MorphTarget;
  22849. /**
  22850. * Gets the target at specified index
  22851. * @param index defines the index to check
  22852. * @returns the requested target
  22853. */
  22854. getTarget(index: number): MorphTarget;
  22855. /**
  22856. * Add a new target to this manager
  22857. * @param target defines the target to add
  22858. */
  22859. addTarget(target: MorphTarget): void;
  22860. /**
  22861. * Removes a target from the manager
  22862. * @param target defines the target to remove
  22863. */
  22864. removeTarget(target: MorphTarget): void;
  22865. /**
  22866. * Clone the current manager
  22867. * @returns a new MorphTargetManager
  22868. */
  22869. clone(): MorphTargetManager;
  22870. /**
  22871. * Serializes the current manager into a Serialization object
  22872. * @returns the serialized object
  22873. */
  22874. serialize(): any;
  22875. private _syncActiveTargets;
  22876. /**
  22877. * Syncrhonize the targets with all the meshes using this morph target manager
  22878. */
  22879. synchronize(): void;
  22880. /**
  22881. * Creates a new MorphTargetManager from serialized data
  22882. * @param serializationObject defines the serialized data
  22883. * @param scene defines the hosting scene
  22884. * @returns the new MorphTargetManager
  22885. */
  22886. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22887. }
  22888. }
  22889. declare module BABYLON {
  22890. /**
  22891. * Class used to represent a specific level of detail of a mesh
  22892. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22893. */
  22894. export class MeshLODLevel {
  22895. /** Defines the distance where this level should start being displayed */
  22896. distance: number;
  22897. /** Defines the mesh to use to render this level */
  22898. mesh: Nullable<Mesh>;
  22899. /**
  22900. * Creates a new LOD level
  22901. * @param distance defines the distance where this level should star being displayed
  22902. * @param mesh defines the mesh to use to render this level
  22903. */
  22904. constructor(
  22905. /** Defines the distance where this level should start being displayed */
  22906. distance: number,
  22907. /** Defines the mesh to use to render this level */
  22908. mesh: Nullable<Mesh>);
  22909. }
  22910. }
  22911. declare module BABYLON {
  22912. /**
  22913. * Mesh representing the gorund
  22914. */
  22915. export class GroundMesh extends Mesh {
  22916. /** If octree should be generated */
  22917. generateOctree: boolean;
  22918. private _heightQuads;
  22919. /** @hidden */
  22920. _subdivisionsX: number;
  22921. /** @hidden */
  22922. _subdivisionsY: number;
  22923. /** @hidden */
  22924. _width: number;
  22925. /** @hidden */
  22926. _height: number;
  22927. /** @hidden */
  22928. _minX: number;
  22929. /** @hidden */
  22930. _maxX: number;
  22931. /** @hidden */
  22932. _minZ: number;
  22933. /** @hidden */
  22934. _maxZ: number;
  22935. constructor(name: string, scene: Scene);
  22936. /**
  22937. * "GroundMesh"
  22938. * @returns "GroundMesh"
  22939. */
  22940. getClassName(): string;
  22941. /**
  22942. * The minimum of x and y subdivisions
  22943. */
  22944. get subdivisions(): number;
  22945. /**
  22946. * X subdivisions
  22947. */
  22948. get subdivisionsX(): number;
  22949. /**
  22950. * Y subdivisions
  22951. */
  22952. get subdivisionsY(): number;
  22953. /**
  22954. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22955. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22956. * @param chunksCount the number of subdivisions for x and y
  22957. * @param octreeBlocksSize (Default: 32)
  22958. */
  22959. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22960. /**
  22961. * Returns a height (y) value in the Worl system :
  22962. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22963. * @param x x coordinate
  22964. * @param z z coordinate
  22965. * @returns the ground y position if (x, z) are outside the ground surface.
  22966. */
  22967. getHeightAtCoordinates(x: number, z: number): number;
  22968. /**
  22969. * Returns a normalized vector (Vector3) orthogonal to the ground
  22970. * at the ground coordinates (x, z) expressed in the World system.
  22971. * @param x x coordinate
  22972. * @param z z coordinate
  22973. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22974. */
  22975. getNormalAtCoordinates(x: number, z: number): Vector3;
  22976. /**
  22977. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22978. * at the ground coordinates (x, z) expressed in the World system.
  22979. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22980. * @param x x coordinate
  22981. * @param z z coordinate
  22982. * @param ref vector to store the result
  22983. * @returns the GroundMesh.
  22984. */
  22985. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22986. /**
  22987. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22988. * if the ground has been updated.
  22989. * This can be used in the render loop.
  22990. * @returns the GroundMesh.
  22991. */
  22992. updateCoordinateHeights(): GroundMesh;
  22993. private _getFacetAt;
  22994. private _initHeightQuads;
  22995. private _computeHeightQuads;
  22996. /**
  22997. * Serializes this ground mesh
  22998. * @param serializationObject object to write serialization to
  22999. */
  23000. serialize(serializationObject: any): void;
  23001. /**
  23002. * Parses a serialized ground mesh
  23003. * @param parsedMesh the serialized mesh
  23004. * @param scene the scene to create the ground mesh in
  23005. * @returns the created ground mesh
  23006. */
  23007. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23008. }
  23009. }
  23010. declare module BABYLON {
  23011. /**
  23012. * Interface for Physics-Joint data
  23013. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23014. */
  23015. export interface PhysicsJointData {
  23016. /**
  23017. * The main pivot of the joint
  23018. */
  23019. mainPivot?: Vector3;
  23020. /**
  23021. * The connected pivot of the joint
  23022. */
  23023. connectedPivot?: Vector3;
  23024. /**
  23025. * The main axis of the joint
  23026. */
  23027. mainAxis?: Vector3;
  23028. /**
  23029. * The connected axis of the joint
  23030. */
  23031. connectedAxis?: Vector3;
  23032. /**
  23033. * The collision of the joint
  23034. */
  23035. collision?: boolean;
  23036. /**
  23037. * Native Oimo/Cannon/Energy data
  23038. */
  23039. nativeParams?: any;
  23040. }
  23041. /**
  23042. * This is a holder class for the physics joint created by the physics plugin
  23043. * It holds a set of functions to control the underlying joint
  23044. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23045. */
  23046. export class PhysicsJoint {
  23047. /**
  23048. * The type of the physics joint
  23049. */
  23050. type: number;
  23051. /**
  23052. * The data for the physics joint
  23053. */
  23054. jointData: PhysicsJointData;
  23055. private _physicsJoint;
  23056. protected _physicsPlugin: IPhysicsEnginePlugin;
  23057. /**
  23058. * Initializes the physics joint
  23059. * @param type The type of the physics joint
  23060. * @param jointData The data for the physics joint
  23061. */
  23062. constructor(
  23063. /**
  23064. * The type of the physics joint
  23065. */
  23066. type: number,
  23067. /**
  23068. * The data for the physics joint
  23069. */
  23070. jointData: PhysicsJointData);
  23071. /**
  23072. * Gets the physics joint
  23073. */
  23074. get physicsJoint(): any;
  23075. /**
  23076. * Sets the physics joint
  23077. */
  23078. set physicsJoint(newJoint: any);
  23079. /**
  23080. * Sets the physics plugin
  23081. */
  23082. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23083. /**
  23084. * Execute a function that is physics-plugin specific.
  23085. * @param {Function} func the function that will be executed.
  23086. * It accepts two parameters: the physics world and the physics joint
  23087. */
  23088. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23089. /**
  23090. * Distance-Joint type
  23091. */
  23092. static DistanceJoint: number;
  23093. /**
  23094. * Hinge-Joint type
  23095. */
  23096. static HingeJoint: number;
  23097. /**
  23098. * Ball-and-Socket joint type
  23099. */
  23100. static BallAndSocketJoint: number;
  23101. /**
  23102. * Wheel-Joint type
  23103. */
  23104. static WheelJoint: number;
  23105. /**
  23106. * Slider-Joint type
  23107. */
  23108. static SliderJoint: number;
  23109. /**
  23110. * Prismatic-Joint type
  23111. */
  23112. static PrismaticJoint: number;
  23113. /**
  23114. * Universal-Joint type
  23115. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23116. */
  23117. static UniversalJoint: number;
  23118. /**
  23119. * Hinge-Joint 2 type
  23120. */
  23121. static Hinge2Joint: number;
  23122. /**
  23123. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23124. */
  23125. static PointToPointJoint: number;
  23126. /**
  23127. * Spring-Joint type
  23128. */
  23129. static SpringJoint: number;
  23130. /**
  23131. * Lock-Joint type
  23132. */
  23133. static LockJoint: number;
  23134. }
  23135. /**
  23136. * A class representing a physics distance joint
  23137. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23138. */
  23139. export class DistanceJoint extends PhysicsJoint {
  23140. /**
  23141. *
  23142. * @param jointData The data for the Distance-Joint
  23143. */
  23144. constructor(jointData: DistanceJointData);
  23145. /**
  23146. * Update the predefined distance.
  23147. * @param maxDistance The maximum preferred distance
  23148. * @param minDistance The minimum preferred distance
  23149. */
  23150. updateDistance(maxDistance: number, minDistance?: number): void;
  23151. }
  23152. /**
  23153. * Represents a Motor-Enabled Joint
  23154. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23155. */
  23156. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23157. /**
  23158. * Initializes the Motor-Enabled Joint
  23159. * @param type The type of the joint
  23160. * @param jointData The physica joint data for the joint
  23161. */
  23162. constructor(type: number, jointData: PhysicsJointData);
  23163. /**
  23164. * Set the motor values.
  23165. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23166. * @param force the force to apply
  23167. * @param maxForce max force for this motor.
  23168. */
  23169. setMotor(force?: number, maxForce?: number): void;
  23170. /**
  23171. * Set the motor's limits.
  23172. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23173. * @param upperLimit The upper limit of the motor
  23174. * @param lowerLimit The lower limit of the motor
  23175. */
  23176. setLimit(upperLimit: number, lowerLimit?: number): void;
  23177. }
  23178. /**
  23179. * This class represents a single physics Hinge-Joint
  23180. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23181. */
  23182. export class HingeJoint extends MotorEnabledJoint {
  23183. /**
  23184. * Initializes the Hinge-Joint
  23185. * @param jointData The joint data for the Hinge-Joint
  23186. */
  23187. constructor(jointData: PhysicsJointData);
  23188. /**
  23189. * Set the motor values.
  23190. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23191. * @param {number} force the force to apply
  23192. * @param {number} maxForce max force for this motor.
  23193. */
  23194. setMotor(force?: number, maxForce?: number): void;
  23195. /**
  23196. * Set the motor's limits.
  23197. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23198. * @param upperLimit The upper limit of the motor
  23199. * @param lowerLimit The lower limit of the motor
  23200. */
  23201. setLimit(upperLimit: number, lowerLimit?: number): void;
  23202. }
  23203. /**
  23204. * This class represents a dual hinge physics joint (same as wheel joint)
  23205. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23206. */
  23207. export class Hinge2Joint extends MotorEnabledJoint {
  23208. /**
  23209. * Initializes the Hinge2-Joint
  23210. * @param jointData The joint data for the Hinge2-Joint
  23211. */
  23212. constructor(jointData: PhysicsJointData);
  23213. /**
  23214. * Set the motor values.
  23215. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23216. * @param {number} targetSpeed the speed the motor is to reach
  23217. * @param {number} maxForce max force for this motor.
  23218. * @param {motorIndex} the motor's index, 0 or 1.
  23219. */
  23220. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23221. /**
  23222. * Set the motor limits.
  23223. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23224. * @param {number} upperLimit the upper limit
  23225. * @param {number} lowerLimit lower limit
  23226. * @param {motorIndex} the motor's index, 0 or 1.
  23227. */
  23228. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23229. }
  23230. /**
  23231. * Interface for a motor enabled joint
  23232. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23233. */
  23234. export interface IMotorEnabledJoint {
  23235. /**
  23236. * Physics joint
  23237. */
  23238. physicsJoint: any;
  23239. /**
  23240. * Sets the motor of the motor-enabled joint
  23241. * @param force The force of the motor
  23242. * @param maxForce The maximum force of the motor
  23243. * @param motorIndex The index of the motor
  23244. */
  23245. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23246. /**
  23247. * Sets the limit of the motor
  23248. * @param upperLimit The upper limit of the motor
  23249. * @param lowerLimit The lower limit of the motor
  23250. * @param motorIndex The index of the motor
  23251. */
  23252. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23253. }
  23254. /**
  23255. * Joint data for a Distance-Joint
  23256. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23257. */
  23258. export interface DistanceJointData extends PhysicsJointData {
  23259. /**
  23260. * Max distance the 2 joint objects can be apart
  23261. */
  23262. maxDistance: number;
  23263. }
  23264. /**
  23265. * Joint data from a spring joint
  23266. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23267. */
  23268. export interface SpringJointData extends PhysicsJointData {
  23269. /**
  23270. * Length of the spring
  23271. */
  23272. length: number;
  23273. /**
  23274. * Stiffness of the spring
  23275. */
  23276. stiffness: number;
  23277. /**
  23278. * Damping of the spring
  23279. */
  23280. damping: number;
  23281. /** this callback will be called when applying the force to the impostors. */
  23282. forceApplicationCallback: () => void;
  23283. }
  23284. }
  23285. declare module BABYLON {
  23286. /**
  23287. * Holds the data for the raycast result
  23288. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23289. */
  23290. export class PhysicsRaycastResult {
  23291. private _hasHit;
  23292. private _hitDistance;
  23293. private _hitNormalWorld;
  23294. private _hitPointWorld;
  23295. private _rayFromWorld;
  23296. private _rayToWorld;
  23297. /**
  23298. * Gets if there was a hit
  23299. */
  23300. get hasHit(): boolean;
  23301. /**
  23302. * Gets the distance from the hit
  23303. */
  23304. get hitDistance(): number;
  23305. /**
  23306. * Gets the hit normal/direction in the world
  23307. */
  23308. get hitNormalWorld(): Vector3;
  23309. /**
  23310. * Gets the hit point in the world
  23311. */
  23312. get hitPointWorld(): Vector3;
  23313. /**
  23314. * Gets the ray "start point" of the ray in the world
  23315. */
  23316. get rayFromWorld(): Vector3;
  23317. /**
  23318. * Gets the ray "end point" of the ray in the world
  23319. */
  23320. get rayToWorld(): Vector3;
  23321. /**
  23322. * Sets the hit data (normal & point in world space)
  23323. * @param hitNormalWorld defines the normal in world space
  23324. * @param hitPointWorld defines the point in world space
  23325. */
  23326. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23327. /**
  23328. * Sets the distance from the start point to the hit point
  23329. * @param distance
  23330. */
  23331. setHitDistance(distance: number): void;
  23332. /**
  23333. * Calculates the distance manually
  23334. */
  23335. calculateHitDistance(): void;
  23336. /**
  23337. * Resets all the values to default
  23338. * @param from The from point on world space
  23339. * @param to The to point on world space
  23340. */
  23341. reset(from?: Vector3, to?: Vector3): void;
  23342. }
  23343. /**
  23344. * Interface for the size containing width and height
  23345. */
  23346. interface IXYZ {
  23347. /**
  23348. * X
  23349. */
  23350. x: number;
  23351. /**
  23352. * Y
  23353. */
  23354. y: number;
  23355. /**
  23356. * Z
  23357. */
  23358. z: number;
  23359. }
  23360. }
  23361. declare module BABYLON {
  23362. /**
  23363. * Interface used to describe a physics joint
  23364. */
  23365. export interface PhysicsImpostorJoint {
  23366. /** Defines the main impostor to which the joint is linked */
  23367. mainImpostor: PhysicsImpostor;
  23368. /** Defines the impostor that is connected to the main impostor using this joint */
  23369. connectedImpostor: PhysicsImpostor;
  23370. /** Defines the joint itself */
  23371. joint: PhysicsJoint;
  23372. }
  23373. /** @hidden */
  23374. export interface IPhysicsEnginePlugin {
  23375. world: any;
  23376. name: string;
  23377. setGravity(gravity: Vector3): void;
  23378. setTimeStep(timeStep: number): void;
  23379. getTimeStep(): number;
  23380. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23381. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23382. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23383. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23384. removePhysicsBody(impostor: PhysicsImpostor): void;
  23385. generateJoint(joint: PhysicsImpostorJoint): void;
  23386. removeJoint(joint: PhysicsImpostorJoint): void;
  23387. isSupported(): boolean;
  23388. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23389. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23390. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23391. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23392. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23393. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23394. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23395. getBodyMass(impostor: PhysicsImpostor): number;
  23396. getBodyFriction(impostor: PhysicsImpostor): number;
  23397. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23398. getBodyRestitution(impostor: PhysicsImpostor): number;
  23399. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23400. getBodyPressure?(impostor: PhysicsImpostor): number;
  23401. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23402. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23403. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23404. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23405. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23406. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23407. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23408. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23409. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23410. sleepBody(impostor: PhysicsImpostor): void;
  23411. wakeUpBody(impostor: PhysicsImpostor): void;
  23412. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23413. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23414. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23415. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23416. getRadius(impostor: PhysicsImpostor): number;
  23417. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23418. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23419. dispose(): void;
  23420. }
  23421. /**
  23422. * Interface used to define a physics engine
  23423. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23424. */
  23425. export interface IPhysicsEngine {
  23426. /**
  23427. * Gets the gravity vector used by the simulation
  23428. */
  23429. gravity: Vector3;
  23430. /**
  23431. * Sets the gravity vector used by the simulation
  23432. * @param gravity defines the gravity vector to use
  23433. */
  23434. setGravity(gravity: Vector3): void;
  23435. /**
  23436. * Set the time step of the physics engine.
  23437. * Default is 1/60.
  23438. * To slow it down, enter 1/600 for example.
  23439. * To speed it up, 1/30
  23440. * @param newTimeStep the new timestep to apply to this world.
  23441. */
  23442. setTimeStep(newTimeStep: number): void;
  23443. /**
  23444. * Get the time step of the physics engine.
  23445. * @returns the current time step
  23446. */
  23447. getTimeStep(): number;
  23448. /**
  23449. * Set the sub time step of the physics engine.
  23450. * Default is 0 meaning there is no sub steps
  23451. * To increase physics resolution precision, set a small value (like 1 ms)
  23452. * @param subTimeStep defines the new sub timestep used for physics resolution.
  23453. */
  23454. setSubTimeStep(subTimeStep: number): void;
  23455. /**
  23456. * Get the sub time step of the physics engine.
  23457. * @returns the current sub time step
  23458. */
  23459. getSubTimeStep(): number;
  23460. /**
  23461. * Release all resources
  23462. */
  23463. dispose(): void;
  23464. /**
  23465. * Gets the name of the current physics plugin
  23466. * @returns the name of the plugin
  23467. */
  23468. getPhysicsPluginName(): string;
  23469. /**
  23470. * Adding a new impostor for the impostor tracking.
  23471. * This will be done by the impostor itself.
  23472. * @param impostor the impostor to add
  23473. */
  23474. addImpostor(impostor: PhysicsImpostor): void;
  23475. /**
  23476. * Remove an impostor from the engine.
  23477. * This impostor and its mesh will not longer be updated by the physics engine.
  23478. * @param impostor the impostor to remove
  23479. */
  23480. removeImpostor(impostor: PhysicsImpostor): void;
  23481. /**
  23482. * Add a joint to the physics engine
  23483. * @param mainImpostor defines the main impostor to which the joint is added.
  23484. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23485. * @param joint defines the joint that will connect both impostors.
  23486. */
  23487. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23488. /**
  23489. * Removes a joint from the simulation
  23490. * @param mainImpostor defines the impostor used with the joint
  23491. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23492. * @param joint defines the joint to remove
  23493. */
  23494. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23495. /**
  23496. * Gets the current plugin used to run the simulation
  23497. * @returns current plugin
  23498. */
  23499. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23500. /**
  23501. * Gets the list of physic impostors
  23502. * @returns an array of PhysicsImpostor
  23503. */
  23504. getImpostors(): Array<PhysicsImpostor>;
  23505. /**
  23506. * Gets the impostor for a physics enabled object
  23507. * @param object defines the object impersonated by the impostor
  23508. * @returns the PhysicsImpostor or null if not found
  23509. */
  23510. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23511. /**
  23512. * Gets the impostor for a physics body object
  23513. * @param body defines physics body used by the impostor
  23514. * @returns the PhysicsImpostor or null if not found
  23515. */
  23516. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23517. /**
  23518. * Does a raycast in the physics world
  23519. * @param from when should the ray start?
  23520. * @param to when should the ray end?
  23521. * @returns PhysicsRaycastResult
  23522. */
  23523. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23524. /**
  23525. * Called by the scene. No need to call it.
  23526. * @param delta defines the timespam between frames
  23527. */
  23528. _step(delta: number): void;
  23529. }
  23530. }
  23531. declare module BABYLON {
  23532. /**
  23533. * The interface for the physics imposter parameters
  23534. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23535. */
  23536. export interface PhysicsImpostorParameters {
  23537. /**
  23538. * The mass of the physics imposter
  23539. */
  23540. mass: number;
  23541. /**
  23542. * The friction of the physics imposter
  23543. */
  23544. friction?: number;
  23545. /**
  23546. * The coefficient of restitution of the physics imposter
  23547. */
  23548. restitution?: number;
  23549. /**
  23550. * The native options of the physics imposter
  23551. */
  23552. nativeOptions?: any;
  23553. /**
  23554. * Specifies if the parent should be ignored
  23555. */
  23556. ignoreParent?: boolean;
  23557. /**
  23558. * Specifies if bi-directional transformations should be disabled
  23559. */
  23560. disableBidirectionalTransformation?: boolean;
  23561. /**
  23562. * The pressure inside the physics imposter, soft object only
  23563. */
  23564. pressure?: number;
  23565. /**
  23566. * The stiffness the physics imposter, soft object only
  23567. */
  23568. stiffness?: number;
  23569. /**
  23570. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23571. */
  23572. velocityIterations?: number;
  23573. /**
  23574. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23575. */
  23576. positionIterations?: number;
  23577. /**
  23578. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23579. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23580. * Add to fix multiple points
  23581. */
  23582. fixedPoints?: number;
  23583. /**
  23584. * The collision margin around a soft object
  23585. */
  23586. margin?: number;
  23587. /**
  23588. * The collision margin around a soft object
  23589. */
  23590. damping?: number;
  23591. /**
  23592. * The path for a rope based on an extrusion
  23593. */
  23594. path?: any;
  23595. /**
  23596. * The shape of an extrusion used for a rope based on an extrusion
  23597. */
  23598. shape?: any;
  23599. }
  23600. /**
  23601. * Interface for a physics-enabled object
  23602. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23603. */
  23604. export interface IPhysicsEnabledObject {
  23605. /**
  23606. * The position of the physics-enabled object
  23607. */
  23608. position: Vector3;
  23609. /**
  23610. * The rotation of the physics-enabled object
  23611. */
  23612. rotationQuaternion: Nullable<Quaternion>;
  23613. /**
  23614. * The scale of the physics-enabled object
  23615. */
  23616. scaling: Vector3;
  23617. /**
  23618. * The rotation of the physics-enabled object
  23619. */
  23620. rotation?: Vector3;
  23621. /**
  23622. * The parent of the physics-enabled object
  23623. */
  23624. parent?: any;
  23625. /**
  23626. * The bounding info of the physics-enabled object
  23627. * @returns The bounding info of the physics-enabled object
  23628. */
  23629. getBoundingInfo(): BoundingInfo;
  23630. /**
  23631. * Computes the world matrix
  23632. * @param force Specifies if the world matrix should be computed by force
  23633. * @returns A world matrix
  23634. */
  23635. computeWorldMatrix(force: boolean): Matrix;
  23636. /**
  23637. * Gets the world matrix
  23638. * @returns A world matrix
  23639. */
  23640. getWorldMatrix?(): Matrix;
  23641. /**
  23642. * Gets the child meshes
  23643. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23644. * @returns An array of abstract meshes
  23645. */
  23646. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23647. /**
  23648. * Gets the vertex data
  23649. * @param kind The type of vertex data
  23650. * @returns A nullable array of numbers, or a float32 array
  23651. */
  23652. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23653. /**
  23654. * Gets the indices from the mesh
  23655. * @returns A nullable array of index arrays
  23656. */
  23657. getIndices?(): Nullable<IndicesArray>;
  23658. /**
  23659. * Gets the scene from the mesh
  23660. * @returns the indices array or null
  23661. */
  23662. getScene?(): Scene;
  23663. /**
  23664. * Gets the absolute position from the mesh
  23665. * @returns the absolute position
  23666. */
  23667. getAbsolutePosition(): Vector3;
  23668. /**
  23669. * Gets the absolute pivot point from the mesh
  23670. * @returns the absolute pivot point
  23671. */
  23672. getAbsolutePivotPoint(): Vector3;
  23673. /**
  23674. * Rotates the mesh
  23675. * @param axis The axis of rotation
  23676. * @param amount The amount of rotation
  23677. * @param space The space of the rotation
  23678. * @returns The rotation transform node
  23679. */
  23680. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23681. /**
  23682. * Translates the mesh
  23683. * @param axis The axis of translation
  23684. * @param distance The distance of translation
  23685. * @param space The space of the translation
  23686. * @returns The transform node
  23687. */
  23688. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23689. /**
  23690. * Sets the absolute position of the mesh
  23691. * @param absolutePosition The absolute position of the mesh
  23692. * @returns The transform node
  23693. */
  23694. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23695. /**
  23696. * Gets the class name of the mesh
  23697. * @returns The class name
  23698. */
  23699. getClassName(): string;
  23700. }
  23701. /**
  23702. * Represents a physics imposter
  23703. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23704. */
  23705. export class PhysicsImpostor {
  23706. /**
  23707. * The physics-enabled object used as the physics imposter
  23708. */
  23709. object: IPhysicsEnabledObject;
  23710. /**
  23711. * The type of the physics imposter
  23712. */
  23713. type: number;
  23714. private _options;
  23715. private _scene?;
  23716. /**
  23717. * The default object size of the imposter
  23718. */
  23719. static DEFAULT_OBJECT_SIZE: Vector3;
  23720. /**
  23721. * The identity quaternion of the imposter
  23722. */
  23723. static IDENTITY_QUATERNION: Quaternion;
  23724. /** @hidden */
  23725. _pluginData: any;
  23726. private _physicsEngine;
  23727. private _physicsBody;
  23728. private _bodyUpdateRequired;
  23729. private _onBeforePhysicsStepCallbacks;
  23730. private _onAfterPhysicsStepCallbacks;
  23731. /** @hidden */
  23732. _onPhysicsCollideCallbacks: Array<{
  23733. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23734. otherImpostors: Array<PhysicsImpostor>;
  23735. }>;
  23736. private _deltaPosition;
  23737. private _deltaRotation;
  23738. private _deltaRotationConjugated;
  23739. /** @hidden */
  23740. _isFromLine: boolean;
  23741. private _parent;
  23742. private _isDisposed;
  23743. private static _tmpVecs;
  23744. private static _tmpQuat;
  23745. /**
  23746. * Specifies if the physics imposter is disposed
  23747. */
  23748. get isDisposed(): boolean;
  23749. /**
  23750. * Gets the mass of the physics imposter
  23751. */
  23752. get mass(): number;
  23753. set mass(value: number);
  23754. /**
  23755. * Gets the coefficient of friction
  23756. */
  23757. get friction(): number;
  23758. /**
  23759. * Sets the coefficient of friction
  23760. */
  23761. set friction(value: number);
  23762. /**
  23763. * Gets the coefficient of restitution
  23764. */
  23765. get restitution(): number;
  23766. /**
  23767. * Sets the coefficient of restitution
  23768. */
  23769. set restitution(value: number);
  23770. /**
  23771. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23772. */
  23773. get pressure(): number;
  23774. /**
  23775. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23776. */
  23777. set pressure(value: number);
  23778. /**
  23779. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23780. */
  23781. get stiffness(): number;
  23782. /**
  23783. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23784. */
  23785. set stiffness(value: number);
  23786. /**
  23787. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23788. */
  23789. get velocityIterations(): number;
  23790. /**
  23791. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23792. */
  23793. set velocityIterations(value: number);
  23794. /**
  23795. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23796. */
  23797. get positionIterations(): number;
  23798. /**
  23799. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23800. */
  23801. set positionIterations(value: number);
  23802. /**
  23803. * The unique id of the physics imposter
  23804. * set by the physics engine when adding this impostor to the array
  23805. */
  23806. uniqueId: number;
  23807. /**
  23808. * @hidden
  23809. */
  23810. soft: boolean;
  23811. /**
  23812. * @hidden
  23813. */
  23814. segments: number;
  23815. private _joints;
  23816. /**
  23817. * Initializes the physics imposter
  23818. * @param object The physics-enabled object used as the physics imposter
  23819. * @param type The type of the physics imposter
  23820. * @param _options The options for the physics imposter
  23821. * @param _scene The Babylon scene
  23822. */
  23823. constructor(
  23824. /**
  23825. * The physics-enabled object used as the physics imposter
  23826. */
  23827. object: IPhysicsEnabledObject,
  23828. /**
  23829. * The type of the physics imposter
  23830. */
  23831. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23832. /**
  23833. * This function will completly initialize this impostor.
  23834. * It will create a new body - but only if this mesh has no parent.
  23835. * If it has, this impostor will not be used other than to define the impostor
  23836. * of the child mesh.
  23837. * @hidden
  23838. */
  23839. _init(): void;
  23840. private _getPhysicsParent;
  23841. /**
  23842. * Should a new body be generated.
  23843. * @returns boolean specifying if body initialization is required
  23844. */
  23845. isBodyInitRequired(): boolean;
  23846. /**
  23847. * Sets the updated scaling
  23848. * @param updated Specifies if the scaling is updated
  23849. */
  23850. setScalingUpdated(): void;
  23851. /**
  23852. * Force a regeneration of this or the parent's impostor's body.
  23853. * Use under cautious - This will remove all joints already implemented.
  23854. */
  23855. forceUpdate(): void;
  23856. /**
  23857. * Gets the body that holds this impostor. Either its own, or its parent.
  23858. */
  23859. get physicsBody(): any;
  23860. /**
  23861. * Get the parent of the physics imposter
  23862. * @returns Physics imposter or null
  23863. */
  23864. get parent(): Nullable<PhysicsImpostor>;
  23865. /**
  23866. * Sets the parent of the physics imposter
  23867. */
  23868. set parent(value: Nullable<PhysicsImpostor>);
  23869. /**
  23870. * Set the physics body. Used mainly by the physics engine/plugin
  23871. */
  23872. set physicsBody(physicsBody: any);
  23873. /**
  23874. * Resets the update flags
  23875. */
  23876. resetUpdateFlags(): void;
  23877. /**
  23878. * Gets the object extend size
  23879. * @returns the object extend size
  23880. */
  23881. getObjectExtendSize(): Vector3;
  23882. /**
  23883. * Gets the object center
  23884. * @returns The object center
  23885. */
  23886. getObjectCenter(): Vector3;
  23887. /**
  23888. * Get a specific parameter from the options parameters
  23889. * @param paramName The object parameter name
  23890. * @returns The object parameter
  23891. */
  23892. getParam(paramName: string): any;
  23893. /**
  23894. * Sets a specific parameter in the options given to the physics plugin
  23895. * @param paramName The parameter name
  23896. * @param value The value of the parameter
  23897. */
  23898. setParam(paramName: string, value: number): void;
  23899. /**
  23900. * Specifically change the body's mass option. Won't recreate the physics body object
  23901. * @param mass The mass of the physics imposter
  23902. */
  23903. setMass(mass: number): void;
  23904. /**
  23905. * Gets the linear velocity
  23906. * @returns linear velocity or null
  23907. */
  23908. getLinearVelocity(): Nullable<Vector3>;
  23909. /**
  23910. * Sets the linear velocity
  23911. * @param velocity linear velocity or null
  23912. */
  23913. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23914. /**
  23915. * Gets the angular velocity
  23916. * @returns angular velocity or null
  23917. */
  23918. getAngularVelocity(): Nullable<Vector3>;
  23919. /**
  23920. * Sets the angular velocity
  23921. * @param velocity The velocity or null
  23922. */
  23923. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23924. /**
  23925. * Execute a function with the physics plugin native code
  23926. * Provide a function the will have two variables - the world object and the physics body object
  23927. * @param func The function to execute with the physics plugin native code
  23928. */
  23929. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23930. /**
  23931. * Register a function that will be executed before the physics world is stepping forward
  23932. * @param func The function to execute before the physics world is stepped forward
  23933. */
  23934. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23935. /**
  23936. * Unregister a function that will be executed before the physics world is stepping forward
  23937. * @param func The function to execute before the physics world is stepped forward
  23938. */
  23939. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23940. /**
  23941. * Register a function that will be executed after the physics step
  23942. * @param func The function to execute after physics step
  23943. */
  23944. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23945. /**
  23946. * Unregisters a function that will be executed after the physics step
  23947. * @param func The function to execute after physics step
  23948. */
  23949. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23950. /**
  23951. * register a function that will be executed when this impostor collides against a different body
  23952. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23953. * @param func Callback that is executed on collision
  23954. */
  23955. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23956. /**
  23957. * Unregisters the physics imposter on contact
  23958. * @param collideAgainst The physics object to collide against
  23959. * @param func Callback to execute on collision
  23960. */
  23961. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23962. private _tmpQuat;
  23963. private _tmpQuat2;
  23964. /**
  23965. * Get the parent rotation
  23966. * @returns The parent rotation
  23967. */
  23968. getParentsRotation(): Quaternion;
  23969. /**
  23970. * this function is executed by the physics engine.
  23971. */
  23972. beforeStep: () => void;
  23973. /**
  23974. * this function is executed by the physics engine
  23975. */
  23976. afterStep: () => void;
  23977. /**
  23978. * Legacy collision detection event support
  23979. */
  23980. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23981. /**
  23982. * event and body object due to cannon's event-based architecture.
  23983. */
  23984. onCollide: (e: {
  23985. body: any;
  23986. }) => void;
  23987. /**
  23988. * Apply a force
  23989. * @param force The force to apply
  23990. * @param contactPoint The contact point for the force
  23991. * @returns The physics imposter
  23992. */
  23993. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23994. /**
  23995. * Apply an impulse
  23996. * @param force The impulse force
  23997. * @param contactPoint The contact point for the impulse force
  23998. * @returns The physics imposter
  23999. */
  24000. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24001. /**
  24002. * A help function to create a joint
  24003. * @param otherImpostor A physics imposter used to create a joint
  24004. * @param jointType The type of joint
  24005. * @param jointData The data for the joint
  24006. * @returns The physics imposter
  24007. */
  24008. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24009. /**
  24010. * Add a joint to this impostor with a different impostor
  24011. * @param otherImpostor A physics imposter used to add a joint
  24012. * @param joint The joint to add
  24013. * @returns The physics imposter
  24014. */
  24015. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24016. /**
  24017. * Add an anchor to a cloth impostor
  24018. * @param otherImpostor rigid impostor to anchor to
  24019. * @param width ratio across width from 0 to 1
  24020. * @param height ratio up height from 0 to 1
  24021. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24022. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24023. * @returns impostor the soft imposter
  24024. */
  24025. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24026. /**
  24027. * Add a hook to a rope impostor
  24028. * @param otherImpostor rigid impostor to anchor to
  24029. * @param length ratio across rope from 0 to 1
  24030. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24031. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24032. * @returns impostor the rope imposter
  24033. */
  24034. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24035. /**
  24036. * Will keep this body still, in a sleep mode.
  24037. * @returns the physics imposter
  24038. */
  24039. sleep(): PhysicsImpostor;
  24040. /**
  24041. * Wake the body up.
  24042. * @returns The physics imposter
  24043. */
  24044. wakeUp(): PhysicsImpostor;
  24045. /**
  24046. * Clones the physics imposter
  24047. * @param newObject The physics imposter clones to this physics-enabled object
  24048. * @returns A nullable physics imposter
  24049. */
  24050. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24051. /**
  24052. * Disposes the physics imposter
  24053. */
  24054. dispose(): void;
  24055. /**
  24056. * Sets the delta position
  24057. * @param position The delta position amount
  24058. */
  24059. setDeltaPosition(position: Vector3): void;
  24060. /**
  24061. * Sets the delta rotation
  24062. * @param rotation The delta rotation amount
  24063. */
  24064. setDeltaRotation(rotation: Quaternion): void;
  24065. /**
  24066. * Gets the box size of the physics imposter and stores the result in the input parameter
  24067. * @param result Stores the box size
  24068. * @returns The physics imposter
  24069. */
  24070. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24071. /**
  24072. * Gets the radius of the physics imposter
  24073. * @returns Radius of the physics imposter
  24074. */
  24075. getRadius(): number;
  24076. /**
  24077. * Sync a bone with this impostor
  24078. * @param bone The bone to sync to the impostor.
  24079. * @param boneMesh The mesh that the bone is influencing.
  24080. * @param jointPivot The pivot of the joint / bone in local space.
  24081. * @param distToJoint Optional distance from the impostor to the joint.
  24082. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24083. */
  24084. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24085. /**
  24086. * Sync impostor to a bone
  24087. * @param bone The bone that the impostor will be synced to.
  24088. * @param boneMesh The mesh that the bone is influencing.
  24089. * @param jointPivot The pivot of the joint / bone in local space.
  24090. * @param distToJoint Optional distance from the impostor to the joint.
  24091. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24092. * @param boneAxis Optional vector3 axis the bone is aligned with
  24093. */
  24094. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24095. /**
  24096. * No-Imposter type
  24097. */
  24098. static NoImpostor: number;
  24099. /**
  24100. * Sphere-Imposter type
  24101. */
  24102. static SphereImpostor: number;
  24103. /**
  24104. * Box-Imposter type
  24105. */
  24106. static BoxImpostor: number;
  24107. /**
  24108. * Plane-Imposter type
  24109. */
  24110. static PlaneImpostor: number;
  24111. /**
  24112. * Mesh-imposter type
  24113. */
  24114. static MeshImpostor: number;
  24115. /**
  24116. * Capsule-Impostor type (Ammo.js plugin only)
  24117. */
  24118. static CapsuleImpostor: number;
  24119. /**
  24120. * Cylinder-Imposter type
  24121. */
  24122. static CylinderImpostor: number;
  24123. /**
  24124. * Particle-Imposter type
  24125. */
  24126. static ParticleImpostor: number;
  24127. /**
  24128. * Heightmap-Imposter type
  24129. */
  24130. static HeightmapImpostor: number;
  24131. /**
  24132. * ConvexHull-Impostor type (Ammo.js plugin only)
  24133. */
  24134. static ConvexHullImpostor: number;
  24135. /**
  24136. * Custom-Imposter type (Ammo.js plugin only)
  24137. */
  24138. static CustomImpostor: number;
  24139. /**
  24140. * Rope-Imposter type
  24141. */
  24142. static RopeImpostor: number;
  24143. /**
  24144. * Cloth-Imposter type
  24145. */
  24146. static ClothImpostor: number;
  24147. /**
  24148. * Softbody-Imposter type
  24149. */
  24150. static SoftbodyImpostor: number;
  24151. }
  24152. }
  24153. declare module BABYLON {
  24154. /**
  24155. * @hidden
  24156. **/
  24157. export class _CreationDataStorage {
  24158. closePath?: boolean;
  24159. closeArray?: boolean;
  24160. idx: number[];
  24161. dashSize: number;
  24162. gapSize: number;
  24163. path3D: Path3D;
  24164. pathArray: Vector3[][];
  24165. arc: number;
  24166. radius: number;
  24167. cap: number;
  24168. tessellation: number;
  24169. }
  24170. /**
  24171. * @hidden
  24172. **/
  24173. class _InstanceDataStorage {
  24174. visibleInstances: any;
  24175. batchCache: _InstancesBatch;
  24176. instancesBufferSize: number;
  24177. instancesBuffer: Nullable<Buffer>;
  24178. instancesData: Float32Array;
  24179. overridenInstanceCount: number;
  24180. isFrozen: boolean;
  24181. previousBatch: Nullable<_InstancesBatch>;
  24182. hardwareInstancedRendering: boolean;
  24183. sideOrientation: number;
  24184. manualUpdate: boolean;
  24185. }
  24186. /**
  24187. * @hidden
  24188. **/
  24189. export class _InstancesBatch {
  24190. mustReturn: boolean;
  24191. visibleInstances: Nullable<InstancedMesh[]>[];
  24192. renderSelf: boolean[];
  24193. hardwareInstancedRendering: boolean[];
  24194. }
  24195. /**
  24196. * Class used to represent renderable models
  24197. */
  24198. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24199. /**
  24200. * Mesh side orientation : usually the external or front surface
  24201. */
  24202. static readonly FRONTSIDE: number;
  24203. /**
  24204. * Mesh side orientation : usually the internal or back surface
  24205. */
  24206. static readonly BACKSIDE: number;
  24207. /**
  24208. * Mesh side orientation : both internal and external or front and back surfaces
  24209. */
  24210. static readonly DOUBLESIDE: number;
  24211. /**
  24212. * Mesh side orientation : by default, `FRONTSIDE`
  24213. */
  24214. static readonly DEFAULTSIDE: number;
  24215. /**
  24216. * Mesh cap setting : no cap
  24217. */
  24218. static readonly NO_CAP: number;
  24219. /**
  24220. * Mesh cap setting : one cap at the beginning of the mesh
  24221. */
  24222. static readonly CAP_START: number;
  24223. /**
  24224. * Mesh cap setting : one cap at the end of the mesh
  24225. */
  24226. static readonly CAP_END: number;
  24227. /**
  24228. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24229. */
  24230. static readonly CAP_ALL: number;
  24231. /**
  24232. * Mesh pattern setting : no flip or rotate
  24233. */
  24234. static readonly NO_FLIP: number;
  24235. /**
  24236. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24237. */
  24238. static readonly FLIP_TILE: number;
  24239. /**
  24240. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24241. */
  24242. static readonly ROTATE_TILE: number;
  24243. /**
  24244. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24245. */
  24246. static readonly FLIP_ROW: number;
  24247. /**
  24248. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24249. */
  24250. static readonly ROTATE_ROW: number;
  24251. /**
  24252. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24253. */
  24254. static readonly FLIP_N_ROTATE_TILE: number;
  24255. /**
  24256. * Mesh pattern setting : rotate pattern and rotate
  24257. */
  24258. static readonly FLIP_N_ROTATE_ROW: number;
  24259. /**
  24260. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24261. */
  24262. static readonly CENTER: number;
  24263. /**
  24264. * Mesh tile positioning : part tiles on left
  24265. */
  24266. static readonly LEFT: number;
  24267. /**
  24268. * Mesh tile positioning : part tiles on right
  24269. */
  24270. static readonly RIGHT: number;
  24271. /**
  24272. * Mesh tile positioning : part tiles on top
  24273. */
  24274. static readonly TOP: number;
  24275. /**
  24276. * Mesh tile positioning : part tiles on bottom
  24277. */
  24278. static readonly BOTTOM: number;
  24279. /**
  24280. * Gets the default side orientation.
  24281. * @param orientation the orientation to value to attempt to get
  24282. * @returns the default orientation
  24283. * @hidden
  24284. */
  24285. static _GetDefaultSideOrientation(orientation?: number): number;
  24286. private _internalMeshDataInfo;
  24287. /**
  24288. * An event triggered before rendering the mesh
  24289. */
  24290. get onBeforeRenderObservable(): Observable<Mesh>;
  24291. /**
  24292. * An event triggered before binding the mesh
  24293. */
  24294. get onBeforeBindObservable(): Observable<Mesh>;
  24295. /**
  24296. * An event triggered after rendering the mesh
  24297. */
  24298. get onAfterRenderObservable(): Observable<Mesh>;
  24299. /**
  24300. * An event triggered before drawing the mesh
  24301. */
  24302. get onBeforeDrawObservable(): Observable<Mesh>;
  24303. private _onBeforeDrawObserver;
  24304. /**
  24305. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24306. */
  24307. set onBeforeDraw(callback: () => void);
  24308. get hasInstances(): boolean;
  24309. /**
  24310. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24311. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24312. */
  24313. delayLoadState: number;
  24314. /**
  24315. * Gets the list of instances created from this mesh
  24316. * it is not supposed to be modified manually.
  24317. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24318. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24319. */
  24320. instances: InstancedMesh[];
  24321. /**
  24322. * Gets the file containing delay loading data for this mesh
  24323. */
  24324. delayLoadingFile: string;
  24325. /** @hidden */
  24326. _binaryInfo: any;
  24327. /**
  24328. * User defined function used to change how LOD level selection is done
  24329. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24330. */
  24331. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24332. /**
  24333. * Gets or sets the morph target manager
  24334. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24335. */
  24336. get morphTargetManager(): Nullable<MorphTargetManager>;
  24337. set morphTargetManager(value: Nullable<MorphTargetManager>);
  24338. /** @hidden */
  24339. _creationDataStorage: Nullable<_CreationDataStorage>;
  24340. /** @hidden */
  24341. _geometry: Nullable<Geometry>;
  24342. /** @hidden */
  24343. _delayInfo: Array<string>;
  24344. /** @hidden */
  24345. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24346. /** @hidden */
  24347. _instanceDataStorage: _InstanceDataStorage;
  24348. private _effectiveMaterial;
  24349. /** @hidden */
  24350. _shouldGenerateFlatShading: boolean;
  24351. /** @hidden */
  24352. _originalBuilderSideOrientation: number;
  24353. /**
  24354. * Use this property to change the original side orientation defined at construction time
  24355. */
  24356. overrideMaterialSideOrientation: Nullable<number>;
  24357. /**
  24358. * Gets the source mesh (the one used to clone this one from)
  24359. */
  24360. get source(): Nullable<Mesh>;
  24361. /**
  24362. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24363. */
  24364. get isUnIndexed(): boolean;
  24365. set isUnIndexed(value: boolean);
  24366. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  24367. get worldMatrixInstancedBuffer(): Float32Array;
  24368. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  24369. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  24370. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  24371. /**
  24372. * @constructor
  24373. * @param name The value used by scene.getMeshByName() to do a lookup.
  24374. * @param scene The scene to add this mesh to.
  24375. * @param parent The parent of this mesh, if it has one
  24376. * @param source An optional Mesh from which geometry is shared, cloned.
  24377. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24378. * When false, achieved by calling a clone(), also passing False.
  24379. * This will make creation of children, recursive.
  24380. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24381. */
  24382. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24383. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  24384. doNotInstantiate: boolean;
  24385. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  24386. /**
  24387. * Gets the class name
  24388. * @returns the string "Mesh".
  24389. */
  24390. getClassName(): string;
  24391. /** @hidden */
  24392. get _isMesh(): boolean;
  24393. /**
  24394. * Returns a description of this mesh
  24395. * @param fullDetails define if full details about this mesh must be used
  24396. * @returns a descriptive string representing this mesh
  24397. */
  24398. toString(fullDetails?: boolean): string;
  24399. /** @hidden */
  24400. _unBindEffect(): void;
  24401. /**
  24402. * Gets a boolean indicating if this mesh has LOD
  24403. */
  24404. get hasLODLevels(): boolean;
  24405. /**
  24406. * Gets the list of MeshLODLevel associated with the current mesh
  24407. * @returns an array of MeshLODLevel
  24408. */
  24409. getLODLevels(): MeshLODLevel[];
  24410. private _sortLODLevels;
  24411. /**
  24412. * Add a mesh as LOD level triggered at the given distance.
  24413. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24414. * @param distance The distance from the center of the object to show this level
  24415. * @param mesh The mesh to be added as LOD level (can be null)
  24416. * @return This mesh (for chaining)
  24417. */
  24418. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24419. /**
  24420. * Returns the LOD level mesh at the passed distance or null if not found.
  24421. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24422. * @param distance The distance from the center of the object to show this level
  24423. * @returns a Mesh or `null`
  24424. */
  24425. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24426. /**
  24427. * Remove a mesh from the LOD array
  24428. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24429. * @param mesh defines the mesh to be removed
  24430. * @return This mesh (for chaining)
  24431. */
  24432. removeLODLevel(mesh: Mesh): Mesh;
  24433. /**
  24434. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24435. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24436. * @param camera defines the camera to use to compute distance
  24437. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24438. * @return This mesh (for chaining)
  24439. */
  24440. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24441. /**
  24442. * Gets the mesh internal Geometry object
  24443. */
  24444. get geometry(): Nullable<Geometry>;
  24445. /**
  24446. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24447. * @returns the total number of vertices
  24448. */
  24449. getTotalVertices(): number;
  24450. /**
  24451. * Returns the content of an associated vertex buffer
  24452. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24453. * - VertexBuffer.PositionKind
  24454. * - VertexBuffer.UVKind
  24455. * - VertexBuffer.UV2Kind
  24456. * - VertexBuffer.UV3Kind
  24457. * - VertexBuffer.UV4Kind
  24458. * - VertexBuffer.UV5Kind
  24459. * - VertexBuffer.UV6Kind
  24460. * - VertexBuffer.ColorKind
  24461. * - VertexBuffer.MatricesIndicesKind
  24462. * - VertexBuffer.MatricesIndicesExtraKind
  24463. * - VertexBuffer.MatricesWeightsKind
  24464. * - VertexBuffer.MatricesWeightsExtraKind
  24465. * @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
  24466. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24467. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24468. */
  24469. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24470. /**
  24471. * Returns the mesh VertexBuffer object from the requested `kind`
  24472. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24473. * - VertexBuffer.PositionKind
  24474. * - VertexBuffer.NormalKind
  24475. * - VertexBuffer.UVKind
  24476. * - VertexBuffer.UV2Kind
  24477. * - VertexBuffer.UV3Kind
  24478. * - VertexBuffer.UV4Kind
  24479. * - VertexBuffer.UV5Kind
  24480. * - VertexBuffer.UV6Kind
  24481. * - VertexBuffer.ColorKind
  24482. * - VertexBuffer.MatricesIndicesKind
  24483. * - VertexBuffer.MatricesIndicesExtraKind
  24484. * - VertexBuffer.MatricesWeightsKind
  24485. * - VertexBuffer.MatricesWeightsExtraKind
  24486. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24487. */
  24488. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24489. /**
  24490. * Tests if a specific vertex buffer is associated with this mesh
  24491. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24492. * - VertexBuffer.PositionKind
  24493. * - VertexBuffer.NormalKind
  24494. * - VertexBuffer.UVKind
  24495. * - VertexBuffer.UV2Kind
  24496. * - VertexBuffer.UV3Kind
  24497. * - VertexBuffer.UV4Kind
  24498. * - VertexBuffer.UV5Kind
  24499. * - VertexBuffer.UV6Kind
  24500. * - VertexBuffer.ColorKind
  24501. * - VertexBuffer.MatricesIndicesKind
  24502. * - VertexBuffer.MatricesIndicesExtraKind
  24503. * - VertexBuffer.MatricesWeightsKind
  24504. * - VertexBuffer.MatricesWeightsExtraKind
  24505. * @returns a boolean
  24506. */
  24507. isVerticesDataPresent(kind: string): boolean;
  24508. /**
  24509. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24510. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24511. * - VertexBuffer.PositionKind
  24512. * - VertexBuffer.UVKind
  24513. * - VertexBuffer.UV2Kind
  24514. * - VertexBuffer.UV3Kind
  24515. * - VertexBuffer.UV4Kind
  24516. * - VertexBuffer.UV5Kind
  24517. * - VertexBuffer.UV6Kind
  24518. * - VertexBuffer.ColorKind
  24519. * - VertexBuffer.MatricesIndicesKind
  24520. * - VertexBuffer.MatricesIndicesExtraKind
  24521. * - VertexBuffer.MatricesWeightsKind
  24522. * - VertexBuffer.MatricesWeightsExtraKind
  24523. * @returns a boolean
  24524. */
  24525. isVertexBufferUpdatable(kind: string): boolean;
  24526. /**
  24527. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24528. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24529. * - VertexBuffer.PositionKind
  24530. * - VertexBuffer.NormalKind
  24531. * - VertexBuffer.UVKind
  24532. * - VertexBuffer.UV2Kind
  24533. * - VertexBuffer.UV3Kind
  24534. * - VertexBuffer.UV4Kind
  24535. * - VertexBuffer.UV5Kind
  24536. * - VertexBuffer.UV6Kind
  24537. * - VertexBuffer.ColorKind
  24538. * - VertexBuffer.MatricesIndicesKind
  24539. * - VertexBuffer.MatricesIndicesExtraKind
  24540. * - VertexBuffer.MatricesWeightsKind
  24541. * - VertexBuffer.MatricesWeightsExtraKind
  24542. * @returns an array of strings
  24543. */
  24544. getVerticesDataKinds(): string[];
  24545. /**
  24546. * Returns a positive integer : the total number of indices in this mesh geometry.
  24547. * @returns the numner of indices or zero if the mesh has no geometry.
  24548. */
  24549. getTotalIndices(): number;
  24550. /**
  24551. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24552. * @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.
  24553. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24554. * @returns the indices array or an empty array if the mesh has no geometry
  24555. */
  24556. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24557. get isBlocked(): boolean;
  24558. /**
  24559. * Determine if the current mesh is ready to be rendered
  24560. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24561. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24562. * @returns true if all associated assets are ready (material, textures, shaders)
  24563. */
  24564. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24565. /**
  24566. * 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.
  24567. */
  24568. get areNormalsFrozen(): boolean;
  24569. /**
  24570. * 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.
  24571. * @returns the current mesh
  24572. */
  24573. freezeNormals(): Mesh;
  24574. /**
  24575. * 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
  24576. * @returns the current mesh
  24577. */
  24578. unfreezeNormals(): Mesh;
  24579. /**
  24580. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24581. */
  24582. set overridenInstanceCount(count: number);
  24583. /** @hidden */
  24584. _preActivate(): Mesh;
  24585. /** @hidden */
  24586. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24587. /** @hidden */
  24588. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24589. /**
  24590. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24591. * This means the mesh underlying bounding box and sphere are recomputed.
  24592. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24593. * @returns the current mesh
  24594. */
  24595. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24596. /** @hidden */
  24597. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24598. /**
  24599. * This function will subdivide the mesh into multiple submeshes
  24600. * @param count defines the expected number of submeshes
  24601. */
  24602. subdivide(count: number): void;
  24603. /**
  24604. * Copy a FloatArray into a specific associated vertex buffer
  24605. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24606. * - VertexBuffer.PositionKind
  24607. * - VertexBuffer.UVKind
  24608. * - VertexBuffer.UV2Kind
  24609. * - VertexBuffer.UV3Kind
  24610. * - VertexBuffer.UV4Kind
  24611. * - VertexBuffer.UV5Kind
  24612. * - VertexBuffer.UV6Kind
  24613. * - VertexBuffer.ColorKind
  24614. * - VertexBuffer.MatricesIndicesKind
  24615. * - VertexBuffer.MatricesIndicesExtraKind
  24616. * - VertexBuffer.MatricesWeightsKind
  24617. * - VertexBuffer.MatricesWeightsExtraKind
  24618. * @param data defines the data source
  24619. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24620. * @param stride defines the data stride size (can be null)
  24621. * @returns the current mesh
  24622. */
  24623. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24624. /**
  24625. * Delete a vertex buffer associated with this mesh
  24626. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  24627. * - VertexBuffer.PositionKind
  24628. * - VertexBuffer.UVKind
  24629. * - VertexBuffer.UV2Kind
  24630. * - VertexBuffer.UV3Kind
  24631. * - VertexBuffer.UV4Kind
  24632. * - VertexBuffer.UV5Kind
  24633. * - VertexBuffer.UV6Kind
  24634. * - VertexBuffer.ColorKind
  24635. * - VertexBuffer.MatricesIndicesKind
  24636. * - VertexBuffer.MatricesIndicesExtraKind
  24637. * - VertexBuffer.MatricesWeightsKind
  24638. * - VertexBuffer.MatricesWeightsExtraKind
  24639. */
  24640. removeVerticesData(kind: string): void;
  24641. /**
  24642. * Flags an associated vertex buffer as updatable
  24643. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24644. * - VertexBuffer.PositionKind
  24645. * - VertexBuffer.UVKind
  24646. * - VertexBuffer.UV2Kind
  24647. * - VertexBuffer.UV3Kind
  24648. * - VertexBuffer.UV4Kind
  24649. * - VertexBuffer.UV5Kind
  24650. * - VertexBuffer.UV6Kind
  24651. * - VertexBuffer.ColorKind
  24652. * - VertexBuffer.MatricesIndicesKind
  24653. * - VertexBuffer.MatricesIndicesExtraKind
  24654. * - VertexBuffer.MatricesWeightsKind
  24655. * - VertexBuffer.MatricesWeightsExtraKind
  24656. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24657. */
  24658. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24659. /**
  24660. * Sets the mesh global Vertex Buffer
  24661. * @param buffer defines the buffer to use
  24662. * @returns the current mesh
  24663. */
  24664. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24665. /**
  24666. * Update a specific associated vertex buffer
  24667. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24668. * - VertexBuffer.PositionKind
  24669. * - VertexBuffer.UVKind
  24670. * - VertexBuffer.UV2Kind
  24671. * - VertexBuffer.UV3Kind
  24672. * - VertexBuffer.UV4Kind
  24673. * - VertexBuffer.UV5Kind
  24674. * - VertexBuffer.UV6Kind
  24675. * - VertexBuffer.ColorKind
  24676. * - VertexBuffer.MatricesIndicesKind
  24677. * - VertexBuffer.MatricesIndicesExtraKind
  24678. * - VertexBuffer.MatricesWeightsKind
  24679. * - VertexBuffer.MatricesWeightsExtraKind
  24680. * @param data defines the data source
  24681. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24682. * @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)
  24683. * @returns the current mesh
  24684. */
  24685. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24686. /**
  24687. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24688. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24689. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24690. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24691. * @returns the current mesh
  24692. */
  24693. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24694. /**
  24695. * Creates a un-shared specific occurence of the geometry for the mesh.
  24696. * @returns the current mesh
  24697. */
  24698. makeGeometryUnique(): Mesh;
  24699. /**
  24700. * Set the index buffer of this mesh
  24701. * @param indices defines the source data
  24702. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24703. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24704. * @returns the current mesh
  24705. */
  24706. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24707. /**
  24708. * Update the current index buffer
  24709. * @param indices defines the source data
  24710. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24711. * @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)
  24712. * @returns the current mesh
  24713. */
  24714. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24715. /**
  24716. * Invert the geometry to move from a right handed system to a left handed one.
  24717. * @returns the current mesh
  24718. */
  24719. toLeftHanded(): Mesh;
  24720. /** @hidden */
  24721. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24722. /** @hidden */
  24723. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24724. /**
  24725. * Registers for this mesh a javascript function called just before the rendering process
  24726. * @param func defines the function to call before rendering this mesh
  24727. * @returns the current mesh
  24728. */
  24729. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24730. /**
  24731. * Disposes a previously registered javascript function called before the rendering
  24732. * @param func defines the function to remove
  24733. * @returns the current mesh
  24734. */
  24735. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24736. /**
  24737. * Registers for this mesh a javascript function called just after the rendering is complete
  24738. * @param func defines the function to call after rendering this mesh
  24739. * @returns the current mesh
  24740. */
  24741. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24742. /**
  24743. * Disposes a previously registered javascript function called after the rendering.
  24744. * @param func defines the function to remove
  24745. * @returns the current mesh
  24746. */
  24747. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24748. /** @hidden */
  24749. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  24750. /** @hidden */
  24751. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24752. /** @hidden */
  24753. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  24754. /** @hidden */
  24755. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24756. /** @hidden */
  24757. _rebuild(): void;
  24758. /** @hidden */
  24759. _freeze(): void;
  24760. /** @hidden */
  24761. _unFreeze(): void;
  24762. /**
  24763. * 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
  24764. * @param subMesh defines the subMesh to render
  24765. * @param enableAlphaMode defines if alpha mode can be changed
  24766. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  24767. * @returns the current mesh
  24768. */
  24769. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  24770. private _onBeforeDraw;
  24771. /**
  24772. * Renormalize the mesh and patch it up if there are no weights
  24773. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24774. * However in the case of zero weights then we set just a single influence to 1.
  24775. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24776. */
  24777. cleanMatrixWeights(): void;
  24778. private normalizeSkinFourWeights;
  24779. private normalizeSkinWeightsAndExtra;
  24780. /**
  24781. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24782. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24783. * the user know there was an issue with importing the mesh
  24784. * @returns a validation object with skinned, valid and report string
  24785. */
  24786. validateSkinning(): {
  24787. skinned: boolean;
  24788. valid: boolean;
  24789. report: string;
  24790. };
  24791. /** @hidden */
  24792. _checkDelayState(): Mesh;
  24793. private _queueLoad;
  24794. /**
  24795. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24796. * A mesh is in the frustum if its bounding box intersects the frustum
  24797. * @param frustumPlanes defines the frustum to test
  24798. * @returns true if the mesh is in the frustum planes
  24799. */
  24800. isInFrustum(frustumPlanes: Plane[]): boolean;
  24801. /**
  24802. * Sets the mesh material by the material or multiMaterial `id` property
  24803. * @param id is a string identifying the material or the multiMaterial
  24804. * @returns the current mesh
  24805. */
  24806. setMaterialByID(id: string): Mesh;
  24807. /**
  24808. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24809. * @returns an array of IAnimatable
  24810. */
  24811. getAnimatables(): IAnimatable[];
  24812. /**
  24813. * Modifies the mesh geometry according to the passed transformation matrix.
  24814. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24815. * The mesh normals are modified using the same transformation.
  24816. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24817. * @param transform defines the transform matrix to use
  24818. * @see http://doc.babylonjs.com/resources/baking_transformations
  24819. * @returns the current mesh
  24820. */
  24821. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24822. /**
  24823. * Modifies the mesh geometry according to its own current World Matrix.
  24824. * The mesh World Matrix is then reset.
  24825. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24826. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24827. * @see http://doc.babylonjs.com/resources/baking_transformations
  24828. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  24829. * @returns the current mesh
  24830. */
  24831. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  24832. /** @hidden */
  24833. get _positions(): Nullable<Vector3[]>;
  24834. /** @hidden */
  24835. _resetPointsArrayCache(): Mesh;
  24836. /** @hidden */
  24837. _generatePointsArray(): boolean;
  24838. /**
  24839. * Returns a new Mesh object generated from the current mesh properties.
  24840. * This method must not get confused with createInstance()
  24841. * @param name is a string, the name given to the new mesh
  24842. * @param newParent can be any Node object (default `null`)
  24843. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24844. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24845. * @returns a new mesh
  24846. */
  24847. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  24848. /**
  24849. * Releases resources associated with this mesh.
  24850. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24851. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24852. */
  24853. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24854. /** @hidden */
  24855. _disposeInstanceSpecificData(): void;
  24856. /**
  24857. * Modifies the mesh geometry according to a displacement map.
  24858. * 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.
  24859. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24860. * @param url is a string, the URL from the image file is to be downloaded.
  24861. * @param minHeight is the lower limit of the displacement.
  24862. * @param maxHeight is the upper limit of the displacement.
  24863. * @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.
  24864. * @param uvOffset is an optional vector2 used to offset UV.
  24865. * @param uvScale is an optional vector2 used to scale UV.
  24866. * @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.
  24867. * @returns the Mesh.
  24868. */
  24869. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24870. /**
  24871. * Modifies the mesh geometry according to a displacementMap buffer.
  24872. * 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.
  24873. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24874. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24875. * @param heightMapWidth is the width of the buffer image.
  24876. * @param heightMapHeight is the height of the buffer image.
  24877. * @param minHeight is the lower limit of the displacement.
  24878. * @param maxHeight is the upper limit of the displacement.
  24879. * @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.
  24880. * @param uvOffset is an optional vector2 used to offset UV.
  24881. * @param uvScale is an optional vector2 used to scale UV.
  24882. * @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.
  24883. * @returns the Mesh.
  24884. */
  24885. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24886. /**
  24887. * Modify the mesh to get a flat shading rendering.
  24888. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24889. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24890. * @returns current mesh
  24891. */
  24892. convertToFlatShadedMesh(): Mesh;
  24893. /**
  24894. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24895. * In other words, more vertices, no more indices and a single bigger VBO.
  24896. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24897. * @returns current mesh
  24898. */
  24899. convertToUnIndexedMesh(): Mesh;
  24900. /**
  24901. * Inverses facet orientations.
  24902. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24903. * @param flipNormals will also inverts the normals
  24904. * @returns current mesh
  24905. */
  24906. flipFaces(flipNormals?: boolean): Mesh;
  24907. /**
  24908. * Increase the number of facets and hence vertices in a mesh
  24909. * Vertex normals are interpolated from existing vertex normals
  24910. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24911. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24912. */
  24913. increaseVertices(numberPerEdge: number): void;
  24914. /**
  24915. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24916. * This will undo any application of covertToFlatShadedMesh
  24917. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24918. */
  24919. forceSharedVertices(): void;
  24920. /** @hidden */
  24921. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24922. /** @hidden */
  24923. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24924. /**
  24925. * Creates a new InstancedMesh object from the mesh model.
  24926. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24927. * @param name defines the name of the new instance
  24928. * @returns a new InstancedMesh
  24929. */
  24930. createInstance(name: string): InstancedMesh;
  24931. /**
  24932. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24933. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24934. * @returns the current mesh
  24935. */
  24936. synchronizeInstances(): Mesh;
  24937. /**
  24938. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24939. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24940. * This should be used together with the simplification to avoid disappearing triangles.
  24941. * @param successCallback an optional success callback to be called after the optimization finished.
  24942. * @returns the current mesh
  24943. */
  24944. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24945. /**
  24946. * Serialize current mesh
  24947. * @param serializationObject defines the object which will receive the serialization data
  24948. */
  24949. serialize(serializationObject: any): void;
  24950. /** @hidden */
  24951. _syncGeometryWithMorphTargetManager(): void;
  24952. /** @hidden */
  24953. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24954. /**
  24955. * Returns a new Mesh object parsed from the source provided.
  24956. * @param parsedMesh is the source
  24957. * @param scene defines the hosting scene
  24958. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24959. * @returns a new Mesh
  24960. */
  24961. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24962. /**
  24963. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24964. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24965. * @param name defines the name of the mesh to create
  24966. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24967. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24968. * @param closePath creates a seam between the first and the last points of each path of the path array
  24969. * @param offset is taken in account only if the `pathArray` is containing a single path
  24970. * @param scene defines the hosting scene
  24971. * @param updatable defines if the mesh must be flagged as updatable
  24972. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24973. * @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)
  24974. * @returns a new Mesh
  24975. */
  24976. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24977. /**
  24978. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24979. * @param name defines the name of the mesh to create
  24980. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24981. * @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
  24982. * @param scene defines the hosting scene
  24983. * @param updatable defines if the mesh must be flagged as updatable
  24984. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24985. * @returns a new Mesh
  24986. */
  24987. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24988. /**
  24989. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24990. * @param name defines the name of the mesh to create
  24991. * @param size sets the size (float) of each box side (default 1)
  24992. * @param scene defines the hosting scene
  24993. * @param updatable defines if the mesh must be flagged as updatable
  24994. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24995. * @returns a new Mesh
  24996. */
  24997. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24998. /**
  24999. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25000. * @param name defines the name of the mesh to create
  25001. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25002. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25003. * @param scene defines the hosting scene
  25004. * @param updatable defines if the mesh must be flagged as updatable
  25005. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25006. * @returns a new Mesh
  25007. */
  25008. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25009. /**
  25010. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25011. * @param name defines the name of the mesh to create
  25012. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25013. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25014. * @param scene defines the hosting scene
  25015. * @returns a new Mesh
  25016. */
  25017. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25018. /**
  25019. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25020. * @param name defines the name of the mesh to create
  25021. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25022. * @param diameterTop set the top cap diameter (floats, default 1)
  25023. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25024. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25025. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25026. * @param scene defines the hosting scene
  25027. * @param updatable defines if the mesh must be flagged as updatable
  25028. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25029. * @returns a new Mesh
  25030. */
  25031. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25032. /**
  25033. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25034. * @param name defines the name of the mesh to create
  25035. * @param diameter sets the diameter size (float) of the torus (default 1)
  25036. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25037. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25038. * @param scene defines the hosting scene
  25039. * @param updatable defines if the mesh must be flagged as updatable
  25040. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25041. * @returns a new Mesh
  25042. */
  25043. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25044. /**
  25045. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25046. * @param name defines the name of the mesh to create
  25047. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25048. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25049. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25050. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25051. * @param p the number of windings on X axis (positive integers, default 2)
  25052. * @param q the number of windings on Y axis (positive integers, default 3)
  25053. * @param scene defines the hosting scene
  25054. * @param updatable defines if the mesh must be flagged as updatable
  25055. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25056. * @returns a new Mesh
  25057. */
  25058. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25059. /**
  25060. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25061. * @param name defines the name of the mesh to create
  25062. * @param points is an array successive Vector3
  25063. * @param scene defines the hosting scene
  25064. * @param updatable defines if the mesh must be flagged as updatable
  25065. * @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).
  25066. * @returns a new Mesh
  25067. */
  25068. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25069. /**
  25070. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25071. * @param name defines the name of the mesh to create
  25072. * @param points is an array successive Vector3
  25073. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25074. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25075. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25076. * @param scene defines the hosting scene
  25077. * @param updatable defines if the mesh must be flagged as updatable
  25078. * @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)
  25079. * @returns a new Mesh
  25080. */
  25081. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25082. /**
  25083. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25084. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25085. * 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.
  25086. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25087. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25088. * Remember you can only change the shape positions, not their number when updating a polygon.
  25089. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25090. * @param name defines the name of the mesh to create
  25091. * @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
  25092. * @param scene defines the hosting scene
  25093. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25094. * @param updatable defines if the mesh must be flagged as updatable
  25095. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25096. * @param earcutInjection can be used to inject your own earcut reference
  25097. * @returns a new Mesh
  25098. */
  25099. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25100. /**
  25101. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25102. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25103. * @param name defines the name of the mesh to create
  25104. * @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
  25105. * @param depth defines the height of extrusion
  25106. * @param scene defines the hosting scene
  25107. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25108. * @param updatable defines if the mesh must be flagged as updatable
  25109. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25110. * @param earcutInjection can be used to inject your own earcut reference
  25111. * @returns a new Mesh
  25112. */
  25113. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25114. /**
  25115. * Creates an extruded shape mesh.
  25116. * 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
  25117. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25118. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25119. * @param name defines the name of the mesh to create
  25120. * @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
  25121. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25122. * @param scale is the value to scale the shape
  25123. * @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
  25124. * @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
  25125. * @param scene defines the hosting scene
  25126. * @param updatable defines if the mesh must be flagged as updatable
  25127. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25128. * @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)
  25129. * @returns a new Mesh
  25130. */
  25131. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25132. /**
  25133. * Creates an custom extruded shape mesh.
  25134. * The custom extrusion is a parametric shape.
  25135. * It has no predefined shape. Its final shape will depend on the input parameters.
  25136. * Please consider using the same method from the MeshBuilder class instead
  25137. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25138. * @param name defines the name of the mesh to create
  25139. * @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
  25140. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25141. * @param scaleFunction is a custom Javascript function called on each path point
  25142. * @param rotationFunction is a custom Javascript function called on each path point
  25143. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25144. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25145. * @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
  25146. * @param scene defines the hosting scene
  25147. * @param updatable defines if the mesh must be flagged as updatable
  25148. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25149. * @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)
  25150. * @returns a new Mesh
  25151. */
  25152. 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;
  25153. /**
  25154. * Creates lathe mesh.
  25155. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25156. * Please consider using the same method from the MeshBuilder class instead
  25157. * @param name defines the name of the mesh to create
  25158. * @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
  25159. * @param radius is the radius value of the lathe
  25160. * @param tessellation is the side number of the lathe.
  25161. * @param scene defines the hosting scene
  25162. * @param updatable defines if the mesh must be flagged as updatable
  25163. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25164. * @returns a new Mesh
  25165. */
  25166. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25167. /**
  25168. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25169. * @param name defines the name of the mesh to create
  25170. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25171. * @param scene defines the hosting scene
  25172. * @param updatable defines if the mesh must be flagged as updatable
  25173. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25174. * @returns a new Mesh
  25175. */
  25176. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25177. /**
  25178. * Creates a ground mesh.
  25179. * Please consider using the same method from the MeshBuilder class instead
  25180. * @param name defines the name of the mesh to create
  25181. * @param width set the width of the ground
  25182. * @param height set the height of the ground
  25183. * @param subdivisions sets the number of subdivisions per side
  25184. * @param scene defines the hosting scene
  25185. * @param updatable defines if the mesh must be flagged as updatable
  25186. * @returns a new Mesh
  25187. */
  25188. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25189. /**
  25190. * Creates a tiled ground mesh.
  25191. * Please consider using the same method from the MeshBuilder class instead
  25192. * @param name defines the name of the mesh to create
  25193. * @param xmin set the ground minimum X coordinate
  25194. * @param zmin set the ground minimum Y coordinate
  25195. * @param xmax set the ground maximum X coordinate
  25196. * @param zmax set the ground maximum Z coordinate
  25197. * @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
  25198. * @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
  25199. * @param scene defines the hosting scene
  25200. * @param updatable defines if the mesh must be flagged as updatable
  25201. * @returns a new Mesh
  25202. */
  25203. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25204. w: number;
  25205. h: number;
  25206. }, precision: {
  25207. w: number;
  25208. h: number;
  25209. }, scene: Scene, updatable?: boolean): Mesh;
  25210. /**
  25211. * Creates a ground mesh from a height map.
  25212. * Please consider using the same method from the MeshBuilder class instead
  25213. * @see http://doc.babylonjs.com/babylon101/height_map
  25214. * @param name defines the name of the mesh to create
  25215. * @param url sets the URL of the height map image resource
  25216. * @param width set the ground width size
  25217. * @param height set the ground height size
  25218. * @param subdivisions sets the number of subdivision per side
  25219. * @param minHeight is the minimum altitude on the ground
  25220. * @param maxHeight is the maximum altitude on the ground
  25221. * @param scene defines the hosting scene
  25222. * @param updatable defines if the mesh must be flagged as updatable
  25223. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25224. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25225. * @returns a new Mesh
  25226. */
  25227. 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;
  25228. /**
  25229. * Creates a tube mesh.
  25230. * The tube is a parametric shape.
  25231. * It has no predefined shape. Its final shape will depend on the input parameters.
  25232. * Please consider using the same method from the MeshBuilder class instead
  25233. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25234. * @param name defines the name of the mesh to create
  25235. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25236. * @param radius sets the tube radius size
  25237. * @param tessellation is the number of sides on the tubular surface
  25238. * @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
  25239. * @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
  25240. * @param scene defines the hosting scene
  25241. * @param updatable defines if the mesh must be flagged as updatable
  25242. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25243. * @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)
  25244. * @returns a new Mesh
  25245. */
  25246. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25247. (i: number, distance: number): number;
  25248. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25249. /**
  25250. * Creates a polyhedron mesh.
  25251. * Please consider using the same method from the MeshBuilder class instead.
  25252. * * 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
  25253. * * The parameter `size` (positive float, default 1) sets the polygon size
  25254. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25255. * * 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`
  25256. * * 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
  25257. * * 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)`)
  25258. * * 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
  25259. * * 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
  25260. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25261. * * 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
  25262. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25263. * @param name defines the name of the mesh to create
  25264. * @param options defines the options used to create the mesh
  25265. * @param scene defines the hosting scene
  25266. * @returns a new Mesh
  25267. */
  25268. static CreatePolyhedron(name: string, options: {
  25269. type?: number;
  25270. size?: number;
  25271. sizeX?: number;
  25272. sizeY?: number;
  25273. sizeZ?: number;
  25274. custom?: any;
  25275. faceUV?: Vector4[];
  25276. faceColors?: Color4[];
  25277. updatable?: boolean;
  25278. sideOrientation?: number;
  25279. }, scene: Scene): Mesh;
  25280. /**
  25281. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25282. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25283. * * 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`)
  25284. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25285. * * 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
  25286. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25287. * * 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
  25288. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25289. * @param name defines the name of the mesh
  25290. * @param options defines the options used to create the mesh
  25291. * @param scene defines the hosting scene
  25292. * @returns a new Mesh
  25293. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25294. */
  25295. static CreateIcoSphere(name: string, options: {
  25296. radius?: number;
  25297. flat?: boolean;
  25298. subdivisions?: number;
  25299. sideOrientation?: number;
  25300. updatable?: boolean;
  25301. }, scene: Scene): Mesh;
  25302. /**
  25303. * Creates a decal mesh.
  25304. * Please consider using the same method from the MeshBuilder class instead.
  25305. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25306. * @param name defines the name of the mesh
  25307. * @param sourceMesh defines the mesh receiving the decal
  25308. * @param position sets the position of the decal in world coordinates
  25309. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25310. * @param size sets the decal scaling
  25311. * @param angle sets the angle to rotate the decal
  25312. * @returns a new Mesh
  25313. */
  25314. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25315. /**
  25316. * Prepare internal position array for software CPU skinning
  25317. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25318. */
  25319. setPositionsForCPUSkinning(): Float32Array;
  25320. /**
  25321. * Prepare internal normal array for software CPU skinning
  25322. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25323. */
  25324. setNormalsForCPUSkinning(): Float32Array;
  25325. /**
  25326. * Updates the vertex buffer by applying transformation from the bones
  25327. * @param skeleton defines the skeleton to apply to current mesh
  25328. * @returns the current mesh
  25329. */
  25330. applySkeleton(skeleton: Skeleton): Mesh;
  25331. /**
  25332. * 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
  25333. * @param meshes defines the list of meshes to scan
  25334. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25335. */
  25336. static MinMax(meshes: AbstractMesh[]): {
  25337. min: Vector3;
  25338. max: Vector3;
  25339. };
  25340. /**
  25341. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25342. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25343. * @returns a vector3
  25344. */
  25345. static Center(meshesOrMinMaxVector: {
  25346. min: Vector3;
  25347. max: Vector3;
  25348. } | AbstractMesh[]): Vector3;
  25349. /**
  25350. * Merge the array of meshes into a single mesh for performance reasons.
  25351. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25352. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25353. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25354. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25355. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25356. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25357. * @returns a new mesh
  25358. */
  25359. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25360. /** @hidden */
  25361. addInstance(instance: InstancedMesh): void;
  25362. /** @hidden */
  25363. removeInstance(instance: InstancedMesh): void;
  25364. }
  25365. }
  25366. declare module BABYLON {
  25367. /**
  25368. * This is the base class of all the camera used in the application.
  25369. * @see http://doc.babylonjs.com/features/cameras
  25370. */
  25371. export class Camera extends Node {
  25372. /** @hidden */
  25373. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25374. /**
  25375. * This is the default projection mode used by the cameras.
  25376. * It helps recreating a feeling of perspective and better appreciate depth.
  25377. * This is the best way to simulate real life cameras.
  25378. */
  25379. static readonly PERSPECTIVE_CAMERA: number;
  25380. /**
  25381. * This helps creating camera with an orthographic mode.
  25382. * 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.
  25383. */
  25384. static readonly ORTHOGRAPHIC_CAMERA: number;
  25385. /**
  25386. * This is the default FOV mode for perspective cameras.
  25387. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25388. */
  25389. static readonly FOVMODE_VERTICAL_FIXED: number;
  25390. /**
  25391. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25392. */
  25393. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25394. /**
  25395. * This specifies ther is no need for a camera rig.
  25396. * Basically only one eye is rendered corresponding to the camera.
  25397. */
  25398. static readonly RIG_MODE_NONE: number;
  25399. /**
  25400. * Simulates a camera Rig with one blue eye and one red eye.
  25401. * This can be use with 3d blue and red glasses.
  25402. */
  25403. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25404. /**
  25405. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25406. */
  25407. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25408. /**
  25409. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25410. */
  25411. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25412. /**
  25413. * Defines that both eyes of the camera will be rendered over under each other.
  25414. */
  25415. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25416. /**
  25417. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  25418. */
  25419. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  25420. /**
  25421. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25422. */
  25423. static readonly RIG_MODE_VR: number;
  25424. /**
  25425. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25426. */
  25427. static readonly RIG_MODE_WEBVR: number;
  25428. /**
  25429. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25430. */
  25431. static readonly RIG_MODE_CUSTOM: number;
  25432. /**
  25433. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25434. */
  25435. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25436. /**
  25437. * Define the input manager associated with the camera.
  25438. */
  25439. inputs: CameraInputsManager<Camera>;
  25440. /** @hidden */
  25441. _position: Vector3;
  25442. /**
  25443. * Define the current local position of the camera in the scene
  25444. */
  25445. get position(): Vector3;
  25446. set position(newPosition: Vector3);
  25447. /**
  25448. * The vector the camera should consider as up.
  25449. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25450. */
  25451. upVector: Vector3;
  25452. /**
  25453. * Define the current limit on the left side for an orthographic camera
  25454. * In scene unit
  25455. */
  25456. orthoLeft: Nullable<number>;
  25457. /**
  25458. * Define the current limit on the right side for an orthographic camera
  25459. * In scene unit
  25460. */
  25461. orthoRight: Nullable<number>;
  25462. /**
  25463. * Define the current limit on the bottom side for an orthographic camera
  25464. * In scene unit
  25465. */
  25466. orthoBottom: Nullable<number>;
  25467. /**
  25468. * Define the current limit on the top side for an orthographic camera
  25469. * In scene unit
  25470. */
  25471. orthoTop: Nullable<number>;
  25472. /**
  25473. * Field Of View is set in Radians. (default is 0.8)
  25474. */
  25475. fov: number;
  25476. /**
  25477. * Define the minimum distance the camera can see from.
  25478. * This is important to note that the depth buffer are not infinite and the closer it starts
  25479. * the more your scene might encounter depth fighting issue.
  25480. */
  25481. minZ: number;
  25482. /**
  25483. * Define the maximum distance the camera can see to.
  25484. * This is important to note that the depth buffer are not infinite and the further it end
  25485. * the more your scene might encounter depth fighting issue.
  25486. */
  25487. maxZ: number;
  25488. /**
  25489. * Define the default inertia of the camera.
  25490. * This helps giving a smooth feeling to the camera movement.
  25491. */
  25492. inertia: number;
  25493. /**
  25494. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25495. */
  25496. mode: number;
  25497. /**
  25498. * Define whether the camera is intermediate.
  25499. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25500. */
  25501. isIntermediate: boolean;
  25502. /**
  25503. * Define the viewport of the camera.
  25504. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25505. */
  25506. viewport: Viewport;
  25507. /**
  25508. * Restricts the camera to viewing objects with the same layerMask.
  25509. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25510. */
  25511. layerMask: number;
  25512. /**
  25513. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25514. */
  25515. fovMode: number;
  25516. /**
  25517. * Rig mode of the camera.
  25518. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25519. * This is normally controlled byt the camera themselves as internal use.
  25520. */
  25521. cameraRigMode: number;
  25522. /**
  25523. * Defines the distance between both "eyes" in case of a RIG
  25524. */
  25525. interaxialDistance: number;
  25526. /**
  25527. * Defines if stereoscopic rendering is done side by side or over under.
  25528. */
  25529. isStereoscopicSideBySide: boolean;
  25530. /**
  25531. * 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
  25532. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25533. * else in the scene. (Eg. security camera)
  25534. *
  25535. * 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)
  25536. */
  25537. customRenderTargets: RenderTargetTexture[];
  25538. /**
  25539. * When set, the camera will render to this render target instead of the default canvas
  25540. *
  25541. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25542. */
  25543. outputRenderTarget: Nullable<RenderTargetTexture>;
  25544. /**
  25545. * Observable triggered when the camera view matrix has changed.
  25546. */
  25547. onViewMatrixChangedObservable: Observable<Camera>;
  25548. /**
  25549. * Observable triggered when the camera Projection matrix has changed.
  25550. */
  25551. onProjectionMatrixChangedObservable: Observable<Camera>;
  25552. /**
  25553. * Observable triggered when the inputs have been processed.
  25554. */
  25555. onAfterCheckInputsObservable: Observable<Camera>;
  25556. /**
  25557. * Observable triggered when reset has been called and applied to the camera.
  25558. */
  25559. onRestoreStateObservable: Observable<Camera>;
  25560. /**
  25561. * Is this camera a part of a rig system?
  25562. */
  25563. isRigCamera: boolean;
  25564. /**
  25565. * If isRigCamera set to true this will be set with the parent camera.
  25566. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  25567. */
  25568. rigParent?: Camera;
  25569. /** @hidden */
  25570. _cameraRigParams: any;
  25571. /** @hidden */
  25572. _rigCameras: Camera[];
  25573. /** @hidden */
  25574. _rigPostProcess: Nullable<PostProcess>;
  25575. protected _webvrViewMatrix: Matrix;
  25576. /** @hidden */
  25577. _skipRendering: boolean;
  25578. /** @hidden */
  25579. _projectionMatrix: Matrix;
  25580. /** @hidden */
  25581. _postProcesses: Nullable<PostProcess>[];
  25582. /** @hidden */
  25583. _activeMeshes: SmartArray<AbstractMesh>;
  25584. protected _globalPosition: Vector3;
  25585. /** @hidden */
  25586. _computedViewMatrix: Matrix;
  25587. private _doNotComputeProjectionMatrix;
  25588. private _transformMatrix;
  25589. private _frustumPlanes;
  25590. private _refreshFrustumPlanes;
  25591. private _storedFov;
  25592. private _stateStored;
  25593. /**
  25594. * Instantiates a new camera object.
  25595. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25596. * @see http://doc.babylonjs.com/features/cameras
  25597. * @param name Defines the name of the camera in the scene
  25598. * @param position Defines the position of the camera
  25599. * @param scene Defines the scene the camera belongs too
  25600. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25601. */
  25602. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25603. /**
  25604. * Store current camera state (fov, position, etc..)
  25605. * @returns the camera
  25606. */
  25607. storeState(): Camera;
  25608. /**
  25609. * Restores the camera state values if it has been stored. You must call storeState() first
  25610. */
  25611. protected _restoreStateValues(): boolean;
  25612. /**
  25613. * Restored camera state. You must call storeState() first.
  25614. * @returns true if restored and false otherwise
  25615. */
  25616. restoreState(): boolean;
  25617. /**
  25618. * Gets the class name of the camera.
  25619. * @returns the class name
  25620. */
  25621. getClassName(): string;
  25622. /** @hidden */
  25623. readonly _isCamera: boolean;
  25624. /**
  25625. * Gets a string representation of the camera useful for debug purpose.
  25626. * @param fullDetails Defines that a more verboe level of logging is required
  25627. * @returns the string representation
  25628. */
  25629. toString(fullDetails?: boolean): string;
  25630. /**
  25631. * Gets the current world space position of the camera.
  25632. */
  25633. get globalPosition(): Vector3;
  25634. /**
  25635. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25636. * @returns the active meshe list
  25637. */
  25638. getActiveMeshes(): SmartArray<AbstractMesh>;
  25639. /**
  25640. * Check whether a mesh is part of the current active mesh list of the camera
  25641. * @param mesh Defines the mesh to check
  25642. * @returns true if active, false otherwise
  25643. */
  25644. isActiveMesh(mesh: Mesh): boolean;
  25645. /**
  25646. * Is this camera ready to be used/rendered
  25647. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25648. * @return true if the camera is ready
  25649. */
  25650. isReady(completeCheck?: boolean): boolean;
  25651. /** @hidden */
  25652. _initCache(): void;
  25653. /** @hidden */
  25654. _updateCache(ignoreParentClass?: boolean): void;
  25655. /** @hidden */
  25656. _isSynchronized(): boolean;
  25657. /** @hidden */
  25658. _isSynchronizedViewMatrix(): boolean;
  25659. /** @hidden */
  25660. _isSynchronizedProjectionMatrix(): boolean;
  25661. /**
  25662. * Attach the input controls to a specific dom element to get the input from.
  25663. * @param element Defines the element the controls should be listened from
  25664. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25665. */
  25666. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25667. /**
  25668. * Detach the current controls from the specified dom element.
  25669. * @param element Defines the element to stop listening the inputs from
  25670. */
  25671. detachControl(element: HTMLElement): void;
  25672. /**
  25673. * Update the camera state according to the different inputs gathered during the frame.
  25674. */
  25675. update(): void;
  25676. /** @hidden */
  25677. _checkInputs(): void;
  25678. /** @hidden */
  25679. get rigCameras(): Camera[];
  25680. /**
  25681. * Gets the post process used by the rig cameras
  25682. */
  25683. get rigPostProcess(): Nullable<PostProcess>;
  25684. /**
  25685. * Internal, gets the first post proces.
  25686. * @returns the first post process to be run on this camera.
  25687. */
  25688. _getFirstPostProcess(): Nullable<PostProcess>;
  25689. private _cascadePostProcessesToRigCams;
  25690. /**
  25691. * Attach a post process to the camera.
  25692. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25693. * @param postProcess The post process to attach to the camera
  25694. * @param insertAt The position of the post process in case several of them are in use in the scene
  25695. * @returns the position the post process has been inserted at
  25696. */
  25697. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25698. /**
  25699. * Detach a post process to the camera.
  25700. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25701. * @param postProcess The post process to detach from the camera
  25702. */
  25703. detachPostProcess(postProcess: PostProcess): void;
  25704. /**
  25705. * Gets the current world matrix of the camera
  25706. */
  25707. getWorldMatrix(): Matrix;
  25708. /** @hidden */
  25709. _getViewMatrix(): Matrix;
  25710. /**
  25711. * Gets the current view matrix of the camera.
  25712. * @param force forces the camera to recompute the matrix without looking at the cached state
  25713. * @returns the view matrix
  25714. */
  25715. getViewMatrix(force?: boolean): Matrix;
  25716. /**
  25717. * Freeze the projection matrix.
  25718. * It will prevent the cache check of the camera projection compute and can speed up perf
  25719. * if no parameter of the camera are meant to change
  25720. * @param projection Defines manually a projection if necessary
  25721. */
  25722. freezeProjectionMatrix(projection?: Matrix): void;
  25723. /**
  25724. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25725. */
  25726. unfreezeProjectionMatrix(): void;
  25727. /**
  25728. * Gets the current projection matrix of the camera.
  25729. * @param force forces the camera to recompute the matrix without looking at the cached state
  25730. * @returns the projection matrix
  25731. */
  25732. getProjectionMatrix(force?: boolean): Matrix;
  25733. /**
  25734. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25735. * @returns a Matrix
  25736. */
  25737. getTransformationMatrix(): Matrix;
  25738. private _updateFrustumPlanes;
  25739. /**
  25740. * Checks if a cullable object (mesh...) is in the camera frustum
  25741. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25742. * @param target The object to check
  25743. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25744. * @returns true if the object is in frustum otherwise false
  25745. */
  25746. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25747. /**
  25748. * Checks if a cullable object (mesh...) is in the camera frustum
  25749. * Unlike isInFrustum this cheks the full bounding box
  25750. * @param target The object to check
  25751. * @returns true if the object is in frustum otherwise false
  25752. */
  25753. isCompletelyInFrustum(target: ICullable): boolean;
  25754. /**
  25755. * Gets a ray in the forward direction from the camera.
  25756. * @param length Defines the length of the ray to create
  25757. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25758. * @param origin Defines the start point of the ray which defaults to the camera position
  25759. * @returns the forward ray
  25760. */
  25761. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25762. /**
  25763. * Releases resources associated with this node.
  25764. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25765. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25766. */
  25767. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25768. /** @hidden */
  25769. _isLeftCamera: boolean;
  25770. /**
  25771. * Gets the left camera of a rig setup in case of Rigged Camera
  25772. */
  25773. get isLeftCamera(): boolean;
  25774. /** @hidden */
  25775. _isRightCamera: boolean;
  25776. /**
  25777. * Gets the right camera of a rig setup in case of Rigged Camera
  25778. */
  25779. get isRightCamera(): boolean;
  25780. /**
  25781. * Gets the left camera of a rig setup in case of Rigged Camera
  25782. */
  25783. get leftCamera(): Nullable<FreeCamera>;
  25784. /**
  25785. * Gets the right camera of a rig setup in case of Rigged Camera
  25786. */
  25787. get rightCamera(): Nullable<FreeCamera>;
  25788. /**
  25789. * Gets the left camera target of a rig setup in case of Rigged Camera
  25790. * @returns the target position
  25791. */
  25792. getLeftTarget(): Nullable<Vector3>;
  25793. /**
  25794. * Gets the right camera target of a rig setup in case of Rigged Camera
  25795. * @returns the target position
  25796. */
  25797. getRightTarget(): Nullable<Vector3>;
  25798. /**
  25799. * @hidden
  25800. */
  25801. setCameraRigMode(mode: number, rigParams: any): void;
  25802. /** @hidden */
  25803. static _setStereoscopicRigMode(camera: Camera): void;
  25804. /** @hidden */
  25805. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25806. /** @hidden */
  25807. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25808. /** @hidden */
  25809. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25810. /** @hidden */
  25811. _getVRProjectionMatrix(): Matrix;
  25812. protected _updateCameraRotationMatrix(): void;
  25813. protected _updateWebVRCameraRotationMatrix(): void;
  25814. /**
  25815. * This function MUST be overwritten by the different WebVR cameras available.
  25816. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25817. * @hidden
  25818. */
  25819. _getWebVRProjectionMatrix(): Matrix;
  25820. /**
  25821. * This function MUST be overwritten by the different WebVR cameras available.
  25822. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25823. * @hidden
  25824. */
  25825. _getWebVRViewMatrix(): Matrix;
  25826. /** @hidden */
  25827. setCameraRigParameter(name: string, value: any): void;
  25828. /**
  25829. * needs to be overridden by children so sub has required properties to be copied
  25830. * @hidden
  25831. */
  25832. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25833. /**
  25834. * May need to be overridden by children
  25835. * @hidden
  25836. */
  25837. _updateRigCameras(): void;
  25838. /** @hidden */
  25839. _setupInputs(): void;
  25840. /**
  25841. * Serialiaze the camera setup to a json represention
  25842. * @returns the JSON representation
  25843. */
  25844. serialize(): any;
  25845. /**
  25846. * Clones the current camera.
  25847. * @param name The cloned camera name
  25848. * @returns the cloned camera
  25849. */
  25850. clone(name: string): Camera;
  25851. /**
  25852. * Gets the direction of the camera relative to a given local axis.
  25853. * @param localAxis Defines the reference axis to provide a relative direction.
  25854. * @return the direction
  25855. */
  25856. getDirection(localAxis: Vector3): Vector3;
  25857. /**
  25858. * Returns the current camera absolute rotation
  25859. */
  25860. get absoluteRotation(): Quaternion;
  25861. /**
  25862. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25863. * @param localAxis Defines the reference axis to provide a relative direction.
  25864. * @param result Defines the vector to store the result in
  25865. */
  25866. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25867. /**
  25868. * Gets a camera constructor for a given camera type
  25869. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25870. * @param name The name of the camera the result will be able to instantiate
  25871. * @param scene The scene the result will construct the camera in
  25872. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25873. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25874. * @returns a factory method to construc the camera
  25875. */
  25876. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25877. /**
  25878. * Compute the world matrix of the camera.
  25879. * @returns the camera world matrix
  25880. */
  25881. computeWorldMatrix(): Matrix;
  25882. /**
  25883. * Parse a JSON and creates the camera from the parsed information
  25884. * @param parsedCamera The JSON to parse
  25885. * @param scene The scene to instantiate the camera in
  25886. * @returns the newly constructed camera
  25887. */
  25888. static Parse(parsedCamera: any, scene: Scene): Camera;
  25889. }
  25890. }
  25891. declare module BABYLON {
  25892. /**
  25893. * Class containing static functions to help procedurally build meshes
  25894. */
  25895. export class DiscBuilder {
  25896. /**
  25897. * Creates a plane polygonal mesh. By default, this is a disc
  25898. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25899. * * 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
  25900. * * 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
  25901. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25902. * * 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
  25903. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25904. * @param name defines the name of the mesh
  25905. * @param options defines the options used to create the mesh
  25906. * @param scene defines the hosting scene
  25907. * @returns the plane polygonal mesh
  25908. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25909. */
  25910. static CreateDisc(name: string, options: {
  25911. radius?: number;
  25912. tessellation?: number;
  25913. arc?: number;
  25914. updatable?: boolean;
  25915. sideOrientation?: number;
  25916. frontUVs?: Vector4;
  25917. backUVs?: Vector4;
  25918. }, scene?: Nullable<Scene>): Mesh;
  25919. }
  25920. }
  25921. declare module BABYLON {
  25922. /**
  25923. * This represents all the required information to add a fresnel effect on a material:
  25924. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25925. */
  25926. export class FresnelParameters {
  25927. private _isEnabled;
  25928. /**
  25929. * Define if the fresnel effect is enable or not.
  25930. */
  25931. get isEnabled(): boolean;
  25932. set isEnabled(value: boolean);
  25933. /**
  25934. * Define the color used on edges (grazing angle)
  25935. */
  25936. leftColor: Color3;
  25937. /**
  25938. * Define the color used on center
  25939. */
  25940. rightColor: Color3;
  25941. /**
  25942. * Define bias applied to computed fresnel term
  25943. */
  25944. bias: number;
  25945. /**
  25946. * Defined the power exponent applied to fresnel term
  25947. */
  25948. power: number;
  25949. /**
  25950. * Clones the current fresnel and its valuues
  25951. * @returns a clone fresnel configuration
  25952. */
  25953. clone(): FresnelParameters;
  25954. /**
  25955. * Serializes the current fresnel parameters to a JSON representation.
  25956. * @return the JSON serialization
  25957. */
  25958. serialize(): any;
  25959. /**
  25960. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  25961. * @param parsedFresnelParameters Define the JSON representation
  25962. * @returns the parsed parameters
  25963. */
  25964. static Parse(parsedFresnelParameters: any): FresnelParameters;
  25965. }
  25966. }
  25967. declare module BABYLON {
  25968. /**
  25969. * Base class of materials working in push mode in babylon JS
  25970. * @hidden
  25971. */
  25972. export class PushMaterial extends Material {
  25973. protected _activeEffect: Effect;
  25974. protected _normalMatrix: Matrix;
  25975. /**
  25976. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  25977. * This means that the material can keep using a previous shader while a new one is being compiled.
  25978. * This is mostly used when shader parallel compilation is supported (true by default)
  25979. */
  25980. allowShaderHotSwapping: boolean;
  25981. constructor(name: string, scene: Scene);
  25982. getEffect(): Effect;
  25983. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  25984. /**
  25985. * Binds the given world matrix to the active effect
  25986. *
  25987. * @param world the matrix to bind
  25988. */
  25989. bindOnlyWorldMatrix(world: Matrix): void;
  25990. /**
  25991. * Binds the given normal matrix to the active effect
  25992. *
  25993. * @param normalMatrix the matrix to bind
  25994. */
  25995. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  25996. bind(world: Matrix, mesh?: Mesh): void;
  25997. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  25998. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  25999. }
  26000. }
  26001. declare module BABYLON {
  26002. /**
  26003. * This groups all the flags used to control the materials channel.
  26004. */
  26005. export class MaterialFlags {
  26006. private static _DiffuseTextureEnabled;
  26007. /**
  26008. * Are diffuse textures enabled in the application.
  26009. */
  26010. static get DiffuseTextureEnabled(): boolean;
  26011. static set DiffuseTextureEnabled(value: boolean);
  26012. private static _AmbientTextureEnabled;
  26013. /**
  26014. * Are ambient textures enabled in the application.
  26015. */
  26016. static get AmbientTextureEnabled(): boolean;
  26017. static set AmbientTextureEnabled(value: boolean);
  26018. private static _OpacityTextureEnabled;
  26019. /**
  26020. * Are opacity textures enabled in the application.
  26021. */
  26022. static get OpacityTextureEnabled(): boolean;
  26023. static set OpacityTextureEnabled(value: boolean);
  26024. private static _ReflectionTextureEnabled;
  26025. /**
  26026. * Are reflection textures enabled in the application.
  26027. */
  26028. static get ReflectionTextureEnabled(): boolean;
  26029. static set ReflectionTextureEnabled(value: boolean);
  26030. private static _EmissiveTextureEnabled;
  26031. /**
  26032. * Are emissive textures enabled in the application.
  26033. */
  26034. static get EmissiveTextureEnabled(): boolean;
  26035. static set EmissiveTextureEnabled(value: boolean);
  26036. private static _SpecularTextureEnabled;
  26037. /**
  26038. * Are specular textures enabled in the application.
  26039. */
  26040. static get SpecularTextureEnabled(): boolean;
  26041. static set SpecularTextureEnabled(value: boolean);
  26042. private static _BumpTextureEnabled;
  26043. /**
  26044. * Are bump textures enabled in the application.
  26045. */
  26046. static get BumpTextureEnabled(): boolean;
  26047. static set BumpTextureEnabled(value: boolean);
  26048. private static _LightmapTextureEnabled;
  26049. /**
  26050. * Are lightmap textures enabled in the application.
  26051. */
  26052. static get LightmapTextureEnabled(): boolean;
  26053. static set LightmapTextureEnabled(value: boolean);
  26054. private static _RefractionTextureEnabled;
  26055. /**
  26056. * Are refraction textures enabled in the application.
  26057. */
  26058. static get RefractionTextureEnabled(): boolean;
  26059. static set RefractionTextureEnabled(value: boolean);
  26060. private static _ColorGradingTextureEnabled;
  26061. /**
  26062. * Are color grading textures enabled in the application.
  26063. */
  26064. static get ColorGradingTextureEnabled(): boolean;
  26065. static set ColorGradingTextureEnabled(value: boolean);
  26066. private static _FresnelEnabled;
  26067. /**
  26068. * Are fresnels enabled in the application.
  26069. */
  26070. static get FresnelEnabled(): boolean;
  26071. static set FresnelEnabled(value: boolean);
  26072. private static _ClearCoatTextureEnabled;
  26073. /**
  26074. * Are clear coat textures enabled in the application.
  26075. */
  26076. static get ClearCoatTextureEnabled(): boolean;
  26077. static set ClearCoatTextureEnabled(value: boolean);
  26078. private static _ClearCoatBumpTextureEnabled;
  26079. /**
  26080. * Are clear coat bump textures enabled in the application.
  26081. */
  26082. static get ClearCoatBumpTextureEnabled(): boolean;
  26083. static set ClearCoatBumpTextureEnabled(value: boolean);
  26084. private static _ClearCoatTintTextureEnabled;
  26085. /**
  26086. * Are clear coat tint textures enabled in the application.
  26087. */
  26088. static get ClearCoatTintTextureEnabled(): boolean;
  26089. static set ClearCoatTintTextureEnabled(value: boolean);
  26090. private static _SheenTextureEnabled;
  26091. /**
  26092. * Are sheen textures enabled in the application.
  26093. */
  26094. static get SheenTextureEnabled(): boolean;
  26095. static set SheenTextureEnabled(value: boolean);
  26096. private static _AnisotropicTextureEnabled;
  26097. /**
  26098. * Are anisotropic textures enabled in the application.
  26099. */
  26100. static get AnisotropicTextureEnabled(): boolean;
  26101. static set AnisotropicTextureEnabled(value: boolean);
  26102. private static _ThicknessTextureEnabled;
  26103. /**
  26104. * Are thickness textures enabled in the application.
  26105. */
  26106. static get ThicknessTextureEnabled(): boolean;
  26107. static set ThicknessTextureEnabled(value: boolean);
  26108. }
  26109. }
  26110. declare module BABYLON {
  26111. /** @hidden */
  26112. export var defaultFragmentDeclaration: {
  26113. name: string;
  26114. shader: string;
  26115. };
  26116. }
  26117. declare module BABYLON {
  26118. /** @hidden */
  26119. export var defaultUboDeclaration: {
  26120. name: string;
  26121. shader: string;
  26122. };
  26123. }
  26124. declare module BABYLON {
  26125. /** @hidden */
  26126. export var lightFragmentDeclaration: {
  26127. name: string;
  26128. shader: string;
  26129. };
  26130. }
  26131. declare module BABYLON {
  26132. /** @hidden */
  26133. export var lightUboDeclaration: {
  26134. name: string;
  26135. shader: string;
  26136. };
  26137. }
  26138. declare module BABYLON {
  26139. /** @hidden */
  26140. export var lightsFragmentFunctions: {
  26141. name: string;
  26142. shader: string;
  26143. };
  26144. }
  26145. declare module BABYLON {
  26146. /** @hidden */
  26147. export var shadowsFragmentFunctions: {
  26148. name: string;
  26149. shader: string;
  26150. };
  26151. }
  26152. declare module BABYLON {
  26153. /** @hidden */
  26154. export var fresnelFunction: {
  26155. name: string;
  26156. shader: string;
  26157. };
  26158. }
  26159. declare module BABYLON {
  26160. /** @hidden */
  26161. export var reflectionFunction: {
  26162. name: string;
  26163. shader: string;
  26164. };
  26165. }
  26166. declare module BABYLON {
  26167. /** @hidden */
  26168. export var bumpFragmentFunctions: {
  26169. name: string;
  26170. shader: string;
  26171. };
  26172. }
  26173. declare module BABYLON {
  26174. /** @hidden */
  26175. export var logDepthDeclaration: {
  26176. name: string;
  26177. shader: string;
  26178. };
  26179. }
  26180. declare module BABYLON {
  26181. /** @hidden */
  26182. export var bumpFragment: {
  26183. name: string;
  26184. shader: string;
  26185. };
  26186. }
  26187. declare module BABYLON {
  26188. /** @hidden */
  26189. export var depthPrePass: {
  26190. name: string;
  26191. shader: string;
  26192. };
  26193. }
  26194. declare module BABYLON {
  26195. /** @hidden */
  26196. export var lightFragment: {
  26197. name: string;
  26198. shader: string;
  26199. };
  26200. }
  26201. declare module BABYLON {
  26202. /** @hidden */
  26203. export var logDepthFragment: {
  26204. name: string;
  26205. shader: string;
  26206. };
  26207. }
  26208. declare module BABYLON {
  26209. /** @hidden */
  26210. export var defaultPixelShader: {
  26211. name: string;
  26212. shader: string;
  26213. };
  26214. }
  26215. declare module BABYLON {
  26216. /** @hidden */
  26217. export var defaultVertexDeclaration: {
  26218. name: string;
  26219. shader: string;
  26220. };
  26221. }
  26222. declare module BABYLON {
  26223. /** @hidden */
  26224. export var bumpVertexDeclaration: {
  26225. name: string;
  26226. shader: string;
  26227. };
  26228. }
  26229. declare module BABYLON {
  26230. /** @hidden */
  26231. export var bumpVertex: {
  26232. name: string;
  26233. shader: string;
  26234. };
  26235. }
  26236. declare module BABYLON {
  26237. /** @hidden */
  26238. export var fogVertex: {
  26239. name: string;
  26240. shader: string;
  26241. };
  26242. }
  26243. declare module BABYLON {
  26244. /** @hidden */
  26245. export var shadowsVertex: {
  26246. name: string;
  26247. shader: string;
  26248. };
  26249. }
  26250. declare module BABYLON {
  26251. /** @hidden */
  26252. export var pointCloudVertex: {
  26253. name: string;
  26254. shader: string;
  26255. };
  26256. }
  26257. declare module BABYLON {
  26258. /** @hidden */
  26259. export var logDepthVertex: {
  26260. name: string;
  26261. shader: string;
  26262. };
  26263. }
  26264. declare module BABYLON {
  26265. /** @hidden */
  26266. export var defaultVertexShader: {
  26267. name: string;
  26268. shader: string;
  26269. };
  26270. }
  26271. declare module BABYLON {
  26272. /** @hidden */
  26273. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  26274. MAINUV1: boolean;
  26275. MAINUV2: boolean;
  26276. DIFFUSE: boolean;
  26277. DIFFUSEDIRECTUV: number;
  26278. AMBIENT: boolean;
  26279. AMBIENTDIRECTUV: number;
  26280. OPACITY: boolean;
  26281. OPACITYDIRECTUV: number;
  26282. OPACITYRGB: boolean;
  26283. REFLECTION: boolean;
  26284. EMISSIVE: boolean;
  26285. EMISSIVEDIRECTUV: number;
  26286. SPECULAR: boolean;
  26287. SPECULARDIRECTUV: number;
  26288. BUMP: boolean;
  26289. BUMPDIRECTUV: number;
  26290. PARALLAX: boolean;
  26291. PARALLAXOCCLUSION: boolean;
  26292. SPECULAROVERALPHA: boolean;
  26293. CLIPPLANE: boolean;
  26294. CLIPPLANE2: boolean;
  26295. CLIPPLANE3: boolean;
  26296. CLIPPLANE4: boolean;
  26297. CLIPPLANE5: boolean;
  26298. CLIPPLANE6: boolean;
  26299. ALPHATEST: boolean;
  26300. DEPTHPREPASS: boolean;
  26301. ALPHAFROMDIFFUSE: boolean;
  26302. POINTSIZE: boolean;
  26303. FOG: boolean;
  26304. SPECULARTERM: boolean;
  26305. DIFFUSEFRESNEL: boolean;
  26306. OPACITYFRESNEL: boolean;
  26307. REFLECTIONFRESNEL: boolean;
  26308. REFRACTIONFRESNEL: boolean;
  26309. EMISSIVEFRESNEL: boolean;
  26310. FRESNEL: boolean;
  26311. NORMAL: boolean;
  26312. UV1: boolean;
  26313. UV2: boolean;
  26314. VERTEXCOLOR: boolean;
  26315. VERTEXALPHA: boolean;
  26316. NUM_BONE_INFLUENCERS: number;
  26317. BonesPerMesh: number;
  26318. BONETEXTURE: boolean;
  26319. INSTANCES: boolean;
  26320. GLOSSINESS: boolean;
  26321. ROUGHNESS: boolean;
  26322. EMISSIVEASILLUMINATION: boolean;
  26323. LINKEMISSIVEWITHDIFFUSE: boolean;
  26324. REFLECTIONFRESNELFROMSPECULAR: boolean;
  26325. LIGHTMAP: boolean;
  26326. LIGHTMAPDIRECTUV: number;
  26327. OBJECTSPACE_NORMALMAP: boolean;
  26328. USELIGHTMAPASSHADOWMAP: boolean;
  26329. REFLECTIONMAP_3D: boolean;
  26330. REFLECTIONMAP_SPHERICAL: boolean;
  26331. REFLECTIONMAP_PLANAR: boolean;
  26332. REFLECTIONMAP_CUBIC: boolean;
  26333. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  26334. REFLECTIONMAP_PROJECTION: boolean;
  26335. REFLECTIONMAP_SKYBOX: boolean;
  26336. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  26337. REFLECTIONMAP_EXPLICIT: boolean;
  26338. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  26339. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  26340. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  26341. INVERTCUBICMAP: boolean;
  26342. LOGARITHMICDEPTH: boolean;
  26343. REFRACTION: boolean;
  26344. REFRACTIONMAP_3D: boolean;
  26345. REFLECTIONOVERALPHA: boolean;
  26346. TWOSIDEDLIGHTING: boolean;
  26347. SHADOWFLOAT: boolean;
  26348. MORPHTARGETS: boolean;
  26349. MORPHTARGETS_NORMAL: boolean;
  26350. MORPHTARGETS_TANGENT: boolean;
  26351. MORPHTARGETS_UV: boolean;
  26352. NUM_MORPH_INFLUENCERS: number;
  26353. NONUNIFORMSCALING: boolean;
  26354. PREMULTIPLYALPHA: boolean;
  26355. IMAGEPROCESSING: boolean;
  26356. VIGNETTE: boolean;
  26357. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26358. VIGNETTEBLENDMODEOPAQUE: boolean;
  26359. TONEMAPPING: boolean;
  26360. TONEMAPPING_ACES: boolean;
  26361. CONTRAST: boolean;
  26362. COLORCURVES: boolean;
  26363. COLORGRADING: boolean;
  26364. COLORGRADING3D: boolean;
  26365. SAMPLER3DGREENDEPTH: boolean;
  26366. SAMPLER3DBGRMAP: boolean;
  26367. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26368. MULTIVIEW: boolean;
  26369. /**
  26370. * If the reflection texture on this material is in linear color space
  26371. * @hidden
  26372. */
  26373. IS_REFLECTION_LINEAR: boolean;
  26374. /**
  26375. * If the refraction texture on this material is in linear color space
  26376. * @hidden
  26377. */
  26378. IS_REFRACTION_LINEAR: boolean;
  26379. EXPOSURE: boolean;
  26380. constructor();
  26381. setReflectionMode(modeToEnable: string): void;
  26382. }
  26383. /**
  26384. * This is the default material used in Babylon. It is the best trade off between quality
  26385. * and performances.
  26386. * @see http://doc.babylonjs.com/babylon101/materials
  26387. */
  26388. export class StandardMaterial extends PushMaterial {
  26389. private _diffuseTexture;
  26390. /**
  26391. * The basic texture of the material as viewed under a light.
  26392. */
  26393. diffuseTexture: Nullable<BaseTexture>;
  26394. private _ambientTexture;
  26395. /**
  26396. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  26397. */
  26398. ambientTexture: Nullable<BaseTexture>;
  26399. private _opacityTexture;
  26400. /**
  26401. * Define the transparency of the material from a texture.
  26402. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  26403. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  26404. */
  26405. opacityTexture: Nullable<BaseTexture>;
  26406. private _reflectionTexture;
  26407. /**
  26408. * Define the texture used to display the reflection.
  26409. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26410. */
  26411. reflectionTexture: Nullable<BaseTexture>;
  26412. private _emissiveTexture;
  26413. /**
  26414. * Define texture of the material as if self lit.
  26415. * This will be mixed in the final result even in the absence of light.
  26416. */
  26417. emissiveTexture: Nullable<BaseTexture>;
  26418. private _specularTexture;
  26419. /**
  26420. * Define how the color and intensity of the highlight given by the light in the material.
  26421. */
  26422. specularTexture: Nullable<BaseTexture>;
  26423. private _bumpTexture;
  26424. /**
  26425. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  26426. * 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.
  26427. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  26428. */
  26429. bumpTexture: Nullable<BaseTexture>;
  26430. private _lightmapTexture;
  26431. /**
  26432. * Complex lighting can be computationally expensive to compute at runtime.
  26433. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  26434. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  26435. */
  26436. lightmapTexture: Nullable<BaseTexture>;
  26437. private _refractionTexture;
  26438. /**
  26439. * Define the texture used to display the refraction.
  26440. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26441. */
  26442. refractionTexture: Nullable<BaseTexture>;
  26443. /**
  26444. * The color of the material lit by the environmental background lighting.
  26445. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  26446. */
  26447. ambientColor: Color3;
  26448. /**
  26449. * The basic color of the material as viewed under a light.
  26450. */
  26451. diffuseColor: Color3;
  26452. /**
  26453. * Define how the color and intensity of the highlight given by the light in the material.
  26454. */
  26455. specularColor: Color3;
  26456. /**
  26457. * Define the color of the material as if self lit.
  26458. * This will be mixed in the final result even in the absence of light.
  26459. */
  26460. emissiveColor: Color3;
  26461. /**
  26462. * Defines how sharp are the highlights in the material.
  26463. * The bigger the value the sharper giving a more glossy feeling to the result.
  26464. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  26465. */
  26466. specularPower: number;
  26467. private _useAlphaFromDiffuseTexture;
  26468. /**
  26469. * Does the transparency come from the diffuse texture alpha channel.
  26470. */
  26471. useAlphaFromDiffuseTexture: boolean;
  26472. private _useEmissiveAsIllumination;
  26473. /**
  26474. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  26475. */
  26476. useEmissiveAsIllumination: boolean;
  26477. private _linkEmissiveWithDiffuse;
  26478. /**
  26479. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  26480. * the emissive level when the final color is close to one.
  26481. */
  26482. linkEmissiveWithDiffuse: boolean;
  26483. private _useSpecularOverAlpha;
  26484. /**
  26485. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  26486. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26487. */
  26488. useSpecularOverAlpha: boolean;
  26489. private _useReflectionOverAlpha;
  26490. /**
  26491. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26492. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26493. */
  26494. useReflectionOverAlpha: boolean;
  26495. private _disableLighting;
  26496. /**
  26497. * Does lights from the scene impacts this material.
  26498. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  26499. */
  26500. disableLighting: boolean;
  26501. private _useObjectSpaceNormalMap;
  26502. /**
  26503. * Allows using an object space normal map (instead of tangent space).
  26504. */
  26505. useObjectSpaceNormalMap: boolean;
  26506. private _useParallax;
  26507. /**
  26508. * Is parallax enabled or not.
  26509. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26510. */
  26511. useParallax: boolean;
  26512. private _useParallaxOcclusion;
  26513. /**
  26514. * Is parallax occlusion enabled or not.
  26515. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  26516. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  26517. */
  26518. useParallaxOcclusion: boolean;
  26519. /**
  26520. * 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.
  26521. */
  26522. parallaxScaleBias: number;
  26523. private _roughness;
  26524. /**
  26525. * Helps to define how blurry the reflections should appears in the material.
  26526. */
  26527. roughness: number;
  26528. /**
  26529. * In case of refraction, define the value of the index of refraction.
  26530. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26531. */
  26532. indexOfRefraction: number;
  26533. /**
  26534. * Invert the refraction texture alongside the y axis.
  26535. * It can be useful with procedural textures or probe for instance.
  26536. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  26537. */
  26538. invertRefractionY: boolean;
  26539. /**
  26540. * Defines the alpha limits in alpha test mode.
  26541. */
  26542. alphaCutOff: number;
  26543. private _useLightmapAsShadowmap;
  26544. /**
  26545. * In case of light mapping, define whether the map contains light or shadow informations.
  26546. */
  26547. useLightmapAsShadowmap: boolean;
  26548. private _diffuseFresnelParameters;
  26549. /**
  26550. * Define the diffuse fresnel parameters of the material.
  26551. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26552. */
  26553. diffuseFresnelParameters: FresnelParameters;
  26554. private _opacityFresnelParameters;
  26555. /**
  26556. * Define the opacity fresnel parameters of the material.
  26557. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26558. */
  26559. opacityFresnelParameters: FresnelParameters;
  26560. private _reflectionFresnelParameters;
  26561. /**
  26562. * Define the reflection fresnel parameters of the material.
  26563. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26564. */
  26565. reflectionFresnelParameters: FresnelParameters;
  26566. private _refractionFresnelParameters;
  26567. /**
  26568. * Define the refraction fresnel parameters of the material.
  26569. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26570. */
  26571. refractionFresnelParameters: FresnelParameters;
  26572. private _emissiveFresnelParameters;
  26573. /**
  26574. * Define the emissive fresnel parameters of the material.
  26575. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26576. */
  26577. emissiveFresnelParameters: FresnelParameters;
  26578. private _useReflectionFresnelFromSpecular;
  26579. /**
  26580. * If true automatically deducts the fresnels values from the material specularity.
  26581. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26582. */
  26583. useReflectionFresnelFromSpecular: boolean;
  26584. private _useGlossinessFromSpecularMapAlpha;
  26585. /**
  26586. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  26587. */
  26588. useGlossinessFromSpecularMapAlpha: boolean;
  26589. private _maxSimultaneousLights;
  26590. /**
  26591. * Defines the maximum number of lights that can be used in the material
  26592. */
  26593. maxSimultaneousLights: number;
  26594. private _invertNormalMapX;
  26595. /**
  26596. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  26597. */
  26598. invertNormalMapX: boolean;
  26599. private _invertNormalMapY;
  26600. /**
  26601. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  26602. */
  26603. invertNormalMapY: boolean;
  26604. private _twoSidedLighting;
  26605. /**
  26606. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26607. */
  26608. twoSidedLighting: boolean;
  26609. /**
  26610. * Default configuration related to image processing available in the standard Material.
  26611. */
  26612. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  26613. /**
  26614. * Gets the image processing configuration used either in this material.
  26615. */
  26616. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  26617. /**
  26618. * Sets the Default image processing configuration used either in the this material.
  26619. *
  26620. * If sets to null, the scene one is in use.
  26621. */
  26622. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  26623. /**
  26624. * Keep track of the image processing observer to allow dispose and replace.
  26625. */
  26626. private _imageProcessingObserver;
  26627. /**
  26628. * Attaches a new image processing configuration to the Standard Material.
  26629. * @param configuration
  26630. */
  26631. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  26632. /**
  26633. * Gets wether the color curves effect is enabled.
  26634. */
  26635. get cameraColorCurvesEnabled(): boolean;
  26636. /**
  26637. * Sets wether the color curves effect is enabled.
  26638. */
  26639. set cameraColorCurvesEnabled(value: boolean);
  26640. /**
  26641. * Gets wether the color grading effect is enabled.
  26642. */
  26643. get cameraColorGradingEnabled(): boolean;
  26644. /**
  26645. * Gets wether the color grading effect is enabled.
  26646. */
  26647. set cameraColorGradingEnabled(value: boolean);
  26648. /**
  26649. * Gets wether tonemapping is enabled or not.
  26650. */
  26651. get cameraToneMappingEnabled(): boolean;
  26652. /**
  26653. * Sets wether tonemapping is enabled or not
  26654. */
  26655. set cameraToneMappingEnabled(value: boolean);
  26656. /**
  26657. * The camera exposure used on this material.
  26658. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26659. * This corresponds to a photographic exposure.
  26660. */
  26661. get cameraExposure(): number;
  26662. /**
  26663. * The camera exposure used on this material.
  26664. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26665. * This corresponds to a photographic exposure.
  26666. */
  26667. set cameraExposure(value: number);
  26668. /**
  26669. * Gets The camera contrast used on this material.
  26670. */
  26671. get cameraContrast(): number;
  26672. /**
  26673. * Sets The camera contrast used on this material.
  26674. */
  26675. set cameraContrast(value: number);
  26676. /**
  26677. * Gets the Color Grading 2D Lookup Texture.
  26678. */
  26679. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  26680. /**
  26681. * Sets the Color Grading 2D Lookup Texture.
  26682. */
  26683. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  26684. /**
  26685. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26686. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26687. * 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;
  26688. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26689. */
  26690. get cameraColorCurves(): Nullable<ColorCurves>;
  26691. /**
  26692. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  26693. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  26694. * 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;
  26695. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  26696. */
  26697. set cameraColorCurves(value: Nullable<ColorCurves>);
  26698. /**
  26699. * Custom callback helping to override the default shader used in the material.
  26700. */
  26701. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  26702. protected _renderTargets: SmartArray<RenderTargetTexture>;
  26703. protected _worldViewProjectionMatrix: Matrix;
  26704. protected _globalAmbientColor: Color3;
  26705. protected _useLogarithmicDepth: boolean;
  26706. protected _rebuildInParallel: boolean;
  26707. /**
  26708. * Instantiates a new standard material.
  26709. * This is the default material used in Babylon. It is the best trade off between quality
  26710. * and performances.
  26711. * @see http://doc.babylonjs.com/babylon101/materials
  26712. * @param name Define the name of the material in the scene
  26713. * @param scene Define the scene the material belong to
  26714. */
  26715. constructor(name: string, scene: Scene);
  26716. /**
  26717. * Gets a boolean indicating that current material needs to register RTT
  26718. */
  26719. get hasRenderTargetTextures(): boolean;
  26720. /**
  26721. * Gets the current class name of the material e.g. "StandardMaterial"
  26722. * Mainly use in serialization.
  26723. * @returns the class name
  26724. */
  26725. getClassName(): string;
  26726. /**
  26727. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  26728. * You can try switching to logarithmic depth.
  26729. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  26730. */
  26731. get useLogarithmicDepth(): boolean;
  26732. set useLogarithmicDepth(value: boolean);
  26733. /**
  26734. * Specifies if the material will require alpha blending
  26735. * @returns a boolean specifying if alpha blending is needed
  26736. */
  26737. needAlphaBlending(): boolean;
  26738. /**
  26739. * Specifies if this material should be rendered in alpha test mode
  26740. * @returns a boolean specifying if an alpha test is needed.
  26741. */
  26742. needAlphaTesting(): boolean;
  26743. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  26744. /**
  26745. * Get the texture used for alpha test purpose.
  26746. * @returns the diffuse texture in case of the standard material.
  26747. */
  26748. getAlphaTestTexture(): Nullable<BaseTexture>;
  26749. /**
  26750. * Get if the submesh is ready to be used and all its information available.
  26751. * Child classes can use it to update shaders
  26752. * @param mesh defines the mesh to check
  26753. * @param subMesh defines which submesh to check
  26754. * @param useInstances specifies that instances should be used
  26755. * @returns a boolean indicating that the submesh is ready or not
  26756. */
  26757. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26758. /**
  26759. * Builds the material UBO layouts.
  26760. * Used internally during the effect preparation.
  26761. */
  26762. buildUniformLayout(): void;
  26763. /**
  26764. * Unbinds the material from the mesh
  26765. */
  26766. unbind(): void;
  26767. /**
  26768. * Binds the submesh to this material by preparing the effect and shader to draw
  26769. * @param world defines the world transformation matrix
  26770. * @param mesh defines the mesh containing the submesh
  26771. * @param subMesh defines the submesh to bind the material to
  26772. */
  26773. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  26774. /**
  26775. * Get the list of animatables in the material.
  26776. * @returns the list of animatables object used in the material
  26777. */
  26778. getAnimatables(): IAnimatable[];
  26779. /**
  26780. * Gets the active textures from the material
  26781. * @returns an array of textures
  26782. */
  26783. getActiveTextures(): BaseTexture[];
  26784. /**
  26785. * Specifies if the material uses a texture
  26786. * @param texture defines the texture to check against the material
  26787. * @returns a boolean specifying if the material uses the texture
  26788. */
  26789. hasTexture(texture: BaseTexture): boolean;
  26790. /**
  26791. * Disposes the material
  26792. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  26793. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  26794. */
  26795. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  26796. /**
  26797. * Makes a duplicate of the material, and gives it a new name
  26798. * @param name defines the new name for the duplicated material
  26799. * @returns the cloned material
  26800. */
  26801. clone(name: string): StandardMaterial;
  26802. /**
  26803. * Serializes this material in a JSON representation
  26804. * @returns the serialized material object
  26805. */
  26806. serialize(): any;
  26807. /**
  26808. * Creates a standard material from parsed material data
  26809. * @param source defines the JSON representation of the material
  26810. * @param scene defines the hosting scene
  26811. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  26812. * @returns a new standard material
  26813. */
  26814. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  26815. /**
  26816. * Are diffuse textures enabled in the application.
  26817. */
  26818. static get DiffuseTextureEnabled(): boolean;
  26819. static set DiffuseTextureEnabled(value: boolean);
  26820. /**
  26821. * Are ambient textures enabled in the application.
  26822. */
  26823. static get AmbientTextureEnabled(): boolean;
  26824. static set AmbientTextureEnabled(value: boolean);
  26825. /**
  26826. * Are opacity textures enabled in the application.
  26827. */
  26828. static get OpacityTextureEnabled(): boolean;
  26829. static set OpacityTextureEnabled(value: boolean);
  26830. /**
  26831. * Are reflection textures enabled in the application.
  26832. */
  26833. static get ReflectionTextureEnabled(): boolean;
  26834. static set ReflectionTextureEnabled(value: boolean);
  26835. /**
  26836. * Are emissive textures enabled in the application.
  26837. */
  26838. static get EmissiveTextureEnabled(): boolean;
  26839. static set EmissiveTextureEnabled(value: boolean);
  26840. /**
  26841. * Are specular textures enabled in the application.
  26842. */
  26843. static get SpecularTextureEnabled(): boolean;
  26844. static set SpecularTextureEnabled(value: boolean);
  26845. /**
  26846. * Are bump textures enabled in the application.
  26847. */
  26848. static get BumpTextureEnabled(): boolean;
  26849. static set BumpTextureEnabled(value: boolean);
  26850. /**
  26851. * Are lightmap textures enabled in the application.
  26852. */
  26853. static get LightmapTextureEnabled(): boolean;
  26854. static set LightmapTextureEnabled(value: boolean);
  26855. /**
  26856. * Are refraction textures enabled in the application.
  26857. */
  26858. static get RefractionTextureEnabled(): boolean;
  26859. static set RefractionTextureEnabled(value: boolean);
  26860. /**
  26861. * Are color grading textures enabled in the application.
  26862. */
  26863. static get ColorGradingTextureEnabled(): boolean;
  26864. static set ColorGradingTextureEnabled(value: boolean);
  26865. /**
  26866. * Are fresnels enabled in the application.
  26867. */
  26868. static get FresnelEnabled(): boolean;
  26869. static set FresnelEnabled(value: boolean);
  26870. }
  26871. }
  26872. declare module BABYLON {
  26873. /**
  26874. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  26875. *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.
  26876. * The SPS is also a particle system. It provides some methods to manage the particles.
  26877. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  26878. *
  26879. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  26880. */
  26881. export class SolidParticleSystem implements IDisposable {
  26882. /**
  26883. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  26884. * Example : var p = SPS.particles[i];
  26885. */
  26886. particles: SolidParticle[];
  26887. /**
  26888. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  26889. */
  26890. nbParticles: number;
  26891. /**
  26892. * If the particles must ever face the camera (default false). Useful for planar particles.
  26893. */
  26894. billboard: boolean;
  26895. /**
  26896. * Recompute normals when adding a shape
  26897. */
  26898. recomputeNormals: boolean;
  26899. /**
  26900. * This a counter ofr your own usage. It's not set by any SPS functions.
  26901. */
  26902. counter: number;
  26903. /**
  26904. * The SPS name. This name is also given to the underlying mesh.
  26905. */
  26906. name: string;
  26907. /**
  26908. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  26909. */
  26910. mesh: Mesh;
  26911. /**
  26912. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  26913. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  26914. */
  26915. vars: any;
  26916. /**
  26917. * This array is populated when the SPS is set as 'pickable'.
  26918. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  26919. * Each element of this array is an object `{idx: int, faceId: int}`.
  26920. * `idx` is the picked particle index in the `SPS.particles` array
  26921. * `faceId` is the picked face index counted within this particle.
  26922. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  26923. */
  26924. pickedParticles: {
  26925. idx: number;
  26926. faceId: number;
  26927. }[];
  26928. /**
  26929. * This array is populated when `enableDepthSort` is set to true.
  26930. * Each element of this array is an instance of the class DepthSortedParticle.
  26931. */
  26932. depthSortedParticles: DepthSortedParticle[];
  26933. /**
  26934. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  26935. * @hidden
  26936. */
  26937. _bSphereOnly: boolean;
  26938. /**
  26939. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  26940. * @hidden
  26941. */
  26942. _bSphereRadiusFactor: number;
  26943. private _scene;
  26944. private _positions;
  26945. private _indices;
  26946. private _normals;
  26947. private _colors;
  26948. private _uvs;
  26949. private _indices32;
  26950. private _positions32;
  26951. private _normals32;
  26952. private _fixedNormal32;
  26953. private _colors32;
  26954. private _uvs32;
  26955. private _index;
  26956. private _updatable;
  26957. private _pickable;
  26958. private _isVisibilityBoxLocked;
  26959. private _alwaysVisible;
  26960. private _depthSort;
  26961. private _expandable;
  26962. private _shapeCounter;
  26963. private _copy;
  26964. private _color;
  26965. private _computeParticleColor;
  26966. private _computeParticleTexture;
  26967. private _computeParticleRotation;
  26968. private _computeParticleVertex;
  26969. private _computeBoundingBox;
  26970. private _depthSortParticles;
  26971. private _camera;
  26972. private _mustUnrotateFixedNormals;
  26973. private _particlesIntersect;
  26974. private _needs32Bits;
  26975. private _isNotBuilt;
  26976. private _lastParticleId;
  26977. private _idxOfId;
  26978. private _multimaterialEnabled;
  26979. private _useModelMaterial;
  26980. private _indicesByMaterial;
  26981. private _materialIndexes;
  26982. private _depthSortFunction;
  26983. private _materialSortFunction;
  26984. private _materials;
  26985. private _multimaterial;
  26986. private _materialIndexesById;
  26987. private _defaultMaterial;
  26988. private _autoUpdateSubMeshes;
  26989. /**
  26990. * Creates a SPS (Solid Particle System) object.
  26991. * @param name (String) is the SPS name, this will be the underlying mesh name.
  26992. * @param scene (Scene) is the scene in which the SPS is added.
  26993. * @param options defines the options of the sps e.g.
  26994. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  26995. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  26996. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  26997. * * 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.
  26998. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  26999. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27000. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27001. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27002. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27003. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27004. */
  27005. constructor(name: string, scene: Scene, options?: {
  27006. updatable?: boolean;
  27007. isPickable?: boolean;
  27008. enableDepthSort?: boolean;
  27009. particleIntersection?: boolean;
  27010. boundingSphereOnly?: boolean;
  27011. bSphereRadiusFactor?: number;
  27012. expandable?: boolean;
  27013. useModelMaterial?: boolean;
  27014. enableMultiMaterial?: boolean;
  27015. });
  27016. /**
  27017. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27018. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27019. * @returns the created mesh
  27020. */
  27021. buildMesh(): Mesh;
  27022. /**
  27023. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27024. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27025. * Thus the particles generated from `digest()` have their property `position` set yet.
  27026. * @param mesh ( Mesh ) is the mesh to be digested
  27027. * @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
  27028. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27029. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27030. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27031. * @returns the current SPS
  27032. */
  27033. digest(mesh: Mesh, options?: {
  27034. facetNb?: number;
  27035. number?: number;
  27036. delta?: number;
  27037. storage?: [];
  27038. }): SolidParticleSystem;
  27039. /**
  27040. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27041. * @hidden
  27042. */
  27043. private _unrotateFixedNormals;
  27044. /**
  27045. * Resets the temporary working copy particle
  27046. * @hidden
  27047. */
  27048. private _resetCopy;
  27049. /**
  27050. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27051. * @param p the current index in the positions array to be updated
  27052. * @param ind the current index in the indices array
  27053. * @param shape a Vector3 array, the shape geometry
  27054. * @param positions the positions array to be updated
  27055. * @param meshInd the shape indices array
  27056. * @param indices the indices array to be updated
  27057. * @param meshUV the shape uv array
  27058. * @param uvs the uv array to be updated
  27059. * @param meshCol the shape color array
  27060. * @param colors the color array to be updated
  27061. * @param meshNor the shape normals array
  27062. * @param normals the normals array to be updated
  27063. * @param idx the particle index
  27064. * @param idxInShape the particle index in its shape
  27065. * @param options the addShape() method passed options
  27066. * @model the particle model
  27067. * @hidden
  27068. */
  27069. private _meshBuilder;
  27070. /**
  27071. * Returns a shape Vector3 array from positions float array
  27072. * @param positions float array
  27073. * @returns a vector3 array
  27074. * @hidden
  27075. */
  27076. private _posToShape;
  27077. /**
  27078. * Returns a shapeUV array from a float uvs (array deep copy)
  27079. * @param uvs as a float array
  27080. * @returns a shapeUV array
  27081. * @hidden
  27082. */
  27083. private _uvsToShapeUV;
  27084. /**
  27085. * Adds a new particle object in the particles array
  27086. * @param idx particle index in particles array
  27087. * @param id particle id
  27088. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27089. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27090. * @param model particle ModelShape object
  27091. * @param shapeId model shape identifier
  27092. * @param idxInShape index of the particle in the current model
  27093. * @param bInfo model bounding info object
  27094. * @param storage target storage array, if any
  27095. * @hidden
  27096. */
  27097. private _addParticle;
  27098. /**
  27099. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27100. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27101. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27102. * @param nb (positive integer) the number of particles to be created from this model
  27103. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27104. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27105. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27106. * @returns the number of shapes in the system
  27107. */
  27108. addShape(mesh: Mesh, nb: number, options?: {
  27109. positionFunction?: any;
  27110. vertexFunction?: any;
  27111. storage?: [];
  27112. }): number;
  27113. /**
  27114. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27115. * @hidden
  27116. */
  27117. private _rebuildParticle;
  27118. /**
  27119. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27120. * @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.
  27121. * @returns the SPS.
  27122. */
  27123. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27124. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27125. * Returns an array with the removed particles.
  27126. * 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.
  27127. * The SPS can't be empty so at least one particle needs to remain in place.
  27128. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27129. * @param start index of the first particle to remove
  27130. * @param end index of the last particle to remove (included)
  27131. * @returns an array populated with the removed particles
  27132. */
  27133. removeParticles(start: number, end: number): SolidParticle[];
  27134. /**
  27135. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27136. * @param solidParticleArray an array populated with Solid Particles objects
  27137. * @returns the SPS
  27138. */
  27139. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27140. /**
  27141. * Creates a new particle and modifies the SPS mesh geometry :
  27142. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27143. * - calls _addParticle() to populate the particle array
  27144. * factorized code from addShape() and insertParticlesFromArray()
  27145. * @param idx particle index in the particles array
  27146. * @param i particle index in its shape
  27147. * @param modelShape particle ModelShape object
  27148. * @param shape shape vertex array
  27149. * @param meshInd shape indices array
  27150. * @param meshUV shape uv array
  27151. * @param meshCol shape color array
  27152. * @param meshNor shape normals array
  27153. * @param bbInfo shape bounding info
  27154. * @param storage target particle storage
  27155. * @options addShape() passed options
  27156. * @hidden
  27157. */
  27158. private _insertNewParticle;
  27159. /**
  27160. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  27161. * This method calls `updateParticle()` for each particle of the SPS.
  27162. * For an animated SPS, it is usually called within the render loop.
  27163. * 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.
  27164. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  27165. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  27166. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  27167. * @returns the SPS.
  27168. */
  27169. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  27170. /**
  27171. * Disposes the SPS.
  27172. */
  27173. dispose(): void;
  27174. /**
  27175. * Returns a SolidParticle object from its identifier : particle.id
  27176. * @param id (integer) the particle Id
  27177. * @returns the searched particle or null if not found in the SPS.
  27178. */
  27179. getParticleById(id: number): Nullable<SolidParticle>;
  27180. /**
  27181. * Returns a new array populated with the particles having the passed shapeId.
  27182. * @param shapeId (integer) the shape identifier
  27183. * @returns a new solid particle array
  27184. */
  27185. getParticlesByShapeId(shapeId: number): SolidParticle[];
  27186. /**
  27187. * Populates the passed array "ref" with the particles having the passed shapeId.
  27188. * @param shapeId the shape identifier
  27189. * @returns the SPS
  27190. * @param ref
  27191. */
  27192. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  27193. /**
  27194. * Computes the required SubMeshes according the materials assigned to the particles.
  27195. * @returns the solid particle system.
  27196. * Does nothing if called before the SPS mesh is built.
  27197. */
  27198. computeSubMeshes(): SolidParticleSystem;
  27199. /**
  27200. * Sorts the solid particles by material when MultiMaterial is enabled.
  27201. * Updates the indices32 array.
  27202. * Updates the indicesByMaterial array.
  27203. * Updates the mesh indices array.
  27204. * @returns the SPS
  27205. * @hidden
  27206. */
  27207. private _sortParticlesByMaterial;
  27208. /**
  27209. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  27210. * @hidden
  27211. */
  27212. private _setMaterialIndexesById;
  27213. /**
  27214. * Returns an array with unique values of Materials from the passed array
  27215. * @param array the material array to be checked and filtered
  27216. * @hidden
  27217. */
  27218. private _filterUniqueMaterialId;
  27219. /**
  27220. * Sets a new Standard Material as _defaultMaterial if not already set.
  27221. * @hidden
  27222. */
  27223. private _setDefaultMaterial;
  27224. /**
  27225. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  27226. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27227. * @returns the SPS.
  27228. */
  27229. refreshVisibleSize(): SolidParticleSystem;
  27230. /**
  27231. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  27232. * @param size the size (float) of the visibility box
  27233. * note : this doesn't lock the SPS mesh bounding box.
  27234. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27235. */
  27236. setVisibilityBox(size: number): void;
  27237. /**
  27238. * Gets whether the SPS as always visible or not
  27239. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27240. */
  27241. get isAlwaysVisible(): boolean;
  27242. /**
  27243. * Sets the SPS as always visible or not
  27244. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27245. */
  27246. set isAlwaysVisible(val: boolean);
  27247. /**
  27248. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27249. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27250. */
  27251. set isVisibilityBoxLocked(val: boolean);
  27252. /**
  27253. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  27254. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  27255. */
  27256. get isVisibilityBoxLocked(): boolean;
  27257. /**
  27258. * Tells to `setParticles()` to compute the particle rotations or not.
  27259. * Default value : true. The SPS is faster when it's set to false.
  27260. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27261. */
  27262. set computeParticleRotation(val: boolean);
  27263. /**
  27264. * Tells to `setParticles()` to compute the particle colors or not.
  27265. * Default value : true. The SPS is faster when it's set to false.
  27266. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27267. */
  27268. set computeParticleColor(val: boolean);
  27269. set computeParticleTexture(val: boolean);
  27270. /**
  27271. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  27272. * Default value : false. The SPS is faster when it's set to false.
  27273. * Note : the particle custom vertex positions aren't stored values.
  27274. */
  27275. set computeParticleVertex(val: boolean);
  27276. /**
  27277. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  27278. */
  27279. set computeBoundingBox(val: boolean);
  27280. /**
  27281. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  27282. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27283. * Default : `true`
  27284. */
  27285. set depthSortParticles(val: boolean);
  27286. /**
  27287. * Gets if `setParticles()` computes the particle rotations or not.
  27288. * Default value : true. The SPS is faster when it's set to false.
  27289. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  27290. */
  27291. get computeParticleRotation(): boolean;
  27292. /**
  27293. * Gets if `setParticles()` computes the particle colors or not.
  27294. * Default value : true. The SPS is faster when it's set to false.
  27295. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  27296. */
  27297. get computeParticleColor(): boolean;
  27298. /**
  27299. * Gets if `setParticles()` computes the particle textures or not.
  27300. * Default value : true. The SPS is faster when it's set to false.
  27301. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  27302. */
  27303. get computeParticleTexture(): boolean;
  27304. /**
  27305. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  27306. * Default value : false. The SPS is faster when it's set to false.
  27307. * Note : the particle custom vertex positions aren't stored values.
  27308. */
  27309. get computeParticleVertex(): boolean;
  27310. /**
  27311. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  27312. */
  27313. get computeBoundingBox(): boolean;
  27314. /**
  27315. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  27316. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  27317. * Default : `true`
  27318. */
  27319. get depthSortParticles(): boolean;
  27320. /**
  27321. * Gets if the SPS is created as expandable at construction time.
  27322. * Default : `false`
  27323. */
  27324. get expandable(): boolean;
  27325. /**
  27326. * Gets if the SPS supports the Multi Materials
  27327. */
  27328. get multimaterialEnabled(): boolean;
  27329. /**
  27330. * Gets if the SPS uses the model materials for its own multimaterial.
  27331. */
  27332. get useModelMaterial(): boolean;
  27333. /**
  27334. * The SPS used material array.
  27335. */
  27336. get materials(): Material[];
  27337. /**
  27338. * Sets the SPS MultiMaterial from the passed materials.
  27339. * Note : the passed array is internally copied and not used then by reference.
  27340. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  27341. */
  27342. setMultiMaterial(materials: Material[]): void;
  27343. /**
  27344. * The SPS computed multimaterial object
  27345. */
  27346. get multimaterial(): MultiMaterial;
  27347. set multimaterial(mm: MultiMaterial);
  27348. /**
  27349. * If the subMeshes must be updated on the next call to setParticles()
  27350. */
  27351. get autoUpdateSubMeshes(): boolean;
  27352. set autoUpdateSubMeshes(val: boolean);
  27353. /**
  27354. * This function does nothing. It may be overwritten to set all the particle first values.
  27355. * The SPS doesn't call this function, you may have to call it by your own.
  27356. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27357. */
  27358. initParticles(): void;
  27359. /**
  27360. * This function does nothing. It may be overwritten to recycle a particle.
  27361. * The SPS doesn't call this function, you may have to call it by your own.
  27362. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27363. * @param particle The particle to recycle
  27364. * @returns the recycled particle
  27365. */
  27366. recycleParticle(particle: SolidParticle): SolidParticle;
  27367. /**
  27368. * Updates a particle : this function should be overwritten by the user.
  27369. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  27370. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  27371. * @example : just set a particle position or velocity and recycle conditions
  27372. * @param particle The particle to update
  27373. * @returns the updated particle
  27374. */
  27375. updateParticle(particle: SolidParticle): SolidParticle;
  27376. /**
  27377. * Updates a vertex of a particle : it can be overwritten by the user.
  27378. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  27379. * @param particle the current particle
  27380. * @param vertex the current index of the current particle
  27381. * @param pt the index of the current vertex in the particle shape
  27382. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  27383. * @example : just set a vertex particle position
  27384. * @returns the updated vertex
  27385. */
  27386. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  27387. /**
  27388. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  27389. * This does nothing and may be overwritten by the user.
  27390. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27391. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27392. * @param update the boolean update value actually passed to setParticles()
  27393. */
  27394. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27395. /**
  27396. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  27397. * This will be passed three parameters.
  27398. * This does nothing and may be overwritten by the user.
  27399. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27400. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  27401. * @param update the boolean update value actually passed to setParticles()
  27402. */
  27403. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  27404. }
  27405. }
  27406. declare module BABYLON {
  27407. /**
  27408. * Represents one particle of a solid particle system.
  27409. */
  27410. export class SolidParticle {
  27411. /**
  27412. * particle global index
  27413. */
  27414. idx: number;
  27415. /**
  27416. * particle identifier
  27417. */
  27418. id: number;
  27419. /**
  27420. * The color of the particle
  27421. */
  27422. color: Nullable<Color4>;
  27423. /**
  27424. * The world space position of the particle.
  27425. */
  27426. position: Vector3;
  27427. /**
  27428. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  27429. */
  27430. rotation: Vector3;
  27431. /**
  27432. * The world space rotation quaternion of the particle.
  27433. */
  27434. rotationQuaternion: Nullable<Quaternion>;
  27435. /**
  27436. * The scaling of the particle.
  27437. */
  27438. scaling: Vector3;
  27439. /**
  27440. * The uvs of the particle.
  27441. */
  27442. uvs: Vector4;
  27443. /**
  27444. * The current speed of the particle.
  27445. */
  27446. velocity: Vector3;
  27447. /**
  27448. * The pivot point in the particle local space.
  27449. */
  27450. pivot: Vector3;
  27451. /**
  27452. * Must the particle be translated from its pivot point in its local space ?
  27453. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  27454. * Default : false
  27455. */
  27456. translateFromPivot: boolean;
  27457. /**
  27458. * Is the particle active or not ?
  27459. */
  27460. alive: boolean;
  27461. /**
  27462. * Is the particle visible or not ?
  27463. */
  27464. isVisible: boolean;
  27465. /**
  27466. * Index of this particle in the global "positions" array (Internal use)
  27467. * @hidden
  27468. */
  27469. _pos: number;
  27470. /**
  27471. * @hidden Index of this particle in the global "indices" array (Internal use)
  27472. */
  27473. _ind: number;
  27474. /**
  27475. * @hidden ModelShape of this particle (Internal use)
  27476. */
  27477. _model: ModelShape;
  27478. /**
  27479. * ModelShape id of this particle
  27480. */
  27481. shapeId: number;
  27482. /**
  27483. * Index of the particle in its shape id
  27484. */
  27485. idxInShape: number;
  27486. /**
  27487. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  27488. */
  27489. _modelBoundingInfo: BoundingInfo;
  27490. /**
  27491. * @hidden Particle BoundingInfo object (Internal use)
  27492. */
  27493. _boundingInfo: BoundingInfo;
  27494. /**
  27495. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  27496. */
  27497. _sps: SolidParticleSystem;
  27498. /**
  27499. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  27500. */
  27501. _stillInvisible: boolean;
  27502. /**
  27503. * @hidden Last computed particle rotation matrix
  27504. */
  27505. _rotationMatrix: number[];
  27506. /**
  27507. * Parent particle Id, if any.
  27508. * Default null.
  27509. */
  27510. parentId: Nullable<number>;
  27511. /**
  27512. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  27513. */
  27514. materialIndex: Nullable<number>;
  27515. /**
  27516. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  27517. * The possible values are :
  27518. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27519. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27520. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27521. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27522. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27523. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  27524. * */
  27525. cullingStrategy: number;
  27526. /**
  27527. * @hidden Internal global position in the SPS.
  27528. */
  27529. _globalPosition: Vector3;
  27530. /**
  27531. * Creates a Solid Particle object.
  27532. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  27533. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  27534. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  27535. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  27536. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  27537. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  27538. * @param shapeId (integer) is the model shape identifier in the SPS.
  27539. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  27540. * @param sps defines the sps it is associated to
  27541. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  27542. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  27543. */
  27544. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  27545. /**
  27546. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  27547. * @param target the particle target
  27548. * @returns the current particle
  27549. */
  27550. copyToRef(target: SolidParticle): SolidParticle;
  27551. /**
  27552. * Legacy support, changed scale to scaling
  27553. */
  27554. get scale(): Vector3;
  27555. /**
  27556. * Legacy support, changed scale to scaling
  27557. */
  27558. set scale(scale: Vector3);
  27559. /**
  27560. * Legacy support, changed quaternion to rotationQuaternion
  27561. */
  27562. get quaternion(): Nullable<Quaternion>;
  27563. /**
  27564. * Legacy support, changed quaternion to rotationQuaternion
  27565. */
  27566. set quaternion(q: Nullable<Quaternion>);
  27567. /**
  27568. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  27569. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  27570. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  27571. * @returns true if it intersects
  27572. */
  27573. intersectsMesh(target: Mesh | SolidParticle): boolean;
  27574. /**
  27575. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  27576. * A particle is in the frustum if its bounding box intersects the frustum
  27577. * @param frustumPlanes defines the frustum to test
  27578. * @returns true if the particle is in the frustum planes
  27579. */
  27580. isInFrustum(frustumPlanes: Plane[]): boolean;
  27581. /**
  27582. * get the rotation matrix of the particle
  27583. * @hidden
  27584. */
  27585. getRotationMatrix(m: Matrix): void;
  27586. }
  27587. /**
  27588. * Represents the shape of the model used by one particle of a solid particle system.
  27589. * SPS internal tool, don't use it manually.
  27590. */
  27591. export class ModelShape {
  27592. /**
  27593. * The shape id
  27594. * @hidden
  27595. */
  27596. shapeID: number;
  27597. /**
  27598. * flat array of model positions (internal use)
  27599. * @hidden
  27600. */
  27601. _shape: Vector3[];
  27602. /**
  27603. * flat array of model UVs (internal use)
  27604. * @hidden
  27605. */
  27606. _shapeUV: number[];
  27607. /**
  27608. * color array of the model
  27609. * @hidden
  27610. */
  27611. _shapeColors: number[];
  27612. /**
  27613. * indices array of the model
  27614. * @hidden
  27615. */
  27616. _indices: number[];
  27617. /**
  27618. * normals array of the model
  27619. * @hidden
  27620. */
  27621. _normals: number[];
  27622. /**
  27623. * length of the shape in the model indices array (internal use)
  27624. * @hidden
  27625. */
  27626. _indicesLength: number;
  27627. /**
  27628. * Custom position function (internal use)
  27629. * @hidden
  27630. */
  27631. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  27632. /**
  27633. * Custom vertex function (internal use)
  27634. * @hidden
  27635. */
  27636. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  27637. /**
  27638. * Model material (internal use)
  27639. * @hidden
  27640. */
  27641. _material: Nullable<Material>;
  27642. /**
  27643. * 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.
  27644. * SPS internal tool, don't use it manually.
  27645. * @hidden
  27646. */
  27647. 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>);
  27648. }
  27649. /**
  27650. * Represents a Depth Sorted Particle in the solid particle system.
  27651. * @hidden
  27652. */
  27653. export class DepthSortedParticle {
  27654. /**
  27655. * Index of the particle in the "indices" array
  27656. */
  27657. ind: number;
  27658. /**
  27659. * Length of the particle shape in the "indices" array
  27660. */
  27661. indicesLength: number;
  27662. /**
  27663. * Squared distance from the particle to the camera
  27664. */
  27665. sqDistance: number;
  27666. /**
  27667. * Material index when used with MultiMaterials
  27668. */
  27669. materialIndex: number;
  27670. /**
  27671. * Creates a new sorted particle
  27672. * @param materialIndex
  27673. */
  27674. constructor(ind: number, indLength: number, materialIndex: number);
  27675. }
  27676. }
  27677. declare module BABYLON {
  27678. /**
  27679. * @hidden
  27680. */
  27681. export class _MeshCollisionData {
  27682. _checkCollisions: boolean;
  27683. _collisionMask: number;
  27684. _collisionGroup: number;
  27685. _collider: Nullable<Collider>;
  27686. _oldPositionForCollisions: Vector3;
  27687. _diffPositionForCollisions: Vector3;
  27688. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  27689. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  27690. }
  27691. }
  27692. declare module BABYLON {
  27693. /** @hidden */
  27694. class _FacetDataStorage {
  27695. facetPositions: Vector3[];
  27696. facetNormals: Vector3[];
  27697. facetPartitioning: number[][];
  27698. facetNb: number;
  27699. partitioningSubdivisions: number;
  27700. partitioningBBoxRatio: number;
  27701. facetDataEnabled: boolean;
  27702. facetParameters: any;
  27703. bbSize: Vector3;
  27704. subDiv: {
  27705. max: number;
  27706. X: number;
  27707. Y: number;
  27708. Z: number;
  27709. };
  27710. facetDepthSort: boolean;
  27711. facetDepthSortEnabled: boolean;
  27712. depthSortedIndices: IndicesArray;
  27713. depthSortedFacets: {
  27714. ind: number;
  27715. sqDistance: number;
  27716. }[];
  27717. facetDepthSortFunction: (f1: {
  27718. ind: number;
  27719. sqDistance: number;
  27720. }, f2: {
  27721. ind: number;
  27722. sqDistance: number;
  27723. }) => number;
  27724. facetDepthSortFrom: Vector3;
  27725. facetDepthSortOrigin: Vector3;
  27726. invertedMatrix: Matrix;
  27727. }
  27728. /**
  27729. * @hidden
  27730. **/
  27731. class _InternalAbstractMeshDataInfo {
  27732. _hasVertexAlpha: boolean;
  27733. _useVertexColors: boolean;
  27734. _numBoneInfluencers: number;
  27735. _applyFog: boolean;
  27736. _receiveShadows: boolean;
  27737. _facetData: _FacetDataStorage;
  27738. _visibility: number;
  27739. _skeleton: Nullable<Skeleton>;
  27740. _layerMask: number;
  27741. _computeBonesUsingShaders: boolean;
  27742. _isActive: boolean;
  27743. _onlyForInstances: boolean;
  27744. _isActiveIntermediate: boolean;
  27745. _onlyForInstancesIntermediate: boolean;
  27746. _actAsRegularMesh: boolean;
  27747. }
  27748. /**
  27749. * Class used to store all common mesh properties
  27750. */
  27751. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  27752. /** No occlusion */
  27753. static OCCLUSION_TYPE_NONE: number;
  27754. /** Occlusion set to optimisitic */
  27755. static OCCLUSION_TYPE_OPTIMISTIC: number;
  27756. /** Occlusion set to strict */
  27757. static OCCLUSION_TYPE_STRICT: number;
  27758. /** Use an accurante occlusion algorithm */
  27759. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  27760. /** Use a conservative occlusion algorithm */
  27761. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  27762. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  27763. * Test order :
  27764. * Is the bounding sphere outside the frustum ?
  27765. * If not, are the bounding box vertices outside the frustum ?
  27766. * It not, then the cullable object is in the frustum.
  27767. */
  27768. static readonly CULLINGSTRATEGY_STANDARD: number;
  27769. /** Culling strategy : Bounding Sphere Only.
  27770. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  27771. * It's also less accurate than the standard because some not visible objects can still be selected.
  27772. * Test : is the bounding sphere outside the frustum ?
  27773. * If not, then the cullable object is in the frustum.
  27774. */
  27775. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  27776. /** Culling strategy : Optimistic Inclusion.
  27777. * This in an inclusion test first, then the standard exclusion test.
  27778. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  27779. * 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.
  27780. * Anyway, it's as accurate as the standard strategy.
  27781. * Test :
  27782. * Is the cullable object bounding sphere center in the frustum ?
  27783. * If not, apply the default culling strategy.
  27784. */
  27785. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  27786. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  27787. * This in an inclusion test first, then the bounding sphere only exclusion test.
  27788. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  27789. * 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.
  27790. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  27791. * Test :
  27792. * Is the cullable object bounding sphere center in the frustum ?
  27793. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  27794. */
  27795. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  27796. /**
  27797. * No billboard
  27798. */
  27799. static get BILLBOARDMODE_NONE(): number;
  27800. /** Billboard on X axis */
  27801. static get BILLBOARDMODE_X(): number;
  27802. /** Billboard on Y axis */
  27803. static get BILLBOARDMODE_Y(): number;
  27804. /** Billboard on Z axis */
  27805. static get BILLBOARDMODE_Z(): number;
  27806. /** Billboard on all axes */
  27807. static get BILLBOARDMODE_ALL(): number;
  27808. /** Billboard on using position instead of orientation */
  27809. static get BILLBOARDMODE_USE_POSITION(): number;
  27810. /** @hidden */
  27811. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  27812. /**
  27813. * The culling strategy to use to check whether the mesh must be rendered or not.
  27814. * This value can be changed at any time and will be used on the next render mesh selection.
  27815. * The possible values are :
  27816. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  27817. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  27818. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  27819. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  27820. * Please read each static variable documentation to get details about the culling process.
  27821. * */
  27822. cullingStrategy: number;
  27823. /**
  27824. * Gets the number of facets in the mesh
  27825. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27826. */
  27827. get facetNb(): number;
  27828. /**
  27829. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  27830. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27831. */
  27832. get partitioningSubdivisions(): number;
  27833. set partitioningSubdivisions(nb: number);
  27834. /**
  27835. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  27836. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  27837. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  27838. */
  27839. get partitioningBBoxRatio(): number;
  27840. set partitioningBBoxRatio(ratio: number);
  27841. /**
  27842. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  27843. * Works only for updatable meshes.
  27844. * Doesn't work with multi-materials
  27845. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27846. */
  27847. get mustDepthSortFacets(): boolean;
  27848. set mustDepthSortFacets(sort: boolean);
  27849. /**
  27850. * The location (Vector3) where the facet depth sort must be computed from.
  27851. * By default, the active camera position.
  27852. * Used only when facet depth sort is enabled
  27853. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  27854. */
  27855. get facetDepthSortFrom(): Vector3;
  27856. set facetDepthSortFrom(location: Vector3);
  27857. /**
  27858. * gets a boolean indicating if facetData is enabled
  27859. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  27860. */
  27861. get isFacetDataEnabled(): boolean;
  27862. /** @hidden */
  27863. _updateNonUniformScalingState(value: boolean): boolean;
  27864. /**
  27865. * An event triggered when this mesh collides with another one
  27866. */
  27867. onCollideObservable: Observable<AbstractMesh>;
  27868. /** Set a function to call when this mesh collides with another one */
  27869. set onCollide(callback: () => void);
  27870. /**
  27871. * An event triggered when the collision's position changes
  27872. */
  27873. onCollisionPositionChangeObservable: Observable<Vector3>;
  27874. /** Set a function to call when the collision's position changes */
  27875. set onCollisionPositionChange(callback: () => void);
  27876. /**
  27877. * An event triggered when material is changed
  27878. */
  27879. onMaterialChangedObservable: Observable<AbstractMesh>;
  27880. /**
  27881. * Gets or sets the orientation for POV movement & rotation
  27882. */
  27883. definedFacingForward: boolean;
  27884. /** @hidden */
  27885. _occlusionQuery: Nullable<WebGLQuery>;
  27886. /** @hidden */
  27887. _renderingGroup: Nullable<RenderingGroup>;
  27888. /**
  27889. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27890. */
  27891. get visibility(): number;
  27892. /**
  27893. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  27894. */
  27895. set visibility(value: number);
  27896. /** Gets or sets the alpha index used to sort transparent meshes
  27897. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  27898. */
  27899. alphaIndex: number;
  27900. /**
  27901. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  27902. */
  27903. isVisible: boolean;
  27904. /**
  27905. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  27906. */
  27907. isPickable: boolean;
  27908. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  27909. showSubMeshesBoundingBox: boolean;
  27910. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  27911. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  27912. */
  27913. isBlocker: boolean;
  27914. /**
  27915. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  27916. */
  27917. enablePointerMoveEvents: boolean;
  27918. /**
  27919. * Specifies the rendering group id for this mesh (0 by default)
  27920. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  27921. */
  27922. renderingGroupId: number;
  27923. private _material;
  27924. /** Gets or sets current material */
  27925. get material(): Nullable<Material>;
  27926. set material(value: Nullable<Material>);
  27927. /**
  27928. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  27929. * @see http://doc.babylonjs.com/babylon101/shadows
  27930. */
  27931. get receiveShadows(): boolean;
  27932. set receiveShadows(value: boolean);
  27933. /** Defines color to use when rendering outline */
  27934. outlineColor: Color3;
  27935. /** Define width to use when rendering outline */
  27936. outlineWidth: number;
  27937. /** Defines color to use when rendering overlay */
  27938. overlayColor: Color3;
  27939. /** Defines alpha to use when rendering overlay */
  27940. overlayAlpha: number;
  27941. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  27942. get hasVertexAlpha(): boolean;
  27943. set hasVertexAlpha(value: boolean);
  27944. /** 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) */
  27945. get useVertexColors(): boolean;
  27946. set useVertexColors(value: boolean);
  27947. /**
  27948. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  27949. */
  27950. get computeBonesUsingShaders(): boolean;
  27951. set computeBonesUsingShaders(value: boolean);
  27952. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  27953. get numBoneInfluencers(): number;
  27954. set numBoneInfluencers(value: number);
  27955. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  27956. get applyFog(): boolean;
  27957. set applyFog(value: boolean);
  27958. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  27959. useOctreeForRenderingSelection: boolean;
  27960. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  27961. useOctreeForPicking: boolean;
  27962. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  27963. useOctreeForCollisions: boolean;
  27964. /**
  27965. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  27966. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  27967. */
  27968. get layerMask(): number;
  27969. set layerMask(value: number);
  27970. /**
  27971. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  27972. */
  27973. alwaysSelectAsActiveMesh: boolean;
  27974. /**
  27975. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  27976. */
  27977. doNotSyncBoundingInfo: boolean;
  27978. /**
  27979. * Gets or sets the current action manager
  27980. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27981. */
  27982. actionManager: Nullable<AbstractActionManager>;
  27983. private _meshCollisionData;
  27984. /**
  27985. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  27986. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27987. */
  27988. ellipsoid: Vector3;
  27989. /**
  27990. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  27991. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27992. */
  27993. ellipsoidOffset: Vector3;
  27994. /**
  27995. * Gets or sets a collision mask used to mask collisions (default is -1).
  27996. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  27997. */
  27998. get collisionMask(): number;
  27999. set collisionMask(mask: number);
  28000. /**
  28001. * Gets or sets the current collision group mask (-1 by default).
  28002. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28003. */
  28004. get collisionGroup(): number;
  28005. set collisionGroup(mask: number);
  28006. /**
  28007. * Defines edge width used when edgesRenderer is enabled
  28008. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28009. */
  28010. edgesWidth: number;
  28011. /**
  28012. * Defines edge color used when edgesRenderer is enabled
  28013. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28014. */
  28015. edgesColor: Color4;
  28016. /** @hidden */
  28017. _edgesRenderer: Nullable<IEdgesRenderer>;
  28018. /** @hidden */
  28019. _masterMesh: Nullable<AbstractMesh>;
  28020. /** @hidden */
  28021. _boundingInfo: Nullable<BoundingInfo>;
  28022. /** @hidden */
  28023. _renderId: number;
  28024. /**
  28025. * Gets or sets the list of subMeshes
  28026. * @see http://doc.babylonjs.com/how_to/multi_materials
  28027. */
  28028. subMeshes: SubMesh[];
  28029. /** @hidden */
  28030. _intersectionsInProgress: AbstractMesh[];
  28031. /** @hidden */
  28032. _unIndexed: boolean;
  28033. /** @hidden */
  28034. _lightSources: Light[];
  28035. /** Gets the list of lights affecting that mesh */
  28036. get lightSources(): Light[];
  28037. /** @hidden */
  28038. get _positions(): Nullable<Vector3[]>;
  28039. /** @hidden */
  28040. _waitingData: {
  28041. lods: Nullable<any>;
  28042. actions: Nullable<any>;
  28043. freezeWorldMatrix: Nullable<boolean>;
  28044. };
  28045. /** @hidden */
  28046. _bonesTransformMatrices: Nullable<Float32Array>;
  28047. /** @hidden */
  28048. _transformMatrixTexture: Nullable<RawTexture>;
  28049. /**
  28050. * Gets or sets a skeleton to apply skining transformations
  28051. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28052. */
  28053. set skeleton(value: Nullable<Skeleton>);
  28054. get skeleton(): Nullable<Skeleton>;
  28055. /**
  28056. * An event triggered when the mesh is rebuilt.
  28057. */
  28058. onRebuildObservable: Observable<AbstractMesh>;
  28059. /**
  28060. * Creates a new AbstractMesh
  28061. * @param name defines the name of the mesh
  28062. * @param scene defines the hosting scene
  28063. */
  28064. constructor(name: string, scene?: Nullable<Scene>);
  28065. /**
  28066. * Returns the string "AbstractMesh"
  28067. * @returns "AbstractMesh"
  28068. */
  28069. getClassName(): string;
  28070. /**
  28071. * Gets a string representation of the current mesh
  28072. * @param fullDetails defines a boolean indicating if full details must be included
  28073. * @returns a string representation of the current mesh
  28074. */
  28075. toString(fullDetails?: boolean): string;
  28076. /**
  28077. * @hidden
  28078. */
  28079. protected _getEffectiveParent(): Nullable<Node>;
  28080. /** @hidden */
  28081. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28082. /** @hidden */
  28083. _rebuild(): void;
  28084. /** @hidden */
  28085. _resyncLightSources(): void;
  28086. /** @hidden */
  28087. _resyncLightSource(light: Light): void;
  28088. /** @hidden */
  28089. _unBindEffect(): void;
  28090. /** @hidden */
  28091. _removeLightSource(light: Light, dispose: boolean): void;
  28092. private _markSubMeshesAsDirty;
  28093. /** @hidden */
  28094. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28095. /** @hidden */
  28096. _markSubMeshesAsAttributesDirty(): void;
  28097. /** @hidden */
  28098. _markSubMeshesAsMiscDirty(): void;
  28099. /**
  28100. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28101. */
  28102. get scaling(): Vector3;
  28103. set scaling(newScaling: Vector3);
  28104. /**
  28105. * Returns true if the mesh is blocked. Implemented by child classes
  28106. */
  28107. get isBlocked(): boolean;
  28108. /**
  28109. * Returns the mesh itself by default. Implemented by child classes
  28110. * @param camera defines the camera to use to pick the right LOD level
  28111. * @returns the currentAbstractMesh
  28112. */
  28113. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28114. /**
  28115. * Returns 0 by default. Implemented by child classes
  28116. * @returns an integer
  28117. */
  28118. getTotalVertices(): number;
  28119. /**
  28120. * Returns a positive integer : the total number of indices in this mesh geometry.
  28121. * @returns the numner of indices or zero if the mesh has no geometry.
  28122. */
  28123. getTotalIndices(): number;
  28124. /**
  28125. * Returns null by default. Implemented by child classes
  28126. * @returns null
  28127. */
  28128. getIndices(): Nullable<IndicesArray>;
  28129. /**
  28130. * Returns the array of the requested vertex data kind. Implemented by child classes
  28131. * @param kind defines the vertex data kind to use
  28132. * @returns null
  28133. */
  28134. getVerticesData(kind: string): Nullable<FloatArray>;
  28135. /**
  28136. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28137. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28138. * Note that a new underlying VertexBuffer object is created each call.
  28139. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28140. * @param kind defines vertex data kind:
  28141. * * VertexBuffer.PositionKind
  28142. * * VertexBuffer.UVKind
  28143. * * VertexBuffer.UV2Kind
  28144. * * VertexBuffer.UV3Kind
  28145. * * VertexBuffer.UV4Kind
  28146. * * VertexBuffer.UV5Kind
  28147. * * VertexBuffer.UV6Kind
  28148. * * VertexBuffer.ColorKind
  28149. * * VertexBuffer.MatricesIndicesKind
  28150. * * VertexBuffer.MatricesIndicesExtraKind
  28151. * * VertexBuffer.MatricesWeightsKind
  28152. * * VertexBuffer.MatricesWeightsExtraKind
  28153. * @param data defines the data source
  28154. * @param updatable defines if the data must be flagged as updatable (or static)
  28155. * @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
  28156. * @returns the current mesh
  28157. */
  28158. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28159. /**
  28160. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28161. * If the mesh has no geometry, it is simply returned as it is.
  28162. * @param kind defines vertex data kind:
  28163. * * VertexBuffer.PositionKind
  28164. * * VertexBuffer.UVKind
  28165. * * VertexBuffer.UV2Kind
  28166. * * VertexBuffer.UV3Kind
  28167. * * VertexBuffer.UV4Kind
  28168. * * VertexBuffer.UV5Kind
  28169. * * VertexBuffer.UV6Kind
  28170. * * VertexBuffer.ColorKind
  28171. * * VertexBuffer.MatricesIndicesKind
  28172. * * VertexBuffer.MatricesIndicesExtraKind
  28173. * * VertexBuffer.MatricesWeightsKind
  28174. * * VertexBuffer.MatricesWeightsExtraKind
  28175. * @param data defines the data source
  28176. * @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
  28177. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  28178. * @returns the current mesh
  28179. */
  28180. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28181. /**
  28182. * Sets the mesh indices,
  28183. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28184. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  28185. * @param totalVertices Defines the total number of vertices
  28186. * @returns the current mesh
  28187. */
  28188. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  28189. /**
  28190. * Gets a boolean indicating if specific vertex data is present
  28191. * @param kind defines the vertex data kind to use
  28192. * @returns true is data kind is present
  28193. */
  28194. isVerticesDataPresent(kind: string): boolean;
  28195. /**
  28196. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  28197. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  28198. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  28199. * @returns a BoundingInfo
  28200. */
  28201. getBoundingInfo(): BoundingInfo;
  28202. /**
  28203. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  28204. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  28205. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  28206. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  28207. * @returns the current mesh
  28208. */
  28209. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  28210. /**
  28211. * Overwrite the current bounding info
  28212. * @param boundingInfo defines the new bounding info
  28213. * @returns the current mesh
  28214. */
  28215. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  28216. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  28217. get useBones(): boolean;
  28218. /** @hidden */
  28219. _preActivate(): void;
  28220. /** @hidden */
  28221. _preActivateForIntermediateRendering(renderId: number): void;
  28222. /** @hidden */
  28223. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28224. /** @hidden */
  28225. _postActivate(): void;
  28226. /** @hidden */
  28227. _freeze(): void;
  28228. /** @hidden */
  28229. _unFreeze(): void;
  28230. /**
  28231. * Gets the current world matrix
  28232. * @returns a Matrix
  28233. */
  28234. getWorldMatrix(): Matrix;
  28235. /** @hidden */
  28236. _getWorldMatrixDeterminant(): number;
  28237. /**
  28238. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  28239. */
  28240. get isAnInstance(): boolean;
  28241. /**
  28242. * Gets a boolean indicating if this mesh has instances
  28243. */
  28244. get hasInstances(): boolean;
  28245. /**
  28246. * Perform relative position change from the point of view of behind the front of the mesh.
  28247. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28248. * Supports definition of mesh facing forward or backward
  28249. * @param amountRight defines the distance on the right axis
  28250. * @param amountUp defines the distance on the up axis
  28251. * @param amountForward defines the distance on the forward axis
  28252. * @returns the current mesh
  28253. */
  28254. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  28255. /**
  28256. * Calculate relative position change from the point of view of behind the front of the mesh.
  28257. * This is performed taking into account the meshes current rotation, so you do not have to care.
  28258. * Supports definition of mesh facing forward or backward
  28259. * @param amountRight defines the distance on the right axis
  28260. * @param amountUp defines the distance on the up axis
  28261. * @param amountForward defines the distance on the forward axis
  28262. * @returns the new displacement vector
  28263. */
  28264. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  28265. /**
  28266. * Perform relative rotation change from the point of view of behind the front of the mesh.
  28267. * Supports definition of mesh facing forward or backward
  28268. * @param flipBack defines the flip
  28269. * @param twirlClockwise defines the twirl
  28270. * @param tiltRight defines the tilt
  28271. * @returns the current mesh
  28272. */
  28273. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  28274. /**
  28275. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  28276. * Supports definition of mesh facing forward or backward.
  28277. * @param flipBack defines the flip
  28278. * @param twirlClockwise defines the twirl
  28279. * @param tiltRight defines the tilt
  28280. * @returns the new rotation vector
  28281. */
  28282. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  28283. /**
  28284. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28285. * This means the mesh underlying bounding box and sphere are recomputed.
  28286. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28287. * @returns the current mesh
  28288. */
  28289. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  28290. /** @hidden */
  28291. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  28292. /** @hidden */
  28293. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  28294. /** @hidden */
  28295. _updateBoundingInfo(): AbstractMesh;
  28296. /** @hidden */
  28297. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  28298. /** @hidden */
  28299. protected _afterComputeWorldMatrix(): void;
  28300. /** @hidden */
  28301. get _effectiveMesh(): AbstractMesh;
  28302. /**
  28303. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28304. * A mesh is in the frustum if its bounding box intersects the frustum
  28305. * @param frustumPlanes defines the frustum to test
  28306. * @returns true if the mesh is in the frustum planes
  28307. */
  28308. isInFrustum(frustumPlanes: Plane[]): boolean;
  28309. /**
  28310. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  28311. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  28312. * @param frustumPlanes defines the frustum to test
  28313. * @returns true if the mesh is completely in the frustum planes
  28314. */
  28315. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  28316. /**
  28317. * True if the mesh intersects another mesh or a SolidParticle object
  28318. * @param mesh defines a target mesh or SolidParticle to test
  28319. * @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)
  28320. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  28321. * @returns true if there is an intersection
  28322. */
  28323. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  28324. /**
  28325. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  28326. * @param point defines the point to test
  28327. * @returns true if there is an intersection
  28328. */
  28329. intersectsPoint(point: Vector3): boolean;
  28330. /**
  28331. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  28332. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28333. */
  28334. get checkCollisions(): boolean;
  28335. set checkCollisions(collisionEnabled: boolean);
  28336. /**
  28337. * Gets Collider object used to compute collisions (not physics)
  28338. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28339. */
  28340. get collider(): Nullable<Collider>;
  28341. /**
  28342. * Move the mesh using collision engine
  28343. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28344. * @param displacement defines the requested displacement vector
  28345. * @returns the current mesh
  28346. */
  28347. moveWithCollisions(displacement: Vector3): AbstractMesh;
  28348. private _onCollisionPositionChange;
  28349. /** @hidden */
  28350. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  28351. /** @hidden */
  28352. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  28353. /** @hidden */
  28354. _checkCollision(collider: Collider): AbstractMesh;
  28355. /** @hidden */
  28356. _generatePointsArray(): boolean;
  28357. /**
  28358. * Checks if the passed Ray intersects with the mesh
  28359. * @param ray defines the ray to use
  28360. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  28361. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  28362. * @returns the picking info
  28363. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  28364. */
  28365. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  28366. /**
  28367. * Clones the current mesh
  28368. * @param name defines the mesh name
  28369. * @param newParent defines the new mesh parent
  28370. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  28371. * @returns the new mesh
  28372. */
  28373. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  28374. /**
  28375. * Disposes all the submeshes of the current meshnp
  28376. * @returns the current mesh
  28377. */
  28378. releaseSubMeshes(): AbstractMesh;
  28379. /**
  28380. * Releases resources associated with this abstract mesh.
  28381. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28382. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28383. */
  28384. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28385. /**
  28386. * Adds the passed mesh as a child to the current mesh
  28387. * @param mesh defines the child mesh
  28388. * @returns the current mesh
  28389. */
  28390. addChild(mesh: AbstractMesh): AbstractMesh;
  28391. /**
  28392. * Removes the passed mesh from the current mesh children list
  28393. * @param mesh defines the child mesh
  28394. * @returns the current mesh
  28395. */
  28396. removeChild(mesh: AbstractMesh): AbstractMesh;
  28397. /** @hidden */
  28398. private _initFacetData;
  28399. /**
  28400. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  28401. * This method can be called within the render loop.
  28402. * 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
  28403. * @returns the current mesh
  28404. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28405. */
  28406. updateFacetData(): AbstractMesh;
  28407. /**
  28408. * Returns the facetLocalNormals array.
  28409. * The normals are expressed in the mesh local spac
  28410. * @returns an array of Vector3
  28411. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28412. */
  28413. getFacetLocalNormals(): Vector3[];
  28414. /**
  28415. * Returns the facetLocalPositions array.
  28416. * The facet positions are expressed in the mesh local space
  28417. * @returns an array of Vector3
  28418. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28419. */
  28420. getFacetLocalPositions(): Vector3[];
  28421. /**
  28422. * Returns the facetLocalPartioning array
  28423. * @returns an array of array of numbers
  28424. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28425. */
  28426. getFacetLocalPartitioning(): number[][];
  28427. /**
  28428. * Returns the i-th facet position in the world system.
  28429. * This method allocates a new Vector3 per call
  28430. * @param i defines the facet index
  28431. * @returns a new Vector3
  28432. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28433. */
  28434. getFacetPosition(i: number): Vector3;
  28435. /**
  28436. * Sets the reference Vector3 with the i-th facet position in the world system
  28437. * @param i defines the facet index
  28438. * @param ref defines the target vector
  28439. * @returns the current mesh
  28440. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28441. */
  28442. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  28443. /**
  28444. * Returns the i-th facet normal in the world system.
  28445. * This method allocates a new Vector3 per call
  28446. * @param i defines the facet index
  28447. * @returns a new Vector3
  28448. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28449. */
  28450. getFacetNormal(i: number): Vector3;
  28451. /**
  28452. * Sets the reference Vector3 with the i-th facet normal in the world system
  28453. * @param i defines the facet index
  28454. * @param ref defines the target vector
  28455. * @returns the current mesh
  28456. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28457. */
  28458. getFacetNormalToRef(i: number, ref: Vector3): this;
  28459. /**
  28460. * 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)
  28461. * @param x defines x coordinate
  28462. * @param y defines y coordinate
  28463. * @param z defines z coordinate
  28464. * @returns the array of facet indexes
  28465. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28466. */
  28467. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  28468. /**
  28469. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  28470. * @param projected sets as the (x,y,z) world projection on the facet
  28471. * @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
  28472. * @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
  28473. * @param x defines x coordinate
  28474. * @param y defines y coordinate
  28475. * @param z defines z coordinate
  28476. * @returns the face index if found (or null instead)
  28477. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28478. */
  28479. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28480. /**
  28481. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  28482. * @param projected sets as the (x,y,z) local projection on the facet
  28483. * @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
  28484. * @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
  28485. * @param x defines x coordinate
  28486. * @param y defines y coordinate
  28487. * @param z defines z coordinate
  28488. * @returns the face index if found (or null instead)
  28489. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28490. */
  28491. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  28492. /**
  28493. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  28494. * @returns the parameters
  28495. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28496. */
  28497. getFacetDataParameters(): any;
  28498. /**
  28499. * Disables the feature FacetData and frees the related memory
  28500. * @returns the current mesh
  28501. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  28502. */
  28503. disableFacetData(): AbstractMesh;
  28504. /**
  28505. * Updates the AbstractMesh indices array
  28506. * @param indices defines the data source
  28507. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28508. * @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)
  28509. * @returns the current mesh
  28510. */
  28511. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28512. /**
  28513. * Creates new normals data for the mesh
  28514. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  28515. * @returns the current mesh
  28516. */
  28517. createNormals(updatable: boolean): AbstractMesh;
  28518. /**
  28519. * Align the mesh with a normal
  28520. * @param normal defines the normal to use
  28521. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  28522. * @returns the current mesh
  28523. */
  28524. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  28525. /** @hidden */
  28526. _checkOcclusionQuery(): boolean;
  28527. /**
  28528. * Disables the mesh edge rendering mode
  28529. * @returns the currentAbstractMesh
  28530. */
  28531. disableEdgesRendering(): AbstractMesh;
  28532. /**
  28533. * Enables the edge rendering mode on the mesh.
  28534. * This mode makes the mesh edges visible
  28535. * @param epsilon defines the maximal distance between two angles to detect a face
  28536. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28537. * @returns the currentAbstractMesh
  28538. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28539. */
  28540. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28541. }
  28542. }
  28543. declare module BABYLON {
  28544. /**
  28545. * Interface used to define ActionEvent
  28546. */
  28547. export interface IActionEvent {
  28548. /** The mesh or sprite that triggered the action */
  28549. source: any;
  28550. /** The X mouse cursor position at the time of the event */
  28551. pointerX: number;
  28552. /** The Y mouse cursor position at the time of the event */
  28553. pointerY: number;
  28554. /** The mesh that is currently pointed at (can be null) */
  28555. meshUnderPointer: Nullable<AbstractMesh>;
  28556. /** the original (browser) event that triggered the ActionEvent */
  28557. sourceEvent?: any;
  28558. /** additional data for the event */
  28559. additionalData?: any;
  28560. }
  28561. /**
  28562. * ActionEvent is the event being sent when an action is triggered.
  28563. */
  28564. export class ActionEvent implements IActionEvent {
  28565. /** The mesh or sprite that triggered the action */
  28566. source: any;
  28567. /** The X mouse cursor position at the time of the event */
  28568. pointerX: number;
  28569. /** The Y mouse cursor position at the time of the event */
  28570. pointerY: number;
  28571. /** The mesh that is currently pointed at (can be null) */
  28572. meshUnderPointer: Nullable<AbstractMesh>;
  28573. /** the original (browser) event that triggered the ActionEvent */
  28574. sourceEvent?: any;
  28575. /** additional data for the event */
  28576. additionalData?: any;
  28577. /**
  28578. * Creates a new ActionEvent
  28579. * @param source The mesh or sprite that triggered the action
  28580. * @param pointerX The X mouse cursor position at the time of the event
  28581. * @param pointerY The Y mouse cursor position at the time of the event
  28582. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  28583. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  28584. * @param additionalData additional data for the event
  28585. */
  28586. constructor(
  28587. /** The mesh or sprite that triggered the action */
  28588. source: any,
  28589. /** The X mouse cursor position at the time of the event */
  28590. pointerX: number,
  28591. /** The Y mouse cursor position at the time of the event */
  28592. pointerY: number,
  28593. /** The mesh that is currently pointed at (can be null) */
  28594. meshUnderPointer: Nullable<AbstractMesh>,
  28595. /** the original (browser) event that triggered the ActionEvent */
  28596. sourceEvent?: any,
  28597. /** additional data for the event */
  28598. additionalData?: any);
  28599. /**
  28600. * Helper function to auto-create an ActionEvent from a source mesh.
  28601. * @param source The source mesh that triggered the event
  28602. * @param evt The original (browser) event
  28603. * @param additionalData additional data for the event
  28604. * @returns the new ActionEvent
  28605. */
  28606. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  28607. /**
  28608. * Helper function to auto-create an ActionEvent from a source sprite
  28609. * @param source The source sprite that triggered the event
  28610. * @param scene Scene associated with the sprite
  28611. * @param evt The original (browser) event
  28612. * @param additionalData additional data for the event
  28613. * @returns the new ActionEvent
  28614. */
  28615. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  28616. /**
  28617. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  28618. * @param scene the scene where the event occurred
  28619. * @param evt The original (browser) event
  28620. * @returns the new ActionEvent
  28621. */
  28622. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  28623. /**
  28624. * Helper function to auto-create an ActionEvent from a primitive
  28625. * @param prim defines the target primitive
  28626. * @param pointerPos defines the pointer position
  28627. * @param evt The original (browser) event
  28628. * @param additionalData additional data for the event
  28629. * @returns the new ActionEvent
  28630. */
  28631. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  28632. }
  28633. }
  28634. declare module BABYLON {
  28635. /**
  28636. * Abstract class used to decouple action Manager from scene and meshes.
  28637. * Do not instantiate.
  28638. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28639. */
  28640. export abstract class AbstractActionManager implements IDisposable {
  28641. /** Gets the list of active triggers */
  28642. static Triggers: {
  28643. [key: string]: number;
  28644. };
  28645. /** Gets the cursor to use when hovering items */
  28646. hoverCursor: string;
  28647. /** Gets the list of actions */
  28648. actions: IAction[];
  28649. /**
  28650. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  28651. */
  28652. isRecursive: boolean;
  28653. /**
  28654. * Releases all associated resources
  28655. */
  28656. abstract dispose(): void;
  28657. /**
  28658. * Does this action manager has pointer triggers
  28659. */
  28660. abstract get hasPointerTriggers(): boolean;
  28661. /**
  28662. * Does this action manager has pick triggers
  28663. */
  28664. abstract get hasPickTriggers(): boolean;
  28665. /**
  28666. * Process a specific trigger
  28667. * @param trigger defines the trigger to process
  28668. * @param evt defines the event details to be processed
  28669. */
  28670. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  28671. /**
  28672. * Does this action manager handles actions of any of the given triggers
  28673. * @param triggers defines the triggers to be tested
  28674. * @return a boolean indicating whether one (or more) of the triggers is handled
  28675. */
  28676. abstract hasSpecificTriggers(triggers: number[]): boolean;
  28677. /**
  28678. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  28679. * speed.
  28680. * @param triggerA defines the trigger to be tested
  28681. * @param triggerB defines the trigger to be tested
  28682. * @return a boolean indicating whether one (or more) of the triggers is handled
  28683. */
  28684. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  28685. /**
  28686. * Does this action manager handles actions of a given trigger
  28687. * @param trigger defines the trigger to be tested
  28688. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  28689. * @return whether the trigger is handled
  28690. */
  28691. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  28692. /**
  28693. * Serialize this manager to a JSON object
  28694. * @param name defines the property name to store this manager
  28695. * @returns a JSON representation of this manager
  28696. */
  28697. abstract serialize(name: string): any;
  28698. /**
  28699. * Registers an action to this action manager
  28700. * @param action defines the action to be registered
  28701. * @return the action amended (prepared) after registration
  28702. */
  28703. abstract registerAction(action: IAction): Nullable<IAction>;
  28704. /**
  28705. * Unregisters an action to this action manager
  28706. * @param action defines the action to be unregistered
  28707. * @return a boolean indicating whether the action has been unregistered
  28708. */
  28709. abstract unregisterAction(action: IAction): Boolean;
  28710. /**
  28711. * Does exist one action manager with at least one trigger
  28712. **/
  28713. static get HasTriggers(): boolean;
  28714. /**
  28715. * Does exist one action manager with at least one pick trigger
  28716. **/
  28717. static get HasPickTriggers(): boolean;
  28718. /**
  28719. * Does exist one action manager that handles actions of a given trigger
  28720. * @param trigger defines the trigger to be tested
  28721. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  28722. **/
  28723. static HasSpecificTrigger(trigger: number): boolean;
  28724. }
  28725. }
  28726. declare module BABYLON {
  28727. /**
  28728. * Defines how a node can be built from a string name.
  28729. */
  28730. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  28731. /**
  28732. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  28733. */
  28734. export class Node implements IBehaviorAware<Node> {
  28735. /** @hidden */
  28736. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  28737. private static _NodeConstructors;
  28738. /**
  28739. * Add a new node constructor
  28740. * @param type defines the type name of the node to construct
  28741. * @param constructorFunc defines the constructor function
  28742. */
  28743. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  28744. /**
  28745. * Returns a node constructor based on type name
  28746. * @param type defines the type name
  28747. * @param name defines the new node name
  28748. * @param scene defines the hosting scene
  28749. * @param options defines optional options to transmit to constructors
  28750. * @returns the new constructor or null
  28751. */
  28752. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  28753. /**
  28754. * Gets or sets the name of the node
  28755. */
  28756. name: string;
  28757. /**
  28758. * Gets or sets the id of the node
  28759. */
  28760. id: string;
  28761. /**
  28762. * Gets or sets the unique id of the node
  28763. */
  28764. uniqueId: number;
  28765. /**
  28766. * Gets or sets a string used to store user defined state for the node
  28767. */
  28768. state: string;
  28769. /**
  28770. * Gets or sets an object used to store user defined information for the node
  28771. */
  28772. metadata: any;
  28773. /**
  28774. * For internal use only. Please do not use.
  28775. */
  28776. reservedDataStore: any;
  28777. /**
  28778. * List of inspectable custom properties (used by the Inspector)
  28779. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28780. */
  28781. inspectableCustomProperties: IInspectable[];
  28782. private _doNotSerialize;
  28783. /**
  28784. * Gets or sets a boolean used to define if the node must be serialized
  28785. */
  28786. get doNotSerialize(): boolean;
  28787. set doNotSerialize(value: boolean);
  28788. /** @hidden */
  28789. _isDisposed: boolean;
  28790. /**
  28791. * Gets a list of Animations associated with the node
  28792. */
  28793. animations: Animation[];
  28794. protected _ranges: {
  28795. [name: string]: Nullable<AnimationRange>;
  28796. };
  28797. /**
  28798. * Callback raised when the node is ready to be used
  28799. */
  28800. onReady: Nullable<(node: Node) => void>;
  28801. private _isEnabled;
  28802. private _isParentEnabled;
  28803. private _isReady;
  28804. /** @hidden */
  28805. _currentRenderId: number;
  28806. private _parentUpdateId;
  28807. /** @hidden */
  28808. _childUpdateId: number;
  28809. /** @hidden */
  28810. _waitingParentId: Nullable<string>;
  28811. /** @hidden */
  28812. _scene: Scene;
  28813. /** @hidden */
  28814. _cache: any;
  28815. private _parentNode;
  28816. private _children;
  28817. /** @hidden */
  28818. _worldMatrix: Matrix;
  28819. /** @hidden */
  28820. _worldMatrixDeterminant: number;
  28821. /** @hidden */
  28822. _worldMatrixDeterminantIsDirty: boolean;
  28823. /** @hidden */
  28824. private _sceneRootNodesIndex;
  28825. /**
  28826. * Gets a boolean indicating if the node has been disposed
  28827. * @returns true if the node was disposed
  28828. */
  28829. isDisposed(): boolean;
  28830. /**
  28831. * Gets or sets the parent of the node (without keeping the current position in the scene)
  28832. * @see https://doc.babylonjs.com/how_to/parenting
  28833. */
  28834. set parent(parent: Nullable<Node>);
  28835. get parent(): Nullable<Node>;
  28836. /** @hidden */
  28837. _addToSceneRootNodes(): void;
  28838. /** @hidden */
  28839. _removeFromSceneRootNodes(): void;
  28840. private _animationPropertiesOverride;
  28841. /**
  28842. * Gets or sets the animation properties override
  28843. */
  28844. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  28845. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  28846. /**
  28847. * Gets a string idenfifying the name of the class
  28848. * @returns "Node" string
  28849. */
  28850. getClassName(): string;
  28851. /** @hidden */
  28852. readonly _isNode: boolean;
  28853. /**
  28854. * An event triggered when the mesh is disposed
  28855. */
  28856. onDisposeObservable: Observable<Node>;
  28857. private _onDisposeObserver;
  28858. /**
  28859. * Sets a callback that will be raised when the node will be disposed
  28860. */
  28861. set onDispose(callback: () => void);
  28862. /**
  28863. * Creates a new Node
  28864. * @param name the name and id to be given to this node
  28865. * @param scene the scene this node will be added to
  28866. */
  28867. constructor(name: string, scene?: Nullable<Scene>);
  28868. /**
  28869. * Gets the scene of the node
  28870. * @returns a scene
  28871. */
  28872. getScene(): Scene;
  28873. /**
  28874. * Gets the engine of the node
  28875. * @returns a Engine
  28876. */
  28877. getEngine(): Engine;
  28878. private _behaviors;
  28879. /**
  28880. * Attach a behavior to the node
  28881. * @see http://doc.babylonjs.com/features/behaviour
  28882. * @param behavior defines the behavior to attach
  28883. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  28884. * @returns the current Node
  28885. */
  28886. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  28887. /**
  28888. * Remove an attached behavior
  28889. * @see http://doc.babylonjs.com/features/behaviour
  28890. * @param behavior defines the behavior to attach
  28891. * @returns the current Node
  28892. */
  28893. removeBehavior(behavior: Behavior<Node>): Node;
  28894. /**
  28895. * Gets the list of attached behaviors
  28896. * @see http://doc.babylonjs.com/features/behaviour
  28897. */
  28898. get behaviors(): Behavior<Node>[];
  28899. /**
  28900. * Gets an attached behavior by name
  28901. * @param name defines the name of the behavior to look for
  28902. * @see http://doc.babylonjs.com/features/behaviour
  28903. * @returns null if behavior was not found else the requested behavior
  28904. */
  28905. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  28906. /**
  28907. * Returns the latest update of the World matrix
  28908. * @returns a Matrix
  28909. */
  28910. getWorldMatrix(): Matrix;
  28911. /** @hidden */
  28912. _getWorldMatrixDeterminant(): number;
  28913. /**
  28914. * Returns directly the latest state of the mesh World matrix.
  28915. * A Matrix is returned.
  28916. */
  28917. get worldMatrixFromCache(): Matrix;
  28918. /** @hidden */
  28919. _initCache(): void;
  28920. /** @hidden */
  28921. updateCache(force?: boolean): void;
  28922. /** @hidden */
  28923. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28924. /** @hidden */
  28925. _updateCache(ignoreParentClass?: boolean): void;
  28926. /** @hidden */
  28927. _isSynchronized(): boolean;
  28928. /** @hidden */
  28929. _markSyncedWithParent(): void;
  28930. /** @hidden */
  28931. isSynchronizedWithParent(): boolean;
  28932. /** @hidden */
  28933. isSynchronized(): boolean;
  28934. /**
  28935. * Is this node ready to be used/rendered
  28936. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28937. * @return true if the node is ready
  28938. */
  28939. isReady(completeCheck?: boolean): boolean;
  28940. /**
  28941. * Is this node enabled?
  28942. * 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
  28943. * @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
  28944. * @return whether this node (and its parent) is enabled
  28945. */
  28946. isEnabled(checkAncestors?: boolean): boolean;
  28947. /** @hidden */
  28948. protected _syncParentEnabledState(): void;
  28949. /**
  28950. * Set the enabled state of this node
  28951. * @param value defines the new enabled state
  28952. */
  28953. setEnabled(value: boolean): void;
  28954. /**
  28955. * Is this node a descendant of the given node?
  28956. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  28957. * @param ancestor defines the parent node to inspect
  28958. * @returns a boolean indicating if this node is a descendant of the given node
  28959. */
  28960. isDescendantOf(ancestor: Node): boolean;
  28961. /** @hidden */
  28962. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  28963. /**
  28964. * Will return all nodes that have this node as ascendant
  28965. * @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
  28966. * @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
  28967. * @return all children nodes of all types
  28968. */
  28969. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  28970. /**
  28971. * Get all child-meshes of this node
  28972. * @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)
  28973. * @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
  28974. * @returns an array of AbstractMesh
  28975. */
  28976. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  28977. /**
  28978. * Get all direct children of this node
  28979. * @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
  28980. * @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)
  28981. * @returns an array of Node
  28982. */
  28983. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  28984. /** @hidden */
  28985. _setReady(state: boolean): void;
  28986. /**
  28987. * Get an animation by name
  28988. * @param name defines the name of the animation to look for
  28989. * @returns null if not found else the requested animation
  28990. */
  28991. getAnimationByName(name: string): Nullable<Animation>;
  28992. /**
  28993. * Creates an animation range for this node
  28994. * @param name defines the name of the range
  28995. * @param from defines the starting key
  28996. * @param to defines the end key
  28997. */
  28998. createAnimationRange(name: string, from: number, to: number): void;
  28999. /**
  29000. * Delete a specific animation range
  29001. * @param name defines the name of the range to delete
  29002. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29003. */
  29004. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29005. /**
  29006. * Get an animation range by name
  29007. * @param name defines the name of the animation range to look for
  29008. * @returns null if not found else the requested animation range
  29009. */
  29010. getAnimationRange(name: string): Nullable<AnimationRange>;
  29011. /**
  29012. * Gets the list of all animation ranges defined on this node
  29013. * @returns an array
  29014. */
  29015. getAnimationRanges(): Nullable<AnimationRange>[];
  29016. /**
  29017. * Will start the animation sequence
  29018. * @param name defines the range frames for animation sequence
  29019. * @param loop defines if the animation should loop (false by default)
  29020. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29021. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29022. * @returns the object created for this animation. If range does not exist, it will return null
  29023. */
  29024. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29025. /**
  29026. * Serialize animation ranges into a JSON compatible object
  29027. * @returns serialization object
  29028. */
  29029. serializeAnimationRanges(): any;
  29030. /**
  29031. * Computes the world matrix of the node
  29032. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29033. * @returns the world matrix
  29034. */
  29035. computeWorldMatrix(force?: boolean): Matrix;
  29036. /**
  29037. * Releases resources associated with this node.
  29038. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29039. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29040. */
  29041. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29042. /**
  29043. * Parse animation range data from a serialization object and store them into a given node
  29044. * @param node defines where to store the animation ranges
  29045. * @param parsedNode defines the serialization object to read data from
  29046. * @param scene defines the hosting scene
  29047. */
  29048. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29049. /**
  29050. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29051. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29052. * @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
  29053. * @returns the new bounding vectors
  29054. */
  29055. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29056. min: Vector3;
  29057. max: Vector3;
  29058. };
  29059. }
  29060. }
  29061. declare module BABYLON {
  29062. /**
  29063. * @hidden
  29064. */
  29065. export class _IAnimationState {
  29066. key: number;
  29067. repeatCount: number;
  29068. workValue?: any;
  29069. loopMode?: number;
  29070. offsetValue?: any;
  29071. highLimitValue?: any;
  29072. }
  29073. /**
  29074. * Class used to store any kind of animation
  29075. */
  29076. export class Animation {
  29077. /**Name of the animation */
  29078. name: string;
  29079. /**Property to animate */
  29080. targetProperty: string;
  29081. /**The frames per second of the animation */
  29082. framePerSecond: number;
  29083. /**The data type of the animation */
  29084. dataType: number;
  29085. /**The loop mode of the animation */
  29086. loopMode?: number | undefined;
  29087. /**Specifies if blending should be enabled */
  29088. enableBlending?: boolean | undefined;
  29089. /**
  29090. * Use matrix interpolation instead of using direct key value when animating matrices
  29091. */
  29092. static AllowMatricesInterpolation: boolean;
  29093. /**
  29094. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  29095. */
  29096. static AllowMatrixDecomposeForInterpolation: boolean;
  29097. /**
  29098. * Stores the key frames of the animation
  29099. */
  29100. private _keys;
  29101. /**
  29102. * Stores the easing function of the animation
  29103. */
  29104. private _easingFunction;
  29105. /**
  29106. * @hidden Internal use only
  29107. */
  29108. _runtimeAnimations: RuntimeAnimation[];
  29109. /**
  29110. * The set of event that will be linked to this animation
  29111. */
  29112. private _events;
  29113. /**
  29114. * Stores an array of target property paths
  29115. */
  29116. targetPropertyPath: string[];
  29117. /**
  29118. * Stores the blending speed of the animation
  29119. */
  29120. blendingSpeed: number;
  29121. /**
  29122. * Stores the animation ranges for the animation
  29123. */
  29124. private _ranges;
  29125. /**
  29126. * @hidden Internal use
  29127. */
  29128. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  29129. /**
  29130. * Sets up an animation
  29131. * @param property The property to animate
  29132. * @param animationType The animation type to apply
  29133. * @param framePerSecond The frames per second of the animation
  29134. * @param easingFunction The easing function used in the animation
  29135. * @returns The created animation
  29136. */
  29137. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  29138. /**
  29139. * Create and start an animation on a node
  29140. * @param name defines the name of the global animation that will be run on all nodes
  29141. * @param node defines the root node where the animation will take place
  29142. * @param targetProperty defines property to animate
  29143. * @param framePerSecond defines the number of frame per second yo use
  29144. * @param totalFrame defines the number of frames in total
  29145. * @param from defines the initial value
  29146. * @param to defines the final value
  29147. * @param loopMode defines which loop mode you want to use (off by default)
  29148. * @param easingFunction defines the easing function to use (linear by default)
  29149. * @param onAnimationEnd defines the callback to call when animation end
  29150. * @returns the animatable created for this animation
  29151. */
  29152. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29153. /**
  29154. * Create and start an animation on a node and its descendants
  29155. * @param name defines the name of the global animation that will be run on all nodes
  29156. * @param node defines the root node where the animation will take place
  29157. * @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
  29158. * @param targetProperty defines property to animate
  29159. * @param framePerSecond defines the number of frame per second to use
  29160. * @param totalFrame defines the number of frames in total
  29161. * @param from defines the initial value
  29162. * @param to defines the final value
  29163. * @param loopMode defines which loop mode you want to use (off by default)
  29164. * @param easingFunction defines the easing function to use (linear by default)
  29165. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  29166. * @returns the list of animatables created for all nodes
  29167. * @example https://www.babylonjs-playground.com/#MH0VLI
  29168. */
  29169. 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[]>;
  29170. /**
  29171. * Creates a new animation, merges it with the existing animations and starts it
  29172. * @param name Name of the animation
  29173. * @param node Node which contains the scene that begins the animations
  29174. * @param targetProperty Specifies which property to animate
  29175. * @param framePerSecond The frames per second of the animation
  29176. * @param totalFrame The total number of frames
  29177. * @param from The frame at the beginning of the animation
  29178. * @param to The frame at the end of the animation
  29179. * @param loopMode Specifies the loop mode of the animation
  29180. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  29181. * @param onAnimationEnd Callback to run once the animation is complete
  29182. * @returns Nullable animation
  29183. */
  29184. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  29185. /**
  29186. * Transition property of an host to the target Value
  29187. * @param property The property to transition
  29188. * @param targetValue The target Value of the property
  29189. * @param host The object where the property to animate belongs
  29190. * @param scene Scene used to run the animation
  29191. * @param frameRate Framerate (in frame/s) to use
  29192. * @param transition The transition type we want to use
  29193. * @param duration The duration of the animation, in milliseconds
  29194. * @param onAnimationEnd Callback trigger at the end of the animation
  29195. * @returns Nullable animation
  29196. */
  29197. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  29198. /**
  29199. * Return the array of runtime animations currently using this animation
  29200. */
  29201. get runtimeAnimations(): RuntimeAnimation[];
  29202. /**
  29203. * Specifies if any of the runtime animations are currently running
  29204. */
  29205. get hasRunningRuntimeAnimations(): boolean;
  29206. /**
  29207. * Initializes the animation
  29208. * @param name Name of the animation
  29209. * @param targetProperty Property to animate
  29210. * @param framePerSecond The frames per second of the animation
  29211. * @param dataType The data type of the animation
  29212. * @param loopMode The loop mode of the animation
  29213. * @param enableBlending Specifies if blending should be enabled
  29214. */
  29215. constructor(
  29216. /**Name of the animation */
  29217. name: string,
  29218. /**Property to animate */
  29219. targetProperty: string,
  29220. /**The frames per second of the animation */
  29221. framePerSecond: number,
  29222. /**The data type of the animation */
  29223. dataType: number,
  29224. /**The loop mode of the animation */
  29225. loopMode?: number | undefined,
  29226. /**Specifies if blending should be enabled */
  29227. enableBlending?: boolean | undefined);
  29228. /**
  29229. * Converts the animation to a string
  29230. * @param fullDetails support for multiple levels of logging within scene loading
  29231. * @returns String form of the animation
  29232. */
  29233. toString(fullDetails?: boolean): string;
  29234. /**
  29235. * Add an event to this animation
  29236. * @param event Event to add
  29237. */
  29238. addEvent(event: AnimationEvent): void;
  29239. /**
  29240. * Remove all events found at the given frame
  29241. * @param frame The frame to remove events from
  29242. */
  29243. removeEvents(frame: number): void;
  29244. /**
  29245. * Retrieves all the events from the animation
  29246. * @returns Events from the animation
  29247. */
  29248. getEvents(): AnimationEvent[];
  29249. /**
  29250. * Creates an animation range
  29251. * @param name Name of the animation range
  29252. * @param from Starting frame of the animation range
  29253. * @param to Ending frame of the animation
  29254. */
  29255. createRange(name: string, from: number, to: number): void;
  29256. /**
  29257. * Deletes an animation range by name
  29258. * @param name Name of the animation range to delete
  29259. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  29260. */
  29261. deleteRange(name: string, deleteFrames?: boolean): void;
  29262. /**
  29263. * Gets the animation range by name, or null if not defined
  29264. * @param name Name of the animation range
  29265. * @returns Nullable animation range
  29266. */
  29267. getRange(name: string): Nullable<AnimationRange>;
  29268. /**
  29269. * Gets the key frames from the animation
  29270. * @returns The key frames of the animation
  29271. */
  29272. getKeys(): Array<IAnimationKey>;
  29273. /**
  29274. * Gets the highest frame rate of the animation
  29275. * @returns Highest frame rate of the animation
  29276. */
  29277. getHighestFrame(): number;
  29278. /**
  29279. * Gets the easing function of the animation
  29280. * @returns Easing function of the animation
  29281. */
  29282. getEasingFunction(): IEasingFunction;
  29283. /**
  29284. * Sets the easing function of the animation
  29285. * @param easingFunction A custom mathematical formula for animation
  29286. */
  29287. setEasingFunction(easingFunction: EasingFunction): void;
  29288. /**
  29289. * Interpolates a scalar linearly
  29290. * @param startValue Start value of the animation curve
  29291. * @param endValue End value of the animation curve
  29292. * @param gradient Scalar amount to interpolate
  29293. * @returns Interpolated scalar value
  29294. */
  29295. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  29296. /**
  29297. * Interpolates a scalar cubically
  29298. * @param startValue Start value of the animation curve
  29299. * @param outTangent End tangent of the animation
  29300. * @param endValue End value of the animation curve
  29301. * @param inTangent Start tangent of the animation curve
  29302. * @param gradient Scalar amount to interpolate
  29303. * @returns Interpolated scalar value
  29304. */
  29305. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  29306. /**
  29307. * Interpolates a quaternion using a spherical linear interpolation
  29308. * @param startValue Start value of the animation curve
  29309. * @param endValue End value of the animation curve
  29310. * @param gradient Scalar amount to interpolate
  29311. * @returns Interpolated quaternion value
  29312. */
  29313. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  29314. /**
  29315. * Interpolates a quaternion cubically
  29316. * @param startValue Start value of the animation curve
  29317. * @param outTangent End tangent of the animation curve
  29318. * @param endValue End value of the animation curve
  29319. * @param inTangent Start tangent of the animation curve
  29320. * @param gradient Scalar amount to interpolate
  29321. * @returns Interpolated quaternion value
  29322. */
  29323. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  29324. /**
  29325. * Interpolates a Vector3 linearl
  29326. * @param startValue Start value of the animation curve
  29327. * @param endValue End value of the animation curve
  29328. * @param gradient Scalar amount to interpolate
  29329. * @returns Interpolated scalar value
  29330. */
  29331. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  29332. /**
  29333. * Interpolates a Vector3 cubically
  29334. * @param startValue Start value of the animation curve
  29335. * @param outTangent End tangent of the animation
  29336. * @param endValue End value of the animation curve
  29337. * @param inTangent Start tangent of the animation curve
  29338. * @param gradient Scalar amount to interpolate
  29339. * @returns InterpolatedVector3 value
  29340. */
  29341. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  29342. /**
  29343. * Interpolates a Vector2 linearly
  29344. * @param startValue Start value of the animation curve
  29345. * @param endValue End value of the animation curve
  29346. * @param gradient Scalar amount to interpolate
  29347. * @returns Interpolated Vector2 value
  29348. */
  29349. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  29350. /**
  29351. * Interpolates a Vector2 cubically
  29352. * @param startValue Start value of the animation curve
  29353. * @param outTangent End tangent of the animation
  29354. * @param endValue End value of the animation curve
  29355. * @param inTangent Start tangent of the animation curve
  29356. * @param gradient Scalar amount to interpolate
  29357. * @returns Interpolated Vector2 value
  29358. */
  29359. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  29360. /**
  29361. * Interpolates a size linearly
  29362. * @param startValue Start value of the animation curve
  29363. * @param endValue End value of the animation curve
  29364. * @param gradient Scalar amount to interpolate
  29365. * @returns Interpolated Size value
  29366. */
  29367. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  29368. /**
  29369. * Interpolates a Color3 linearly
  29370. * @param startValue Start value of the animation curve
  29371. * @param endValue End value of the animation curve
  29372. * @param gradient Scalar amount to interpolate
  29373. * @returns Interpolated Color3 value
  29374. */
  29375. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  29376. /**
  29377. * Interpolates a Color4 linearly
  29378. * @param startValue Start value of the animation curve
  29379. * @param endValue End value of the animation curve
  29380. * @param gradient Scalar amount to interpolate
  29381. * @returns Interpolated Color3 value
  29382. */
  29383. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  29384. /**
  29385. * @hidden Internal use only
  29386. */
  29387. _getKeyValue(value: any): any;
  29388. /**
  29389. * @hidden Internal use only
  29390. */
  29391. _interpolate(currentFrame: number, state: _IAnimationState): any;
  29392. /**
  29393. * Defines the function to use to interpolate matrices
  29394. * @param startValue defines the start matrix
  29395. * @param endValue defines the end matrix
  29396. * @param gradient defines the gradient between both matrices
  29397. * @param result defines an optional target matrix where to store the interpolation
  29398. * @returns the interpolated matrix
  29399. */
  29400. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  29401. /**
  29402. * Makes a copy of the animation
  29403. * @returns Cloned animation
  29404. */
  29405. clone(): Animation;
  29406. /**
  29407. * Sets the key frames of the animation
  29408. * @param values The animation key frames to set
  29409. */
  29410. setKeys(values: Array<IAnimationKey>): void;
  29411. /**
  29412. * Serializes the animation to an object
  29413. * @returns Serialized object
  29414. */
  29415. serialize(): any;
  29416. /**
  29417. * Float animation type
  29418. */
  29419. static readonly ANIMATIONTYPE_FLOAT: number;
  29420. /**
  29421. * Vector3 animation type
  29422. */
  29423. static readonly ANIMATIONTYPE_VECTOR3: number;
  29424. /**
  29425. * Quaternion animation type
  29426. */
  29427. static readonly ANIMATIONTYPE_QUATERNION: number;
  29428. /**
  29429. * Matrix animation type
  29430. */
  29431. static readonly ANIMATIONTYPE_MATRIX: number;
  29432. /**
  29433. * Color3 animation type
  29434. */
  29435. static readonly ANIMATIONTYPE_COLOR3: number;
  29436. /**
  29437. * Color3 animation type
  29438. */
  29439. static readonly ANIMATIONTYPE_COLOR4: number;
  29440. /**
  29441. * Vector2 animation type
  29442. */
  29443. static readonly ANIMATIONTYPE_VECTOR2: number;
  29444. /**
  29445. * Size animation type
  29446. */
  29447. static readonly ANIMATIONTYPE_SIZE: number;
  29448. /**
  29449. * Relative Loop Mode
  29450. */
  29451. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  29452. /**
  29453. * Cycle Loop Mode
  29454. */
  29455. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  29456. /**
  29457. * Constant Loop Mode
  29458. */
  29459. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  29460. /** @hidden */
  29461. static _UniversalLerp(left: any, right: any, amount: number): any;
  29462. /**
  29463. * Parses an animation object and creates an animation
  29464. * @param parsedAnimation Parsed animation object
  29465. * @returns Animation object
  29466. */
  29467. static Parse(parsedAnimation: any): Animation;
  29468. /**
  29469. * Appends the serialized animations from the source animations
  29470. * @param source Source containing the animations
  29471. * @param destination Target to store the animations
  29472. */
  29473. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29474. }
  29475. }
  29476. declare module BABYLON {
  29477. /**
  29478. * Interface containing an array of animations
  29479. */
  29480. export interface IAnimatable {
  29481. /**
  29482. * Array of animations
  29483. */
  29484. animations: Nullable<Array<Animation>>;
  29485. }
  29486. }
  29487. declare module BABYLON {
  29488. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29489. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29490. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29491. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29492. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29493. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29494. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29495. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29496. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29497. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29498. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29499. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29500. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29501. /**
  29502. * Decorator used to define property that can be serialized as reference to a camera
  29503. * @param sourceName defines the name of the property to decorate
  29504. */
  29505. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29506. /**
  29507. * Class used to help serialization objects
  29508. */
  29509. export class SerializationHelper {
  29510. /** @hidden */
  29511. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  29512. /** @hidden */
  29513. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  29514. /** @hidden */
  29515. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  29516. /** @hidden */
  29517. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  29518. /**
  29519. * Appends the serialized animations from the source animations
  29520. * @param source Source containing the animations
  29521. * @param destination Target to store the animations
  29522. */
  29523. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29524. /**
  29525. * Static function used to serialized a specific entity
  29526. * @param entity defines the entity to serialize
  29527. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29528. * @returns a JSON compatible object representing the serialization of the entity
  29529. */
  29530. static Serialize<T>(entity: T, serializationObject?: any): any;
  29531. /**
  29532. * Creates a new entity from a serialization data object
  29533. * @param creationFunction defines a function used to instanciated the new entity
  29534. * @param source defines the source serialization data
  29535. * @param scene defines the hosting scene
  29536. * @param rootUrl defines the root url for resources
  29537. * @returns a new entity
  29538. */
  29539. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29540. /**
  29541. * Clones an object
  29542. * @param creationFunction defines the function used to instanciate the new object
  29543. * @param source defines the source object
  29544. * @returns the cloned object
  29545. */
  29546. static Clone<T>(creationFunction: () => T, source: T): T;
  29547. /**
  29548. * Instanciates a new object based on a source one (some data will be shared between both object)
  29549. * @param creationFunction defines the function used to instanciate the new object
  29550. * @param source defines the source object
  29551. * @returns the new object
  29552. */
  29553. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29554. }
  29555. }
  29556. declare module BABYLON {
  29557. /**
  29558. * Class used to manipulate GUIDs
  29559. */
  29560. export class GUID {
  29561. /**
  29562. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  29563. * Be aware Math.random() could cause collisions, but:
  29564. * "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"
  29565. * @returns a pseudo random id
  29566. */
  29567. static RandomId(): string;
  29568. }
  29569. }
  29570. declare module BABYLON {
  29571. /**
  29572. * Base class of all the textures in babylon.
  29573. * It groups all the common properties the materials, post process, lights... might need
  29574. * in order to make a correct use of the texture.
  29575. */
  29576. export class BaseTexture implements IAnimatable {
  29577. /**
  29578. * Default anisotropic filtering level for the application.
  29579. * It is set to 4 as a good tradeoff between perf and quality.
  29580. */
  29581. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  29582. /**
  29583. * Gets or sets the unique id of the texture
  29584. */
  29585. uniqueId: number;
  29586. /**
  29587. * Define the name of the texture.
  29588. */
  29589. name: string;
  29590. /**
  29591. * Gets or sets an object used to store user defined information.
  29592. */
  29593. metadata: any;
  29594. /**
  29595. * For internal use only. Please do not use.
  29596. */
  29597. reservedDataStore: any;
  29598. private _hasAlpha;
  29599. /**
  29600. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  29601. */
  29602. set hasAlpha(value: boolean);
  29603. get hasAlpha(): boolean;
  29604. /**
  29605. * Defines if the alpha value should be determined via the rgb values.
  29606. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  29607. */
  29608. getAlphaFromRGB: boolean;
  29609. /**
  29610. * Intensity or strength of the texture.
  29611. * It is commonly used by materials to fine tune the intensity of the texture
  29612. */
  29613. level: number;
  29614. /**
  29615. * Define the UV chanel to use starting from 0 and defaulting to 0.
  29616. * This is part of the texture as textures usually maps to one uv set.
  29617. */
  29618. coordinatesIndex: number;
  29619. private _coordinatesMode;
  29620. /**
  29621. * How a texture is mapped.
  29622. *
  29623. * | Value | Type | Description |
  29624. * | ----- | ----------------------------------- | ----------- |
  29625. * | 0 | EXPLICIT_MODE | |
  29626. * | 1 | SPHERICAL_MODE | |
  29627. * | 2 | PLANAR_MODE | |
  29628. * | 3 | CUBIC_MODE | |
  29629. * | 4 | PROJECTION_MODE | |
  29630. * | 5 | SKYBOX_MODE | |
  29631. * | 6 | INVCUBIC_MODE | |
  29632. * | 7 | EQUIRECTANGULAR_MODE | |
  29633. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  29634. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  29635. */
  29636. set coordinatesMode(value: number);
  29637. get coordinatesMode(): number;
  29638. /**
  29639. * | Value | Type | Description |
  29640. * | ----- | ------------------ | ----------- |
  29641. * | 0 | CLAMP_ADDRESSMODE | |
  29642. * | 1 | WRAP_ADDRESSMODE | |
  29643. * | 2 | MIRROR_ADDRESSMODE | |
  29644. */
  29645. wrapU: number;
  29646. /**
  29647. * | Value | Type | Description |
  29648. * | ----- | ------------------ | ----------- |
  29649. * | 0 | CLAMP_ADDRESSMODE | |
  29650. * | 1 | WRAP_ADDRESSMODE | |
  29651. * | 2 | MIRROR_ADDRESSMODE | |
  29652. */
  29653. wrapV: number;
  29654. /**
  29655. * | Value | Type | Description |
  29656. * | ----- | ------------------ | ----------- |
  29657. * | 0 | CLAMP_ADDRESSMODE | |
  29658. * | 1 | WRAP_ADDRESSMODE | |
  29659. * | 2 | MIRROR_ADDRESSMODE | |
  29660. */
  29661. wrapR: number;
  29662. /**
  29663. * With compliant hardware and browser (supporting anisotropic filtering)
  29664. * this defines the level of anisotropic filtering in the texture.
  29665. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  29666. */
  29667. anisotropicFilteringLevel: number;
  29668. /**
  29669. * Define if the texture is a cube texture or if false a 2d texture.
  29670. */
  29671. get isCube(): boolean;
  29672. set isCube(value: boolean);
  29673. /**
  29674. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  29675. */
  29676. get is3D(): boolean;
  29677. set is3D(value: boolean);
  29678. /**
  29679. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  29680. */
  29681. get is2DArray(): boolean;
  29682. set is2DArray(value: boolean);
  29683. /**
  29684. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  29685. * HDR texture are usually stored in linear space.
  29686. * This only impacts the PBR and Background materials
  29687. */
  29688. gammaSpace: boolean;
  29689. /**
  29690. * Gets or sets whether or not the texture contains RGBD data.
  29691. */
  29692. get isRGBD(): boolean;
  29693. set isRGBD(value: boolean);
  29694. /**
  29695. * Is Z inverted in the texture (useful in a cube texture).
  29696. */
  29697. invertZ: boolean;
  29698. /**
  29699. * Are mip maps generated for this texture or not.
  29700. */
  29701. get noMipmap(): boolean;
  29702. /**
  29703. * @hidden
  29704. */
  29705. lodLevelInAlpha: boolean;
  29706. /**
  29707. * With prefiltered texture, defined the offset used during the prefiltering steps.
  29708. */
  29709. get lodGenerationOffset(): number;
  29710. set lodGenerationOffset(value: number);
  29711. /**
  29712. * With prefiltered texture, defined the scale used during the prefiltering steps.
  29713. */
  29714. get lodGenerationScale(): number;
  29715. set lodGenerationScale(value: number);
  29716. /**
  29717. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  29718. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  29719. * average roughness values.
  29720. */
  29721. get linearSpecularLOD(): boolean;
  29722. set linearSpecularLOD(value: boolean);
  29723. /**
  29724. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  29725. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  29726. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  29727. */
  29728. get irradianceTexture(): Nullable<BaseTexture>;
  29729. set irradianceTexture(value: Nullable<BaseTexture>);
  29730. /**
  29731. * Define if the texture is a render target.
  29732. */
  29733. isRenderTarget: boolean;
  29734. /**
  29735. * Define the unique id of the texture in the scene.
  29736. */
  29737. get uid(): string;
  29738. /**
  29739. * Return a string representation of the texture.
  29740. * @returns the texture as a string
  29741. */
  29742. toString(): string;
  29743. /**
  29744. * Get the class name of the texture.
  29745. * @returns "BaseTexture"
  29746. */
  29747. getClassName(): string;
  29748. /**
  29749. * Define the list of animation attached to the texture.
  29750. */
  29751. animations: Animation[];
  29752. /**
  29753. * An event triggered when the texture is disposed.
  29754. */
  29755. onDisposeObservable: Observable<BaseTexture>;
  29756. private _onDisposeObserver;
  29757. /**
  29758. * Callback triggered when the texture has been disposed.
  29759. * Kept for back compatibility, you can use the onDisposeObservable instead.
  29760. */
  29761. set onDispose(callback: () => void);
  29762. /**
  29763. * Define the current state of the loading sequence when in delayed load mode.
  29764. */
  29765. delayLoadState: number;
  29766. private _scene;
  29767. /** @hidden */
  29768. _texture: Nullable<InternalTexture>;
  29769. private _uid;
  29770. /**
  29771. * Define if the texture is preventinga material to render or not.
  29772. * If not and the texture is not ready, the engine will use a default black texture instead.
  29773. */
  29774. get isBlocking(): boolean;
  29775. /**
  29776. * Instantiates a new BaseTexture.
  29777. * Base class of all the textures in babylon.
  29778. * It groups all the common properties the materials, post process, lights... might need
  29779. * in order to make a correct use of the texture.
  29780. * @param scene Define the scene the texture blongs to
  29781. */
  29782. constructor(scene: Nullable<Scene>);
  29783. /**
  29784. * Get the scene the texture belongs to.
  29785. * @returns the scene or null if undefined
  29786. */
  29787. getScene(): Nullable<Scene>;
  29788. /**
  29789. * Get the texture transform matrix used to offset tile the texture for istance.
  29790. * @returns the transformation matrix
  29791. */
  29792. getTextureMatrix(): Matrix;
  29793. /**
  29794. * Get the texture reflection matrix used to rotate/transform the reflection.
  29795. * @returns the reflection matrix
  29796. */
  29797. getReflectionTextureMatrix(): Matrix;
  29798. /**
  29799. * Get the underlying lower level texture from Babylon.
  29800. * @returns the insternal texture
  29801. */
  29802. getInternalTexture(): Nullable<InternalTexture>;
  29803. /**
  29804. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  29805. * @returns true if ready or not blocking
  29806. */
  29807. isReadyOrNotBlocking(): boolean;
  29808. /**
  29809. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  29810. * @returns true if fully ready
  29811. */
  29812. isReady(): boolean;
  29813. private _cachedSize;
  29814. /**
  29815. * Get the size of the texture.
  29816. * @returns the texture size.
  29817. */
  29818. getSize(): ISize;
  29819. /**
  29820. * Get the base size of the texture.
  29821. * It can be different from the size if the texture has been resized for POT for instance
  29822. * @returns the base size
  29823. */
  29824. getBaseSize(): ISize;
  29825. /**
  29826. * Update the sampling mode of the texture.
  29827. * Default is Trilinear mode.
  29828. *
  29829. * | Value | Type | Description |
  29830. * | ----- | ------------------ | ----------- |
  29831. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  29832. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  29833. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  29834. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  29835. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  29836. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  29837. * | 7 | NEAREST_LINEAR | |
  29838. * | 8 | NEAREST_NEAREST | |
  29839. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  29840. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  29841. * | 11 | LINEAR_LINEAR | |
  29842. * | 12 | LINEAR_NEAREST | |
  29843. *
  29844. * > _mag_: magnification filter (close to the viewer)
  29845. * > _min_: minification filter (far from the viewer)
  29846. * > _mip_: filter used between mip map levels
  29847. *@param samplingMode Define the new sampling mode of the texture
  29848. */
  29849. updateSamplingMode(samplingMode: number): void;
  29850. /**
  29851. * Scales the texture if is `canRescale()`
  29852. * @param ratio the resize factor we want to use to rescale
  29853. */
  29854. scale(ratio: number): void;
  29855. /**
  29856. * Get if the texture can rescale.
  29857. */
  29858. get canRescale(): boolean;
  29859. /** @hidden */
  29860. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  29861. /** @hidden */
  29862. _rebuild(): void;
  29863. /**
  29864. * Triggers the load sequence in delayed load mode.
  29865. */
  29866. delayLoad(): void;
  29867. /**
  29868. * Clones the texture.
  29869. * @returns the cloned texture
  29870. */
  29871. clone(): Nullable<BaseTexture>;
  29872. /**
  29873. * Get the texture underlying type (INT, FLOAT...)
  29874. */
  29875. get textureType(): number;
  29876. /**
  29877. * Get the texture underlying format (RGB, RGBA...)
  29878. */
  29879. get textureFormat(): number;
  29880. /**
  29881. * Indicates that textures need to be re-calculated for all materials
  29882. */
  29883. protected _markAllSubMeshesAsTexturesDirty(): void;
  29884. /**
  29885. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  29886. * This will returns an RGBA array buffer containing either in values (0-255) or
  29887. * float values (0-1) depending of the underlying buffer type.
  29888. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  29889. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  29890. * @param buffer defines a user defined buffer to fill with data (can be null)
  29891. * @returns The Array buffer containing the pixels data.
  29892. */
  29893. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  29894. /**
  29895. * Release and destroy the underlying lower level texture aka internalTexture.
  29896. */
  29897. releaseInternalTexture(): void;
  29898. /** @hidden */
  29899. get _lodTextureHigh(): Nullable<BaseTexture>;
  29900. /** @hidden */
  29901. get _lodTextureMid(): Nullable<BaseTexture>;
  29902. /** @hidden */
  29903. get _lodTextureLow(): Nullable<BaseTexture>;
  29904. /**
  29905. * Dispose the texture and release its associated resources.
  29906. */
  29907. dispose(): void;
  29908. /**
  29909. * Serialize the texture into a JSON representation that can be parsed later on.
  29910. * @returns the JSON representation of the texture
  29911. */
  29912. serialize(): any;
  29913. /**
  29914. * Helper function to be called back once a list of texture contains only ready textures.
  29915. * @param textures Define the list of textures to wait for
  29916. * @param callback Define the callback triggered once the entire list will be ready
  29917. */
  29918. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  29919. }
  29920. }
  29921. declare module BABYLON {
  29922. /**
  29923. * Options to be used when creating an effect.
  29924. */
  29925. export interface IEffectCreationOptions {
  29926. /**
  29927. * Atrributes that will be used in the shader.
  29928. */
  29929. attributes: string[];
  29930. /**
  29931. * Uniform varible names that will be set in the shader.
  29932. */
  29933. uniformsNames: string[];
  29934. /**
  29935. * Uniform buffer variable names that will be set in the shader.
  29936. */
  29937. uniformBuffersNames: string[];
  29938. /**
  29939. * Sampler texture variable names that will be set in the shader.
  29940. */
  29941. samplers: string[];
  29942. /**
  29943. * Define statements that will be set in the shader.
  29944. */
  29945. defines: any;
  29946. /**
  29947. * Possible fallbacks for this effect to improve performance when needed.
  29948. */
  29949. fallbacks: Nullable<IEffectFallbacks>;
  29950. /**
  29951. * Callback that will be called when the shader is compiled.
  29952. */
  29953. onCompiled: Nullable<(effect: Effect) => void>;
  29954. /**
  29955. * Callback that will be called if an error occurs during shader compilation.
  29956. */
  29957. onError: Nullable<(effect: Effect, errors: string) => void>;
  29958. /**
  29959. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29960. */
  29961. indexParameters?: any;
  29962. /**
  29963. * Max number of lights that can be used in the shader.
  29964. */
  29965. maxSimultaneousLights?: number;
  29966. /**
  29967. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29968. */
  29969. transformFeedbackVaryings?: Nullable<string[]>;
  29970. }
  29971. /**
  29972. * Effect containing vertex and fragment shader that can be executed on an object.
  29973. */
  29974. export class Effect implements IDisposable {
  29975. /**
  29976. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29977. */
  29978. static ShadersRepository: string;
  29979. /**
  29980. * Name of the effect.
  29981. */
  29982. name: any;
  29983. /**
  29984. * String container all the define statements that should be set on the shader.
  29985. */
  29986. defines: string;
  29987. /**
  29988. * Callback that will be called when the shader is compiled.
  29989. */
  29990. onCompiled: Nullable<(effect: Effect) => void>;
  29991. /**
  29992. * Callback that will be called if an error occurs during shader compilation.
  29993. */
  29994. onError: Nullable<(effect: Effect, errors: string) => void>;
  29995. /**
  29996. * Callback that will be called when effect is bound.
  29997. */
  29998. onBind: Nullable<(effect: Effect) => void>;
  29999. /**
  30000. * Unique ID of the effect.
  30001. */
  30002. uniqueId: number;
  30003. /**
  30004. * Observable that will be called when the shader is compiled.
  30005. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30006. */
  30007. onCompileObservable: Observable<Effect>;
  30008. /**
  30009. * Observable that will be called if an error occurs during shader compilation.
  30010. */
  30011. onErrorObservable: Observable<Effect>;
  30012. /** @hidden */
  30013. _onBindObservable: Nullable<Observable<Effect>>;
  30014. /**
  30015. * @hidden
  30016. * Specifies if the effect was previously ready
  30017. */
  30018. _wasPreviouslyReady: boolean;
  30019. /**
  30020. * Observable that will be called when effect is bound.
  30021. */
  30022. get onBindObservable(): Observable<Effect>;
  30023. /** @hidden */
  30024. _bonesComputationForcedToCPU: boolean;
  30025. private static _uniqueIdSeed;
  30026. private _engine;
  30027. private _uniformBuffersNames;
  30028. private _uniformsNames;
  30029. private _samplerList;
  30030. private _samplers;
  30031. private _isReady;
  30032. private _compilationError;
  30033. private _allFallbacksProcessed;
  30034. private _attributesNames;
  30035. private _attributes;
  30036. private _attributeLocationByName;
  30037. private _uniforms;
  30038. /**
  30039. * Key for the effect.
  30040. * @hidden
  30041. */
  30042. _key: string;
  30043. private _indexParameters;
  30044. private _fallbacks;
  30045. private _vertexSourceCode;
  30046. private _fragmentSourceCode;
  30047. private _vertexSourceCodeOverride;
  30048. private _fragmentSourceCodeOverride;
  30049. private _transformFeedbackVaryings;
  30050. /**
  30051. * Compiled shader to webGL program.
  30052. * @hidden
  30053. */
  30054. _pipelineContext: Nullable<IPipelineContext>;
  30055. private _valueCache;
  30056. private static _baseCache;
  30057. /**
  30058. * Instantiates an effect.
  30059. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30060. * @param baseName Name of the effect.
  30061. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30062. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  30063. * @param samplers List of sampler variables that will be passed to the shader.
  30064. * @param engine Engine to be used to render the effect
  30065. * @param defines Define statements to be added to the shader.
  30066. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  30067. * @param onCompiled Callback that will be called when the shader is compiled.
  30068. * @param onError Callback that will be called if an error occurs during shader compilation.
  30069. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30070. */
  30071. 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);
  30072. private _useFinalCode;
  30073. /**
  30074. * Unique key for this effect
  30075. */
  30076. get key(): string;
  30077. /**
  30078. * If the effect has been compiled and prepared.
  30079. * @returns if the effect is compiled and prepared.
  30080. */
  30081. isReady(): boolean;
  30082. private _isReadyInternal;
  30083. /**
  30084. * The engine the effect was initialized with.
  30085. * @returns the engine.
  30086. */
  30087. getEngine(): Engine;
  30088. /**
  30089. * The pipeline context for this effect
  30090. * @returns the associated pipeline context
  30091. */
  30092. getPipelineContext(): Nullable<IPipelineContext>;
  30093. /**
  30094. * The set of names of attribute variables for the shader.
  30095. * @returns An array of attribute names.
  30096. */
  30097. getAttributesNames(): string[];
  30098. /**
  30099. * Returns the attribute at the given index.
  30100. * @param index The index of the attribute.
  30101. * @returns The location of the attribute.
  30102. */
  30103. getAttributeLocation(index: number): number;
  30104. /**
  30105. * Returns the attribute based on the name of the variable.
  30106. * @param name of the attribute to look up.
  30107. * @returns the attribute location.
  30108. */
  30109. getAttributeLocationByName(name: string): number;
  30110. /**
  30111. * The number of attributes.
  30112. * @returns the numnber of attributes.
  30113. */
  30114. getAttributesCount(): number;
  30115. /**
  30116. * Gets the index of a uniform variable.
  30117. * @param uniformName of the uniform to look up.
  30118. * @returns the index.
  30119. */
  30120. getUniformIndex(uniformName: string): number;
  30121. /**
  30122. * Returns the attribute based on the name of the variable.
  30123. * @param uniformName of the uniform to look up.
  30124. * @returns the location of the uniform.
  30125. */
  30126. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30127. /**
  30128. * Returns an array of sampler variable names
  30129. * @returns The array of sampler variable neames.
  30130. */
  30131. getSamplers(): string[];
  30132. /**
  30133. * The error from the last compilation.
  30134. * @returns the error string.
  30135. */
  30136. getCompilationError(): string;
  30137. /**
  30138. * Gets a boolean indicating that all fallbacks were used during compilation
  30139. * @returns true if all fallbacks were used
  30140. */
  30141. allFallbacksProcessed(): boolean;
  30142. /**
  30143. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30144. * @param func The callback to be used.
  30145. */
  30146. executeWhenCompiled(func: (effect: Effect) => void): void;
  30147. private _checkIsReady;
  30148. private _loadShader;
  30149. /**
  30150. * Recompiles the webGL program
  30151. * @param vertexSourceCode The source code for the vertex shader.
  30152. * @param fragmentSourceCode The source code for the fragment shader.
  30153. * @param onCompiled Callback called when completed.
  30154. * @param onError Callback called on error.
  30155. * @hidden
  30156. */
  30157. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30158. /**
  30159. * Prepares the effect
  30160. * @hidden
  30161. */
  30162. _prepareEffect(): void;
  30163. private _processCompilationErrors;
  30164. /**
  30165. * Checks if the effect is supported. (Must be called after compilation)
  30166. */
  30167. get isSupported(): boolean;
  30168. /**
  30169. * Binds a texture to the engine to be used as output of the shader.
  30170. * @param channel Name of the output variable.
  30171. * @param texture Texture to bind.
  30172. * @hidden
  30173. */
  30174. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  30175. /**
  30176. * Sets a texture on the engine to be used in the shader.
  30177. * @param channel Name of the sampler variable.
  30178. * @param texture Texture to set.
  30179. */
  30180. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30181. /**
  30182. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30183. * @param channel Name of the sampler variable.
  30184. * @param texture Texture to set.
  30185. */
  30186. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30187. /**
  30188. * Sets an array of textures on the engine to be used in the shader.
  30189. * @param channel Name of the variable.
  30190. * @param textures Textures to set.
  30191. */
  30192. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30193. /**
  30194. * 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)
  30195. * @param channel Name of the sampler variable.
  30196. * @param postProcess Post process to get the input texture from.
  30197. */
  30198. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30199. /**
  30200. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30201. * 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)
  30202. * @param channel Name of the sampler variable.
  30203. * @param postProcess Post process to get the output texture from.
  30204. */
  30205. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30206. /** @hidden */
  30207. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  30208. /** @hidden */
  30209. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30210. /** @hidden */
  30211. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30212. /** @hidden */
  30213. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30214. /**
  30215. * Binds a buffer to a uniform.
  30216. * @param buffer Buffer to bind.
  30217. * @param name Name of the uniform variable to bind to.
  30218. */
  30219. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30220. /**
  30221. * Binds block to a uniform.
  30222. * @param blockName Name of the block to bind.
  30223. * @param index Index to bind.
  30224. */
  30225. bindUniformBlock(blockName: string, index: number): void;
  30226. /**
  30227. * Sets an interger value on a uniform variable.
  30228. * @param uniformName Name of the variable.
  30229. * @param value Value to be set.
  30230. * @returns this effect.
  30231. */
  30232. setInt(uniformName: string, value: number): Effect;
  30233. /**
  30234. * Sets an int array on a uniform variable.
  30235. * @param uniformName Name of the variable.
  30236. * @param array array to be set.
  30237. * @returns this effect.
  30238. */
  30239. setIntArray(uniformName: string, array: Int32Array): Effect;
  30240. /**
  30241. * 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)
  30242. * @param uniformName Name of the variable.
  30243. * @param array array to be set.
  30244. * @returns this effect.
  30245. */
  30246. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30247. /**
  30248. * 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)
  30249. * @param uniformName Name of the variable.
  30250. * @param array array to be set.
  30251. * @returns this effect.
  30252. */
  30253. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30254. /**
  30255. * 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)
  30256. * @param uniformName Name of the variable.
  30257. * @param array array to be set.
  30258. * @returns this effect.
  30259. */
  30260. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30261. /**
  30262. * Sets an float array on a uniform variable.
  30263. * @param uniformName Name of the variable.
  30264. * @param array array to be set.
  30265. * @returns this effect.
  30266. */
  30267. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30268. /**
  30269. * 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)
  30270. * @param uniformName Name of the variable.
  30271. * @param array array to be set.
  30272. * @returns this effect.
  30273. */
  30274. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30275. /**
  30276. * 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)
  30277. * @param uniformName Name of the variable.
  30278. * @param array array to be set.
  30279. * @returns this effect.
  30280. */
  30281. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30282. /**
  30283. * 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)
  30284. * @param uniformName Name of the variable.
  30285. * @param array array to be set.
  30286. * @returns this effect.
  30287. */
  30288. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30289. /**
  30290. * Sets an array on a uniform variable.
  30291. * @param uniformName Name of the variable.
  30292. * @param array array to be set.
  30293. * @returns this effect.
  30294. */
  30295. setArray(uniformName: string, array: number[]): Effect;
  30296. /**
  30297. * 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)
  30298. * @param uniformName Name of the variable.
  30299. * @param array array to be set.
  30300. * @returns this effect.
  30301. */
  30302. setArray2(uniformName: string, array: number[]): Effect;
  30303. /**
  30304. * 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)
  30305. * @param uniformName Name of the variable.
  30306. * @param array array to be set.
  30307. * @returns this effect.
  30308. */
  30309. setArray3(uniformName: string, array: number[]): Effect;
  30310. /**
  30311. * 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)
  30312. * @param uniformName Name of the variable.
  30313. * @param array array to be set.
  30314. * @returns this effect.
  30315. */
  30316. setArray4(uniformName: string, array: number[]): Effect;
  30317. /**
  30318. * Sets matrices on a uniform variable.
  30319. * @param uniformName Name of the variable.
  30320. * @param matrices matrices to be set.
  30321. * @returns this effect.
  30322. */
  30323. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30324. /**
  30325. * Sets matrix on a uniform variable.
  30326. * @param uniformName Name of the variable.
  30327. * @param matrix matrix to be set.
  30328. * @returns this effect.
  30329. */
  30330. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  30331. /**
  30332. * 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)
  30333. * @param uniformName Name of the variable.
  30334. * @param matrix matrix to be set.
  30335. * @returns this effect.
  30336. */
  30337. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30338. /**
  30339. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30340. * @param uniformName Name of the variable.
  30341. * @param matrix matrix to be set.
  30342. * @returns this effect.
  30343. */
  30344. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30345. /**
  30346. * Sets a float on a uniform variable.
  30347. * @param uniformName Name of the variable.
  30348. * @param value value to be set.
  30349. * @returns this effect.
  30350. */
  30351. setFloat(uniformName: string, value: number): Effect;
  30352. /**
  30353. * Sets a boolean on a uniform variable.
  30354. * @param uniformName Name of the variable.
  30355. * @param bool value to be set.
  30356. * @returns this effect.
  30357. */
  30358. setBool(uniformName: string, bool: boolean): Effect;
  30359. /**
  30360. * Sets a Vector2 on a uniform variable.
  30361. * @param uniformName Name of the variable.
  30362. * @param vector2 vector2 to be set.
  30363. * @returns this effect.
  30364. */
  30365. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  30366. /**
  30367. * Sets a float2 on a uniform variable.
  30368. * @param uniformName Name of the variable.
  30369. * @param x First float in float2.
  30370. * @param y Second float in float2.
  30371. * @returns this effect.
  30372. */
  30373. setFloat2(uniformName: string, x: number, y: number): Effect;
  30374. /**
  30375. * Sets a Vector3 on a uniform variable.
  30376. * @param uniformName Name of the variable.
  30377. * @param vector3 Value to be set.
  30378. * @returns this effect.
  30379. */
  30380. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  30381. /**
  30382. * Sets a float3 on a uniform variable.
  30383. * @param uniformName Name of the variable.
  30384. * @param x First float in float3.
  30385. * @param y Second float in float3.
  30386. * @param z Third float in float3.
  30387. * @returns this effect.
  30388. */
  30389. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30390. /**
  30391. * Sets a Vector4 on a uniform variable.
  30392. * @param uniformName Name of the variable.
  30393. * @param vector4 Value to be set.
  30394. * @returns this effect.
  30395. */
  30396. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  30397. /**
  30398. * Sets a float4 on a uniform variable.
  30399. * @param uniformName Name of the variable.
  30400. * @param x First float in float4.
  30401. * @param y Second float in float4.
  30402. * @param z Third float in float4.
  30403. * @param w Fourth float in float4.
  30404. * @returns this effect.
  30405. */
  30406. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30407. /**
  30408. * Sets a Color3 on a uniform variable.
  30409. * @param uniformName Name of the variable.
  30410. * @param color3 Value to be set.
  30411. * @returns this effect.
  30412. */
  30413. setColor3(uniformName: string, color3: IColor3Like): Effect;
  30414. /**
  30415. * Sets a Color4 on a uniform variable.
  30416. * @param uniformName Name of the variable.
  30417. * @param color3 Value to be set.
  30418. * @param alpha Alpha value to be set.
  30419. * @returns this effect.
  30420. */
  30421. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  30422. /**
  30423. * Sets a Color4 on a uniform variable
  30424. * @param uniformName defines the name of the variable
  30425. * @param color4 defines the value to be set
  30426. * @returns this effect.
  30427. */
  30428. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  30429. /** Release all associated resources */
  30430. dispose(): void;
  30431. /**
  30432. * This function will add a new shader to the shader store
  30433. * @param name the name of the shader
  30434. * @param pixelShader optional pixel shader content
  30435. * @param vertexShader optional vertex shader content
  30436. */
  30437. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30438. /**
  30439. * Store of each shader (The can be looked up using effect.key)
  30440. */
  30441. static ShadersStore: {
  30442. [key: string]: string;
  30443. };
  30444. /**
  30445. * Store of each included file for a shader (The can be looked up using effect.key)
  30446. */
  30447. static IncludesShadersStore: {
  30448. [key: string]: string;
  30449. };
  30450. /**
  30451. * Resets the cache of effects.
  30452. */
  30453. static ResetCache(): void;
  30454. }
  30455. }
  30456. declare module BABYLON {
  30457. /**
  30458. * Interface used to describe the capabilities of the engine relatively to the current browser
  30459. */
  30460. export interface EngineCapabilities {
  30461. /** Maximum textures units per fragment shader */
  30462. maxTexturesImageUnits: number;
  30463. /** Maximum texture units per vertex shader */
  30464. maxVertexTextureImageUnits: number;
  30465. /** Maximum textures units in the entire pipeline */
  30466. maxCombinedTexturesImageUnits: number;
  30467. /** Maximum texture size */
  30468. maxTextureSize: number;
  30469. /** Maximum texture samples */
  30470. maxSamples?: number;
  30471. /** Maximum cube texture size */
  30472. maxCubemapTextureSize: number;
  30473. /** Maximum render texture size */
  30474. maxRenderTextureSize: number;
  30475. /** Maximum number of vertex attributes */
  30476. maxVertexAttribs: number;
  30477. /** Maximum number of varyings */
  30478. maxVaryingVectors: number;
  30479. /** Maximum number of uniforms per vertex shader */
  30480. maxVertexUniformVectors: number;
  30481. /** Maximum number of uniforms per fragment shader */
  30482. maxFragmentUniformVectors: number;
  30483. /** Defines if standard derivates (dx/dy) are supported */
  30484. standardDerivatives: boolean;
  30485. /** Defines if s3tc texture compression is supported */
  30486. s3tc?: WEBGL_compressed_texture_s3tc;
  30487. /** Defines if pvrtc texture compression is supported */
  30488. pvrtc: any;
  30489. /** Defines if etc1 texture compression is supported */
  30490. etc1: any;
  30491. /** Defines if etc2 texture compression is supported */
  30492. etc2: any;
  30493. /** Defines if astc texture compression is supported */
  30494. astc: any;
  30495. /** Defines if float textures are supported */
  30496. textureFloat: boolean;
  30497. /** Defines if vertex array objects are supported */
  30498. vertexArrayObject: boolean;
  30499. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  30500. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  30501. /** Gets the maximum level of anisotropy supported */
  30502. maxAnisotropy: number;
  30503. /** Defines if instancing is supported */
  30504. instancedArrays: boolean;
  30505. /** Defines if 32 bits indices are supported */
  30506. uintIndices: boolean;
  30507. /** Defines if high precision shaders are supported */
  30508. highPrecisionShaderSupported: boolean;
  30509. /** Defines if depth reading in the fragment shader is supported */
  30510. fragmentDepthSupported: boolean;
  30511. /** Defines if float texture linear filtering is supported*/
  30512. textureFloatLinearFiltering: boolean;
  30513. /** Defines if rendering to float textures is supported */
  30514. textureFloatRender: boolean;
  30515. /** Defines if half float textures are supported*/
  30516. textureHalfFloat: boolean;
  30517. /** Defines if half float texture linear filtering is supported*/
  30518. textureHalfFloatLinearFiltering: boolean;
  30519. /** Defines if rendering to half float textures is supported */
  30520. textureHalfFloatRender: boolean;
  30521. /** Defines if textureLOD shader command is supported */
  30522. textureLOD: boolean;
  30523. /** Defines if draw buffers extension is supported */
  30524. drawBuffersExtension: boolean;
  30525. /** Defines if depth textures are supported */
  30526. depthTextureExtension: boolean;
  30527. /** Defines if float color buffer are supported */
  30528. colorBufferFloat: boolean;
  30529. /** Gets disjoint timer query extension (null if not supported) */
  30530. timerQuery?: EXT_disjoint_timer_query;
  30531. /** Defines if timestamp can be used with timer query */
  30532. canUseTimestampForTimerQuery: boolean;
  30533. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  30534. multiview?: any;
  30535. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  30536. oculusMultiview?: any;
  30537. /** Function used to let the system compiles shaders in background */
  30538. parallelShaderCompile?: {
  30539. COMPLETION_STATUS_KHR: number;
  30540. };
  30541. /** Max number of texture samples for MSAA */
  30542. maxMSAASamples: number;
  30543. /** Defines if the blend min max extension is supported */
  30544. blendMinMax: boolean;
  30545. }
  30546. }
  30547. declare module BABYLON {
  30548. /**
  30549. * @hidden
  30550. **/
  30551. export class DepthCullingState {
  30552. private _isDepthTestDirty;
  30553. private _isDepthMaskDirty;
  30554. private _isDepthFuncDirty;
  30555. private _isCullFaceDirty;
  30556. private _isCullDirty;
  30557. private _isZOffsetDirty;
  30558. private _isFrontFaceDirty;
  30559. private _depthTest;
  30560. private _depthMask;
  30561. private _depthFunc;
  30562. private _cull;
  30563. private _cullFace;
  30564. private _zOffset;
  30565. private _frontFace;
  30566. /**
  30567. * Initializes the state.
  30568. */
  30569. constructor();
  30570. get isDirty(): boolean;
  30571. get zOffset(): number;
  30572. set zOffset(value: number);
  30573. get cullFace(): Nullable<number>;
  30574. set cullFace(value: Nullable<number>);
  30575. get cull(): Nullable<boolean>;
  30576. set cull(value: Nullable<boolean>);
  30577. get depthFunc(): Nullable<number>;
  30578. set depthFunc(value: Nullable<number>);
  30579. get depthMask(): boolean;
  30580. set depthMask(value: boolean);
  30581. get depthTest(): boolean;
  30582. set depthTest(value: boolean);
  30583. get frontFace(): Nullable<number>;
  30584. set frontFace(value: Nullable<number>);
  30585. reset(): void;
  30586. apply(gl: WebGLRenderingContext): void;
  30587. }
  30588. }
  30589. declare module BABYLON {
  30590. /**
  30591. * @hidden
  30592. **/
  30593. export class StencilState {
  30594. /** 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 */
  30595. static readonly ALWAYS: number;
  30596. /** Passed to stencilOperation to specify that stencil value must be kept */
  30597. static readonly KEEP: number;
  30598. /** Passed to stencilOperation to specify that stencil value must be replaced */
  30599. static readonly REPLACE: number;
  30600. private _isStencilTestDirty;
  30601. private _isStencilMaskDirty;
  30602. private _isStencilFuncDirty;
  30603. private _isStencilOpDirty;
  30604. private _stencilTest;
  30605. private _stencilMask;
  30606. private _stencilFunc;
  30607. private _stencilFuncRef;
  30608. private _stencilFuncMask;
  30609. private _stencilOpStencilFail;
  30610. private _stencilOpDepthFail;
  30611. private _stencilOpStencilDepthPass;
  30612. get isDirty(): boolean;
  30613. get stencilFunc(): number;
  30614. set stencilFunc(value: number);
  30615. get stencilFuncRef(): number;
  30616. set stencilFuncRef(value: number);
  30617. get stencilFuncMask(): number;
  30618. set stencilFuncMask(value: number);
  30619. get stencilOpStencilFail(): number;
  30620. set stencilOpStencilFail(value: number);
  30621. get stencilOpDepthFail(): number;
  30622. set stencilOpDepthFail(value: number);
  30623. get stencilOpStencilDepthPass(): number;
  30624. set stencilOpStencilDepthPass(value: number);
  30625. get stencilMask(): number;
  30626. set stencilMask(value: number);
  30627. get stencilTest(): boolean;
  30628. set stencilTest(value: boolean);
  30629. constructor();
  30630. reset(): void;
  30631. apply(gl: WebGLRenderingContext): void;
  30632. }
  30633. }
  30634. declare module BABYLON {
  30635. /**
  30636. * @hidden
  30637. **/
  30638. export class AlphaState {
  30639. private _isAlphaBlendDirty;
  30640. private _isBlendFunctionParametersDirty;
  30641. private _isBlendEquationParametersDirty;
  30642. private _isBlendConstantsDirty;
  30643. private _alphaBlend;
  30644. private _blendFunctionParameters;
  30645. private _blendEquationParameters;
  30646. private _blendConstants;
  30647. /**
  30648. * Initializes the state.
  30649. */
  30650. constructor();
  30651. get isDirty(): boolean;
  30652. get alphaBlend(): boolean;
  30653. set alphaBlend(value: boolean);
  30654. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  30655. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  30656. setAlphaEquationParameters(rgb: number, alpha: number): void;
  30657. reset(): void;
  30658. apply(gl: WebGLRenderingContext): void;
  30659. }
  30660. }
  30661. declare module BABYLON {
  30662. /** @hidden */
  30663. export class WebGL2ShaderProcessor implements IShaderProcessor {
  30664. attributeProcessor(attribute: string): string;
  30665. varyingProcessor(varying: string, isFragment: boolean): string;
  30666. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  30667. }
  30668. }
  30669. declare module BABYLON {
  30670. /**
  30671. * Interface for attribute information associated with buffer instanciation
  30672. */
  30673. export interface InstancingAttributeInfo {
  30674. /**
  30675. * Name of the GLSL attribute
  30676. * if attribute index is not specified, this is used to retrieve the index from the effect
  30677. */
  30678. attributeName: string;
  30679. /**
  30680. * Index/offset of the attribute in the vertex shader
  30681. * if not specified, this will be computes from the name.
  30682. */
  30683. index?: number;
  30684. /**
  30685. * size of the attribute, 1, 2, 3 or 4
  30686. */
  30687. attributeSize: number;
  30688. /**
  30689. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  30690. */
  30691. offset: number;
  30692. /**
  30693. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  30694. * default to 1
  30695. */
  30696. divisor?: number;
  30697. /**
  30698. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  30699. * default is FLOAT
  30700. */
  30701. attributeType?: number;
  30702. /**
  30703. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  30704. */
  30705. normalized?: boolean;
  30706. }
  30707. }
  30708. declare module BABYLON {
  30709. interface ThinEngine {
  30710. /**
  30711. * Update a video texture
  30712. * @param texture defines the texture to update
  30713. * @param video defines the video element to use
  30714. * @param invertY defines if data must be stored with Y axis inverted
  30715. */
  30716. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  30717. }
  30718. }
  30719. declare module BABYLON {
  30720. /**
  30721. * Settings for finer control over video usage
  30722. */
  30723. export interface VideoTextureSettings {
  30724. /**
  30725. * Applies `autoplay` to video, if specified
  30726. */
  30727. autoPlay?: boolean;
  30728. /**
  30729. * Applies `loop` to video, if specified
  30730. */
  30731. loop?: boolean;
  30732. /**
  30733. * Automatically updates internal texture from video at every frame in the render loop
  30734. */
  30735. autoUpdateTexture: boolean;
  30736. /**
  30737. * Image src displayed during the video loading or until the user interacts with the video.
  30738. */
  30739. poster?: string;
  30740. }
  30741. /**
  30742. * If you want to display a video in your scene, this is the special texture for that.
  30743. * This special texture works similar to other textures, with the exception of a few parameters.
  30744. * @see https://doc.babylonjs.com/how_to/video_texture
  30745. */
  30746. export class VideoTexture extends Texture {
  30747. /**
  30748. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  30749. */
  30750. readonly autoUpdateTexture: boolean;
  30751. /**
  30752. * The video instance used by the texture internally
  30753. */
  30754. readonly video: HTMLVideoElement;
  30755. private _onUserActionRequestedObservable;
  30756. /**
  30757. * Event triggerd when a dom action is required by the user to play the video.
  30758. * This happens due to recent changes in browser policies preventing video to auto start.
  30759. */
  30760. get onUserActionRequestedObservable(): Observable<Texture>;
  30761. private _generateMipMaps;
  30762. private _engine;
  30763. private _stillImageCaptured;
  30764. private _displayingPosterTexture;
  30765. private _settings;
  30766. private _createInternalTextureOnEvent;
  30767. private _frameId;
  30768. private _currentSrc;
  30769. /**
  30770. * Creates a video texture.
  30771. * If you want to display a video in your scene, this is the special texture for that.
  30772. * This special texture works similar to other textures, with the exception of a few parameters.
  30773. * @see https://doc.babylonjs.com/how_to/video_texture
  30774. * @param name optional name, will detect from video source, if not defined
  30775. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  30776. * @param scene is obviously the current scene.
  30777. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  30778. * @param invertY is false by default but can be used to invert video on Y axis
  30779. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  30780. * @param settings allows finer control over video usage
  30781. */
  30782. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  30783. private _getName;
  30784. private _getVideo;
  30785. private _createInternalTexture;
  30786. private reset;
  30787. /**
  30788. * @hidden Internal method to initiate `update`.
  30789. */
  30790. _rebuild(): void;
  30791. /**
  30792. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  30793. */
  30794. update(): void;
  30795. /**
  30796. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  30797. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  30798. */
  30799. updateTexture(isVisible: boolean): void;
  30800. protected _updateInternalTexture: () => void;
  30801. /**
  30802. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  30803. * @param url New url.
  30804. */
  30805. updateURL(url: string): void;
  30806. /**
  30807. * Clones the texture.
  30808. * @returns the cloned texture
  30809. */
  30810. clone(): VideoTexture;
  30811. /**
  30812. * Dispose the texture and release its associated resources.
  30813. */
  30814. dispose(): void;
  30815. /**
  30816. * Creates a video texture straight from a stream.
  30817. * @param scene Define the scene the texture should be created in
  30818. * @param stream Define the stream the texture should be created from
  30819. * @returns The created video texture as a promise
  30820. */
  30821. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  30822. /**
  30823. * Creates a video texture straight from your WebCam video feed.
  30824. * @param scene Define the scene the texture should be created in
  30825. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30826. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30827. * @returns The created video texture as a promise
  30828. */
  30829. static CreateFromWebCamAsync(scene: Scene, constraints: {
  30830. minWidth: number;
  30831. maxWidth: number;
  30832. minHeight: number;
  30833. maxHeight: number;
  30834. deviceId: string;
  30835. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  30836. /**
  30837. * Creates a video texture straight from your WebCam video feed.
  30838. * @param scene Define the scene the texture should be created in
  30839. * @param onReady Define a callback to triggered once the texture will be ready
  30840. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  30841. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  30842. */
  30843. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  30844. minWidth: number;
  30845. maxWidth: number;
  30846. minHeight: number;
  30847. maxHeight: number;
  30848. deviceId: string;
  30849. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  30850. }
  30851. }
  30852. declare module BABYLON {
  30853. /**
  30854. * Defines the interface used by objects working like Scene
  30855. * @hidden
  30856. */
  30857. interface ISceneLike {
  30858. _addPendingData(data: any): void;
  30859. _removePendingData(data: any): void;
  30860. offlineProvider: IOfflineProvider;
  30861. }
  30862. /** Interface defining initialization parameters for Engine class */
  30863. export interface EngineOptions extends WebGLContextAttributes {
  30864. /**
  30865. * Defines if the engine should no exceed a specified device ratio
  30866. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  30867. */
  30868. limitDeviceRatio?: number;
  30869. /**
  30870. * Defines if webvr should be enabled automatically
  30871. * @see http://doc.babylonjs.com/how_to/webvr_camera
  30872. */
  30873. autoEnableWebVR?: boolean;
  30874. /**
  30875. * Defines if webgl2 should be turned off even if supported
  30876. * @see http://doc.babylonjs.com/features/webgl2
  30877. */
  30878. disableWebGL2Support?: boolean;
  30879. /**
  30880. * Defines if webaudio should be initialized as well
  30881. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30882. */
  30883. audioEngine?: boolean;
  30884. /**
  30885. * Defines if animations should run using a deterministic lock step
  30886. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30887. */
  30888. deterministicLockstep?: boolean;
  30889. /** Defines the maximum steps to use with deterministic lock step mode */
  30890. lockstepMaxSteps?: number;
  30891. /** Defines the seconds between each deterministic lock step */
  30892. timeStep?: number;
  30893. /**
  30894. * Defines that engine should ignore context lost events
  30895. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30896. */
  30897. doNotHandleContextLost?: boolean;
  30898. /**
  30899. * Defines that engine should ignore modifying touch action attribute and style
  30900. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30901. */
  30902. doNotHandleTouchAction?: boolean;
  30903. /**
  30904. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30905. */
  30906. useHighPrecisionFloats?: boolean;
  30907. }
  30908. /**
  30909. * The base engine class (root of all engines)
  30910. */
  30911. export class ThinEngine {
  30912. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30913. static ExceptionList: ({
  30914. key: string;
  30915. capture: string;
  30916. captureConstraint: number;
  30917. targets: string[];
  30918. } | {
  30919. key: string;
  30920. capture: null;
  30921. captureConstraint: null;
  30922. targets: string[];
  30923. })[];
  30924. /** @hidden */
  30925. static _TextureLoaders: IInternalTextureLoader[];
  30926. /**
  30927. * Returns the current npm package of the sdk
  30928. */
  30929. static get NpmPackage(): string;
  30930. /**
  30931. * Returns the current version of the framework
  30932. */
  30933. static get Version(): string;
  30934. /**
  30935. * Returns a string describing the current engine
  30936. */
  30937. get description(): string;
  30938. /**
  30939. * Gets or sets the epsilon value used by collision engine
  30940. */
  30941. static CollisionsEpsilon: number;
  30942. /**
  30943. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30944. */
  30945. static get ShadersRepository(): string;
  30946. static set ShadersRepository(value: string);
  30947. /**
  30948. * Gets or sets the textures that the engine should not attempt to load as compressed
  30949. */
  30950. protected _excludedCompressedTextures: string[];
  30951. /**
  30952. * Filters the compressed texture formats to only include
  30953. * files that are not included in the skippable list
  30954. *
  30955. * @param url the current extension
  30956. * @param textureFormatInUse the current compressed texture format
  30957. * @returns "format" string
  30958. */
  30959. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  30960. /** @hidden */
  30961. _shaderProcessor: IShaderProcessor;
  30962. /**
  30963. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30964. */
  30965. forcePOTTextures: boolean;
  30966. /**
  30967. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30968. */
  30969. isFullscreen: boolean;
  30970. /**
  30971. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30972. */
  30973. cullBackFaces: boolean;
  30974. /**
  30975. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30976. */
  30977. renderEvenInBackground: boolean;
  30978. /**
  30979. * Gets or sets a boolean indicating that cache can be kept between frames
  30980. */
  30981. preventCacheWipeBetweenFrames: boolean;
  30982. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30983. validateShaderPrograms: boolean;
  30984. /**
  30985. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  30986. * This can provide greater z depth for distant objects.
  30987. */
  30988. useReverseDepthBuffer: boolean;
  30989. /**
  30990. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30991. */
  30992. disableUniformBuffers: boolean;
  30993. /** @hidden */
  30994. _uniformBuffers: UniformBuffer[];
  30995. /**
  30996. * Gets a boolean indicating that the engine supports uniform buffers
  30997. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30998. */
  30999. get supportsUniformBuffers(): boolean;
  31000. /** @hidden */
  31001. _gl: WebGLRenderingContext;
  31002. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31003. protected _windowIsBackground: boolean;
  31004. protected _webGLVersion: number;
  31005. protected _creationOptions: EngineOptions;
  31006. protected _highPrecisionShadersAllowed: boolean;
  31007. /** @hidden */
  31008. get _shouldUseHighPrecisionShader(): boolean;
  31009. /**
  31010. * Gets a boolean indicating that only power of 2 textures are supported
  31011. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31012. */
  31013. get needPOTTextures(): boolean;
  31014. /** @hidden */
  31015. _badOS: boolean;
  31016. /** @hidden */
  31017. _badDesktopOS: boolean;
  31018. private _hardwareScalingLevel;
  31019. /** @hidden */
  31020. _caps: EngineCapabilities;
  31021. private _isStencilEnable;
  31022. private _glVersion;
  31023. private _glRenderer;
  31024. private _glVendor;
  31025. /** @hidden */
  31026. _videoTextureSupported: boolean;
  31027. protected _renderingQueueLaunched: boolean;
  31028. protected _activeRenderLoops: (() => void)[];
  31029. /**
  31030. * Observable signaled when a context lost event is raised
  31031. */
  31032. onContextLostObservable: Observable<ThinEngine>;
  31033. /**
  31034. * Observable signaled when a context restored event is raised
  31035. */
  31036. onContextRestoredObservable: Observable<ThinEngine>;
  31037. private _onContextLost;
  31038. private _onContextRestored;
  31039. protected _contextWasLost: boolean;
  31040. /** @hidden */
  31041. _doNotHandleContextLost: boolean;
  31042. /**
  31043. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  31044. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  31045. */
  31046. get doNotHandleContextLost(): boolean;
  31047. set doNotHandleContextLost(value: boolean);
  31048. /**
  31049. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  31050. */
  31051. disableVertexArrayObjects: boolean;
  31052. /** @hidden */
  31053. protected _colorWrite: boolean;
  31054. /** @hidden */
  31055. protected _colorWriteChanged: boolean;
  31056. /** @hidden */
  31057. protected _depthCullingState: DepthCullingState;
  31058. /** @hidden */
  31059. protected _stencilState: StencilState;
  31060. /** @hidden */
  31061. _alphaState: AlphaState;
  31062. /** @hidden */
  31063. _alphaMode: number;
  31064. /** @hidden */
  31065. _alphaEquation: number;
  31066. /** @hidden */
  31067. _internalTexturesCache: InternalTexture[];
  31068. /** @hidden */
  31069. protected _activeChannel: number;
  31070. private _currentTextureChannel;
  31071. /** @hidden */
  31072. protected _boundTexturesCache: {
  31073. [key: string]: Nullable<InternalTexture>;
  31074. };
  31075. /** @hidden */
  31076. protected _currentEffect: Nullable<Effect>;
  31077. /** @hidden */
  31078. protected _currentProgram: Nullable<WebGLProgram>;
  31079. private _compiledEffects;
  31080. private _vertexAttribArraysEnabled;
  31081. /** @hidden */
  31082. protected _cachedViewport: Nullable<IViewportLike>;
  31083. private _cachedVertexArrayObject;
  31084. /** @hidden */
  31085. protected _cachedVertexBuffers: any;
  31086. /** @hidden */
  31087. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  31088. /** @hidden */
  31089. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  31090. /** @hidden */
  31091. _currentRenderTarget: Nullable<InternalTexture>;
  31092. private _uintIndicesCurrentlySet;
  31093. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  31094. /** @hidden */
  31095. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  31096. private _currentBufferPointers;
  31097. private _currentInstanceLocations;
  31098. private _currentInstanceBuffers;
  31099. private _textureUnits;
  31100. /** @hidden */
  31101. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  31102. /** @hidden */
  31103. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  31104. /** @hidden */
  31105. _boundRenderFunction: any;
  31106. private _vaoRecordInProgress;
  31107. private _mustWipeVertexAttributes;
  31108. private _emptyTexture;
  31109. private _emptyCubeTexture;
  31110. private _emptyTexture3D;
  31111. private _emptyTexture2DArray;
  31112. /** @hidden */
  31113. _frameHandler: number;
  31114. private _nextFreeTextureSlots;
  31115. private _maxSimultaneousTextures;
  31116. private _activeRequests;
  31117. protected _texturesSupported: string[];
  31118. /** @hidden */
  31119. _textureFormatInUse: Nullable<string>;
  31120. protected get _supportsHardwareTextureRescaling(): boolean;
  31121. /**
  31122. * Gets the list of texture formats supported
  31123. */
  31124. get texturesSupported(): Array<string>;
  31125. /**
  31126. * Gets the list of texture formats in use
  31127. */
  31128. get textureFormatInUse(): Nullable<string>;
  31129. /**
  31130. * Gets the current viewport
  31131. */
  31132. get currentViewport(): Nullable<IViewportLike>;
  31133. /**
  31134. * Gets the default empty texture
  31135. */
  31136. get emptyTexture(): InternalTexture;
  31137. /**
  31138. * Gets the default empty 3D texture
  31139. */
  31140. get emptyTexture3D(): InternalTexture;
  31141. /**
  31142. * Gets the default empty 2D array texture
  31143. */
  31144. get emptyTexture2DArray(): InternalTexture;
  31145. /**
  31146. * Gets the default empty cube texture
  31147. */
  31148. get emptyCubeTexture(): InternalTexture;
  31149. /**
  31150. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  31151. */
  31152. readonly premultipliedAlpha: boolean;
  31153. /**
  31154. * Observable event triggered before each texture is initialized
  31155. */
  31156. onBeforeTextureInitObservable: Observable<Texture>;
  31157. /**
  31158. * Creates a new engine
  31159. * @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
  31160. * @param antialias defines enable antialiasing (default: false)
  31161. * @param options defines further options to be sent to the getContext() function
  31162. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  31163. */
  31164. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  31165. private _rebuildInternalTextures;
  31166. private _rebuildEffects;
  31167. /**
  31168. * Gets a boolean indicating if all created effects are ready
  31169. * @returns true if all effects are ready
  31170. */
  31171. areAllEffectsReady(): boolean;
  31172. protected _rebuildBuffers(): void;
  31173. private _initGLContext;
  31174. /**
  31175. * Gets version of the current webGL context
  31176. */
  31177. get webGLVersion(): number;
  31178. /**
  31179. * Gets a string idenfifying the name of the class
  31180. * @returns "Engine" string
  31181. */
  31182. getClassName(): string;
  31183. /**
  31184. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  31185. */
  31186. get isStencilEnable(): boolean;
  31187. /** @hidden */
  31188. _prepareWorkingCanvas(): void;
  31189. /**
  31190. * Reset the texture cache to empty state
  31191. */
  31192. resetTextureCache(): void;
  31193. /**
  31194. * Gets an object containing information about the current webGL context
  31195. * @returns an object containing the vender, the renderer and the version of the current webGL context
  31196. */
  31197. getGlInfo(): {
  31198. vendor: string;
  31199. renderer: string;
  31200. version: string;
  31201. };
  31202. /**
  31203. * Defines the hardware scaling level.
  31204. * By default the hardware scaling level is computed from the window device ratio.
  31205. * 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.
  31206. * @param level defines the level to use
  31207. */
  31208. setHardwareScalingLevel(level: number): void;
  31209. /**
  31210. * Gets the current hardware scaling level.
  31211. * By default the hardware scaling level is computed from the window device ratio.
  31212. * 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.
  31213. * @returns a number indicating the current hardware scaling level
  31214. */
  31215. getHardwareScalingLevel(): number;
  31216. /**
  31217. * Gets the list of loaded textures
  31218. * @returns an array containing all loaded textures
  31219. */
  31220. getLoadedTexturesCache(): InternalTexture[];
  31221. /**
  31222. * Gets the object containing all engine capabilities
  31223. * @returns the EngineCapabilities object
  31224. */
  31225. getCaps(): EngineCapabilities;
  31226. /**
  31227. * stop executing a render loop function and remove it from the execution array
  31228. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  31229. */
  31230. stopRenderLoop(renderFunction?: () => void): void;
  31231. /** @hidden */
  31232. _renderLoop(): void;
  31233. /**
  31234. * Gets the HTML canvas attached with the current webGL context
  31235. * @returns a HTML canvas
  31236. */
  31237. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  31238. /**
  31239. * Gets host window
  31240. * @returns the host window object
  31241. */
  31242. getHostWindow(): Nullable<Window>;
  31243. /**
  31244. * Gets the current render width
  31245. * @param useScreen defines if screen size must be used (or the current render target if any)
  31246. * @returns a number defining the current render width
  31247. */
  31248. getRenderWidth(useScreen?: boolean): number;
  31249. /**
  31250. * Gets the current render height
  31251. * @param useScreen defines if screen size must be used (or the current render target if any)
  31252. * @returns a number defining the current render height
  31253. */
  31254. getRenderHeight(useScreen?: boolean): number;
  31255. /**
  31256. * Can be used to override the current requestAnimationFrame requester.
  31257. * @hidden
  31258. */
  31259. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  31260. /**
  31261. * Register and execute a render loop. The engine can have more than one render function
  31262. * @param renderFunction defines the function to continuously execute
  31263. */
  31264. runRenderLoop(renderFunction: () => void): void;
  31265. /**
  31266. * Clear the current render buffer or the current render target (if any is set up)
  31267. * @param color defines the color to use
  31268. * @param backBuffer defines if the back buffer must be cleared
  31269. * @param depth defines if the depth buffer must be cleared
  31270. * @param stencil defines if the stencil buffer must be cleared
  31271. */
  31272. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  31273. private _viewportCached;
  31274. /** @hidden */
  31275. _viewport(x: number, y: number, width: number, height: number): void;
  31276. /**
  31277. * Set the WebGL's viewport
  31278. * @param viewport defines the viewport element to be used
  31279. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  31280. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  31281. */
  31282. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  31283. /**
  31284. * Begin a new frame
  31285. */
  31286. beginFrame(): void;
  31287. /**
  31288. * Enf the current frame
  31289. */
  31290. endFrame(): void;
  31291. /**
  31292. * Resize the view according to the canvas' size
  31293. */
  31294. resize(): void;
  31295. /**
  31296. * Force a specific size of the canvas
  31297. * @param width defines the new canvas' width
  31298. * @param height defines the new canvas' height
  31299. */
  31300. setSize(width: number, height: number): void;
  31301. /**
  31302. * Binds the frame buffer to the specified texture.
  31303. * @param texture The texture to render to or null for the default canvas
  31304. * @param faceIndex The face of the texture to render to in case of cube texture
  31305. * @param requiredWidth The width of the target to render to
  31306. * @param requiredHeight The height of the target to render to
  31307. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  31308. * @param lodLevel defines the lod level to bind to the frame buffer
  31309. * @param layer defines the 2d array index to bind to frame buffer to
  31310. */
  31311. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  31312. /** @hidden */
  31313. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  31314. /**
  31315. * Unbind the current render target texture from the webGL context
  31316. * @param texture defines the render target texture to unbind
  31317. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  31318. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  31319. */
  31320. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  31321. /**
  31322. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  31323. */
  31324. flushFramebuffer(): void;
  31325. /**
  31326. * Unbind the current render target and bind the default framebuffer
  31327. */
  31328. restoreDefaultFramebuffer(): void;
  31329. /** @hidden */
  31330. protected _resetVertexBufferBinding(): void;
  31331. /**
  31332. * Creates a vertex buffer
  31333. * @param data the data for the vertex buffer
  31334. * @returns the new WebGL static buffer
  31335. */
  31336. createVertexBuffer(data: DataArray): DataBuffer;
  31337. private _createVertexBuffer;
  31338. /**
  31339. * Creates a dynamic vertex buffer
  31340. * @param data the data for the dynamic vertex buffer
  31341. * @returns the new WebGL dynamic buffer
  31342. */
  31343. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  31344. protected _resetIndexBufferBinding(): void;
  31345. /**
  31346. * Creates a new index buffer
  31347. * @param indices defines the content of the index buffer
  31348. * @param updatable defines if the index buffer must be updatable
  31349. * @returns a new webGL buffer
  31350. */
  31351. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  31352. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  31353. /**
  31354. * Bind a webGL buffer to the webGL context
  31355. * @param buffer defines the buffer to bind
  31356. */
  31357. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  31358. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  31359. private bindBuffer;
  31360. /**
  31361. * update the bound buffer with the given data
  31362. * @param data defines the data to update
  31363. */
  31364. updateArrayBuffer(data: Float32Array): void;
  31365. private _vertexAttribPointer;
  31366. /** @hidden */
  31367. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  31368. private _bindVertexBuffersAttributes;
  31369. /**
  31370. * Records a vertex array object
  31371. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31372. * @param vertexBuffers defines the list of vertex buffers to store
  31373. * @param indexBuffer defines the index buffer to store
  31374. * @param effect defines the effect to store
  31375. * @returns the new vertex array object
  31376. */
  31377. recordVertexArrayObject(vertexBuffers: {
  31378. [key: string]: VertexBuffer;
  31379. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  31380. /**
  31381. * Bind a specific vertex array object
  31382. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  31383. * @param vertexArrayObject defines the vertex array object to bind
  31384. * @param indexBuffer defines the index buffer to bind
  31385. */
  31386. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  31387. /**
  31388. * Bind webGl buffers directly to the webGL context
  31389. * @param vertexBuffer defines the vertex buffer to bind
  31390. * @param indexBuffer defines the index buffer to bind
  31391. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  31392. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  31393. * @param effect defines the effect associated with the vertex buffer
  31394. */
  31395. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  31396. private _unbindVertexArrayObject;
  31397. /**
  31398. * Bind a list of vertex buffers to the webGL context
  31399. * @param vertexBuffers defines the list of vertex buffers to bind
  31400. * @param indexBuffer defines the index buffer to bind
  31401. * @param effect defines the effect associated with the vertex buffers
  31402. */
  31403. bindBuffers(vertexBuffers: {
  31404. [key: string]: Nullable<VertexBuffer>;
  31405. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  31406. /**
  31407. * Unbind all instance attributes
  31408. */
  31409. unbindInstanceAttributes(): void;
  31410. /**
  31411. * Release and free the memory of a vertex array object
  31412. * @param vao defines the vertex array object to delete
  31413. */
  31414. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  31415. /** @hidden */
  31416. _releaseBuffer(buffer: DataBuffer): boolean;
  31417. protected _deleteBuffer(buffer: DataBuffer): void;
  31418. /**
  31419. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  31420. * @param instancesBuffer defines the webGL buffer to update and bind
  31421. * @param data defines the data to store in the buffer
  31422. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  31423. */
  31424. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  31425. /**
  31426. * Bind the content of a webGL buffer used with instantiation
  31427. * @param instancesBuffer defines the webGL buffer to bind
  31428. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  31429. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  31430. */
  31431. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  31432. /**
  31433. * Disable the instance attribute corresponding to the name in parameter
  31434. * @param name defines the name of the attribute to disable
  31435. */
  31436. disableInstanceAttributeByName(name: string): void;
  31437. /**
  31438. * Disable the instance attribute corresponding to the location in parameter
  31439. * @param attributeLocation defines the attribute location of the attribute to disable
  31440. */
  31441. disableInstanceAttribute(attributeLocation: number): void;
  31442. /**
  31443. * Disable the attribute corresponding to the location in parameter
  31444. * @param attributeLocation defines the attribute location of the attribute to disable
  31445. */
  31446. disableAttributeByIndex(attributeLocation: number): void;
  31447. /**
  31448. * Send a draw order
  31449. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31450. * @param indexStart defines the starting index
  31451. * @param indexCount defines the number of index to draw
  31452. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31453. */
  31454. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  31455. /**
  31456. * Draw a list of points
  31457. * @param verticesStart defines the index of first vertex to draw
  31458. * @param verticesCount defines the count of vertices to draw
  31459. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31460. */
  31461. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31462. /**
  31463. * Draw a list of unindexed primitives
  31464. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  31465. * @param verticesStart defines the index of first vertex to draw
  31466. * @param verticesCount defines the count of vertices to draw
  31467. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31468. */
  31469. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31470. /**
  31471. * Draw a list of indexed primitives
  31472. * @param fillMode defines the primitive to use
  31473. * @param indexStart defines the starting index
  31474. * @param indexCount defines the number of index to draw
  31475. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31476. */
  31477. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  31478. /**
  31479. * Draw a list of unindexed primitives
  31480. * @param fillMode defines the primitive to use
  31481. * @param verticesStart defines the index of first vertex to draw
  31482. * @param verticesCount defines the count of vertices to draw
  31483. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  31484. */
  31485. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  31486. private _drawMode;
  31487. /** @hidden */
  31488. protected _reportDrawCall(): void;
  31489. /** @hidden */
  31490. _releaseEffect(effect: Effect): void;
  31491. /** @hidden */
  31492. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  31493. /**
  31494. * Create a new effect (used to store vertex/fragment shaders)
  31495. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  31496. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  31497. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  31498. * @param samplers defines an array of string used to represent textures
  31499. * @param defines defines the string containing the defines to use to compile the shaders
  31500. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  31501. * @param onCompiled defines a function to call when the effect creation is successful
  31502. * @param onError defines a function to call when the effect creation has failed
  31503. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  31504. * @returns the new Effect
  31505. */
  31506. 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;
  31507. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  31508. private _compileShader;
  31509. private _compileRawShader;
  31510. /**
  31511. * Directly creates a webGL program
  31512. * @param pipelineContext defines the pipeline context to attach to
  31513. * @param vertexCode defines the vertex shader code to use
  31514. * @param fragmentCode defines the fragment shader code to use
  31515. * @param context defines the webGL context to use (if not set, the current one will be used)
  31516. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31517. * @returns the new webGL program
  31518. */
  31519. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31520. /**
  31521. * Creates a webGL program
  31522. * @param pipelineContext defines the pipeline context to attach to
  31523. * @param vertexCode defines the vertex shader code to use
  31524. * @param fragmentCode defines the fragment shader code to use
  31525. * @param defines defines the string containing the defines to use to compile the shaders
  31526. * @param context defines the webGL context to use (if not set, the current one will be used)
  31527. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  31528. * @returns the new webGL program
  31529. */
  31530. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31531. /**
  31532. * Creates a new pipeline context
  31533. * @returns the new pipeline
  31534. */
  31535. createPipelineContext(): IPipelineContext;
  31536. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  31537. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  31538. /** @hidden */
  31539. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  31540. /** @hidden */
  31541. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  31542. /** @hidden */
  31543. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  31544. /**
  31545. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  31546. * @param pipelineContext defines the pipeline context to use
  31547. * @param uniformsNames defines the list of uniform names
  31548. * @returns an array of webGL uniform locations
  31549. */
  31550. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  31551. /**
  31552. * Gets the lsit of active attributes for a given webGL program
  31553. * @param pipelineContext defines the pipeline context to use
  31554. * @param attributesNames defines the list of attribute names to get
  31555. * @returns an array of indices indicating the offset of each attribute
  31556. */
  31557. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  31558. /**
  31559. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  31560. * @param effect defines the effect to activate
  31561. */
  31562. enableEffect(effect: Nullable<Effect>): void;
  31563. /**
  31564. * Set the value of an uniform to a number (int)
  31565. * @param uniform defines the webGL uniform location where to store the value
  31566. * @param value defines the int number to store
  31567. */
  31568. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31569. /**
  31570. * Set the value of an uniform to an array of int32
  31571. * @param uniform defines the webGL uniform location where to store the value
  31572. * @param array defines the array of int32 to store
  31573. */
  31574. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31575. /**
  31576. * Set the value of an uniform to an array of int32 (stored as vec2)
  31577. * @param uniform defines the webGL uniform location where to store the value
  31578. * @param array defines the array of int32 to store
  31579. */
  31580. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31581. /**
  31582. * Set the value of an uniform to an array of int32 (stored as vec3)
  31583. * @param uniform defines the webGL uniform location where to store the value
  31584. * @param array defines the array of int32 to store
  31585. */
  31586. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31587. /**
  31588. * Set the value of an uniform to an array of int32 (stored as vec4)
  31589. * @param uniform defines the webGL uniform location where to store the value
  31590. * @param array defines the array of int32 to store
  31591. */
  31592. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  31593. /**
  31594. * Set the value of an uniform to an array of number
  31595. * @param uniform defines the webGL uniform location where to store the value
  31596. * @param array defines the array of number to store
  31597. */
  31598. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31599. /**
  31600. * Set the value of an uniform to an array of number (stored as vec2)
  31601. * @param uniform defines the webGL uniform location where to store the value
  31602. * @param array defines the array of number to store
  31603. */
  31604. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31605. /**
  31606. * Set the value of an uniform to an array of number (stored as vec3)
  31607. * @param uniform defines the webGL uniform location where to store the value
  31608. * @param array defines the array of number to store
  31609. */
  31610. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31611. /**
  31612. * Set the value of an uniform to an array of number (stored as vec4)
  31613. * @param uniform defines the webGL uniform location where to store the value
  31614. * @param array defines the array of number to store
  31615. */
  31616. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  31617. /**
  31618. * Set the value of an uniform to an array of float32 (stored as matrices)
  31619. * @param uniform defines the webGL uniform location where to store the value
  31620. * @param matrices defines the array of float32 to store
  31621. */
  31622. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  31623. /**
  31624. * Set the value of an uniform to a matrix (3x3)
  31625. * @param uniform defines the webGL uniform location where to store the value
  31626. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  31627. */
  31628. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31629. /**
  31630. * Set the value of an uniform to a matrix (2x2)
  31631. * @param uniform defines the webGL uniform location where to store the value
  31632. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  31633. */
  31634. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  31635. /**
  31636. * Set the value of an uniform to a number (float)
  31637. * @param uniform defines the webGL uniform location where to store the value
  31638. * @param value defines the float number to store
  31639. */
  31640. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  31641. /**
  31642. * Set the value of an uniform to a vec2
  31643. * @param uniform defines the webGL uniform location where to store the value
  31644. * @param x defines the 1st component of the value
  31645. * @param y defines the 2nd component of the value
  31646. */
  31647. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  31648. /**
  31649. * Set the value of an uniform to a vec3
  31650. * @param uniform defines the webGL uniform location where to store the value
  31651. * @param x defines the 1st component of the value
  31652. * @param y defines the 2nd component of the value
  31653. * @param z defines the 3rd component of the value
  31654. */
  31655. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  31656. /**
  31657. * Set the value of an uniform to a vec4
  31658. * @param uniform defines the webGL uniform location where to store the value
  31659. * @param x defines the 1st component of the value
  31660. * @param y defines the 2nd component of the value
  31661. * @param z defines the 3rd component of the value
  31662. * @param w defines the 4th component of the value
  31663. */
  31664. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  31665. /**
  31666. * Apply all cached states (depth, culling, stencil and alpha)
  31667. */
  31668. applyStates(): void;
  31669. /**
  31670. * Enable or disable color writing
  31671. * @param enable defines the state to set
  31672. */
  31673. setColorWrite(enable: boolean): void;
  31674. /**
  31675. * Gets a boolean indicating if color writing is enabled
  31676. * @returns the current color writing state
  31677. */
  31678. getColorWrite(): boolean;
  31679. /**
  31680. * Gets the depth culling state manager
  31681. */
  31682. get depthCullingState(): DepthCullingState;
  31683. /**
  31684. * Gets the alpha state manager
  31685. */
  31686. get alphaState(): AlphaState;
  31687. /**
  31688. * Gets the stencil state manager
  31689. */
  31690. get stencilState(): StencilState;
  31691. /**
  31692. * Clears the list of texture accessible through engine.
  31693. * This can help preventing texture load conflict due to name collision.
  31694. */
  31695. clearInternalTexturesCache(): void;
  31696. /**
  31697. * Force the entire cache to be cleared
  31698. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  31699. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  31700. */
  31701. wipeCaches(bruteForce?: boolean): void;
  31702. /** @hidden */
  31703. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  31704. min: number;
  31705. mag: number;
  31706. };
  31707. /** @hidden */
  31708. _createTexture(): WebGLTexture;
  31709. /**
  31710. * Usually called from Texture.ts.
  31711. * Passed information to create a WebGLTexture
  31712. * @param urlArg defines a value which contains one of the following:
  31713. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  31714. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  31715. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  31716. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  31717. * @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)
  31718. * @param scene needed for loading to the correct scene
  31719. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  31720. * @param onLoad optional callback to be called upon successful completion
  31721. * @param onError optional callback to be called upon failure
  31722. * @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
  31723. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  31724. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  31725. * @param forcedExtension defines the extension to use to pick the right loader
  31726. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  31727. * @param mimeType defines an optional mime type
  31728. * @returns a InternalTexture for assignment back into BABYLON.Texture
  31729. */
  31730. 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;
  31731. /**
  31732. * Loads an image as an HTMLImageElement.
  31733. * @param input url string, ArrayBuffer, or Blob to load
  31734. * @param onLoad callback called when the image successfully loads
  31735. * @param onError callback called when the image fails to load
  31736. * @param offlineProvider offline provider for caching
  31737. * @param mimeType optional mime type
  31738. * @returns the HTMLImageElement of the loaded image
  31739. * @hidden
  31740. */
  31741. 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>;
  31742. /**
  31743. * @hidden
  31744. */
  31745. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  31746. /**
  31747. * Creates a raw texture
  31748. * @param data defines the data to store in the texture
  31749. * @param width defines the width of the texture
  31750. * @param height defines the height of the texture
  31751. * @param format defines the format of the data
  31752. * @param generateMipMaps defines if the engine should generate the mip levels
  31753. * @param invertY defines if data must be stored with Y axis inverted
  31754. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31755. * @param compression defines the compression used (null by default)
  31756. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31757. * @returns the raw texture inside an InternalTexture
  31758. */
  31759. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  31760. /**
  31761. * Creates a new raw cube texture
  31762. * @param data defines the array of data to use to create each face
  31763. * @param size defines the size of the textures
  31764. * @param format defines the format of the data
  31765. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  31766. * @param generateMipMaps defines if the engine should generate the mip levels
  31767. * @param invertY defines if data must be stored with Y axis inverted
  31768. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31769. * @param compression defines the compression used (null by default)
  31770. * @returns the cube texture as an InternalTexture
  31771. */
  31772. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  31773. /**
  31774. * Creates a new raw 3D texture
  31775. * @param data defines the data used to create the texture
  31776. * @param width defines the width of the texture
  31777. * @param height defines the height of the texture
  31778. * @param depth defines the depth of the texture
  31779. * @param format defines the format of the texture
  31780. * @param generateMipMaps defines if the engine must generate mip levels
  31781. * @param invertY defines if data must be stored with Y axis inverted
  31782. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31783. * @param compression defines the compressed used (can be null)
  31784. * @param textureType defines the compressed used (can be null)
  31785. * @returns a new raw 3D texture (stored in an InternalTexture)
  31786. */
  31787. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31788. /**
  31789. * Creates a new raw 2D array texture
  31790. * @param data defines the data used to create the texture
  31791. * @param width defines the width of the texture
  31792. * @param height defines the height of the texture
  31793. * @param depth defines the number of layers of the texture
  31794. * @param format defines the format of the texture
  31795. * @param generateMipMaps defines if the engine must generate mip levels
  31796. * @param invertY defines if data must be stored with Y axis inverted
  31797. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  31798. * @param compression defines the compressed used (can be null)
  31799. * @param textureType defines the compressed used (can be null)
  31800. * @returns a new raw 2D array texture (stored in an InternalTexture)
  31801. */
  31802. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  31803. private _unpackFlipYCached;
  31804. /**
  31805. * In case you are sharing the context with other applications, it might
  31806. * be interested to not cache the unpack flip y state to ensure a consistent
  31807. * value would be set.
  31808. */
  31809. enableUnpackFlipYCached: boolean;
  31810. /** @hidden */
  31811. _unpackFlipY(value: boolean): void;
  31812. /** @hidden */
  31813. _getUnpackAlignement(): number;
  31814. private _getTextureTarget;
  31815. /**
  31816. * Update the sampling mode of a given texture
  31817. * @param samplingMode defines the required sampling mode
  31818. * @param texture defines the texture to update
  31819. * @param generateMipMaps defines whether to generate mipmaps for the texture
  31820. */
  31821. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  31822. /**
  31823. * Update the sampling mode of a given texture
  31824. * @param texture defines the texture to update
  31825. * @param wrapU defines the texture wrap mode of the u coordinates
  31826. * @param wrapV defines the texture wrap mode of the v coordinates
  31827. * @param wrapR defines the texture wrap mode of the r coordinates
  31828. */
  31829. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  31830. /** @hidden */
  31831. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  31832. width: number;
  31833. height: number;
  31834. layers?: number;
  31835. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  31836. /** @hidden */
  31837. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31838. /** @hidden */
  31839. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  31840. /**
  31841. * Update a portion of an internal texture
  31842. * @param texture defines the texture to update
  31843. * @param imageData defines the data to store into the texture
  31844. * @param xOffset defines the x coordinates of the update rectangle
  31845. * @param yOffset defines the y coordinates of the update rectangle
  31846. * @param width defines the width of the update rectangle
  31847. * @param height defines the height of the update rectangle
  31848. * @param faceIndex defines the face index if texture is a cube (0 by default)
  31849. * @param lod defines the lod level to update (0 by default)
  31850. */
  31851. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  31852. /** @hidden */
  31853. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  31854. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  31855. private _prepareWebGLTexture;
  31856. /** @hidden */
  31857. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  31858. private _getDepthStencilBuffer;
  31859. /** @hidden */
  31860. _releaseFramebufferObjects(texture: InternalTexture): void;
  31861. /** @hidden */
  31862. _releaseTexture(texture: InternalTexture): void;
  31863. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  31864. protected _setProgram(program: WebGLProgram): void;
  31865. protected _boundUniforms: {
  31866. [key: number]: WebGLUniformLocation;
  31867. };
  31868. /**
  31869. * Binds an effect to the webGL context
  31870. * @param effect defines the effect to bind
  31871. */
  31872. bindSamplers(effect: Effect): void;
  31873. private _activateCurrentTexture;
  31874. /** @hidden */
  31875. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  31876. /** @hidden */
  31877. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  31878. /**
  31879. * Unbind all textures from the webGL context
  31880. */
  31881. unbindAllTextures(): void;
  31882. /**
  31883. * Sets a texture to the according uniform.
  31884. * @param channel The texture channel
  31885. * @param uniform The uniform to set
  31886. * @param texture The texture to apply
  31887. */
  31888. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  31889. private _bindSamplerUniformToChannel;
  31890. private _getTextureWrapMode;
  31891. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  31892. /**
  31893. * Sets an array of texture to the webGL context
  31894. * @param channel defines the channel where the texture array must be set
  31895. * @param uniform defines the associated uniform location
  31896. * @param textures defines the array of textures to bind
  31897. */
  31898. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  31899. /** @hidden */
  31900. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  31901. private _setTextureParameterFloat;
  31902. private _setTextureParameterInteger;
  31903. /**
  31904. * Unbind all vertex attributes from the webGL context
  31905. */
  31906. unbindAllAttributes(): void;
  31907. /**
  31908. * 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
  31909. */
  31910. releaseEffects(): void;
  31911. /**
  31912. * Dispose and release all associated resources
  31913. */
  31914. dispose(): void;
  31915. /**
  31916. * Attach a new callback raised when context lost event is fired
  31917. * @param callback defines the callback to call
  31918. */
  31919. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31920. /**
  31921. * Attach a new callback raised when context restored event is fired
  31922. * @param callback defines the callback to call
  31923. */
  31924. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31925. /**
  31926. * Get the current error code of the webGL context
  31927. * @returns the error code
  31928. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31929. */
  31930. getError(): number;
  31931. private _canRenderToFloatFramebuffer;
  31932. private _canRenderToHalfFloatFramebuffer;
  31933. private _canRenderToFramebuffer;
  31934. /** @hidden */
  31935. _getWebGLTextureType(type: number): number;
  31936. /** @hidden */
  31937. _getInternalFormat(format: number): number;
  31938. /** @hidden */
  31939. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31940. /** @hidden */
  31941. _getRGBAMultiSampleBufferFormat(type: number): number;
  31942. /** @hidden */
  31943. _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;
  31944. /**
  31945. * Loads a file from a url
  31946. * @param url url to load
  31947. * @param onSuccess callback called when the file successfully loads
  31948. * @param onProgress callback called while file is loading (if the server supports this mode)
  31949. * @param offlineProvider defines the offline provider for caching
  31950. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31951. * @param onError callback called when the file fails to load
  31952. * @returns a file request object
  31953. * @hidden
  31954. */
  31955. 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;
  31956. /**
  31957. * Reads pixels from the current frame buffer. Please note that this function can be slow
  31958. * @param x defines the x coordinate of the rectangle where pixels must be read
  31959. * @param y defines the y coordinate of the rectangle where pixels must be read
  31960. * @param width defines the width of the rectangle where pixels must be read
  31961. * @param height defines the height of the rectangle where pixels must be read
  31962. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  31963. * @returns a Uint8Array containing RGBA colors
  31964. */
  31965. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  31966. private static _isSupported;
  31967. /**
  31968. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  31969. * @returns true if the engine can be created
  31970. * @ignorenaming
  31971. */
  31972. static isSupported(): boolean;
  31973. /**
  31974. * Find the next highest power of two.
  31975. * @param x Number to start search from.
  31976. * @return Next highest power of two.
  31977. */
  31978. static CeilingPOT(x: number): number;
  31979. /**
  31980. * Find the next lowest power of two.
  31981. * @param x Number to start search from.
  31982. * @return Next lowest power of two.
  31983. */
  31984. static FloorPOT(x: number): number;
  31985. /**
  31986. * Find the nearest power of two.
  31987. * @param x Number to start search from.
  31988. * @return Next nearest power of two.
  31989. */
  31990. static NearestPOT(x: number): number;
  31991. /**
  31992. * Get the closest exponent of two
  31993. * @param value defines the value to approximate
  31994. * @param max defines the maximum value to return
  31995. * @param mode defines how to define the closest value
  31996. * @returns closest exponent of two of the given value
  31997. */
  31998. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31999. /**
  32000. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32001. * @param func - the function to be called
  32002. * @param requester - the object that will request the next frame. Falls back to window.
  32003. * @returns frame number
  32004. */
  32005. static QueueNewFrame(func: () => void, requester?: any): number;
  32006. /**
  32007. * Gets host document
  32008. * @returns the host document object
  32009. */
  32010. getHostDocument(): Nullable<Document>;
  32011. }
  32012. }
  32013. declare module BABYLON {
  32014. /**
  32015. * Class representing spherical harmonics coefficients to the 3rd degree
  32016. */
  32017. export class SphericalHarmonics {
  32018. /**
  32019. * Defines whether or not the harmonics have been prescaled for rendering.
  32020. */
  32021. preScaled: boolean;
  32022. /**
  32023. * The l0,0 coefficients of the spherical harmonics
  32024. */
  32025. l00: Vector3;
  32026. /**
  32027. * The l1,-1 coefficients of the spherical harmonics
  32028. */
  32029. l1_1: Vector3;
  32030. /**
  32031. * The l1,0 coefficients of the spherical harmonics
  32032. */
  32033. l10: Vector3;
  32034. /**
  32035. * The l1,1 coefficients of the spherical harmonics
  32036. */
  32037. l11: Vector3;
  32038. /**
  32039. * The l2,-2 coefficients of the spherical harmonics
  32040. */
  32041. l2_2: Vector3;
  32042. /**
  32043. * The l2,-1 coefficients of the spherical harmonics
  32044. */
  32045. l2_1: Vector3;
  32046. /**
  32047. * The l2,0 coefficients of the spherical harmonics
  32048. */
  32049. l20: Vector3;
  32050. /**
  32051. * The l2,1 coefficients of the spherical harmonics
  32052. */
  32053. l21: Vector3;
  32054. /**
  32055. * The l2,2 coefficients of the spherical harmonics
  32056. */
  32057. l22: Vector3;
  32058. /**
  32059. * Adds a light to the spherical harmonics
  32060. * @param direction the direction of the light
  32061. * @param color the color of the light
  32062. * @param deltaSolidAngle the delta solid angle of the light
  32063. */
  32064. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  32065. /**
  32066. * Scales the spherical harmonics by the given amount
  32067. * @param scale the amount to scale
  32068. */
  32069. scaleInPlace(scale: number): void;
  32070. /**
  32071. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  32072. *
  32073. * ```
  32074. * E_lm = A_l * L_lm
  32075. * ```
  32076. *
  32077. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  32078. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  32079. * the scaling factors are given in equation 9.
  32080. */
  32081. convertIncidentRadianceToIrradiance(): void;
  32082. /**
  32083. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  32084. *
  32085. * ```
  32086. * L = (1/pi) * E * rho
  32087. * ```
  32088. *
  32089. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  32090. */
  32091. convertIrradianceToLambertianRadiance(): void;
  32092. /**
  32093. * Integrates the reconstruction coefficients directly in to the SH preventing further
  32094. * required operations at run time.
  32095. *
  32096. * This is simply done by scaling back the SH with Ylm constants parameter.
  32097. * The trigonometric part being applied by the shader at run time.
  32098. */
  32099. preScaleForRendering(): void;
  32100. /**
  32101. * Constructs a spherical harmonics from an array.
  32102. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  32103. * @returns the spherical harmonics
  32104. */
  32105. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  32106. /**
  32107. * Gets the spherical harmonics from polynomial
  32108. * @param polynomial the spherical polynomial
  32109. * @returns the spherical harmonics
  32110. */
  32111. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  32112. }
  32113. /**
  32114. * Class representing spherical polynomial coefficients to the 3rd degree
  32115. */
  32116. export class SphericalPolynomial {
  32117. private _harmonics;
  32118. /**
  32119. * The spherical harmonics used to create the polynomials.
  32120. */
  32121. get preScaledHarmonics(): SphericalHarmonics;
  32122. /**
  32123. * The x coefficients of the spherical polynomial
  32124. */
  32125. x: Vector3;
  32126. /**
  32127. * The y coefficients of the spherical polynomial
  32128. */
  32129. y: Vector3;
  32130. /**
  32131. * The z coefficients of the spherical polynomial
  32132. */
  32133. z: Vector3;
  32134. /**
  32135. * The xx coefficients of the spherical polynomial
  32136. */
  32137. xx: Vector3;
  32138. /**
  32139. * The yy coefficients of the spherical polynomial
  32140. */
  32141. yy: Vector3;
  32142. /**
  32143. * The zz coefficients of the spherical polynomial
  32144. */
  32145. zz: Vector3;
  32146. /**
  32147. * The xy coefficients of the spherical polynomial
  32148. */
  32149. xy: Vector3;
  32150. /**
  32151. * The yz coefficients of the spherical polynomial
  32152. */
  32153. yz: Vector3;
  32154. /**
  32155. * The zx coefficients of the spherical polynomial
  32156. */
  32157. zx: Vector3;
  32158. /**
  32159. * Adds an ambient color to the spherical polynomial
  32160. * @param color the color to add
  32161. */
  32162. addAmbient(color: Color3): void;
  32163. /**
  32164. * Scales the spherical polynomial by the given amount
  32165. * @param scale the amount to scale
  32166. */
  32167. scaleInPlace(scale: number): void;
  32168. /**
  32169. * Gets the spherical polynomial from harmonics
  32170. * @param harmonics the spherical harmonics
  32171. * @returns the spherical polynomial
  32172. */
  32173. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  32174. /**
  32175. * Constructs a spherical polynomial from an array.
  32176. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  32177. * @returns the spherical polynomial
  32178. */
  32179. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  32180. }
  32181. }
  32182. declare module BABYLON {
  32183. /**
  32184. * Defines the source of the internal texture
  32185. */
  32186. export enum InternalTextureSource {
  32187. /**
  32188. * The source of the texture data is unknown
  32189. */
  32190. Unknown = 0,
  32191. /**
  32192. * Texture data comes from an URL
  32193. */
  32194. Url = 1,
  32195. /**
  32196. * Texture data is only used for temporary storage
  32197. */
  32198. Temp = 2,
  32199. /**
  32200. * Texture data comes from raw data (ArrayBuffer)
  32201. */
  32202. Raw = 3,
  32203. /**
  32204. * Texture content is dynamic (video or dynamic texture)
  32205. */
  32206. Dynamic = 4,
  32207. /**
  32208. * Texture content is generated by rendering to it
  32209. */
  32210. RenderTarget = 5,
  32211. /**
  32212. * Texture content is part of a multi render target process
  32213. */
  32214. MultiRenderTarget = 6,
  32215. /**
  32216. * Texture data comes from a cube data file
  32217. */
  32218. Cube = 7,
  32219. /**
  32220. * Texture data comes from a raw cube data
  32221. */
  32222. CubeRaw = 8,
  32223. /**
  32224. * Texture data come from a prefiltered cube data file
  32225. */
  32226. CubePrefiltered = 9,
  32227. /**
  32228. * Texture content is raw 3D data
  32229. */
  32230. Raw3D = 10,
  32231. /**
  32232. * Texture content is raw 2D array data
  32233. */
  32234. Raw2DArray = 11,
  32235. /**
  32236. * Texture content is a depth texture
  32237. */
  32238. Depth = 12,
  32239. /**
  32240. * Texture data comes from a raw cube data encoded with RGBD
  32241. */
  32242. CubeRawRGBD = 13
  32243. }
  32244. /**
  32245. * Class used to store data associated with WebGL texture data for the engine
  32246. * This class should not be used directly
  32247. */
  32248. export class InternalTexture {
  32249. /** @hidden */
  32250. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  32251. /**
  32252. * Defines if the texture is ready
  32253. */
  32254. isReady: boolean;
  32255. /**
  32256. * Defines if the texture is a cube texture
  32257. */
  32258. isCube: boolean;
  32259. /**
  32260. * Defines if the texture contains 3D data
  32261. */
  32262. is3D: boolean;
  32263. /**
  32264. * Defines if the texture contains 2D array data
  32265. */
  32266. is2DArray: boolean;
  32267. /**
  32268. * Defines if the texture contains multiview data
  32269. */
  32270. isMultiview: boolean;
  32271. /**
  32272. * Gets the URL used to load this texture
  32273. */
  32274. url: string;
  32275. /**
  32276. * Gets the sampling mode of the texture
  32277. */
  32278. samplingMode: number;
  32279. /**
  32280. * Gets a boolean indicating if the texture needs mipmaps generation
  32281. */
  32282. generateMipMaps: boolean;
  32283. /**
  32284. * Gets the number of samples used by the texture (WebGL2+ only)
  32285. */
  32286. samples: number;
  32287. /**
  32288. * Gets the type of the texture (int, float...)
  32289. */
  32290. type: number;
  32291. /**
  32292. * Gets the format of the texture (RGB, RGBA...)
  32293. */
  32294. format: number;
  32295. /**
  32296. * Observable called when the texture is loaded
  32297. */
  32298. onLoadedObservable: Observable<InternalTexture>;
  32299. /**
  32300. * Gets the width of the texture
  32301. */
  32302. width: number;
  32303. /**
  32304. * Gets the height of the texture
  32305. */
  32306. height: number;
  32307. /**
  32308. * Gets the depth of the texture
  32309. */
  32310. depth: number;
  32311. /**
  32312. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  32313. */
  32314. baseWidth: number;
  32315. /**
  32316. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  32317. */
  32318. baseHeight: number;
  32319. /**
  32320. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  32321. */
  32322. baseDepth: number;
  32323. /**
  32324. * Gets a boolean indicating if the texture is inverted on Y axis
  32325. */
  32326. invertY: boolean;
  32327. /** @hidden */
  32328. _invertVScale: boolean;
  32329. /** @hidden */
  32330. _associatedChannel: number;
  32331. /** @hidden */
  32332. _source: InternalTextureSource;
  32333. /** @hidden */
  32334. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  32335. /** @hidden */
  32336. _bufferView: Nullable<ArrayBufferView>;
  32337. /** @hidden */
  32338. _bufferViewArray: Nullable<ArrayBufferView[]>;
  32339. /** @hidden */
  32340. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  32341. /** @hidden */
  32342. _size: number;
  32343. /** @hidden */
  32344. _extension: string;
  32345. /** @hidden */
  32346. _files: Nullable<string[]>;
  32347. /** @hidden */
  32348. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32349. /** @hidden */
  32350. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32351. /** @hidden */
  32352. _framebuffer: Nullable<WebGLFramebuffer>;
  32353. /** @hidden */
  32354. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  32355. /** @hidden */
  32356. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  32357. /** @hidden */
  32358. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  32359. /** @hidden */
  32360. _attachments: Nullable<number[]>;
  32361. /** @hidden */
  32362. _cachedCoordinatesMode: Nullable<number>;
  32363. /** @hidden */
  32364. _cachedWrapU: Nullable<number>;
  32365. /** @hidden */
  32366. _cachedWrapV: Nullable<number>;
  32367. /** @hidden */
  32368. _cachedWrapR: Nullable<number>;
  32369. /** @hidden */
  32370. _cachedAnisotropicFilteringLevel: Nullable<number>;
  32371. /** @hidden */
  32372. _isDisabled: boolean;
  32373. /** @hidden */
  32374. _compression: Nullable<string>;
  32375. /** @hidden */
  32376. _generateStencilBuffer: boolean;
  32377. /** @hidden */
  32378. _generateDepthBuffer: boolean;
  32379. /** @hidden */
  32380. _comparisonFunction: number;
  32381. /** @hidden */
  32382. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  32383. /** @hidden */
  32384. _lodGenerationScale: number;
  32385. /** @hidden */
  32386. _lodGenerationOffset: number;
  32387. /** @hidden */
  32388. _depthStencilTexture: Nullable<InternalTexture>;
  32389. /** @hidden */
  32390. _colorTextureArray: Nullable<WebGLTexture>;
  32391. /** @hidden */
  32392. _depthStencilTextureArray: Nullable<WebGLTexture>;
  32393. /** @hidden */
  32394. _lodTextureHigh: Nullable<BaseTexture>;
  32395. /** @hidden */
  32396. _lodTextureMid: Nullable<BaseTexture>;
  32397. /** @hidden */
  32398. _lodTextureLow: Nullable<BaseTexture>;
  32399. /** @hidden */
  32400. _isRGBD: boolean;
  32401. /** @hidden */
  32402. _linearSpecularLOD: boolean;
  32403. /** @hidden */
  32404. _irradianceTexture: Nullable<BaseTexture>;
  32405. /** @hidden */
  32406. _webGLTexture: Nullable<WebGLTexture>;
  32407. /** @hidden */
  32408. _references: number;
  32409. private _engine;
  32410. /**
  32411. * Gets the Engine the texture belongs to.
  32412. * @returns The babylon engine
  32413. */
  32414. getEngine(): ThinEngine;
  32415. /**
  32416. * Gets the data source type of the texture
  32417. */
  32418. get source(): InternalTextureSource;
  32419. /**
  32420. * Creates a new InternalTexture
  32421. * @param engine defines the engine to use
  32422. * @param source defines the type of data that will be used
  32423. * @param delayAllocation if the texture allocation should be delayed (default: false)
  32424. */
  32425. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  32426. /**
  32427. * Increments the number of references (ie. the number of Texture that point to it)
  32428. */
  32429. incrementReferences(): void;
  32430. /**
  32431. * Change the size of the texture (not the size of the content)
  32432. * @param width defines the new width
  32433. * @param height defines the new height
  32434. * @param depth defines the new depth (1 by default)
  32435. */
  32436. updateSize(width: int, height: int, depth?: int): void;
  32437. /** @hidden */
  32438. _rebuild(): void;
  32439. /** @hidden */
  32440. _swapAndDie(target: InternalTexture): void;
  32441. /**
  32442. * Dispose the current allocated resources
  32443. */
  32444. dispose(): void;
  32445. }
  32446. }
  32447. declare module BABYLON {
  32448. /**
  32449. * Class used to work with sound analyzer using fast fourier transform (FFT)
  32450. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32451. */
  32452. export class Analyser {
  32453. /**
  32454. * Gets or sets the smoothing
  32455. * @ignorenaming
  32456. */
  32457. SMOOTHING: number;
  32458. /**
  32459. * Gets or sets the FFT table size
  32460. * @ignorenaming
  32461. */
  32462. FFT_SIZE: number;
  32463. /**
  32464. * Gets or sets the bar graph amplitude
  32465. * @ignorenaming
  32466. */
  32467. BARGRAPHAMPLITUDE: number;
  32468. /**
  32469. * Gets or sets the position of the debug canvas
  32470. * @ignorenaming
  32471. */
  32472. DEBUGCANVASPOS: {
  32473. x: number;
  32474. y: number;
  32475. };
  32476. /**
  32477. * Gets or sets the debug canvas size
  32478. * @ignorenaming
  32479. */
  32480. DEBUGCANVASSIZE: {
  32481. width: number;
  32482. height: number;
  32483. };
  32484. private _byteFreqs;
  32485. private _byteTime;
  32486. private _floatFreqs;
  32487. private _webAudioAnalyser;
  32488. private _debugCanvas;
  32489. private _debugCanvasContext;
  32490. private _scene;
  32491. private _registerFunc;
  32492. private _audioEngine;
  32493. /**
  32494. * Creates a new analyser
  32495. * @param scene defines hosting scene
  32496. */
  32497. constructor(scene: Scene);
  32498. /**
  32499. * Get the number of data values you will have to play with for the visualization
  32500. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  32501. * @returns a number
  32502. */
  32503. getFrequencyBinCount(): number;
  32504. /**
  32505. * Gets the current frequency data as a byte array
  32506. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32507. * @returns a Uint8Array
  32508. */
  32509. getByteFrequencyData(): Uint8Array;
  32510. /**
  32511. * Gets the current waveform as a byte array
  32512. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  32513. * @returns a Uint8Array
  32514. */
  32515. getByteTimeDomainData(): Uint8Array;
  32516. /**
  32517. * Gets the current frequency data as a float array
  32518. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  32519. * @returns a Float32Array
  32520. */
  32521. getFloatFrequencyData(): Float32Array;
  32522. /**
  32523. * Renders the debug canvas
  32524. */
  32525. drawDebugCanvas(): void;
  32526. /**
  32527. * Stops rendering the debug canvas and removes it
  32528. */
  32529. stopDebugCanvas(): void;
  32530. /**
  32531. * Connects two audio nodes
  32532. * @param inputAudioNode defines first node to connect
  32533. * @param outputAudioNode defines second node to connect
  32534. */
  32535. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  32536. /**
  32537. * Releases all associated resources
  32538. */
  32539. dispose(): void;
  32540. }
  32541. }
  32542. declare module BABYLON {
  32543. /**
  32544. * This represents an audio engine and it is responsible
  32545. * to play, synchronize and analyse sounds throughout the application.
  32546. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32547. */
  32548. export interface IAudioEngine extends IDisposable {
  32549. /**
  32550. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32551. */
  32552. readonly canUseWebAudio: boolean;
  32553. /**
  32554. * Gets the current AudioContext if available.
  32555. */
  32556. readonly audioContext: Nullable<AudioContext>;
  32557. /**
  32558. * The master gain node defines the global audio volume of your audio engine.
  32559. */
  32560. readonly masterGain: GainNode;
  32561. /**
  32562. * Gets whether or not mp3 are supported by your browser.
  32563. */
  32564. readonly isMP3supported: boolean;
  32565. /**
  32566. * Gets whether or not ogg are supported by your browser.
  32567. */
  32568. readonly isOGGsupported: boolean;
  32569. /**
  32570. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32571. * @ignoreNaming
  32572. */
  32573. WarnedWebAudioUnsupported: boolean;
  32574. /**
  32575. * Defines if the audio engine relies on a custom unlocked button.
  32576. * In this case, the embedded button will not be displayed.
  32577. */
  32578. useCustomUnlockedButton: boolean;
  32579. /**
  32580. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  32581. */
  32582. readonly unlocked: boolean;
  32583. /**
  32584. * Event raised when audio has been unlocked on the browser.
  32585. */
  32586. onAudioUnlockedObservable: Observable<AudioEngine>;
  32587. /**
  32588. * Event raised when audio has been locked on the browser.
  32589. */
  32590. onAudioLockedObservable: Observable<AudioEngine>;
  32591. /**
  32592. * Flags the audio engine in Locked state.
  32593. * This happens due to new browser policies preventing audio to autoplay.
  32594. */
  32595. lock(): void;
  32596. /**
  32597. * Unlocks the audio engine once a user action has been done on the dom.
  32598. * This is helpful to resume play once browser policies have been satisfied.
  32599. */
  32600. unlock(): void;
  32601. }
  32602. /**
  32603. * This represents the default audio engine used in babylon.
  32604. * It is responsible to play, synchronize and analyse sounds throughout the application.
  32605. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32606. */
  32607. export class AudioEngine implements IAudioEngine {
  32608. private _audioContext;
  32609. private _audioContextInitialized;
  32610. private _muteButton;
  32611. private _hostElement;
  32612. /**
  32613. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  32614. */
  32615. canUseWebAudio: boolean;
  32616. /**
  32617. * The master gain node defines the global audio volume of your audio engine.
  32618. */
  32619. masterGain: GainNode;
  32620. /**
  32621. * Defines if Babylon should emit a warning if WebAudio is not supported.
  32622. * @ignoreNaming
  32623. */
  32624. WarnedWebAudioUnsupported: boolean;
  32625. /**
  32626. * Gets whether or not mp3 are supported by your browser.
  32627. */
  32628. isMP3supported: boolean;
  32629. /**
  32630. * Gets whether or not ogg are supported by your browser.
  32631. */
  32632. isOGGsupported: boolean;
  32633. /**
  32634. * Gets whether audio has been unlocked on the device.
  32635. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  32636. * a user interaction has happened.
  32637. */
  32638. unlocked: boolean;
  32639. /**
  32640. * Defines if the audio engine relies on a custom unlocked button.
  32641. * In this case, the embedded button will not be displayed.
  32642. */
  32643. useCustomUnlockedButton: boolean;
  32644. /**
  32645. * Event raised when audio has been unlocked on the browser.
  32646. */
  32647. onAudioUnlockedObservable: Observable<AudioEngine>;
  32648. /**
  32649. * Event raised when audio has been locked on the browser.
  32650. */
  32651. onAudioLockedObservable: Observable<AudioEngine>;
  32652. /**
  32653. * Gets the current AudioContext if available.
  32654. */
  32655. get audioContext(): Nullable<AudioContext>;
  32656. private _connectedAnalyser;
  32657. /**
  32658. * Instantiates a new audio engine.
  32659. *
  32660. * There should be only one per page as some browsers restrict the number
  32661. * of audio contexts you can create.
  32662. * @param hostElement defines the host element where to display the mute icon if necessary
  32663. */
  32664. constructor(hostElement?: Nullable<HTMLElement>);
  32665. /**
  32666. * Flags the audio engine in Locked state.
  32667. * This happens due to new browser policies preventing audio to autoplay.
  32668. */
  32669. lock(): void;
  32670. /**
  32671. * Unlocks the audio engine once a user action has been done on the dom.
  32672. * This is helpful to resume play once browser policies have been satisfied.
  32673. */
  32674. unlock(): void;
  32675. private _resumeAudioContext;
  32676. private _initializeAudioContext;
  32677. private _tryToRun;
  32678. private _triggerRunningState;
  32679. private _triggerSuspendedState;
  32680. private _displayMuteButton;
  32681. private _moveButtonToTopLeft;
  32682. private _onResize;
  32683. private _hideMuteButton;
  32684. /**
  32685. * Destroy and release the resources associated with the audio ccontext.
  32686. */
  32687. dispose(): void;
  32688. /**
  32689. * Gets the global volume sets on the master gain.
  32690. * @returns the global volume if set or -1 otherwise
  32691. */
  32692. getGlobalVolume(): number;
  32693. /**
  32694. * Sets the global volume of your experience (sets on the master gain).
  32695. * @param newVolume Defines the new global volume of the application
  32696. */
  32697. setGlobalVolume(newVolume: number): void;
  32698. /**
  32699. * Connect the audio engine to an audio analyser allowing some amazing
  32700. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  32701. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  32702. * @param analyser The analyser to connect to the engine
  32703. */
  32704. connectToAnalyser(analyser: Analyser): void;
  32705. }
  32706. }
  32707. declare module BABYLON {
  32708. /**
  32709. * Interface used to present a loading screen while loading a scene
  32710. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32711. */
  32712. export interface ILoadingScreen {
  32713. /**
  32714. * Function called to display the loading screen
  32715. */
  32716. displayLoadingUI: () => void;
  32717. /**
  32718. * Function called to hide the loading screen
  32719. */
  32720. hideLoadingUI: () => void;
  32721. /**
  32722. * Gets or sets the color to use for the background
  32723. */
  32724. loadingUIBackgroundColor: string;
  32725. /**
  32726. * Gets or sets the text to display while loading
  32727. */
  32728. loadingUIText: string;
  32729. }
  32730. /**
  32731. * Class used for the default loading screen
  32732. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32733. */
  32734. export class DefaultLoadingScreen implements ILoadingScreen {
  32735. private _renderingCanvas;
  32736. private _loadingText;
  32737. private _loadingDivBackgroundColor;
  32738. private _loadingDiv;
  32739. private _loadingTextDiv;
  32740. /** Gets or sets the logo url to use for the default loading screen */
  32741. static DefaultLogoUrl: string;
  32742. /** Gets or sets the spinner url to use for the default loading screen */
  32743. static DefaultSpinnerUrl: string;
  32744. /**
  32745. * Creates a new default loading screen
  32746. * @param _renderingCanvas defines the canvas used to render the scene
  32747. * @param _loadingText defines the default text to display
  32748. * @param _loadingDivBackgroundColor defines the default background color
  32749. */
  32750. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  32751. /**
  32752. * Function called to display the loading screen
  32753. */
  32754. displayLoadingUI(): void;
  32755. /**
  32756. * Function called to hide the loading screen
  32757. */
  32758. hideLoadingUI(): void;
  32759. /**
  32760. * Gets or sets the text to display while loading
  32761. */
  32762. set loadingUIText(text: string);
  32763. get loadingUIText(): string;
  32764. /**
  32765. * Gets or sets the color to use for the background
  32766. */
  32767. get loadingUIBackgroundColor(): string;
  32768. set loadingUIBackgroundColor(color: string);
  32769. private _resizeLoadingUI;
  32770. }
  32771. }
  32772. declare module BABYLON {
  32773. /**
  32774. * Interface for any object that can request an animation frame
  32775. */
  32776. export interface ICustomAnimationFrameRequester {
  32777. /**
  32778. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  32779. */
  32780. renderFunction?: Function;
  32781. /**
  32782. * Called to request the next frame to render to
  32783. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  32784. */
  32785. requestAnimationFrame: Function;
  32786. /**
  32787. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  32788. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  32789. */
  32790. requestID?: number;
  32791. }
  32792. }
  32793. declare module BABYLON {
  32794. /**
  32795. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  32796. */
  32797. export class PerformanceMonitor {
  32798. private _enabled;
  32799. private _rollingFrameTime;
  32800. private _lastFrameTimeMs;
  32801. /**
  32802. * constructor
  32803. * @param frameSampleSize The number of samples required to saturate the sliding window
  32804. */
  32805. constructor(frameSampleSize?: number);
  32806. /**
  32807. * Samples current frame
  32808. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  32809. */
  32810. sampleFrame(timeMs?: number): void;
  32811. /**
  32812. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32813. */
  32814. get averageFrameTime(): number;
  32815. /**
  32816. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  32817. */
  32818. get averageFrameTimeVariance(): number;
  32819. /**
  32820. * Returns the frame time of the most recent frame
  32821. */
  32822. get instantaneousFrameTime(): number;
  32823. /**
  32824. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  32825. */
  32826. get averageFPS(): number;
  32827. /**
  32828. * Returns the average framerate in frames per second using the most recent frame time
  32829. */
  32830. get instantaneousFPS(): number;
  32831. /**
  32832. * Returns true if enough samples have been taken to completely fill the sliding window
  32833. */
  32834. get isSaturated(): boolean;
  32835. /**
  32836. * Enables contributions to the sliding window sample set
  32837. */
  32838. enable(): void;
  32839. /**
  32840. * Disables contributions to the sliding window sample set
  32841. * Samples will not be interpolated over the disabled period
  32842. */
  32843. disable(): void;
  32844. /**
  32845. * Returns true if sampling is enabled
  32846. */
  32847. get isEnabled(): boolean;
  32848. /**
  32849. * Resets performance monitor
  32850. */
  32851. reset(): void;
  32852. }
  32853. /**
  32854. * RollingAverage
  32855. *
  32856. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  32857. */
  32858. export class RollingAverage {
  32859. /**
  32860. * Current average
  32861. */
  32862. average: number;
  32863. /**
  32864. * Current variance
  32865. */
  32866. variance: number;
  32867. protected _samples: Array<number>;
  32868. protected _sampleCount: number;
  32869. protected _pos: number;
  32870. protected _m2: number;
  32871. /**
  32872. * constructor
  32873. * @param length The number of samples required to saturate the sliding window
  32874. */
  32875. constructor(length: number);
  32876. /**
  32877. * Adds a sample to the sample set
  32878. * @param v The sample value
  32879. */
  32880. add(v: number): void;
  32881. /**
  32882. * Returns previously added values or null if outside of history or outside the sliding window domain
  32883. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  32884. * @return Value previously recorded with add() or null if outside of range
  32885. */
  32886. history(i: number): number;
  32887. /**
  32888. * Returns true if enough samples have been taken to completely fill the sliding window
  32889. * @return true if sample-set saturated
  32890. */
  32891. isSaturated(): boolean;
  32892. /**
  32893. * Resets the rolling average (equivalent to 0 samples taken so far)
  32894. */
  32895. reset(): void;
  32896. /**
  32897. * Wraps a value around the sample range boundaries
  32898. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  32899. * @return Wrapped position in sample range
  32900. */
  32901. protected _wrapPosition(i: number): number;
  32902. }
  32903. }
  32904. declare module BABYLON {
  32905. /**
  32906. * This class is used to track a performance counter which is number based.
  32907. * The user has access to many properties which give statistics of different nature.
  32908. *
  32909. * The implementer can track two kinds of Performance Counter: time and count.
  32910. * 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.
  32911. * 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.
  32912. */
  32913. export class PerfCounter {
  32914. /**
  32915. * Gets or sets a global boolean to turn on and off all the counters
  32916. */
  32917. static Enabled: boolean;
  32918. /**
  32919. * Returns the smallest value ever
  32920. */
  32921. get min(): number;
  32922. /**
  32923. * Returns the biggest value ever
  32924. */
  32925. get max(): number;
  32926. /**
  32927. * Returns the average value since the performance counter is running
  32928. */
  32929. get average(): number;
  32930. /**
  32931. * Returns the average value of the last second the counter was monitored
  32932. */
  32933. get lastSecAverage(): number;
  32934. /**
  32935. * Returns the current value
  32936. */
  32937. get current(): number;
  32938. /**
  32939. * Gets the accumulated total
  32940. */
  32941. get total(): number;
  32942. /**
  32943. * Gets the total value count
  32944. */
  32945. get count(): number;
  32946. /**
  32947. * Creates a new counter
  32948. */
  32949. constructor();
  32950. /**
  32951. * Call this method to start monitoring a new frame.
  32952. * 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.
  32953. */
  32954. fetchNewFrame(): void;
  32955. /**
  32956. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32957. * @param newCount the count value to add to the monitored count
  32958. * @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.
  32959. */
  32960. addCount(newCount: number, fetchResult: boolean): void;
  32961. /**
  32962. * Start monitoring this performance counter
  32963. */
  32964. beginMonitoring(): void;
  32965. /**
  32966. * Compute the time lapsed since the previous beginMonitoring() call.
  32967. * @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
  32968. */
  32969. endMonitoring(newFrame?: boolean): void;
  32970. private _fetchResult;
  32971. private _startMonitoringTime;
  32972. private _min;
  32973. private _max;
  32974. private _average;
  32975. private _current;
  32976. private _totalValueCount;
  32977. private _totalAccumulated;
  32978. private _lastSecAverage;
  32979. private _lastSecAccumulated;
  32980. private _lastSecTime;
  32981. private _lastSecValueCount;
  32982. }
  32983. }
  32984. declare module BABYLON {
  32985. interface ThinEngine {
  32986. /**
  32987. * Sets alpha constants used by some alpha blending modes
  32988. * @param r defines the red component
  32989. * @param g defines the green component
  32990. * @param b defines the blue component
  32991. * @param a defines the alpha component
  32992. */
  32993. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32994. /**
  32995. * Sets the current alpha mode
  32996. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32997. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32998. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32999. */
  33000. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33001. /**
  33002. * Gets the current alpha mode
  33003. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33004. * @returns the current alpha mode
  33005. */
  33006. getAlphaMode(): number;
  33007. /**
  33008. * Sets the current alpha equation
  33009. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33010. */
  33011. setAlphaEquation(equation: number): void;
  33012. /**
  33013. * Gets the current alpha equation.
  33014. * @returns the current alpha equation
  33015. */
  33016. getAlphaEquation(): number;
  33017. }
  33018. }
  33019. declare module BABYLON {
  33020. /**
  33021. * Defines the interface used by display changed events
  33022. */
  33023. export interface IDisplayChangedEventArgs {
  33024. /** Gets the vrDisplay object (if any) */
  33025. vrDisplay: Nullable<any>;
  33026. /** Gets a boolean indicating if webVR is supported */
  33027. vrSupported: boolean;
  33028. }
  33029. /**
  33030. * Defines the interface used by objects containing a viewport (like a camera)
  33031. */
  33032. interface IViewportOwnerLike {
  33033. /**
  33034. * Gets or sets the viewport
  33035. */
  33036. viewport: IViewportLike;
  33037. }
  33038. /**
  33039. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  33040. */
  33041. export class Engine extends ThinEngine {
  33042. /** Defines that alpha blending is disabled */
  33043. static readonly ALPHA_DISABLE: number;
  33044. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  33045. static readonly ALPHA_ADD: number;
  33046. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  33047. static readonly ALPHA_COMBINE: number;
  33048. /** Defines that alpha blending to DEST - SRC * DEST */
  33049. static readonly ALPHA_SUBTRACT: number;
  33050. /** Defines that alpha blending to SRC * DEST */
  33051. static readonly ALPHA_MULTIPLY: number;
  33052. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  33053. static readonly ALPHA_MAXIMIZED: number;
  33054. /** Defines that alpha blending to SRC + DEST */
  33055. static readonly ALPHA_ONEONE: number;
  33056. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  33057. static readonly ALPHA_PREMULTIPLIED: number;
  33058. /**
  33059. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  33060. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  33061. */
  33062. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  33063. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  33064. static readonly ALPHA_INTERPOLATE: number;
  33065. /**
  33066. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  33067. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  33068. */
  33069. static readonly ALPHA_SCREENMODE: number;
  33070. /** Defines that the ressource is not delayed*/
  33071. static readonly DELAYLOADSTATE_NONE: number;
  33072. /** Defines that the ressource was successfully delay loaded */
  33073. static readonly DELAYLOADSTATE_LOADED: number;
  33074. /** Defines that the ressource is currently delay loading */
  33075. static readonly DELAYLOADSTATE_LOADING: number;
  33076. /** Defines that the ressource is delayed and has not started loading */
  33077. static readonly DELAYLOADSTATE_NOTLOADED: number;
  33078. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  33079. static readonly NEVER: number;
  33080. /** 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 */
  33081. static readonly ALWAYS: number;
  33082. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  33083. static readonly LESS: number;
  33084. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  33085. static readonly EQUAL: number;
  33086. /** 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 */
  33087. static readonly LEQUAL: number;
  33088. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  33089. static readonly GREATER: number;
  33090. /** 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 */
  33091. static readonly GEQUAL: number;
  33092. /** 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 */
  33093. static readonly NOTEQUAL: number;
  33094. /** Passed to stencilOperation to specify that stencil value must be kept */
  33095. static readonly KEEP: number;
  33096. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33097. static readonly REPLACE: number;
  33098. /** Passed to stencilOperation to specify that stencil value must be incremented */
  33099. static readonly INCR: number;
  33100. /** Passed to stencilOperation to specify that stencil value must be decremented */
  33101. static readonly DECR: number;
  33102. /** Passed to stencilOperation to specify that stencil value must be inverted */
  33103. static readonly INVERT: number;
  33104. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  33105. static readonly INCR_WRAP: number;
  33106. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  33107. static readonly DECR_WRAP: number;
  33108. /** Texture is not repeating outside of 0..1 UVs */
  33109. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  33110. /** Texture is repeating outside of 0..1 UVs */
  33111. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  33112. /** Texture is repeating and mirrored */
  33113. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  33114. /** ALPHA */
  33115. static readonly TEXTUREFORMAT_ALPHA: number;
  33116. /** LUMINANCE */
  33117. static readonly TEXTUREFORMAT_LUMINANCE: number;
  33118. /** LUMINANCE_ALPHA */
  33119. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  33120. /** RGB */
  33121. static readonly TEXTUREFORMAT_RGB: number;
  33122. /** RGBA */
  33123. static readonly TEXTUREFORMAT_RGBA: number;
  33124. /** RED */
  33125. static readonly TEXTUREFORMAT_RED: number;
  33126. /** RED (2nd reference) */
  33127. static readonly TEXTUREFORMAT_R: number;
  33128. /** RG */
  33129. static readonly TEXTUREFORMAT_RG: number;
  33130. /** RED_INTEGER */
  33131. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  33132. /** RED_INTEGER (2nd reference) */
  33133. static readonly TEXTUREFORMAT_R_INTEGER: number;
  33134. /** RG_INTEGER */
  33135. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  33136. /** RGB_INTEGER */
  33137. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  33138. /** RGBA_INTEGER */
  33139. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  33140. /** UNSIGNED_BYTE */
  33141. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  33142. /** UNSIGNED_BYTE (2nd reference) */
  33143. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  33144. /** FLOAT */
  33145. static readonly TEXTURETYPE_FLOAT: number;
  33146. /** HALF_FLOAT */
  33147. static readonly TEXTURETYPE_HALF_FLOAT: number;
  33148. /** BYTE */
  33149. static readonly TEXTURETYPE_BYTE: number;
  33150. /** SHORT */
  33151. static readonly TEXTURETYPE_SHORT: number;
  33152. /** UNSIGNED_SHORT */
  33153. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  33154. /** INT */
  33155. static readonly TEXTURETYPE_INT: number;
  33156. /** UNSIGNED_INT */
  33157. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  33158. /** UNSIGNED_SHORT_4_4_4_4 */
  33159. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  33160. /** UNSIGNED_SHORT_5_5_5_1 */
  33161. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  33162. /** UNSIGNED_SHORT_5_6_5 */
  33163. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  33164. /** UNSIGNED_INT_2_10_10_10_REV */
  33165. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  33166. /** UNSIGNED_INT_24_8 */
  33167. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  33168. /** UNSIGNED_INT_10F_11F_11F_REV */
  33169. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  33170. /** UNSIGNED_INT_5_9_9_9_REV */
  33171. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  33172. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  33173. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  33174. /** nearest is mag = nearest and min = nearest and mip = linear */
  33175. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  33176. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33177. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  33178. /** Trilinear is mag = linear and min = linear and mip = linear */
  33179. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  33180. /** nearest is mag = nearest and min = nearest and mip = linear */
  33181. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  33182. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33183. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  33184. /** Trilinear is mag = linear and min = linear and mip = linear */
  33185. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  33186. /** mag = nearest and min = nearest and mip = nearest */
  33187. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  33188. /** mag = nearest and min = linear and mip = nearest */
  33189. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  33190. /** mag = nearest and min = linear and mip = linear */
  33191. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  33192. /** mag = nearest and min = linear and mip = none */
  33193. static readonly TEXTURE_NEAREST_LINEAR: number;
  33194. /** mag = nearest and min = nearest and mip = none */
  33195. static readonly TEXTURE_NEAREST_NEAREST: number;
  33196. /** mag = linear and min = nearest and mip = nearest */
  33197. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  33198. /** mag = linear and min = nearest and mip = linear */
  33199. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  33200. /** mag = linear and min = linear and mip = none */
  33201. static readonly TEXTURE_LINEAR_LINEAR: number;
  33202. /** mag = linear and min = nearest and mip = none */
  33203. static readonly TEXTURE_LINEAR_NEAREST: number;
  33204. /** Explicit coordinates mode */
  33205. static readonly TEXTURE_EXPLICIT_MODE: number;
  33206. /** Spherical coordinates mode */
  33207. static readonly TEXTURE_SPHERICAL_MODE: number;
  33208. /** Planar coordinates mode */
  33209. static readonly TEXTURE_PLANAR_MODE: number;
  33210. /** Cubic coordinates mode */
  33211. static readonly TEXTURE_CUBIC_MODE: number;
  33212. /** Projection coordinates mode */
  33213. static readonly TEXTURE_PROJECTION_MODE: number;
  33214. /** Skybox coordinates mode */
  33215. static readonly TEXTURE_SKYBOX_MODE: number;
  33216. /** Inverse Cubic coordinates mode */
  33217. static readonly TEXTURE_INVCUBIC_MODE: number;
  33218. /** Equirectangular coordinates mode */
  33219. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  33220. /** Equirectangular Fixed coordinates mode */
  33221. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  33222. /** Equirectangular Fixed Mirrored coordinates mode */
  33223. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  33224. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  33225. static readonly SCALEMODE_FLOOR: number;
  33226. /** Defines that texture rescaling will look for the nearest power of 2 size */
  33227. static readonly SCALEMODE_NEAREST: number;
  33228. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  33229. static readonly SCALEMODE_CEILING: number;
  33230. /**
  33231. * Returns the current npm package of the sdk
  33232. */
  33233. static get NpmPackage(): string;
  33234. /**
  33235. * Returns the current version of the framework
  33236. */
  33237. static get Version(): string;
  33238. /** Gets the list of created engines */
  33239. static get Instances(): Engine[];
  33240. /**
  33241. * Gets the latest created engine
  33242. */
  33243. static get LastCreatedEngine(): Nullable<Engine>;
  33244. /**
  33245. * Gets the latest created scene
  33246. */
  33247. static get LastCreatedScene(): Nullable<Scene>;
  33248. /**
  33249. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  33250. * @param flag defines which part of the materials must be marked as dirty
  33251. * @param predicate defines a predicate used to filter which materials should be affected
  33252. */
  33253. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33254. /**
  33255. * Method called to create the default loading screen.
  33256. * This can be overriden in your own app.
  33257. * @param canvas The rendering canvas element
  33258. * @returns The loading screen
  33259. */
  33260. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  33261. /**
  33262. * Method called to create the default rescale post process on each engine.
  33263. */
  33264. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  33265. /**
  33266. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  33267. **/
  33268. enableOfflineSupport: boolean;
  33269. /**
  33270. * 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)
  33271. **/
  33272. disableManifestCheck: boolean;
  33273. /**
  33274. * Gets the list of created scenes
  33275. */
  33276. scenes: Scene[];
  33277. /**
  33278. * Event raised when a new scene is created
  33279. */
  33280. onNewSceneAddedObservable: Observable<Scene>;
  33281. /**
  33282. * Gets the list of created postprocesses
  33283. */
  33284. postProcesses: PostProcess[];
  33285. /**
  33286. * Gets a boolean indicating if the pointer is currently locked
  33287. */
  33288. isPointerLock: boolean;
  33289. /**
  33290. * Observable event triggered each time the rendering canvas is resized
  33291. */
  33292. onResizeObservable: Observable<Engine>;
  33293. /**
  33294. * Observable event triggered each time the canvas loses focus
  33295. */
  33296. onCanvasBlurObservable: Observable<Engine>;
  33297. /**
  33298. * Observable event triggered each time the canvas gains focus
  33299. */
  33300. onCanvasFocusObservable: Observable<Engine>;
  33301. /**
  33302. * Observable event triggered each time the canvas receives pointerout event
  33303. */
  33304. onCanvasPointerOutObservable: Observable<PointerEvent>;
  33305. /**
  33306. * Observable raised when the engine begins a new frame
  33307. */
  33308. onBeginFrameObservable: Observable<Engine>;
  33309. /**
  33310. * If set, will be used to request the next animation frame for the render loop
  33311. */
  33312. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  33313. /**
  33314. * Observable raised when the engine ends the current frame
  33315. */
  33316. onEndFrameObservable: Observable<Engine>;
  33317. /**
  33318. * Observable raised when the engine is about to compile a shader
  33319. */
  33320. onBeforeShaderCompilationObservable: Observable<Engine>;
  33321. /**
  33322. * Observable raised when the engine has jsut compiled a shader
  33323. */
  33324. onAfterShaderCompilationObservable: Observable<Engine>;
  33325. /**
  33326. * Gets the audio engine
  33327. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33328. * @ignorenaming
  33329. */
  33330. static audioEngine: IAudioEngine;
  33331. /**
  33332. * Default AudioEngine factory responsible of creating the Audio Engine.
  33333. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  33334. */
  33335. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  33336. /**
  33337. * Default offline support factory responsible of creating a tool used to store data locally.
  33338. * By default, this will create a Database object if the workload has been embedded.
  33339. */
  33340. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  33341. private _loadingScreen;
  33342. private _pointerLockRequested;
  33343. private _dummyFramebuffer;
  33344. private _rescalePostProcess;
  33345. private _deterministicLockstep;
  33346. private _lockstepMaxSteps;
  33347. private _timeStep;
  33348. protected get _supportsHardwareTextureRescaling(): boolean;
  33349. private _fps;
  33350. private _deltaTime;
  33351. /** @hidden */
  33352. _drawCalls: PerfCounter;
  33353. /** Gets or sets the tab index to set to the rendering canvas. 1 is the minimum value to set to be able to capture keyboard events */
  33354. canvasTabIndex: number;
  33355. /**
  33356. * Turn this value on if you want to pause FPS computation when in background
  33357. */
  33358. disablePerformanceMonitorInBackground: boolean;
  33359. private _performanceMonitor;
  33360. /**
  33361. * Gets the performance monitor attached to this engine
  33362. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  33363. */
  33364. get performanceMonitor(): PerformanceMonitor;
  33365. private _onFocus;
  33366. private _onBlur;
  33367. private _onCanvasPointerOut;
  33368. private _onCanvasBlur;
  33369. private _onCanvasFocus;
  33370. private _onFullscreenChange;
  33371. private _onPointerLockChange;
  33372. /**
  33373. * Gets the HTML element used to attach event listeners
  33374. * @returns a HTML element
  33375. */
  33376. getInputElement(): Nullable<HTMLElement>;
  33377. /**
  33378. * Creates a new engine
  33379. * @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
  33380. * @param antialias defines enable antialiasing (default: false)
  33381. * @param options defines further options to be sent to the getContext() function
  33382. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  33383. */
  33384. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  33385. /**
  33386. * Gets current aspect ratio
  33387. * @param viewportOwner defines the camera to use to get the aspect ratio
  33388. * @param useScreen defines if screen size must be used (or the current render target if any)
  33389. * @returns a number defining the aspect ratio
  33390. */
  33391. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  33392. /**
  33393. * Gets current screen aspect ratio
  33394. * @returns a number defining the aspect ratio
  33395. */
  33396. getScreenAspectRatio(): number;
  33397. /**
  33398. * Gets the client rect of the HTML canvas attached with the current webGL context
  33399. * @returns a client rectanglee
  33400. */
  33401. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  33402. /**
  33403. * Gets the client rect of the HTML element used for events
  33404. * @returns a client rectanglee
  33405. */
  33406. getInputElementClientRect(): Nullable<ClientRect>;
  33407. /**
  33408. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  33409. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33410. * @returns true if engine is in deterministic lock step mode
  33411. */
  33412. isDeterministicLockStep(): boolean;
  33413. /**
  33414. * Gets the max steps when engine is running in deterministic lock step
  33415. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33416. * @returns the max steps
  33417. */
  33418. getLockstepMaxSteps(): number;
  33419. /**
  33420. * Returns the time in ms between steps when using deterministic lock step.
  33421. * @returns time step in (ms)
  33422. */
  33423. getTimeStep(): number;
  33424. /**
  33425. * Force the mipmap generation for the given render target texture
  33426. * @param texture defines the render target texture to use
  33427. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  33428. */
  33429. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  33430. /** States */
  33431. /**
  33432. * Set various states to the webGL context
  33433. * @param culling defines backface culling state
  33434. * @param zOffset defines the value to apply to zOffset (0 by default)
  33435. * @param force defines if states must be applied even if cache is up to date
  33436. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  33437. */
  33438. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  33439. /**
  33440. * Set the z offset to apply to current rendering
  33441. * @param value defines the offset to apply
  33442. */
  33443. setZOffset(value: number): void;
  33444. /**
  33445. * Gets the current value of the zOffset
  33446. * @returns the current zOffset state
  33447. */
  33448. getZOffset(): number;
  33449. /**
  33450. * Enable or disable depth buffering
  33451. * @param enable defines the state to set
  33452. */
  33453. setDepthBuffer(enable: boolean): void;
  33454. /**
  33455. * Gets a boolean indicating if depth writing is enabled
  33456. * @returns the current depth writing state
  33457. */
  33458. getDepthWrite(): boolean;
  33459. /**
  33460. * Enable or disable depth writing
  33461. * @param enable defines the state to set
  33462. */
  33463. setDepthWrite(enable: boolean): void;
  33464. /**
  33465. * Gets a boolean indicating if stencil buffer is enabled
  33466. * @returns the current stencil buffer state
  33467. */
  33468. getStencilBuffer(): boolean;
  33469. /**
  33470. * Enable or disable the stencil buffer
  33471. * @param enable defines if the stencil buffer must be enabled or disabled
  33472. */
  33473. setStencilBuffer(enable: boolean): void;
  33474. /**
  33475. * Gets the current stencil mask
  33476. * @returns a number defining the new stencil mask to use
  33477. */
  33478. getStencilMask(): number;
  33479. /**
  33480. * Sets the current stencil mask
  33481. * @param mask defines the new stencil mask to use
  33482. */
  33483. setStencilMask(mask: number): void;
  33484. /**
  33485. * Gets the current stencil function
  33486. * @returns a number defining the stencil function to use
  33487. */
  33488. getStencilFunction(): number;
  33489. /**
  33490. * Gets the current stencil reference value
  33491. * @returns a number defining the stencil reference value to use
  33492. */
  33493. getStencilFunctionReference(): number;
  33494. /**
  33495. * Gets the current stencil mask
  33496. * @returns a number defining the stencil mask to use
  33497. */
  33498. getStencilFunctionMask(): number;
  33499. /**
  33500. * Sets the current stencil function
  33501. * @param stencilFunc defines the new stencil function to use
  33502. */
  33503. setStencilFunction(stencilFunc: number): void;
  33504. /**
  33505. * Sets the current stencil reference
  33506. * @param reference defines the new stencil reference to use
  33507. */
  33508. setStencilFunctionReference(reference: number): void;
  33509. /**
  33510. * Sets the current stencil mask
  33511. * @param mask defines the new stencil mask to use
  33512. */
  33513. setStencilFunctionMask(mask: number): void;
  33514. /**
  33515. * Gets the current stencil operation when stencil fails
  33516. * @returns a number defining stencil operation to use when stencil fails
  33517. */
  33518. getStencilOperationFail(): number;
  33519. /**
  33520. * Gets the current stencil operation when depth fails
  33521. * @returns a number defining stencil operation to use when depth fails
  33522. */
  33523. getStencilOperationDepthFail(): number;
  33524. /**
  33525. * Gets the current stencil operation when stencil passes
  33526. * @returns a number defining stencil operation to use when stencil passes
  33527. */
  33528. getStencilOperationPass(): number;
  33529. /**
  33530. * Sets the stencil operation to use when stencil fails
  33531. * @param operation defines the stencil operation to use when stencil fails
  33532. */
  33533. setStencilOperationFail(operation: number): void;
  33534. /**
  33535. * Sets the stencil operation to use when depth fails
  33536. * @param operation defines the stencil operation to use when depth fails
  33537. */
  33538. setStencilOperationDepthFail(operation: number): void;
  33539. /**
  33540. * Sets the stencil operation to use when stencil passes
  33541. * @param operation defines the stencil operation to use when stencil passes
  33542. */
  33543. setStencilOperationPass(operation: number): void;
  33544. /**
  33545. * Sets a boolean indicating if the dithering state is enabled or disabled
  33546. * @param value defines the dithering state
  33547. */
  33548. setDitheringState(value: boolean): void;
  33549. /**
  33550. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  33551. * @param value defines the rasterizer state
  33552. */
  33553. setRasterizerState(value: boolean): void;
  33554. /**
  33555. * Gets the current depth function
  33556. * @returns a number defining the depth function
  33557. */
  33558. getDepthFunction(): Nullable<number>;
  33559. /**
  33560. * Sets the current depth function
  33561. * @param depthFunc defines the function to use
  33562. */
  33563. setDepthFunction(depthFunc: number): void;
  33564. /**
  33565. * Sets the current depth function to GREATER
  33566. */
  33567. setDepthFunctionToGreater(): void;
  33568. /**
  33569. * Sets the current depth function to GEQUAL
  33570. */
  33571. setDepthFunctionToGreaterOrEqual(): void;
  33572. /**
  33573. * Sets the current depth function to LESS
  33574. */
  33575. setDepthFunctionToLess(): void;
  33576. /**
  33577. * Sets the current depth function to LEQUAL
  33578. */
  33579. setDepthFunctionToLessOrEqual(): void;
  33580. private _cachedStencilBuffer;
  33581. private _cachedStencilFunction;
  33582. private _cachedStencilMask;
  33583. private _cachedStencilOperationPass;
  33584. private _cachedStencilOperationFail;
  33585. private _cachedStencilOperationDepthFail;
  33586. private _cachedStencilReference;
  33587. /**
  33588. * Caches the the state of the stencil buffer
  33589. */
  33590. cacheStencilState(): void;
  33591. /**
  33592. * Restores the state of the stencil buffer
  33593. */
  33594. restoreStencilState(): void;
  33595. /**
  33596. * Directly set the WebGL Viewport
  33597. * @param x defines the x coordinate of the viewport (in screen space)
  33598. * @param y defines the y coordinate of the viewport (in screen space)
  33599. * @param width defines the width of the viewport (in screen space)
  33600. * @param height defines the height of the viewport (in screen space)
  33601. * @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
  33602. */
  33603. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  33604. /**
  33605. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  33606. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33607. * @param y defines the y-coordinate of the corner of the clear rectangle
  33608. * @param width defines the width of the clear rectangle
  33609. * @param height defines the height of the clear rectangle
  33610. * @param clearColor defines the clear color
  33611. */
  33612. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  33613. /**
  33614. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  33615. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  33616. * @param y defines the y-coordinate of the corner of the clear rectangle
  33617. * @param width defines the width of the clear rectangle
  33618. * @param height defines the height of the clear rectangle
  33619. */
  33620. enableScissor(x: number, y: number, width: number, height: number): void;
  33621. /**
  33622. * Disable previously set scissor test rectangle
  33623. */
  33624. disableScissor(): void;
  33625. protected _reportDrawCall(): void;
  33626. /**
  33627. * Initializes a webVR display and starts listening to display change events
  33628. * The onVRDisplayChangedObservable will be notified upon these changes
  33629. * @returns The onVRDisplayChangedObservable
  33630. */
  33631. initWebVR(): Observable<IDisplayChangedEventArgs>;
  33632. /** @hidden */
  33633. _prepareVRComponent(): void;
  33634. /** @hidden */
  33635. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  33636. /** @hidden */
  33637. _submitVRFrame(): void;
  33638. /**
  33639. * Call this function to leave webVR mode
  33640. * Will do nothing if webVR is not supported or if there is no webVR device
  33641. * @see http://doc.babylonjs.com/how_to/webvr_camera
  33642. */
  33643. disableVR(): void;
  33644. /**
  33645. * Gets a boolean indicating that the system is in VR mode and is presenting
  33646. * @returns true if VR mode is engaged
  33647. */
  33648. isVRPresenting(): boolean;
  33649. /** @hidden */
  33650. _requestVRFrame(): void;
  33651. /** @hidden */
  33652. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33653. /**
  33654. * Gets the source code of the vertex shader associated with a specific webGL program
  33655. * @param program defines the program to use
  33656. * @returns a string containing the source code of the vertex shader associated with the program
  33657. */
  33658. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  33659. /**
  33660. * Gets the source code of the fragment shader associated with a specific webGL program
  33661. * @param program defines the program to use
  33662. * @returns a string containing the source code of the fragment shader associated with the program
  33663. */
  33664. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  33665. /**
  33666. * Sets a depth stencil texture from a render target to the according uniform.
  33667. * @param channel The texture channel
  33668. * @param uniform The uniform to set
  33669. * @param texture The render target texture containing the depth stencil texture to apply
  33670. */
  33671. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  33672. /**
  33673. * Sets a texture to the webGL context from a postprocess
  33674. * @param channel defines the channel to use
  33675. * @param postProcess defines the source postprocess
  33676. */
  33677. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  33678. /**
  33679. * Binds the output of the passed in post process to the texture channel specified
  33680. * @param channel The channel the texture should be bound to
  33681. * @param postProcess The post process which's output should be bound
  33682. */
  33683. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  33684. /** @hidden */
  33685. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  33686. protected _rebuildBuffers(): void;
  33687. /** @hidden */
  33688. _renderFrame(): void;
  33689. _renderLoop(): void;
  33690. /** @hidden */
  33691. _renderViews(): boolean;
  33692. /**
  33693. * Toggle full screen mode
  33694. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33695. */
  33696. switchFullscreen(requestPointerLock: boolean): void;
  33697. /**
  33698. * Enters full screen mode
  33699. * @param requestPointerLock defines if a pointer lock should be requested from the user
  33700. */
  33701. enterFullscreen(requestPointerLock: boolean): void;
  33702. /**
  33703. * Exits full screen mode
  33704. */
  33705. exitFullscreen(): void;
  33706. /**
  33707. * Enters Pointerlock mode
  33708. */
  33709. enterPointerlock(): void;
  33710. /**
  33711. * Exits Pointerlock mode
  33712. */
  33713. exitPointerlock(): void;
  33714. /**
  33715. * Begin a new frame
  33716. */
  33717. beginFrame(): void;
  33718. /**
  33719. * Enf the current frame
  33720. */
  33721. endFrame(): void;
  33722. resize(): void;
  33723. /**
  33724. * Set the compressed texture format to use, based on the formats you have, and the formats
  33725. * supported by the hardware / browser.
  33726. *
  33727. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  33728. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  33729. * to API arguments needed to compressed textures. This puts the burden on the container
  33730. * generator to house the arcane code for determining these for current & future formats.
  33731. *
  33732. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  33733. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  33734. *
  33735. * Note: The result of this call is not taken into account when a texture is base64.
  33736. *
  33737. * @param formatsAvailable defines the list of those format families you have created
  33738. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  33739. *
  33740. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  33741. * @returns The extension selected.
  33742. */
  33743. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  33744. /**
  33745. * Set the compressed texture extensions or file names to skip.
  33746. *
  33747. * @param skippedFiles defines the list of those texture files you want to skip
  33748. * Example: [".dds", ".env", "myfile.png"]
  33749. */
  33750. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  33751. /**
  33752. * Force a specific size of the canvas
  33753. * @param width defines the new canvas' width
  33754. * @param height defines the new canvas' height
  33755. */
  33756. setSize(width: number, height: number): void;
  33757. /**
  33758. * Updates a dynamic vertex buffer.
  33759. * @param vertexBuffer the vertex buffer to update
  33760. * @param data the data used to update the vertex buffer
  33761. * @param byteOffset the byte offset of the data
  33762. * @param byteLength the byte length of the data
  33763. */
  33764. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  33765. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  33766. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33767. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  33768. _releaseTexture(texture: InternalTexture): void;
  33769. /**
  33770. * @hidden
  33771. * Rescales a texture
  33772. * @param source input texutre
  33773. * @param destination destination texture
  33774. * @param scene scene to use to render the resize
  33775. * @param internalFormat format to use when resizing
  33776. * @param onComplete callback to be called when resize has completed
  33777. */
  33778. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  33779. /**
  33780. * Gets the current framerate
  33781. * @returns a number representing the framerate
  33782. */
  33783. getFps(): number;
  33784. /**
  33785. * Gets the time spent between current and previous frame
  33786. * @returns a number representing the delta time in ms
  33787. */
  33788. getDeltaTime(): number;
  33789. private _measureFps;
  33790. /** @hidden */
  33791. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  33792. /**
  33793. * Update a dynamic index buffer
  33794. * @param indexBuffer defines the target index buffer
  33795. * @param indices defines the data to update
  33796. * @param offset defines the offset in the target index buffer where update should start
  33797. */
  33798. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  33799. /**
  33800. * Updates the sample count of a render target texture
  33801. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  33802. * @param texture defines the texture to update
  33803. * @param samples defines the sample count to set
  33804. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  33805. */
  33806. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  33807. /**
  33808. * Updates a depth texture Comparison Mode and Function.
  33809. * If the comparison Function is equal to 0, the mode will be set to none.
  33810. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  33811. * @param texture The texture to set the comparison function for
  33812. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  33813. */
  33814. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  33815. /**
  33816. * Creates a webGL buffer to use with instanciation
  33817. * @param capacity defines the size of the buffer
  33818. * @returns the webGL buffer
  33819. */
  33820. createInstancesBuffer(capacity: number): DataBuffer;
  33821. /**
  33822. * Delete a webGL buffer used with instanciation
  33823. * @param buffer defines the webGL buffer to delete
  33824. */
  33825. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  33826. /** @hidden */
  33827. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  33828. dispose(): void;
  33829. private _disableTouchAction;
  33830. /**
  33831. * Display the loading screen
  33832. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33833. */
  33834. displayLoadingUI(): void;
  33835. /**
  33836. * Hide the loading screen
  33837. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33838. */
  33839. hideLoadingUI(): void;
  33840. /**
  33841. * Gets the current loading screen object
  33842. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33843. */
  33844. get loadingScreen(): ILoadingScreen;
  33845. /**
  33846. * Sets the current loading screen object
  33847. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33848. */
  33849. set loadingScreen(loadingScreen: ILoadingScreen);
  33850. /**
  33851. * Sets the current loading screen text
  33852. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33853. */
  33854. set loadingUIText(text: string);
  33855. /**
  33856. * Sets the current loading screen background color
  33857. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33858. */
  33859. set loadingUIBackgroundColor(color: string);
  33860. /** Pointerlock and fullscreen */
  33861. /**
  33862. * Ask the browser to promote the current element to pointerlock mode
  33863. * @param element defines the DOM element to promote
  33864. */
  33865. static _RequestPointerlock(element: HTMLElement): void;
  33866. /**
  33867. * Asks the browser to exit pointerlock mode
  33868. */
  33869. static _ExitPointerlock(): void;
  33870. /**
  33871. * Ask the browser to promote the current element to fullscreen rendering mode
  33872. * @param element defines the DOM element to promote
  33873. */
  33874. static _RequestFullscreen(element: HTMLElement): void;
  33875. /**
  33876. * Asks the browser to exit fullscreen mode
  33877. */
  33878. static _ExitFullscreen(): void;
  33879. }
  33880. }
  33881. declare module BABYLON {
  33882. /**
  33883. * The engine store class is responsible to hold all the instances of Engine and Scene created
  33884. * during the life time of the application.
  33885. */
  33886. export class EngineStore {
  33887. /** Gets the list of created engines */
  33888. static Instances: Engine[];
  33889. /** @hidden */
  33890. static _LastCreatedScene: Nullable<Scene>;
  33891. /**
  33892. * Gets the latest created engine
  33893. */
  33894. static get LastCreatedEngine(): Nullable<Engine>;
  33895. /**
  33896. * Gets the latest created scene
  33897. */
  33898. static get LastCreatedScene(): Nullable<Scene>;
  33899. /**
  33900. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33901. * @ignorenaming
  33902. */
  33903. static UseFallbackTexture: boolean;
  33904. /**
  33905. * Texture content used if a texture cannot loaded
  33906. * @ignorenaming
  33907. */
  33908. static FallbackTexture: string;
  33909. }
  33910. }
  33911. declare module BABYLON {
  33912. /**
  33913. * Helper class that provides a small promise polyfill
  33914. */
  33915. export class PromisePolyfill {
  33916. /**
  33917. * Static function used to check if the polyfill is required
  33918. * If this is the case then the function will inject the polyfill to window.Promise
  33919. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  33920. */
  33921. static Apply(force?: boolean): void;
  33922. }
  33923. }
  33924. declare module BABYLON {
  33925. /**
  33926. * Interface for screenshot methods with describe argument called `size` as object with options
  33927. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  33928. */
  33929. export interface IScreenshotSize {
  33930. /**
  33931. * number in pixels for canvas height
  33932. */
  33933. height?: number;
  33934. /**
  33935. * multiplier allowing render at a higher or lower resolution
  33936. * If value is defined then height and width will be ignored and taken from camera
  33937. */
  33938. precision?: number;
  33939. /**
  33940. * number in pixels for canvas width
  33941. */
  33942. width?: number;
  33943. }
  33944. }
  33945. declare module BABYLON {
  33946. interface IColor4Like {
  33947. r: float;
  33948. g: float;
  33949. b: float;
  33950. a: float;
  33951. }
  33952. /**
  33953. * Class containing a set of static utilities functions
  33954. */
  33955. export class Tools {
  33956. /**
  33957. * Gets or sets the base URL to use to load assets
  33958. */
  33959. static get BaseUrl(): string;
  33960. static set BaseUrl(value: string);
  33961. /**
  33962. * Enable/Disable Custom HTTP Request Headers globally.
  33963. * default = false
  33964. * @see CustomRequestHeaders
  33965. */
  33966. static UseCustomRequestHeaders: boolean;
  33967. /**
  33968. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  33969. * i.e. when loading files, where the server/service expects an Authorization header
  33970. */
  33971. static CustomRequestHeaders: {
  33972. [key: string]: string;
  33973. };
  33974. /**
  33975. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  33976. */
  33977. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  33978. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  33979. /**
  33980. * Default behaviour for cors in the application.
  33981. * It can be a string if the expected behavior is identical in the entire app.
  33982. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  33983. */
  33984. static CorsBehavior: string | ((url: string | string[]) => string);
  33985. /**
  33986. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  33987. * @ignorenaming
  33988. */
  33989. static get UseFallbackTexture(): boolean;
  33990. static set UseFallbackTexture(value: boolean);
  33991. /**
  33992. * Use this object to register external classes like custom textures or material
  33993. * to allow the laoders to instantiate them
  33994. */
  33995. static get RegisteredExternalClasses(): {
  33996. [key: string]: Object;
  33997. };
  33998. static set RegisteredExternalClasses(classes: {
  33999. [key: string]: Object;
  34000. });
  34001. /**
  34002. * Texture content used if a texture cannot loaded
  34003. * @ignorenaming
  34004. */
  34005. static get fallbackTexture(): string;
  34006. static set fallbackTexture(value: string);
  34007. /**
  34008. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  34009. * @param u defines the coordinate on X axis
  34010. * @param v defines the coordinate on Y axis
  34011. * @param width defines the width of the source data
  34012. * @param height defines the height of the source data
  34013. * @param pixels defines the source byte array
  34014. * @param color defines the output color
  34015. */
  34016. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  34017. /**
  34018. * Interpolates between a and b via alpha
  34019. * @param a The lower value (returned when alpha = 0)
  34020. * @param b The upper value (returned when alpha = 1)
  34021. * @param alpha The interpolation-factor
  34022. * @return The mixed value
  34023. */
  34024. static Mix(a: number, b: number, alpha: number): number;
  34025. /**
  34026. * Tries to instantiate a new object from a given class name
  34027. * @param className defines the class name to instantiate
  34028. * @returns the new object or null if the system was not able to do the instantiation
  34029. */
  34030. static Instantiate(className: string): any;
  34031. /**
  34032. * Provides a slice function that will work even on IE
  34033. * @param data defines the array to slice
  34034. * @param start defines the start of the data (optional)
  34035. * @param end defines the end of the data (optional)
  34036. * @returns the new sliced array
  34037. */
  34038. static Slice<T>(data: T, start?: number, end?: number): T;
  34039. /**
  34040. * Polyfill for setImmediate
  34041. * @param action defines the action to execute after the current execution block
  34042. */
  34043. static SetImmediate(action: () => void): void;
  34044. /**
  34045. * Function indicating if a number is an exponent of 2
  34046. * @param value defines the value to test
  34047. * @returns true if the value is an exponent of 2
  34048. */
  34049. static IsExponentOfTwo(value: number): boolean;
  34050. private static _tmpFloatArray;
  34051. /**
  34052. * Returns the nearest 32-bit single precision float representation of a Number
  34053. * @param value A Number. If the parameter is of a different type, it will get converted
  34054. * to a number or to NaN if it cannot be converted
  34055. * @returns number
  34056. */
  34057. static FloatRound(value: number): number;
  34058. /**
  34059. * Extracts the filename from a path
  34060. * @param path defines the path to use
  34061. * @returns the filename
  34062. */
  34063. static GetFilename(path: string): string;
  34064. /**
  34065. * Extracts the "folder" part of a path (everything before the filename).
  34066. * @param uri The URI to extract the info from
  34067. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  34068. * @returns The "folder" part of the path
  34069. */
  34070. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  34071. /**
  34072. * Extracts text content from a DOM element hierarchy
  34073. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  34074. */
  34075. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  34076. /**
  34077. * Convert an angle in radians to degrees
  34078. * @param angle defines the angle to convert
  34079. * @returns the angle in degrees
  34080. */
  34081. static ToDegrees(angle: number): number;
  34082. /**
  34083. * Convert an angle in degrees to radians
  34084. * @param angle defines the angle to convert
  34085. * @returns the angle in radians
  34086. */
  34087. static ToRadians(angle: number): number;
  34088. /**
  34089. * Returns an array if obj is not an array
  34090. * @param obj defines the object to evaluate as an array
  34091. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  34092. * @returns either obj directly if obj is an array or a new array containing obj
  34093. */
  34094. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  34095. /**
  34096. * Gets the pointer prefix to use
  34097. * @returns "pointer" if touch is enabled. Else returns "mouse"
  34098. */
  34099. static GetPointerPrefix(): string;
  34100. /**
  34101. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  34102. * @param url define the url we are trying
  34103. * @param element define the dom element where to configure the cors policy
  34104. */
  34105. static SetCorsBehavior(url: string | string[], element: {
  34106. crossOrigin: string | null;
  34107. }): void;
  34108. /**
  34109. * Removes unwanted characters from an url
  34110. * @param url defines the url to clean
  34111. * @returns the cleaned url
  34112. */
  34113. static CleanUrl(url: string): string;
  34114. /**
  34115. * Gets or sets a function used to pre-process url before using them to load assets
  34116. */
  34117. static get PreprocessUrl(): (url: string) => string;
  34118. static set PreprocessUrl(processor: (url: string) => string);
  34119. /**
  34120. * Loads an image as an HTMLImageElement.
  34121. * @param input url string, ArrayBuffer, or Blob to load
  34122. * @param onLoad callback called when the image successfully loads
  34123. * @param onError callback called when the image fails to load
  34124. * @param offlineProvider offline provider for caching
  34125. * @param mimeType optional mime type
  34126. * @returns the HTMLImageElement of the loaded image
  34127. */
  34128. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  34129. /**
  34130. * Loads a file from a url
  34131. * @param url url string, ArrayBuffer, or Blob to load
  34132. * @param onSuccess callback called when the file successfully loads
  34133. * @param onProgress callback called while file is loading (if the server supports this mode)
  34134. * @param offlineProvider defines the offline provider for caching
  34135. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34136. * @param onError callback called when the file fails to load
  34137. * @returns a file request object
  34138. */
  34139. 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;
  34140. /**
  34141. * Loads a file from a url
  34142. * @param url the file url to load
  34143. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  34144. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  34145. */
  34146. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  34147. /**
  34148. * Load a script (identified by an url). When the url returns, the
  34149. * content of this file is added into a new script element, attached to the DOM (body element)
  34150. * @param scriptUrl defines the url of the script to laod
  34151. * @param onSuccess defines the callback called when the script is loaded
  34152. * @param onError defines the callback to call if an error occurs
  34153. * @param scriptId defines the id of the script element
  34154. */
  34155. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  34156. /**
  34157. * Load an asynchronous script (identified by an url). When the url returns, the
  34158. * content of this file is added into a new script element, attached to the DOM (body element)
  34159. * @param scriptUrl defines the url of the script to laod
  34160. * @param scriptId defines the id of the script element
  34161. * @returns a promise request object
  34162. */
  34163. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  34164. /**
  34165. * Loads a file from a blob
  34166. * @param fileToLoad defines the blob to use
  34167. * @param callback defines the callback to call when data is loaded
  34168. * @param progressCallback defines the callback to call during loading process
  34169. * @returns a file request object
  34170. */
  34171. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  34172. /**
  34173. * Reads a file from a File object
  34174. * @param file defines the file to load
  34175. * @param onSuccess defines the callback to call when data is loaded
  34176. * @param onProgress defines the callback to call during loading process
  34177. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  34178. * @param onError defines the callback to call when an error occurs
  34179. * @returns a file request object
  34180. */
  34181. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  34182. /**
  34183. * Creates a data url from a given string content
  34184. * @param content defines the content to convert
  34185. * @returns the new data url link
  34186. */
  34187. static FileAsURL(content: string): string;
  34188. /**
  34189. * Format the given number to a specific decimal format
  34190. * @param value defines the number to format
  34191. * @param decimals defines the number of decimals to use
  34192. * @returns the formatted string
  34193. */
  34194. static Format(value: number, decimals?: number): string;
  34195. /**
  34196. * Tries to copy an object by duplicating every property
  34197. * @param source defines the source object
  34198. * @param destination defines the target object
  34199. * @param doNotCopyList defines a list of properties to avoid
  34200. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  34201. */
  34202. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  34203. /**
  34204. * Gets a boolean indicating if the given object has no own property
  34205. * @param obj defines the object to test
  34206. * @returns true if object has no own property
  34207. */
  34208. static IsEmpty(obj: any): boolean;
  34209. /**
  34210. * Function used to register events at window level
  34211. * @param windowElement defines the Window object to use
  34212. * @param events defines the events to register
  34213. */
  34214. static RegisterTopRootEvents(windowElement: Window, events: {
  34215. name: string;
  34216. handler: Nullable<(e: FocusEvent) => any>;
  34217. }[]): void;
  34218. /**
  34219. * Function used to unregister events from window level
  34220. * @param windowElement defines the Window object to use
  34221. * @param events defines the events to unregister
  34222. */
  34223. static UnregisterTopRootEvents(windowElement: Window, events: {
  34224. name: string;
  34225. handler: Nullable<(e: FocusEvent) => any>;
  34226. }[]): void;
  34227. /**
  34228. * @ignore
  34229. */
  34230. static _ScreenshotCanvas: HTMLCanvasElement;
  34231. /**
  34232. * Dumps the current bound framebuffer
  34233. * @param width defines the rendering width
  34234. * @param height defines the rendering height
  34235. * @param engine defines the hosting engine
  34236. * @param successCallback defines the callback triggered once the data are available
  34237. * @param mimeType defines the mime type of the result
  34238. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  34239. */
  34240. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34241. /**
  34242. * Converts the canvas data to blob.
  34243. * This acts as a polyfill for browsers not supporting the to blob function.
  34244. * @param canvas Defines the canvas to extract the data from
  34245. * @param successCallback Defines the callback triggered once the data are available
  34246. * @param mimeType Defines the mime type of the result
  34247. */
  34248. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  34249. /**
  34250. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  34251. * @param successCallback defines the callback triggered once the data are available
  34252. * @param mimeType defines the mime type of the result
  34253. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  34254. */
  34255. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  34256. /**
  34257. * Downloads a blob in the browser
  34258. * @param blob defines the blob to download
  34259. * @param fileName defines the name of the downloaded file
  34260. */
  34261. static Download(blob: Blob, fileName: string): void;
  34262. /**
  34263. * Captures a screenshot of the current rendering
  34264. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34265. * @param engine defines the rendering engine
  34266. * @param camera defines the source camera
  34267. * @param size This parameter can be set to a single number or to an object with the
  34268. * following (optional) properties: precision, width, height. If a single number is passed,
  34269. * it will be used for both width and height. If an object is passed, the screenshot size
  34270. * will be derived from the parameters. The precision property is a multiplier allowing
  34271. * rendering at a higher or lower resolution
  34272. * @param successCallback defines the callback receives a single parameter which contains the
  34273. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34274. * src parameter of an <img> to display it
  34275. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34276. * Check your browser for supported MIME types
  34277. */
  34278. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  34279. /**
  34280. * Captures a screenshot of the current rendering
  34281. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34282. * @param engine defines the rendering engine
  34283. * @param camera defines the source camera
  34284. * @param size This parameter can be set to a single number or to an object with the
  34285. * following (optional) properties: precision, width, height. If a single number is passed,
  34286. * it will be used for both width and height. If an object is passed, the screenshot size
  34287. * will be derived from the parameters. The precision property is a multiplier allowing
  34288. * rendering at a higher or lower resolution
  34289. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  34290. * Check your browser for supported MIME types
  34291. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34292. * to the src parameter of an <img> to display it
  34293. */
  34294. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  34295. /**
  34296. * Generates an image screenshot from the specified camera.
  34297. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34298. * @param engine The engine to use for rendering
  34299. * @param camera The camera to use for rendering
  34300. * @param size This parameter can be set to a single number or to an object with the
  34301. * following (optional) properties: precision, width, height. If a single number is passed,
  34302. * it will be used for both width and height. If an object is passed, the screenshot size
  34303. * will be derived from the parameters. The precision property is a multiplier allowing
  34304. * rendering at a higher or lower resolution
  34305. * @param successCallback The callback receives a single parameter which contains the
  34306. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  34307. * src parameter of an <img> to display it
  34308. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34309. * Check your browser for supported MIME types
  34310. * @param samples Texture samples (default: 1)
  34311. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34312. * @param fileName A name for for the downloaded file.
  34313. */
  34314. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  34315. /**
  34316. * Generates an image screenshot from the specified camera.
  34317. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  34318. * @param engine The engine to use for rendering
  34319. * @param camera The camera to use for rendering
  34320. * @param size This parameter can be set to a single number or to an object with the
  34321. * following (optional) properties: precision, width, height. If a single number is passed,
  34322. * it will be used for both width and height. If an object is passed, the screenshot size
  34323. * will be derived from the parameters. The precision property is a multiplier allowing
  34324. * rendering at a higher or lower resolution
  34325. * @param mimeType The MIME type of the screenshot image (default: image/png).
  34326. * Check your browser for supported MIME types
  34327. * @param samples Texture samples (default: 1)
  34328. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  34329. * @param fileName A name for for the downloaded file.
  34330. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  34331. * to the src parameter of an <img> to display it
  34332. */
  34333. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  34334. /**
  34335. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  34336. * Be aware Math.random() could cause collisions, but:
  34337. * "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"
  34338. * @returns a pseudo random id
  34339. */
  34340. static RandomId(): string;
  34341. /**
  34342. * Test if the given uri is a base64 string
  34343. * @param uri The uri to test
  34344. * @return True if the uri is a base64 string or false otherwise
  34345. */
  34346. static IsBase64(uri: string): boolean;
  34347. /**
  34348. * Decode the given base64 uri.
  34349. * @param uri The uri to decode
  34350. * @return The decoded base64 data.
  34351. */
  34352. static DecodeBase64(uri: string): ArrayBuffer;
  34353. /**
  34354. * Gets the absolute url.
  34355. * @param url the input url
  34356. * @return the absolute url
  34357. */
  34358. static GetAbsoluteUrl(url: string): string;
  34359. /**
  34360. * No log
  34361. */
  34362. static readonly NoneLogLevel: number;
  34363. /**
  34364. * Only message logs
  34365. */
  34366. static readonly MessageLogLevel: number;
  34367. /**
  34368. * Only warning logs
  34369. */
  34370. static readonly WarningLogLevel: number;
  34371. /**
  34372. * Only error logs
  34373. */
  34374. static readonly ErrorLogLevel: number;
  34375. /**
  34376. * All logs
  34377. */
  34378. static readonly AllLogLevel: number;
  34379. /**
  34380. * Gets a value indicating the number of loading errors
  34381. * @ignorenaming
  34382. */
  34383. static get errorsCount(): number;
  34384. /**
  34385. * Callback called when a new log is added
  34386. */
  34387. static OnNewCacheEntry: (entry: string) => void;
  34388. /**
  34389. * Log a message to the console
  34390. * @param message defines the message to log
  34391. */
  34392. static Log(message: string): void;
  34393. /**
  34394. * Write a warning message to the console
  34395. * @param message defines the message to log
  34396. */
  34397. static Warn(message: string): void;
  34398. /**
  34399. * Write an error message to the console
  34400. * @param message defines the message to log
  34401. */
  34402. static Error(message: string): void;
  34403. /**
  34404. * Gets current log cache (list of logs)
  34405. */
  34406. static get LogCache(): string;
  34407. /**
  34408. * Clears the log cache
  34409. */
  34410. static ClearLogCache(): void;
  34411. /**
  34412. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  34413. */
  34414. static set LogLevels(level: number);
  34415. /**
  34416. * Checks if the window object exists
  34417. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  34418. */
  34419. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  34420. /**
  34421. * No performance log
  34422. */
  34423. static readonly PerformanceNoneLogLevel: number;
  34424. /**
  34425. * Use user marks to log performance
  34426. */
  34427. static readonly PerformanceUserMarkLogLevel: number;
  34428. /**
  34429. * Log performance to the console
  34430. */
  34431. static readonly PerformanceConsoleLogLevel: number;
  34432. private static _performance;
  34433. /**
  34434. * Sets the current performance log level
  34435. */
  34436. static set PerformanceLogLevel(level: number);
  34437. private static _StartPerformanceCounterDisabled;
  34438. private static _EndPerformanceCounterDisabled;
  34439. private static _StartUserMark;
  34440. private static _EndUserMark;
  34441. private static _StartPerformanceConsole;
  34442. private static _EndPerformanceConsole;
  34443. /**
  34444. * Starts a performance counter
  34445. */
  34446. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34447. /**
  34448. * Ends a specific performance coutner
  34449. */
  34450. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  34451. /**
  34452. * Gets either window.performance.now() if supported or Date.now() else
  34453. */
  34454. static get Now(): number;
  34455. /**
  34456. * This method will return the name of the class used to create the instance of the given object.
  34457. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  34458. * @param object the object to get the class name from
  34459. * @param isType defines if the object is actually a type
  34460. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  34461. */
  34462. static GetClassName(object: any, isType?: boolean): string;
  34463. /**
  34464. * Gets the first element of an array satisfying a given predicate
  34465. * @param array defines the array to browse
  34466. * @param predicate defines the predicate to use
  34467. * @returns null if not found or the element
  34468. */
  34469. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  34470. /**
  34471. * This method will return the name of the full name of the class, including its owning module (if any).
  34472. * 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).
  34473. * @param object the object to get the class name from
  34474. * @param isType defines if the object is actually a type
  34475. * @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.
  34476. * @ignorenaming
  34477. */
  34478. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  34479. /**
  34480. * Returns a promise that resolves after the given amount of time.
  34481. * @param delay Number of milliseconds to delay
  34482. * @returns Promise that resolves after the given amount of time
  34483. */
  34484. static DelayAsync(delay: number): Promise<void>;
  34485. /**
  34486. * Utility function to detect if the current user agent is Safari
  34487. * @returns whether or not the current user agent is safari
  34488. */
  34489. static IsSafari(): boolean;
  34490. }
  34491. /**
  34492. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  34493. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  34494. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  34495. * @param name The name of the class, case should be preserved
  34496. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  34497. */
  34498. export function className(name: string, module?: string): (target: Object) => void;
  34499. /**
  34500. * An implementation of a loop for asynchronous functions.
  34501. */
  34502. export class AsyncLoop {
  34503. /**
  34504. * Defines the number of iterations for the loop
  34505. */
  34506. iterations: number;
  34507. /**
  34508. * Defines the current index of the loop.
  34509. */
  34510. index: number;
  34511. private _done;
  34512. private _fn;
  34513. private _successCallback;
  34514. /**
  34515. * Constructor.
  34516. * @param iterations the number of iterations.
  34517. * @param func the function to run each iteration
  34518. * @param successCallback the callback that will be called upon succesful execution
  34519. * @param offset starting offset.
  34520. */
  34521. constructor(
  34522. /**
  34523. * Defines the number of iterations for the loop
  34524. */
  34525. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  34526. /**
  34527. * Execute the next iteration. Must be called after the last iteration was finished.
  34528. */
  34529. executeNext(): void;
  34530. /**
  34531. * Break the loop and run the success callback.
  34532. */
  34533. breakLoop(): void;
  34534. /**
  34535. * Create and run an async loop.
  34536. * @param iterations the number of iterations.
  34537. * @param fn the function to run each iteration
  34538. * @param successCallback the callback that will be called upon succesful execution
  34539. * @param offset starting offset.
  34540. * @returns the created async loop object
  34541. */
  34542. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  34543. /**
  34544. * A for-loop that will run a given number of iterations synchronous and the rest async.
  34545. * @param iterations total number of iterations
  34546. * @param syncedIterations number of synchronous iterations in each async iteration.
  34547. * @param fn the function to call each iteration.
  34548. * @param callback a success call back that will be called when iterating stops.
  34549. * @param breakFunction a break condition (optional)
  34550. * @param timeout timeout settings for the setTimeout function. default - 0.
  34551. * @returns the created async loop object
  34552. */
  34553. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  34554. }
  34555. }
  34556. declare module BABYLON {
  34557. /**
  34558. * This class implement a typical dictionary using a string as key and the generic type T as value.
  34559. * The underlying implementation relies on an associative array to ensure the best performances.
  34560. * The value can be anything including 'null' but except 'undefined'
  34561. */
  34562. export class StringDictionary<T> {
  34563. /**
  34564. * This will clear this dictionary and copy the content from the 'source' one.
  34565. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  34566. * @param source the dictionary to take the content from and copy to this dictionary
  34567. */
  34568. copyFrom(source: StringDictionary<T>): void;
  34569. /**
  34570. * Get a value based from its key
  34571. * @param key the given key to get the matching value from
  34572. * @return the value if found, otherwise undefined is returned
  34573. */
  34574. get(key: string): T | undefined;
  34575. /**
  34576. * Get a value from its key or add it if it doesn't exist.
  34577. * This method will ensure you that a given key/data will be present in the dictionary.
  34578. * @param key the given key to get the matching value from
  34579. * @param factory the factory that will create the value if the key is not present in the dictionary.
  34580. * The factory will only be invoked if there's no data for the given key.
  34581. * @return the value corresponding to the key.
  34582. */
  34583. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  34584. /**
  34585. * Get a value from its key if present in the dictionary otherwise add it
  34586. * @param key the key to get the value from
  34587. * @param val if there's no such key/value pair in the dictionary add it with this value
  34588. * @return the value corresponding to the key
  34589. */
  34590. getOrAdd(key: string, val: T): T;
  34591. /**
  34592. * Check if there's a given key in the dictionary
  34593. * @param key the key to check for
  34594. * @return true if the key is present, false otherwise
  34595. */
  34596. contains(key: string): boolean;
  34597. /**
  34598. * Add a new key and its corresponding value
  34599. * @param key the key to add
  34600. * @param value the value corresponding to the key
  34601. * @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
  34602. */
  34603. add(key: string, value: T): boolean;
  34604. /**
  34605. * Update a specific value associated to a key
  34606. * @param key defines the key to use
  34607. * @param value defines the value to store
  34608. * @returns true if the value was updated (or false if the key was not found)
  34609. */
  34610. set(key: string, value: T): boolean;
  34611. /**
  34612. * Get the element of the given key and remove it from the dictionary
  34613. * @param key defines the key to search
  34614. * @returns the value associated with the key or null if not found
  34615. */
  34616. getAndRemove(key: string): Nullable<T>;
  34617. /**
  34618. * Remove a key/value from the dictionary.
  34619. * @param key the key to remove
  34620. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  34621. */
  34622. remove(key: string): boolean;
  34623. /**
  34624. * Clear the whole content of the dictionary
  34625. */
  34626. clear(): void;
  34627. /**
  34628. * Gets the current count
  34629. */
  34630. get count(): number;
  34631. /**
  34632. * Execute a callback on each key/val of the dictionary.
  34633. * Note that you can remove any element in this dictionary in the callback implementation
  34634. * @param callback the callback to execute on a given key/value pair
  34635. */
  34636. forEach(callback: (key: string, val: T) => void): void;
  34637. /**
  34638. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  34639. * If the callback returns null or undefined the method will iterate to the next key/value pair
  34640. * Note that you can remove any element in this dictionary in the callback implementation
  34641. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  34642. * @returns the first item
  34643. */
  34644. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  34645. private _count;
  34646. private _data;
  34647. }
  34648. }
  34649. declare module BABYLON {
  34650. /** @hidden */
  34651. export interface ICollisionCoordinator {
  34652. createCollider(): Collider;
  34653. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34654. init(scene: Scene): void;
  34655. }
  34656. /** @hidden */
  34657. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  34658. private _scene;
  34659. private _scaledPosition;
  34660. private _scaledVelocity;
  34661. private _finalPosition;
  34662. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  34663. createCollider(): Collider;
  34664. init(scene: Scene): void;
  34665. private _collideWithWorld;
  34666. }
  34667. }
  34668. declare module BABYLON {
  34669. /**
  34670. * Class used to manage all inputs for the scene.
  34671. */
  34672. export class InputManager {
  34673. /** The distance in pixel that you have to move to prevent some events */
  34674. static DragMovementThreshold: number;
  34675. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  34676. static LongPressDelay: number;
  34677. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  34678. static DoubleClickDelay: number;
  34679. /** If you need to check double click without raising a single click at first click, enable this flag */
  34680. static ExclusiveDoubleClickMode: boolean;
  34681. private _wheelEventName;
  34682. private _onPointerMove;
  34683. private _onPointerDown;
  34684. private _onPointerUp;
  34685. private _initClickEvent;
  34686. private _initActionManager;
  34687. private _delayedSimpleClick;
  34688. private _delayedSimpleClickTimeout;
  34689. private _previousDelayedSimpleClickTimeout;
  34690. private _meshPickProceed;
  34691. private _previousButtonPressed;
  34692. private _currentPickResult;
  34693. private _previousPickResult;
  34694. private _totalPointersPressed;
  34695. private _doubleClickOccured;
  34696. private _pointerOverMesh;
  34697. private _pickedDownMesh;
  34698. private _pickedUpMesh;
  34699. private _pointerX;
  34700. private _pointerY;
  34701. private _unTranslatedPointerX;
  34702. private _unTranslatedPointerY;
  34703. private _startingPointerPosition;
  34704. private _previousStartingPointerPosition;
  34705. private _startingPointerTime;
  34706. private _previousStartingPointerTime;
  34707. private _pointerCaptures;
  34708. private _onKeyDown;
  34709. private _onKeyUp;
  34710. private _onCanvasFocusObserver;
  34711. private _onCanvasBlurObserver;
  34712. private _scene;
  34713. /**
  34714. * Creates a new InputManager
  34715. * @param scene defines the hosting scene
  34716. */
  34717. constructor(scene: Scene);
  34718. /**
  34719. * Gets the mesh that is currently under the pointer
  34720. */
  34721. get meshUnderPointer(): Nullable<AbstractMesh>;
  34722. /**
  34723. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  34724. */
  34725. get unTranslatedPointer(): Vector2;
  34726. /**
  34727. * Gets or sets the current on-screen X position of the pointer
  34728. */
  34729. get pointerX(): number;
  34730. set pointerX(value: number);
  34731. /**
  34732. * Gets or sets the current on-screen Y position of the pointer
  34733. */
  34734. get pointerY(): number;
  34735. set pointerY(value: number);
  34736. private _updatePointerPosition;
  34737. private _processPointerMove;
  34738. private _setRayOnPointerInfo;
  34739. private _checkPrePointerObservable;
  34740. /**
  34741. * Use this method to simulate a pointer move on a mesh
  34742. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34743. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34744. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34745. */
  34746. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34747. /**
  34748. * Use this method to simulate a pointer down on a mesh
  34749. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34750. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34751. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34752. */
  34753. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  34754. private _processPointerDown;
  34755. /** @hidden */
  34756. _isPointerSwiping(): boolean;
  34757. /**
  34758. * Use this method to simulate a pointer up on a mesh
  34759. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34760. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34761. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34762. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34763. */
  34764. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  34765. private _processPointerUp;
  34766. /**
  34767. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34768. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34769. * @returns true if the pointer was captured
  34770. */
  34771. isPointerCaptured(pointerId?: number): boolean;
  34772. /**
  34773. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34774. * @param attachUp defines if you want to attach events to pointerup
  34775. * @param attachDown defines if you want to attach events to pointerdown
  34776. * @param attachMove defines if you want to attach events to pointermove
  34777. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  34778. */
  34779. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  34780. /**
  34781. * Detaches all event handlers
  34782. */
  34783. detachControl(): void;
  34784. /**
  34785. * Force the value of meshUnderPointer
  34786. * @param mesh defines the mesh to use
  34787. */
  34788. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34789. /**
  34790. * Gets the mesh under the pointer
  34791. * @returns a Mesh or null if no mesh is under the pointer
  34792. */
  34793. getPointerOverMesh(): Nullable<AbstractMesh>;
  34794. }
  34795. }
  34796. declare module BABYLON {
  34797. /**
  34798. * Helper class used to generate session unique ID
  34799. */
  34800. export class UniqueIdGenerator {
  34801. private static _UniqueIdCounter;
  34802. /**
  34803. * Gets an unique (relatively to the current scene) Id
  34804. */
  34805. static get UniqueId(): number;
  34806. }
  34807. }
  34808. declare module BABYLON {
  34809. /**
  34810. * This class defines the direct association between an animation and a target
  34811. */
  34812. export class TargetedAnimation {
  34813. /**
  34814. * Animation to perform
  34815. */
  34816. animation: Animation;
  34817. /**
  34818. * Target to animate
  34819. */
  34820. target: any;
  34821. /**
  34822. * Serialize the object
  34823. * @returns the JSON object representing the current entity
  34824. */
  34825. serialize(): any;
  34826. }
  34827. /**
  34828. * Use this class to create coordinated animations on multiple targets
  34829. */
  34830. export class AnimationGroup implements IDisposable {
  34831. /** The name of the animation group */
  34832. name: string;
  34833. private _scene;
  34834. private _targetedAnimations;
  34835. private _animatables;
  34836. private _from;
  34837. private _to;
  34838. private _isStarted;
  34839. private _isPaused;
  34840. private _speedRatio;
  34841. private _loopAnimation;
  34842. /**
  34843. * Gets or sets the unique id of the node
  34844. */
  34845. uniqueId: number;
  34846. /**
  34847. * This observable will notify when one animation have ended
  34848. */
  34849. onAnimationEndObservable: Observable<TargetedAnimation>;
  34850. /**
  34851. * Observer raised when one animation loops
  34852. */
  34853. onAnimationLoopObservable: Observable<TargetedAnimation>;
  34854. /**
  34855. * Observer raised when all animations have looped
  34856. */
  34857. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  34858. /**
  34859. * This observable will notify when all animations have ended.
  34860. */
  34861. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  34862. /**
  34863. * This observable will notify when all animations have paused.
  34864. */
  34865. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  34866. /**
  34867. * This observable will notify when all animations are playing.
  34868. */
  34869. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  34870. /**
  34871. * Gets the first frame
  34872. */
  34873. get from(): number;
  34874. /**
  34875. * Gets the last frame
  34876. */
  34877. get to(): number;
  34878. /**
  34879. * Define if the animations are started
  34880. */
  34881. get isStarted(): boolean;
  34882. /**
  34883. * Gets a value indicating that the current group is playing
  34884. */
  34885. get isPlaying(): boolean;
  34886. /**
  34887. * Gets or sets the speed ratio to use for all animations
  34888. */
  34889. get speedRatio(): number;
  34890. /**
  34891. * Gets or sets the speed ratio to use for all animations
  34892. */
  34893. set speedRatio(value: number);
  34894. /**
  34895. * Gets or sets if all animations should loop or not
  34896. */
  34897. get loopAnimation(): boolean;
  34898. set loopAnimation(value: boolean);
  34899. /**
  34900. * Gets the targeted animations for this animation group
  34901. */
  34902. get targetedAnimations(): Array<TargetedAnimation>;
  34903. /**
  34904. * returning the list of animatables controlled by this animation group.
  34905. */
  34906. get animatables(): Array<Animatable>;
  34907. /**
  34908. * Instantiates a new Animation Group.
  34909. * This helps managing several animations at once.
  34910. * @see http://doc.babylonjs.com/how_to/group
  34911. * @param name Defines the name of the group
  34912. * @param scene Defines the scene the group belongs to
  34913. */
  34914. constructor(
  34915. /** The name of the animation group */
  34916. name: string, scene?: Nullable<Scene>);
  34917. /**
  34918. * Add an animation (with its target) in the group
  34919. * @param animation defines the animation we want to add
  34920. * @param target defines the target of the animation
  34921. * @returns the TargetedAnimation object
  34922. */
  34923. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  34924. /**
  34925. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  34926. * It can add constant keys at begin or end
  34927. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  34928. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  34929. * @returns the animation group
  34930. */
  34931. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  34932. private _animationLoopCount;
  34933. private _animationLoopFlags;
  34934. private _processLoop;
  34935. /**
  34936. * Start all animations on given targets
  34937. * @param loop defines if animations must loop
  34938. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  34939. * @param from defines the from key (optional)
  34940. * @param to defines the to key (optional)
  34941. * @returns the current animation group
  34942. */
  34943. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  34944. /**
  34945. * Pause all animations
  34946. * @returns the animation group
  34947. */
  34948. pause(): AnimationGroup;
  34949. /**
  34950. * Play all animations to initial state
  34951. * This function will start() the animations if they were not started or will restart() them if they were paused
  34952. * @param loop defines if animations must loop
  34953. * @returns the animation group
  34954. */
  34955. play(loop?: boolean): AnimationGroup;
  34956. /**
  34957. * Reset all animations to initial state
  34958. * @returns the animation group
  34959. */
  34960. reset(): AnimationGroup;
  34961. /**
  34962. * Restart animations from key 0
  34963. * @returns the animation group
  34964. */
  34965. restart(): AnimationGroup;
  34966. /**
  34967. * Stop all animations
  34968. * @returns the animation group
  34969. */
  34970. stop(): AnimationGroup;
  34971. /**
  34972. * Set animation weight for all animatables
  34973. * @param weight defines the weight to use
  34974. * @return the animationGroup
  34975. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34976. */
  34977. setWeightForAllAnimatables(weight: number): AnimationGroup;
  34978. /**
  34979. * Synchronize and normalize all animatables with a source animatable
  34980. * @param root defines the root animatable to synchronize with
  34981. * @return the animationGroup
  34982. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  34983. */
  34984. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  34985. /**
  34986. * Goes to a specific frame in this animation group
  34987. * @param frame the frame number to go to
  34988. * @return the animationGroup
  34989. */
  34990. goToFrame(frame: number): AnimationGroup;
  34991. /**
  34992. * Dispose all associated resources
  34993. */
  34994. dispose(): void;
  34995. private _checkAnimationGroupEnded;
  34996. /**
  34997. * Clone the current animation group and returns a copy
  34998. * @param newName defines the name of the new group
  34999. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  35000. * @returns the new aniamtion group
  35001. */
  35002. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  35003. /**
  35004. * Serializes the animationGroup to an object
  35005. * @returns Serialized object
  35006. */
  35007. serialize(): any;
  35008. /**
  35009. * Returns a new AnimationGroup object parsed from the source provided.
  35010. * @param parsedAnimationGroup defines the source
  35011. * @param scene defines the scene that will receive the animationGroup
  35012. * @returns a new AnimationGroup
  35013. */
  35014. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  35015. /**
  35016. * Returns the string "AnimationGroup"
  35017. * @returns "AnimationGroup"
  35018. */
  35019. getClassName(): string;
  35020. /**
  35021. * Creates a detailled string about the object
  35022. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  35023. * @returns a string representing the object
  35024. */
  35025. toString(fullDetails?: boolean): string;
  35026. }
  35027. }
  35028. declare module BABYLON {
  35029. /**
  35030. * Define an interface for all classes that will hold resources
  35031. */
  35032. export interface IDisposable {
  35033. /**
  35034. * Releases all held resources
  35035. */
  35036. dispose(): void;
  35037. }
  35038. /** Interface defining initialization parameters for Scene class */
  35039. export interface SceneOptions {
  35040. /**
  35041. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  35042. * It will improve performance when the number of geometries becomes important.
  35043. */
  35044. useGeometryUniqueIdsMap?: boolean;
  35045. /**
  35046. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  35047. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35048. */
  35049. useMaterialMeshMap?: boolean;
  35050. /**
  35051. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  35052. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  35053. */
  35054. useClonedMeshMap?: boolean;
  35055. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  35056. virtual?: boolean;
  35057. }
  35058. /**
  35059. * Represents a scene to be rendered by the engine.
  35060. * @see http://doc.babylonjs.com/features/scene
  35061. */
  35062. export class Scene extends AbstractScene implements IAnimatable {
  35063. /** The fog is deactivated */
  35064. static readonly FOGMODE_NONE: number;
  35065. /** The fog density is following an exponential function */
  35066. static readonly FOGMODE_EXP: number;
  35067. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  35068. static readonly FOGMODE_EXP2: number;
  35069. /** The fog density is following a linear function. */
  35070. static readonly FOGMODE_LINEAR: number;
  35071. /**
  35072. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  35073. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35074. */
  35075. static MinDeltaTime: number;
  35076. /**
  35077. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  35078. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35079. */
  35080. static MaxDeltaTime: number;
  35081. /**
  35082. * Factory used to create the default material.
  35083. * @param name The name of the material to create
  35084. * @param scene The scene to create the material for
  35085. * @returns The default material
  35086. */
  35087. static DefaultMaterialFactory(scene: Scene): Material;
  35088. /**
  35089. * Factory used to create the a collision coordinator.
  35090. * @returns The collision coordinator
  35091. */
  35092. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  35093. /** @hidden */
  35094. _inputManager: InputManager;
  35095. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  35096. cameraToUseForPointers: Nullable<Camera>;
  35097. /** @hidden */
  35098. readonly _isScene: boolean;
  35099. /**
  35100. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  35101. */
  35102. autoClear: boolean;
  35103. /**
  35104. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  35105. */
  35106. autoClearDepthAndStencil: boolean;
  35107. /**
  35108. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  35109. */
  35110. clearColor: Color4;
  35111. /**
  35112. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  35113. */
  35114. ambientColor: Color3;
  35115. /**
  35116. * This is use to store the default BRDF lookup for PBR materials in your scene.
  35117. * It should only be one of the following (if not the default embedded one):
  35118. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  35119. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  35120. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  35121. * The material properties need to be setup according to the type of texture in use.
  35122. */
  35123. environmentBRDFTexture: BaseTexture;
  35124. /** @hidden */
  35125. protected _environmentTexture: Nullable<BaseTexture>;
  35126. /**
  35127. * Texture used in all pbr material as the reflection texture.
  35128. * As in the majority of the scene they are the same (exception for multi room and so on),
  35129. * this is easier to reference from here than from all the materials.
  35130. */
  35131. get environmentTexture(): Nullable<BaseTexture>;
  35132. /**
  35133. * Texture used in all pbr material as the reflection texture.
  35134. * As in the majority of the scene they are the same (exception for multi room and so on),
  35135. * this is easier to set here than in all the materials.
  35136. */
  35137. set environmentTexture(value: Nullable<BaseTexture>);
  35138. /** @hidden */
  35139. protected _environmentIntensity: number;
  35140. /**
  35141. * Intensity of the environment in all pbr material.
  35142. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35143. * As in the majority of the scene they are the same (exception for multi room and so on),
  35144. * this is easier to reference from here than from all the materials.
  35145. */
  35146. get environmentIntensity(): number;
  35147. /**
  35148. * Intensity of the environment in all pbr material.
  35149. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  35150. * As in the majority of the scene they are the same (exception for multi room and so on),
  35151. * this is easier to set here than in all the materials.
  35152. */
  35153. set environmentIntensity(value: number);
  35154. /** @hidden */
  35155. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  35156. /**
  35157. * Default image processing configuration used either in the rendering
  35158. * Forward main pass or through the imageProcessingPostProcess if present.
  35159. * As in the majority of the scene they are the same (exception for multi camera),
  35160. * this is easier to reference from here than from all the materials and post process.
  35161. *
  35162. * No setter as we it is a shared configuration, you can set the values instead.
  35163. */
  35164. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  35165. private _forceWireframe;
  35166. /**
  35167. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  35168. */
  35169. set forceWireframe(value: boolean);
  35170. get forceWireframe(): boolean;
  35171. private _skipFrustumClipping;
  35172. /**
  35173. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  35174. */
  35175. set skipFrustumClipping(value: boolean);
  35176. get skipFrustumClipping(): boolean;
  35177. private _forcePointsCloud;
  35178. /**
  35179. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  35180. */
  35181. set forcePointsCloud(value: boolean);
  35182. get forcePointsCloud(): boolean;
  35183. /**
  35184. * Gets or sets the active clipplane 1
  35185. */
  35186. clipPlane: Nullable<Plane>;
  35187. /**
  35188. * Gets or sets the active clipplane 2
  35189. */
  35190. clipPlane2: Nullable<Plane>;
  35191. /**
  35192. * Gets or sets the active clipplane 3
  35193. */
  35194. clipPlane3: Nullable<Plane>;
  35195. /**
  35196. * Gets or sets the active clipplane 4
  35197. */
  35198. clipPlane4: Nullable<Plane>;
  35199. /**
  35200. * Gets or sets the active clipplane 5
  35201. */
  35202. clipPlane5: Nullable<Plane>;
  35203. /**
  35204. * Gets or sets the active clipplane 6
  35205. */
  35206. clipPlane6: Nullable<Plane>;
  35207. /**
  35208. * Gets or sets a boolean indicating if animations are enabled
  35209. */
  35210. animationsEnabled: boolean;
  35211. private _animationPropertiesOverride;
  35212. /**
  35213. * Gets or sets the animation properties override
  35214. */
  35215. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  35216. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  35217. /**
  35218. * Gets or sets a boolean indicating if a constant deltatime has to be used
  35219. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  35220. */
  35221. useConstantAnimationDeltaTime: boolean;
  35222. /**
  35223. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  35224. * Please note that it requires to run a ray cast through the scene on every frame
  35225. */
  35226. constantlyUpdateMeshUnderPointer: boolean;
  35227. /**
  35228. * Defines the HTML cursor to use when hovering over interactive elements
  35229. */
  35230. hoverCursor: string;
  35231. /**
  35232. * Defines the HTML default cursor to use (empty by default)
  35233. */
  35234. defaultCursor: string;
  35235. /**
  35236. * Defines whether cursors are handled by the scene.
  35237. */
  35238. doNotHandleCursors: boolean;
  35239. /**
  35240. * This is used to call preventDefault() on pointer down
  35241. * in order to block unwanted artifacts like system double clicks
  35242. */
  35243. preventDefaultOnPointerDown: boolean;
  35244. /**
  35245. * This is used to call preventDefault() on pointer up
  35246. * in order to block unwanted artifacts like system double clicks
  35247. */
  35248. preventDefaultOnPointerUp: boolean;
  35249. /**
  35250. * Gets or sets user defined metadata
  35251. */
  35252. metadata: any;
  35253. /**
  35254. * For internal use only. Please do not use.
  35255. */
  35256. reservedDataStore: any;
  35257. /**
  35258. * Gets the name of the plugin used to load this scene (null by default)
  35259. */
  35260. loadingPluginName: string;
  35261. /**
  35262. * Use this array to add regular expressions used to disable offline support for specific urls
  35263. */
  35264. disableOfflineSupportExceptionRules: RegExp[];
  35265. /**
  35266. * An event triggered when the scene is disposed.
  35267. */
  35268. onDisposeObservable: Observable<Scene>;
  35269. private _onDisposeObserver;
  35270. /** Sets a function to be executed when this scene is disposed. */
  35271. set onDispose(callback: () => void);
  35272. /**
  35273. * An event triggered before rendering the scene (right after animations and physics)
  35274. */
  35275. onBeforeRenderObservable: Observable<Scene>;
  35276. private _onBeforeRenderObserver;
  35277. /** Sets a function to be executed before rendering this scene */
  35278. set beforeRender(callback: Nullable<() => void>);
  35279. /**
  35280. * An event triggered after rendering the scene
  35281. */
  35282. onAfterRenderObservable: Observable<Scene>;
  35283. /**
  35284. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  35285. */
  35286. onAfterRenderCameraObservable: Observable<Camera>;
  35287. private _onAfterRenderObserver;
  35288. /** Sets a function to be executed after rendering this scene */
  35289. set afterRender(callback: Nullable<() => void>);
  35290. /**
  35291. * An event triggered before animating the scene
  35292. */
  35293. onBeforeAnimationsObservable: Observable<Scene>;
  35294. /**
  35295. * An event triggered after animations processing
  35296. */
  35297. onAfterAnimationsObservable: Observable<Scene>;
  35298. /**
  35299. * An event triggered before draw calls are ready to be sent
  35300. */
  35301. onBeforeDrawPhaseObservable: Observable<Scene>;
  35302. /**
  35303. * An event triggered after draw calls have been sent
  35304. */
  35305. onAfterDrawPhaseObservable: Observable<Scene>;
  35306. /**
  35307. * An event triggered when the scene is ready
  35308. */
  35309. onReadyObservable: Observable<Scene>;
  35310. /**
  35311. * An event triggered before rendering a camera
  35312. */
  35313. onBeforeCameraRenderObservable: Observable<Camera>;
  35314. private _onBeforeCameraRenderObserver;
  35315. /** Sets a function to be executed before rendering a camera*/
  35316. set beforeCameraRender(callback: () => void);
  35317. /**
  35318. * An event triggered after rendering a camera
  35319. */
  35320. onAfterCameraRenderObservable: Observable<Camera>;
  35321. private _onAfterCameraRenderObserver;
  35322. /** Sets a function to be executed after rendering a camera*/
  35323. set afterCameraRender(callback: () => void);
  35324. /**
  35325. * An event triggered when active meshes evaluation is about to start
  35326. */
  35327. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  35328. /**
  35329. * An event triggered when active meshes evaluation is done
  35330. */
  35331. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  35332. /**
  35333. * An event triggered when particles rendering is about to start
  35334. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35335. */
  35336. onBeforeParticlesRenderingObservable: Observable<Scene>;
  35337. /**
  35338. * An event triggered when particles rendering is done
  35339. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  35340. */
  35341. onAfterParticlesRenderingObservable: Observable<Scene>;
  35342. /**
  35343. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  35344. */
  35345. onDataLoadedObservable: Observable<Scene>;
  35346. /**
  35347. * An event triggered when a camera is created
  35348. */
  35349. onNewCameraAddedObservable: Observable<Camera>;
  35350. /**
  35351. * An event triggered when a camera is removed
  35352. */
  35353. onCameraRemovedObservable: Observable<Camera>;
  35354. /**
  35355. * An event triggered when a light is created
  35356. */
  35357. onNewLightAddedObservable: Observable<Light>;
  35358. /**
  35359. * An event triggered when a light is removed
  35360. */
  35361. onLightRemovedObservable: Observable<Light>;
  35362. /**
  35363. * An event triggered when a geometry is created
  35364. */
  35365. onNewGeometryAddedObservable: Observable<Geometry>;
  35366. /**
  35367. * An event triggered when a geometry is removed
  35368. */
  35369. onGeometryRemovedObservable: Observable<Geometry>;
  35370. /**
  35371. * An event triggered when a transform node is created
  35372. */
  35373. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  35374. /**
  35375. * An event triggered when a transform node is removed
  35376. */
  35377. onTransformNodeRemovedObservable: Observable<TransformNode>;
  35378. /**
  35379. * An event triggered when a mesh is created
  35380. */
  35381. onNewMeshAddedObservable: Observable<AbstractMesh>;
  35382. /**
  35383. * An event triggered when a mesh is removed
  35384. */
  35385. onMeshRemovedObservable: Observable<AbstractMesh>;
  35386. /**
  35387. * An event triggered when a skeleton is created
  35388. */
  35389. onNewSkeletonAddedObservable: Observable<Skeleton>;
  35390. /**
  35391. * An event triggered when a skeleton is removed
  35392. */
  35393. onSkeletonRemovedObservable: Observable<Skeleton>;
  35394. /**
  35395. * An event triggered when a material is created
  35396. */
  35397. onNewMaterialAddedObservable: Observable<Material>;
  35398. /**
  35399. * An event triggered when a material is removed
  35400. */
  35401. onMaterialRemovedObservable: Observable<Material>;
  35402. /**
  35403. * An event triggered when a texture is created
  35404. */
  35405. onNewTextureAddedObservable: Observable<BaseTexture>;
  35406. /**
  35407. * An event triggered when a texture is removed
  35408. */
  35409. onTextureRemovedObservable: Observable<BaseTexture>;
  35410. /**
  35411. * An event triggered when render targets are about to be rendered
  35412. * Can happen multiple times per frame.
  35413. */
  35414. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  35415. /**
  35416. * An event triggered when render targets were rendered.
  35417. * Can happen multiple times per frame.
  35418. */
  35419. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  35420. /**
  35421. * An event triggered before calculating deterministic simulation step
  35422. */
  35423. onBeforeStepObservable: Observable<Scene>;
  35424. /**
  35425. * An event triggered after calculating deterministic simulation step
  35426. */
  35427. onAfterStepObservable: Observable<Scene>;
  35428. /**
  35429. * An event triggered when the activeCamera property is updated
  35430. */
  35431. onActiveCameraChanged: Observable<Scene>;
  35432. /**
  35433. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  35434. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35435. * 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)
  35436. */
  35437. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35438. /**
  35439. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  35440. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  35441. * 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)
  35442. */
  35443. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  35444. /**
  35445. * This Observable will when a mesh has been imported into the scene.
  35446. */
  35447. onMeshImportedObservable: Observable<AbstractMesh>;
  35448. /**
  35449. * This Observable will when an animation file has been imported into the scene.
  35450. */
  35451. onAnimationFileImportedObservable: Observable<Scene>;
  35452. /**
  35453. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  35454. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  35455. */
  35456. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  35457. /** @hidden */
  35458. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  35459. /**
  35460. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  35461. */
  35462. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  35463. /**
  35464. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  35465. */
  35466. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  35467. /**
  35468. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  35469. */
  35470. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  35471. /** Callback called when a pointer move is detected */
  35472. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35473. /** Callback called when a pointer down is detected */
  35474. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  35475. /** Callback called when a pointer up is detected */
  35476. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  35477. /** Callback called when a pointer pick is detected */
  35478. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  35479. /**
  35480. * 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).
  35481. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  35482. */
  35483. onPrePointerObservable: Observable<PointerInfoPre>;
  35484. /**
  35485. * Observable event triggered each time an input event is received from the rendering canvas
  35486. */
  35487. onPointerObservable: Observable<PointerInfo>;
  35488. /**
  35489. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  35490. */
  35491. get unTranslatedPointer(): Vector2;
  35492. /**
  35493. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  35494. */
  35495. static get DragMovementThreshold(): number;
  35496. static set DragMovementThreshold(value: number);
  35497. /**
  35498. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  35499. */
  35500. static get LongPressDelay(): number;
  35501. static set LongPressDelay(value: number);
  35502. /**
  35503. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  35504. */
  35505. static get DoubleClickDelay(): number;
  35506. static set DoubleClickDelay(value: number);
  35507. /** If you need to check double click without raising a single click at first click, enable this flag */
  35508. static get ExclusiveDoubleClickMode(): boolean;
  35509. static set ExclusiveDoubleClickMode(value: boolean);
  35510. /** @hidden */
  35511. _mirroredCameraPosition: Nullable<Vector3>;
  35512. /**
  35513. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  35514. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  35515. */
  35516. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  35517. /**
  35518. * Observable event triggered each time an keyboard event is received from the hosting window
  35519. */
  35520. onKeyboardObservable: Observable<KeyboardInfo>;
  35521. private _useRightHandedSystem;
  35522. /**
  35523. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  35524. */
  35525. set useRightHandedSystem(value: boolean);
  35526. get useRightHandedSystem(): boolean;
  35527. private _timeAccumulator;
  35528. private _currentStepId;
  35529. private _currentInternalStep;
  35530. /**
  35531. * Sets the step Id used by deterministic lock step
  35532. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35533. * @param newStepId defines the step Id
  35534. */
  35535. setStepId(newStepId: number): void;
  35536. /**
  35537. * Gets the step Id used by deterministic lock step
  35538. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35539. * @returns the step Id
  35540. */
  35541. getStepId(): number;
  35542. /**
  35543. * Gets the internal step used by deterministic lock step
  35544. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35545. * @returns the internal step
  35546. */
  35547. getInternalStep(): number;
  35548. private _fogEnabled;
  35549. /**
  35550. * Gets or sets a boolean indicating if fog is enabled on this scene
  35551. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35552. * (Default is true)
  35553. */
  35554. set fogEnabled(value: boolean);
  35555. get fogEnabled(): boolean;
  35556. private _fogMode;
  35557. /**
  35558. * Gets or sets the fog mode to use
  35559. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35560. * | mode | value |
  35561. * | --- | --- |
  35562. * | FOGMODE_NONE | 0 |
  35563. * | FOGMODE_EXP | 1 |
  35564. * | FOGMODE_EXP2 | 2 |
  35565. * | FOGMODE_LINEAR | 3 |
  35566. */
  35567. set fogMode(value: number);
  35568. get fogMode(): number;
  35569. /**
  35570. * Gets or sets the fog color to use
  35571. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35572. * (Default is Color3(0.2, 0.2, 0.3))
  35573. */
  35574. fogColor: Color3;
  35575. /**
  35576. * Gets or sets the fog density to use
  35577. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35578. * (Default is 0.1)
  35579. */
  35580. fogDensity: number;
  35581. /**
  35582. * Gets or sets the fog start distance to use
  35583. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35584. * (Default is 0)
  35585. */
  35586. fogStart: number;
  35587. /**
  35588. * Gets or sets the fog end distance to use
  35589. * @see http://doc.babylonjs.com/babylon101/environment#fog
  35590. * (Default is 1000)
  35591. */
  35592. fogEnd: number;
  35593. private _shadowsEnabled;
  35594. /**
  35595. * Gets or sets a boolean indicating if shadows are enabled on this scene
  35596. */
  35597. set shadowsEnabled(value: boolean);
  35598. get shadowsEnabled(): boolean;
  35599. private _lightsEnabled;
  35600. /**
  35601. * Gets or sets a boolean indicating if lights are enabled on this scene
  35602. */
  35603. set lightsEnabled(value: boolean);
  35604. get lightsEnabled(): boolean;
  35605. /** All of the active cameras added to this scene. */
  35606. activeCameras: Camera[];
  35607. /** @hidden */
  35608. _activeCamera: Nullable<Camera>;
  35609. /** Gets or sets the current active camera */
  35610. get activeCamera(): Nullable<Camera>;
  35611. set activeCamera(value: Nullable<Camera>);
  35612. private _defaultMaterial;
  35613. /** The default material used on meshes when no material is affected */
  35614. get defaultMaterial(): Material;
  35615. /** The default material used on meshes when no material is affected */
  35616. set defaultMaterial(value: Material);
  35617. private _texturesEnabled;
  35618. /**
  35619. * Gets or sets a boolean indicating if textures are enabled on this scene
  35620. */
  35621. set texturesEnabled(value: boolean);
  35622. get texturesEnabled(): boolean;
  35623. /**
  35624. * Gets or sets a boolean indicating if particles are enabled on this scene
  35625. */
  35626. particlesEnabled: boolean;
  35627. /**
  35628. * Gets or sets a boolean indicating if sprites are enabled on this scene
  35629. */
  35630. spritesEnabled: boolean;
  35631. private _skeletonsEnabled;
  35632. /**
  35633. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  35634. */
  35635. set skeletonsEnabled(value: boolean);
  35636. get skeletonsEnabled(): boolean;
  35637. /**
  35638. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  35639. */
  35640. lensFlaresEnabled: boolean;
  35641. /**
  35642. * Gets or sets a boolean indicating if collisions are enabled on this scene
  35643. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35644. */
  35645. collisionsEnabled: boolean;
  35646. private _collisionCoordinator;
  35647. /** @hidden */
  35648. get collisionCoordinator(): ICollisionCoordinator;
  35649. /**
  35650. * Defines the gravity applied to this scene (used only for collisions)
  35651. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35652. */
  35653. gravity: Vector3;
  35654. /**
  35655. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  35656. */
  35657. postProcessesEnabled: boolean;
  35658. /**
  35659. * The list of postprocesses added to the scene
  35660. */
  35661. postProcesses: PostProcess[];
  35662. /**
  35663. * Gets the current postprocess manager
  35664. */
  35665. postProcessManager: PostProcessManager;
  35666. /**
  35667. * Gets or sets a boolean indicating if render targets are enabled on this scene
  35668. */
  35669. renderTargetsEnabled: boolean;
  35670. /**
  35671. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  35672. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  35673. */
  35674. dumpNextRenderTargets: boolean;
  35675. /**
  35676. * The list of user defined render targets added to the scene
  35677. */
  35678. customRenderTargets: RenderTargetTexture[];
  35679. /**
  35680. * Defines if texture loading must be delayed
  35681. * If true, textures will only be loaded when they need to be rendered
  35682. */
  35683. useDelayedTextureLoading: boolean;
  35684. /**
  35685. * Gets the list of meshes imported to the scene through SceneLoader
  35686. */
  35687. importedMeshesFiles: String[];
  35688. /**
  35689. * Gets or sets a boolean indicating if probes are enabled on this scene
  35690. */
  35691. probesEnabled: boolean;
  35692. /**
  35693. * Gets or sets the current offline provider to use to store scene data
  35694. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  35695. */
  35696. offlineProvider: IOfflineProvider;
  35697. /**
  35698. * Gets or sets the action manager associated with the scene
  35699. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35700. */
  35701. actionManager: AbstractActionManager;
  35702. private _meshesForIntersections;
  35703. /**
  35704. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  35705. */
  35706. proceduralTexturesEnabled: boolean;
  35707. private _engine;
  35708. private _totalVertices;
  35709. /** @hidden */
  35710. _activeIndices: PerfCounter;
  35711. /** @hidden */
  35712. _activeParticles: PerfCounter;
  35713. /** @hidden */
  35714. _activeBones: PerfCounter;
  35715. private _animationRatio;
  35716. /** @hidden */
  35717. _animationTimeLast: number;
  35718. /** @hidden */
  35719. _animationTime: number;
  35720. /**
  35721. * Gets or sets a general scale for animation speed
  35722. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  35723. */
  35724. animationTimeScale: number;
  35725. /** @hidden */
  35726. _cachedMaterial: Nullable<Material>;
  35727. /** @hidden */
  35728. _cachedEffect: Nullable<Effect>;
  35729. /** @hidden */
  35730. _cachedVisibility: Nullable<number>;
  35731. private _renderId;
  35732. private _frameId;
  35733. private _executeWhenReadyTimeoutId;
  35734. private _intermediateRendering;
  35735. private _viewUpdateFlag;
  35736. private _projectionUpdateFlag;
  35737. /** @hidden */
  35738. _toBeDisposed: Nullable<IDisposable>[];
  35739. private _activeRequests;
  35740. /** @hidden */
  35741. _pendingData: any[];
  35742. private _isDisposed;
  35743. /**
  35744. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  35745. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  35746. */
  35747. dispatchAllSubMeshesOfActiveMeshes: boolean;
  35748. private _activeMeshes;
  35749. private _processedMaterials;
  35750. private _renderTargets;
  35751. /** @hidden */
  35752. _activeParticleSystems: SmartArray<IParticleSystem>;
  35753. private _activeSkeletons;
  35754. private _softwareSkinnedMeshes;
  35755. private _renderingManager;
  35756. /** @hidden */
  35757. _activeAnimatables: Animatable[];
  35758. private _transformMatrix;
  35759. private _sceneUbo;
  35760. /** @hidden */
  35761. _viewMatrix: Matrix;
  35762. private _projectionMatrix;
  35763. /** @hidden */
  35764. _forcedViewPosition: Nullable<Vector3>;
  35765. /** @hidden */
  35766. _frustumPlanes: Plane[];
  35767. /**
  35768. * Gets the list of frustum planes (built from the active camera)
  35769. */
  35770. get frustumPlanes(): Plane[];
  35771. /**
  35772. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  35773. * This is useful if there are more lights that the maximum simulteanous authorized
  35774. */
  35775. requireLightSorting: boolean;
  35776. /** @hidden */
  35777. readonly useMaterialMeshMap: boolean;
  35778. /** @hidden */
  35779. readonly useClonedMeshMap: boolean;
  35780. private _externalData;
  35781. private _uid;
  35782. /**
  35783. * @hidden
  35784. * Backing store of defined scene components.
  35785. */
  35786. _components: ISceneComponent[];
  35787. /**
  35788. * @hidden
  35789. * Backing store of defined scene components.
  35790. */
  35791. _serializableComponents: ISceneSerializableComponent[];
  35792. /**
  35793. * List of components to register on the next registration step.
  35794. */
  35795. private _transientComponents;
  35796. /**
  35797. * Registers the transient components if needed.
  35798. */
  35799. private _registerTransientComponents;
  35800. /**
  35801. * @hidden
  35802. * Add a component to the scene.
  35803. * Note that the ccomponent could be registered on th next frame if this is called after
  35804. * the register component stage.
  35805. * @param component Defines the component to add to the scene
  35806. */
  35807. _addComponent(component: ISceneComponent): void;
  35808. /**
  35809. * @hidden
  35810. * Gets a component from the scene.
  35811. * @param name defines the name of the component to retrieve
  35812. * @returns the component or null if not present
  35813. */
  35814. _getComponent(name: string): Nullable<ISceneComponent>;
  35815. /**
  35816. * @hidden
  35817. * Defines the actions happening before camera updates.
  35818. */
  35819. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  35820. /**
  35821. * @hidden
  35822. * Defines the actions happening before clear the canvas.
  35823. */
  35824. _beforeClearStage: Stage<SimpleStageAction>;
  35825. /**
  35826. * @hidden
  35827. * Defines the actions when collecting render targets for the frame.
  35828. */
  35829. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35830. /**
  35831. * @hidden
  35832. * Defines the actions happening for one camera in the frame.
  35833. */
  35834. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  35835. /**
  35836. * @hidden
  35837. * Defines the actions happening during the per mesh ready checks.
  35838. */
  35839. _isReadyForMeshStage: Stage<MeshStageAction>;
  35840. /**
  35841. * @hidden
  35842. * Defines the actions happening before evaluate active mesh checks.
  35843. */
  35844. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  35845. /**
  35846. * @hidden
  35847. * Defines the actions happening during the evaluate sub mesh checks.
  35848. */
  35849. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  35850. /**
  35851. * @hidden
  35852. * Defines the actions happening during the active mesh stage.
  35853. */
  35854. _activeMeshStage: Stage<ActiveMeshStageAction>;
  35855. /**
  35856. * @hidden
  35857. * Defines the actions happening during the per camera render target step.
  35858. */
  35859. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  35860. /**
  35861. * @hidden
  35862. * Defines the actions happening just before the active camera is drawing.
  35863. */
  35864. _beforeCameraDrawStage: Stage<CameraStageAction>;
  35865. /**
  35866. * @hidden
  35867. * Defines the actions happening just before a render target is drawing.
  35868. */
  35869. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35870. /**
  35871. * @hidden
  35872. * Defines the actions happening just before a rendering group is drawing.
  35873. */
  35874. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35875. /**
  35876. * @hidden
  35877. * Defines the actions happening just before a mesh is drawing.
  35878. */
  35879. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35880. /**
  35881. * @hidden
  35882. * Defines the actions happening just after a mesh has been drawn.
  35883. */
  35884. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  35885. /**
  35886. * @hidden
  35887. * Defines the actions happening just after a rendering group has been drawn.
  35888. */
  35889. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  35890. /**
  35891. * @hidden
  35892. * Defines the actions happening just after the active camera has been drawn.
  35893. */
  35894. _afterCameraDrawStage: Stage<CameraStageAction>;
  35895. /**
  35896. * @hidden
  35897. * Defines the actions happening just after a render target has been drawn.
  35898. */
  35899. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  35900. /**
  35901. * @hidden
  35902. * Defines the actions happening just after rendering all cameras and computing intersections.
  35903. */
  35904. _afterRenderStage: Stage<SimpleStageAction>;
  35905. /**
  35906. * @hidden
  35907. * Defines the actions happening when a pointer move event happens.
  35908. */
  35909. _pointerMoveStage: Stage<PointerMoveStageAction>;
  35910. /**
  35911. * @hidden
  35912. * Defines the actions happening when a pointer down event happens.
  35913. */
  35914. _pointerDownStage: Stage<PointerUpDownStageAction>;
  35915. /**
  35916. * @hidden
  35917. * Defines the actions happening when a pointer up event happens.
  35918. */
  35919. _pointerUpStage: Stage<PointerUpDownStageAction>;
  35920. /**
  35921. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  35922. */
  35923. private geometriesByUniqueId;
  35924. /**
  35925. * Creates a new Scene
  35926. * @param engine defines the engine to use to render this scene
  35927. * @param options defines the scene options
  35928. */
  35929. constructor(engine: Engine, options?: SceneOptions);
  35930. /**
  35931. * Gets a string idenfifying the name of the class
  35932. * @returns "Scene" string
  35933. */
  35934. getClassName(): string;
  35935. private _defaultMeshCandidates;
  35936. /**
  35937. * @hidden
  35938. */
  35939. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  35940. private _defaultSubMeshCandidates;
  35941. /**
  35942. * @hidden
  35943. */
  35944. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  35945. /**
  35946. * Sets the default candidate providers for the scene.
  35947. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  35948. * and getCollidingSubMeshCandidates to their default function
  35949. */
  35950. setDefaultCandidateProviders(): void;
  35951. /**
  35952. * Gets the mesh that is currently under the pointer
  35953. */
  35954. get meshUnderPointer(): Nullable<AbstractMesh>;
  35955. /**
  35956. * Gets or sets the current on-screen X position of the pointer
  35957. */
  35958. get pointerX(): number;
  35959. set pointerX(value: number);
  35960. /**
  35961. * Gets or sets the current on-screen Y position of the pointer
  35962. */
  35963. get pointerY(): number;
  35964. set pointerY(value: number);
  35965. /**
  35966. * Gets the cached material (ie. the latest rendered one)
  35967. * @returns the cached material
  35968. */
  35969. getCachedMaterial(): Nullable<Material>;
  35970. /**
  35971. * Gets the cached effect (ie. the latest rendered one)
  35972. * @returns the cached effect
  35973. */
  35974. getCachedEffect(): Nullable<Effect>;
  35975. /**
  35976. * Gets the cached visibility state (ie. the latest rendered one)
  35977. * @returns the cached visibility state
  35978. */
  35979. getCachedVisibility(): Nullable<number>;
  35980. /**
  35981. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  35982. * @param material defines the current material
  35983. * @param effect defines the current effect
  35984. * @param visibility defines the current visibility state
  35985. * @returns true if one parameter is not cached
  35986. */
  35987. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  35988. /**
  35989. * Gets the engine associated with the scene
  35990. * @returns an Engine
  35991. */
  35992. getEngine(): Engine;
  35993. /**
  35994. * Gets the total number of vertices rendered per frame
  35995. * @returns the total number of vertices rendered per frame
  35996. */
  35997. getTotalVertices(): number;
  35998. /**
  35999. * Gets the performance counter for total vertices
  36000. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36001. */
  36002. get totalVerticesPerfCounter(): PerfCounter;
  36003. /**
  36004. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  36005. * @returns the total number of active indices rendered per frame
  36006. */
  36007. getActiveIndices(): number;
  36008. /**
  36009. * Gets the performance counter for active indices
  36010. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36011. */
  36012. get totalActiveIndicesPerfCounter(): PerfCounter;
  36013. /**
  36014. * Gets the total number of active particles rendered per frame
  36015. * @returns the total number of active particles rendered per frame
  36016. */
  36017. getActiveParticles(): number;
  36018. /**
  36019. * Gets the performance counter for active particles
  36020. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36021. */
  36022. get activeParticlesPerfCounter(): PerfCounter;
  36023. /**
  36024. * Gets the total number of active bones rendered per frame
  36025. * @returns the total number of active bones rendered per frame
  36026. */
  36027. getActiveBones(): number;
  36028. /**
  36029. * Gets the performance counter for active bones
  36030. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  36031. */
  36032. get activeBonesPerfCounter(): PerfCounter;
  36033. /**
  36034. * Gets the array of active meshes
  36035. * @returns an array of AbstractMesh
  36036. */
  36037. getActiveMeshes(): SmartArray<AbstractMesh>;
  36038. /**
  36039. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  36040. * @returns a number
  36041. */
  36042. getAnimationRatio(): number;
  36043. /**
  36044. * Gets an unique Id for the current render phase
  36045. * @returns a number
  36046. */
  36047. getRenderId(): number;
  36048. /**
  36049. * Gets an unique Id for the current frame
  36050. * @returns a number
  36051. */
  36052. getFrameId(): number;
  36053. /** Call this function if you want to manually increment the render Id*/
  36054. incrementRenderId(): void;
  36055. private _createUbo;
  36056. /**
  36057. * Use this method to simulate a pointer move on a mesh
  36058. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36059. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36060. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36061. * @returns the current scene
  36062. */
  36063. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36064. /**
  36065. * Use this method to simulate a pointer down on a mesh
  36066. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36067. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36068. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36069. * @returns the current scene
  36070. */
  36071. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  36072. /**
  36073. * Use this method to simulate a pointer up on a mesh
  36074. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36075. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36076. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36077. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36078. * @returns the current scene
  36079. */
  36080. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  36081. /**
  36082. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36083. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36084. * @returns true if the pointer was captured
  36085. */
  36086. isPointerCaptured(pointerId?: number): boolean;
  36087. /**
  36088. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36089. * @param attachUp defines if you want to attach events to pointerup
  36090. * @param attachDown defines if you want to attach events to pointerdown
  36091. * @param attachMove defines if you want to attach events to pointermove
  36092. */
  36093. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  36094. /** Detaches all event handlers*/
  36095. detachControl(): void;
  36096. /**
  36097. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  36098. * Delay loaded resources are not taking in account
  36099. * @return true if all required resources are ready
  36100. */
  36101. isReady(): boolean;
  36102. /** Resets all cached information relative to material (including effect and visibility) */
  36103. resetCachedMaterial(): void;
  36104. /**
  36105. * Registers a function to be called before every frame render
  36106. * @param func defines the function to register
  36107. */
  36108. registerBeforeRender(func: () => void): void;
  36109. /**
  36110. * Unregisters a function called before every frame render
  36111. * @param func defines the function to unregister
  36112. */
  36113. unregisterBeforeRender(func: () => void): void;
  36114. /**
  36115. * Registers a function to be called after every frame render
  36116. * @param func defines the function to register
  36117. */
  36118. registerAfterRender(func: () => void): void;
  36119. /**
  36120. * Unregisters a function called after every frame render
  36121. * @param func defines the function to unregister
  36122. */
  36123. unregisterAfterRender(func: () => void): void;
  36124. private _executeOnceBeforeRender;
  36125. /**
  36126. * The provided function will run before render once and will be disposed afterwards.
  36127. * A timeout delay can be provided so that the function will be executed in N ms.
  36128. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  36129. * @param func The function to be executed.
  36130. * @param timeout optional delay in ms
  36131. */
  36132. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  36133. /** @hidden */
  36134. _addPendingData(data: any): void;
  36135. /** @hidden */
  36136. _removePendingData(data: any): void;
  36137. /**
  36138. * Returns the number of items waiting to be loaded
  36139. * @returns the number of items waiting to be loaded
  36140. */
  36141. getWaitingItemsCount(): number;
  36142. /**
  36143. * Returns a boolean indicating if the scene is still loading data
  36144. */
  36145. get isLoading(): boolean;
  36146. /**
  36147. * Registers a function to be executed when the scene is ready
  36148. * @param {Function} func - the function to be executed
  36149. */
  36150. executeWhenReady(func: () => void): void;
  36151. /**
  36152. * Returns a promise that resolves when the scene is ready
  36153. * @returns A promise that resolves when the scene is ready
  36154. */
  36155. whenReadyAsync(): Promise<void>;
  36156. /** @hidden */
  36157. _checkIsReady(): void;
  36158. /**
  36159. * Gets all animatable attached to the scene
  36160. */
  36161. get animatables(): Animatable[];
  36162. /**
  36163. * Resets the last animation time frame.
  36164. * Useful to override when animations start running when loading a scene for the first time.
  36165. */
  36166. resetLastAnimationTimeFrame(): void;
  36167. /**
  36168. * Gets the current view matrix
  36169. * @returns a Matrix
  36170. */
  36171. getViewMatrix(): Matrix;
  36172. /**
  36173. * Gets the current projection matrix
  36174. * @returns a Matrix
  36175. */
  36176. getProjectionMatrix(): Matrix;
  36177. /**
  36178. * Gets the current transform matrix
  36179. * @returns a Matrix made of View * Projection
  36180. */
  36181. getTransformMatrix(): Matrix;
  36182. /**
  36183. * Sets the current transform matrix
  36184. * @param viewL defines the View matrix to use
  36185. * @param projectionL defines the Projection matrix to use
  36186. * @param viewR defines the right View matrix to use (if provided)
  36187. * @param projectionR defines the right Projection matrix to use (if provided)
  36188. */
  36189. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  36190. /**
  36191. * Gets the uniform buffer used to store scene data
  36192. * @returns a UniformBuffer
  36193. */
  36194. getSceneUniformBuffer(): UniformBuffer;
  36195. /**
  36196. * Gets an unique (relatively to the current scene) Id
  36197. * @returns an unique number for the scene
  36198. */
  36199. getUniqueId(): number;
  36200. /**
  36201. * Add a mesh to the list of scene's meshes
  36202. * @param newMesh defines the mesh to add
  36203. * @param recursive if all child meshes should also be added to the scene
  36204. */
  36205. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  36206. /**
  36207. * Remove a mesh for the list of scene's meshes
  36208. * @param toRemove defines the mesh to remove
  36209. * @param recursive if all child meshes should also be removed from the scene
  36210. * @returns the index where the mesh was in the mesh list
  36211. */
  36212. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  36213. /**
  36214. * Add a transform node to the list of scene's transform nodes
  36215. * @param newTransformNode defines the transform node to add
  36216. */
  36217. addTransformNode(newTransformNode: TransformNode): void;
  36218. /**
  36219. * Remove a transform node for the list of scene's transform nodes
  36220. * @param toRemove defines the transform node to remove
  36221. * @returns the index where the transform node was in the transform node list
  36222. */
  36223. removeTransformNode(toRemove: TransformNode): number;
  36224. /**
  36225. * Remove a skeleton for the list of scene's skeletons
  36226. * @param toRemove defines the skeleton to remove
  36227. * @returns the index where the skeleton was in the skeleton list
  36228. */
  36229. removeSkeleton(toRemove: Skeleton): number;
  36230. /**
  36231. * Remove a morph target for the list of scene's morph targets
  36232. * @param toRemove defines the morph target to remove
  36233. * @returns the index where the morph target was in the morph target list
  36234. */
  36235. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  36236. /**
  36237. * Remove a light for the list of scene's lights
  36238. * @param toRemove defines the light to remove
  36239. * @returns the index where the light was in the light list
  36240. */
  36241. removeLight(toRemove: Light): number;
  36242. /**
  36243. * Remove a camera for the list of scene's cameras
  36244. * @param toRemove defines the camera to remove
  36245. * @returns the index where the camera was in the camera list
  36246. */
  36247. removeCamera(toRemove: Camera): number;
  36248. /**
  36249. * Remove a particle system for the list of scene's particle systems
  36250. * @param toRemove defines the particle system to remove
  36251. * @returns the index where the particle system was in the particle system list
  36252. */
  36253. removeParticleSystem(toRemove: IParticleSystem): number;
  36254. /**
  36255. * Remove a animation for the list of scene's animations
  36256. * @param toRemove defines the animation to remove
  36257. * @returns the index where the animation was in the animation list
  36258. */
  36259. removeAnimation(toRemove: Animation): number;
  36260. /**
  36261. * Will stop the animation of the given target
  36262. * @param target - the target
  36263. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  36264. * @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)
  36265. */
  36266. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  36267. /**
  36268. * Removes the given animation group from this scene.
  36269. * @param toRemove The animation group to remove
  36270. * @returns The index of the removed animation group
  36271. */
  36272. removeAnimationGroup(toRemove: AnimationGroup): number;
  36273. /**
  36274. * Removes the given multi-material from this scene.
  36275. * @param toRemove The multi-material to remove
  36276. * @returns The index of the removed multi-material
  36277. */
  36278. removeMultiMaterial(toRemove: MultiMaterial): number;
  36279. /**
  36280. * Removes the given material from this scene.
  36281. * @param toRemove The material to remove
  36282. * @returns The index of the removed material
  36283. */
  36284. removeMaterial(toRemove: Material): number;
  36285. /**
  36286. * Removes the given action manager from this scene.
  36287. * @param toRemove The action manager to remove
  36288. * @returns The index of the removed action manager
  36289. */
  36290. removeActionManager(toRemove: AbstractActionManager): number;
  36291. /**
  36292. * Removes the given texture from this scene.
  36293. * @param toRemove The texture to remove
  36294. * @returns The index of the removed texture
  36295. */
  36296. removeTexture(toRemove: BaseTexture): number;
  36297. /**
  36298. * Adds the given light to this scene
  36299. * @param newLight The light to add
  36300. */
  36301. addLight(newLight: Light): void;
  36302. /**
  36303. * Sorts the list list based on light priorities
  36304. */
  36305. sortLightsByPriority(): void;
  36306. /**
  36307. * Adds the given camera to this scene
  36308. * @param newCamera The camera to add
  36309. */
  36310. addCamera(newCamera: Camera): void;
  36311. /**
  36312. * Adds the given skeleton to this scene
  36313. * @param newSkeleton The skeleton to add
  36314. */
  36315. addSkeleton(newSkeleton: Skeleton): void;
  36316. /**
  36317. * Adds the given particle system to this scene
  36318. * @param newParticleSystem The particle system to add
  36319. */
  36320. addParticleSystem(newParticleSystem: IParticleSystem): void;
  36321. /**
  36322. * Adds the given animation to this scene
  36323. * @param newAnimation The animation to add
  36324. */
  36325. addAnimation(newAnimation: Animation): void;
  36326. /**
  36327. * Adds the given animation group to this scene.
  36328. * @param newAnimationGroup The animation group to add
  36329. */
  36330. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  36331. /**
  36332. * Adds the given multi-material to this scene
  36333. * @param newMultiMaterial The multi-material to add
  36334. */
  36335. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  36336. /**
  36337. * Adds the given material to this scene
  36338. * @param newMaterial The material to add
  36339. */
  36340. addMaterial(newMaterial: Material): void;
  36341. /**
  36342. * Adds the given morph target to this scene
  36343. * @param newMorphTargetManager The morph target to add
  36344. */
  36345. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  36346. /**
  36347. * Adds the given geometry to this scene
  36348. * @param newGeometry The geometry to add
  36349. */
  36350. addGeometry(newGeometry: Geometry): void;
  36351. /**
  36352. * Adds the given action manager to this scene
  36353. * @param newActionManager The action manager to add
  36354. */
  36355. addActionManager(newActionManager: AbstractActionManager): void;
  36356. /**
  36357. * Adds the given texture to this scene.
  36358. * @param newTexture The texture to add
  36359. */
  36360. addTexture(newTexture: BaseTexture): void;
  36361. /**
  36362. * Switch active camera
  36363. * @param newCamera defines the new active camera
  36364. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  36365. */
  36366. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  36367. /**
  36368. * sets the active camera of the scene using its ID
  36369. * @param id defines the camera's ID
  36370. * @return the new active camera or null if none found.
  36371. */
  36372. setActiveCameraByID(id: string): Nullable<Camera>;
  36373. /**
  36374. * sets the active camera of the scene using its name
  36375. * @param name defines the camera's name
  36376. * @returns the new active camera or null if none found.
  36377. */
  36378. setActiveCameraByName(name: string): Nullable<Camera>;
  36379. /**
  36380. * get an animation group using its name
  36381. * @param name defines the material's name
  36382. * @return the animation group or null if none found.
  36383. */
  36384. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  36385. /**
  36386. * Get a material using its unique id
  36387. * @param uniqueId defines the material's unique id
  36388. * @return the material or null if none found.
  36389. */
  36390. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  36391. /**
  36392. * get a material using its id
  36393. * @param id defines the material's ID
  36394. * @return the material or null if none found.
  36395. */
  36396. getMaterialByID(id: string): Nullable<Material>;
  36397. /**
  36398. * Gets a the last added material using a given id
  36399. * @param id defines the material's ID
  36400. * @return the last material with the given id or null if none found.
  36401. */
  36402. getLastMaterialByID(id: string): Nullable<Material>;
  36403. /**
  36404. * Gets a material using its name
  36405. * @param name defines the material's name
  36406. * @return the material or null if none found.
  36407. */
  36408. getMaterialByName(name: string): Nullable<Material>;
  36409. /**
  36410. * Get a texture using its unique id
  36411. * @param uniqueId defines the texture's unique id
  36412. * @return the texture or null if none found.
  36413. */
  36414. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  36415. /**
  36416. * Gets a camera using its id
  36417. * @param id defines the id to look for
  36418. * @returns the camera or null if not found
  36419. */
  36420. getCameraByID(id: string): Nullable<Camera>;
  36421. /**
  36422. * Gets a camera using its unique id
  36423. * @param uniqueId defines the unique id to look for
  36424. * @returns the camera or null if not found
  36425. */
  36426. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  36427. /**
  36428. * Gets a camera using its name
  36429. * @param name defines the camera's name
  36430. * @return the camera or null if none found.
  36431. */
  36432. getCameraByName(name: string): Nullable<Camera>;
  36433. /**
  36434. * Gets a bone using its id
  36435. * @param id defines the bone's id
  36436. * @return the bone or null if not found
  36437. */
  36438. getBoneByID(id: string): Nullable<Bone>;
  36439. /**
  36440. * Gets a bone using its id
  36441. * @param name defines the bone's name
  36442. * @return the bone or null if not found
  36443. */
  36444. getBoneByName(name: string): Nullable<Bone>;
  36445. /**
  36446. * Gets a light node using its name
  36447. * @param name defines the the light's name
  36448. * @return the light or null if none found.
  36449. */
  36450. getLightByName(name: string): Nullable<Light>;
  36451. /**
  36452. * Gets a light node using its id
  36453. * @param id defines the light's id
  36454. * @return the light or null if none found.
  36455. */
  36456. getLightByID(id: string): Nullable<Light>;
  36457. /**
  36458. * Gets a light node using its scene-generated unique ID
  36459. * @param uniqueId defines the light's unique id
  36460. * @return the light or null if none found.
  36461. */
  36462. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  36463. /**
  36464. * Gets a particle system by id
  36465. * @param id defines the particle system id
  36466. * @return the corresponding system or null if none found
  36467. */
  36468. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  36469. /**
  36470. * Gets a geometry using its ID
  36471. * @param id defines the geometry's id
  36472. * @return the geometry or null if none found.
  36473. */
  36474. getGeometryByID(id: string): Nullable<Geometry>;
  36475. private _getGeometryByUniqueID;
  36476. /**
  36477. * Add a new geometry to this scene
  36478. * @param geometry defines the geometry to be added to the scene.
  36479. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  36480. * @return a boolean defining if the geometry was added or not
  36481. */
  36482. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  36483. /**
  36484. * Removes an existing geometry
  36485. * @param geometry defines the geometry to be removed from the scene
  36486. * @return a boolean defining if the geometry was removed or not
  36487. */
  36488. removeGeometry(geometry: Geometry): boolean;
  36489. /**
  36490. * Gets the list of geometries attached to the scene
  36491. * @returns an array of Geometry
  36492. */
  36493. getGeometries(): Geometry[];
  36494. /**
  36495. * Gets the first added mesh found of a given ID
  36496. * @param id defines the id to search for
  36497. * @return the mesh found or null if not found at all
  36498. */
  36499. getMeshByID(id: string): Nullable<AbstractMesh>;
  36500. /**
  36501. * Gets a list of meshes using their id
  36502. * @param id defines the id to search for
  36503. * @returns a list of meshes
  36504. */
  36505. getMeshesByID(id: string): Array<AbstractMesh>;
  36506. /**
  36507. * Gets the first added transform node found of a given ID
  36508. * @param id defines the id to search for
  36509. * @return the found transform node or null if not found at all.
  36510. */
  36511. getTransformNodeByID(id: string): Nullable<TransformNode>;
  36512. /**
  36513. * Gets a transform node with its auto-generated unique id
  36514. * @param uniqueId efines the unique id to search for
  36515. * @return the found transform node or null if not found at all.
  36516. */
  36517. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  36518. /**
  36519. * Gets a list of transform nodes using their id
  36520. * @param id defines the id to search for
  36521. * @returns a list of transform nodes
  36522. */
  36523. getTransformNodesByID(id: string): Array<TransformNode>;
  36524. /**
  36525. * Gets a mesh with its auto-generated unique id
  36526. * @param uniqueId defines the unique id to search for
  36527. * @return the found mesh or null if not found at all.
  36528. */
  36529. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  36530. /**
  36531. * Gets a the last added mesh using a given id
  36532. * @param id defines the id to search for
  36533. * @return the found mesh or null if not found at all.
  36534. */
  36535. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  36536. /**
  36537. * Gets a the last added node (Mesh, Camera, Light) using a given id
  36538. * @param id defines the id to search for
  36539. * @return the found node or null if not found at all
  36540. */
  36541. getLastEntryByID(id: string): Nullable<Node>;
  36542. /**
  36543. * Gets a node (Mesh, Camera, Light) using a given id
  36544. * @param id defines the id to search for
  36545. * @return the found node or null if not found at all
  36546. */
  36547. getNodeByID(id: string): Nullable<Node>;
  36548. /**
  36549. * Gets a node (Mesh, Camera, Light) using a given name
  36550. * @param name defines the name to search for
  36551. * @return the found node or null if not found at all.
  36552. */
  36553. getNodeByName(name: string): Nullable<Node>;
  36554. /**
  36555. * Gets a mesh using a given name
  36556. * @param name defines the name to search for
  36557. * @return the found mesh or null if not found at all.
  36558. */
  36559. getMeshByName(name: string): Nullable<AbstractMesh>;
  36560. /**
  36561. * Gets a transform node using a given name
  36562. * @param name defines the name to search for
  36563. * @return the found transform node or null if not found at all.
  36564. */
  36565. getTransformNodeByName(name: string): Nullable<TransformNode>;
  36566. /**
  36567. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  36568. * @param id defines the id to search for
  36569. * @return the found skeleton or null if not found at all.
  36570. */
  36571. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  36572. /**
  36573. * Gets a skeleton using a given auto generated unique id
  36574. * @param uniqueId defines the unique id to search for
  36575. * @return the found skeleton or null if not found at all.
  36576. */
  36577. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  36578. /**
  36579. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  36580. * @param id defines the id to search for
  36581. * @return the found skeleton or null if not found at all.
  36582. */
  36583. getSkeletonById(id: string): Nullable<Skeleton>;
  36584. /**
  36585. * Gets a skeleton using a given name
  36586. * @param name defines the name to search for
  36587. * @return the found skeleton or null if not found at all.
  36588. */
  36589. getSkeletonByName(name: string): Nullable<Skeleton>;
  36590. /**
  36591. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  36592. * @param id defines the id to search for
  36593. * @return the found morph target manager or null if not found at all.
  36594. */
  36595. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  36596. /**
  36597. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  36598. * @param id defines the id to search for
  36599. * @return the found morph target or null if not found at all.
  36600. */
  36601. getMorphTargetById(id: string): Nullable<MorphTarget>;
  36602. /**
  36603. * Gets a boolean indicating if the given mesh is active
  36604. * @param mesh defines the mesh to look for
  36605. * @returns true if the mesh is in the active list
  36606. */
  36607. isActiveMesh(mesh: AbstractMesh): boolean;
  36608. /**
  36609. * Return a unique id as a string which can serve as an identifier for the scene
  36610. */
  36611. get uid(): string;
  36612. /**
  36613. * Add an externaly attached data from its key.
  36614. * This method call will fail and return false, if such key already exists.
  36615. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  36616. * @param key the unique key that identifies the data
  36617. * @param data the data object to associate to the key for this Engine instance
  36618. * @return true if no such key were already present and the data was added successfully, false otherwise
  36619. */
  36620. addExternalData<T>(key: string, data: T): boolean;
  36621. /**
  36622. * Get an externaly attached data from its key
  36623. * @param key the unique key that identifies the data
  36624. * @return the associated data, if present (can be null), or undefined if not present
  36625. */
  36626. getExternalData<T>(key: string): Nullable<T>;
  36627. /**
  36628. * Get an externaly attached data from its key, create it using a factory if it's not already present
  36629. * @param key the unique key that identifies the data
  36630. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  36631. * @return the associated data, can be null if the factory returned null.
  36632. */
  36633. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  36634. /**
  36635. * Remove an externaly attached data from the Engine instance
  36636. * @param key the unique key that identifies the data
  36637. * @return true if the data was successfully removed, false if it doesn't exist
  36638. */
  36639. removeExternalData(key: string): boolean;
  36640. private _evaluateSubMesh;
  36641. /**
  36642. * Clear the processed materials smart array preventing retention point in material dispose.
  36643. */
  36644. freeProcessedMaterials(): void;
  36645. private _preventFreeActiveMeshesAndRenderingGroups;
  36646. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  36647. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  36648. * when disposing several meshes in a row or a hierarchy of meshes.
  36649. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  36650. */
  36651. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  36652. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  36653. /**
  36654. * Clear the active meshes smart array preventing retention point in mesh dispose.
  36655. */
  36656. freeActiveMeshes(): void;
  36657. /**
  36658. * Clear the info related to rendering groups preventing retention points during dispose.
  36659. */
  36660. freeRenderingGroups(): void;
  36661. /** @hidden */
  36662. _isInIntermediateRendering(): boolean;
  36663. /**
  36664. * Lambda returning the list of potentially active meshes.
  36665. */
  36666. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  36667. /**
  36668. * Lambda returning the list of potentially active sub meshes.
  36669. */
  36670. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  36671. /**
  36672. * Lambda returning the list of potentially intersecting sub meshes.
  36673. */
  36674. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  36675. /**
  36676. * Lambda returning the list of potentially colliding sub meshes.
  36677. */
  36678. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  36679. private _activeMeshesFrozen;
  36680. private _skipEvaluateActiveMeshesCompletely;
  36681. /**
  36682. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  36683. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  36684. * @returns the current scene
  36685. */
  36686. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  36687. /**
  36688. * Use this function to restart evaluating active meshes on every frame
  36689. * @returns the current scene
  36690. */
  36691. unfreezeActiveMeshes(): Scene;
  36692. private _evaluateActiveMeshes;
  36693. private _activeMesh;
  36694. /**
  36695. * Update the transform matrix to update from the current active camera
  36696. * @param force defines a boolean used to force the update even if cache is up to date
  36697. */
  36698. updateTransformMatrix(force?: boolean): void;
  36699. private _bindFrameBuffer;
  36700. /** @hidden */
  36701. _allowPostProcessClearColor: boolean;
  36702. /** @hidden */
  36703. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  36704. private _processSubCameras;
  36705. private _checkIntersections;
  36706. /** @hidden */
  36707. _advancePhysicsEngineStep(step: number): void;
  36708. /**
  36709. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  36710. */
  36711. getDeterministicFrameTime: () => number;
  36712. /** @hidden */
  36713. _animate(): void;
  36714. /** Execute all animations (for a frame) */
  36715. animate(): void;
  36716. /**
  36717. * Render the scene
  36718. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  36719. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  36720. */
  36721. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  36722. /**
  36723. * Freeze all materials
  36724. * A frozen material will not be updatable but should be faster to render
  36725. */
  36726. freezeMaterials(): void;
  36727. /**
  36728. * Unfreeze all materials
  36729. * A frozen material will not be updatable but should be faster to render
  36730. */
  36731. unfreezeMaterials(): void;
  36732. /**
  36733. * Releases all held ressources
  36734. */
  36735. dispose(): void;
  36736. /**
  36737. * Gets if the scene is already disposed
  36738. */
  36739. get isDisposed(): boolean;
  36740. /**
  36741. * Call this function to reduce memory footprint of the scene.
  36742. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  36743. */
  36744. clearCachedVertexData(): void;
  36745. /**
  36746. * This function will remove the local cached buffer data from texture.
  36747. * It will save memory but will prevent the texture from being rebuilt
  36748. */
  36749. cleanCachedTextureBuffer(): void;
  36750. /**
  36751. * Get the world extend vectors with an optional filter
  36752. *
  36753. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  36754. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  36755. */
  36756. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  36757. min: Vector3;
  36758. max: Vector3;
  36759. };
  36760. /**
  36761. * Creates a ray that can be used to pick in the scene
  36762. * @param x defines the x coordinate of the origin (on-screen)
  36763. * @param y defines the y coordinate of the origin (on-screen)
  36764. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36765. * @param camera defines the camera to use for the picking
  36766. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36767. * @returns a Ray
  36768. */
  36769. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  36770. /**
  36771. * Creates a ray that can be used to pick in the scene
  36772. * @param x defines the x coordinate of the origin (on-screen)
  36773. * @param y defines the y coordinate of the origin (on-screen)
  36774. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  36775. * @param result defines the ray where to store the picking ray
  36776. * @param camera defines the camera to use for the picking
  36777. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  36778. * @returns the current scene
  36779. */
  36780. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  36781. /**
  36782. * Creates a ray that can be used to pick in the scene
  36783. * @param x defines the x coordinate of the origin (on-screen)
  36784. * @param y defines the y coordinate of the origin (on-screen)
  36785. * @param camera defines the camera to use for the picking
  36786. * @returns a Ray
  36787. */
  36788. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  36789. /**
  36790. * Creates a ray that can be used to pick in the scene
  36791. * @param x defines the x coordinate of the origin (on-screen)
  36792. * @param y defines the y coordinate of the origin (on-screen)
  36793. * @param result defines the ray where to store the picking ray
  36794. * @param camera defines the camera to use for the picking
  36795. * @returns the current scene
  36796. */
  36797. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  36798. /** Launch a ray to try to pick a mesh in the scene
  36799. * @param x position on screen
  36800. * @param y position on screen
  36801. * @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
  36802. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  36803. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36804. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36805. * @returns a PickingInfo
  36806. */
  36807. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36808. /** Use the given ray to pick a mesh in the scene
  36809. * @param ray The ray to use to pick meshes
  36810. * @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
  36811. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  36812. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36813. * @returns a PickingInfo
  36814. */
  36815. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  36816. /**
  36817. * Launch a ray to try to pick a mesh in the scene
  36818. * @param x X position on screen
  36819. * @param y Y position on screen
  36820. * @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
  36821. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  36822. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36823. * @returns an array of PickingInfo
  36824. */
  36825. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36826. /**
  36827. * Launch a ray to try to pick a mesh in the scene
  36828. * @param ray Ray to use
  36829. * @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
  36830. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36831. * @returns an array of PickingInfo
  36832. */
  36833. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  36834. /**
  36835. * Force the value of meshUnderPointer
  36836. * @param mesh defines the mesh to use
  36837. */
  36838. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  36839. /**
  36840. * Gets the mesh under the pointer
  36841. * @returns a Mesh or null if no mesh is under the pointer
  36842. */
  36843. getPointerOverMesh(): Nullable<AbstractMesh>;
  36844. /** @hidden */
  36845. _rebuildGeometries(): void;
  36846. /** @hidden */
  36847. _rebuildTextures(): void;
  36848. private _getByTags;
  36849. /**
  36850. * Get a list of meshes by tags
  36851. * @param tagsQuery defines the tags query to use
  36852. * @param forEach defines a predicate used to filter results
  36853. * @returns an array of Mesh
  36854. */
  36855. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  36856. /**
  36857. * Get a list of cameras by tags
  36858. * @param tagsQuery defines the tags query to use
  36859. * @param forEach defines a predicate used to filter results
  36860. * @returns an array of Camera
  36861. */
  36862. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  36863. /**
  36864. * Get a list of lights by tags
  36865. * @param tagsQuery defines the tags query to use
  36866. * @param forEach defines a predicate used to filter results
  36867. * @returns an array of Light
  36868. */
  36869. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  36870. /**
  36871. * Get a list of materials by tags
  36872. * @param tagsQuery defines the tags query to use
  36873. * @param forEach defines a predicate used to filter results
  36874. * @returns an array of Material
  36875. */
  36876. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  36877. /**
  36878. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  36879. * This allowed control for front to back rendering or reversly depending of the special needs.
  36880. *
  36881. * @param renderingGroupId The rendering group id corresponding to its index
  36882. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  36883. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  36884. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  36885. */
  36886. 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;
  36887. /**
  36888. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  36889. *
  36890. * @param renderingGroupId The rendering group id corresponding to its index
  36891. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  36892. * @param depth Automatically clears depth between groups if true and autoClear is true.
  36893. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  36894. */
  36895. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  36896. /**
  36897. * Gets the current auto clear configuration for one rendering group of the rendering
  36898. * manager.
  36899. * @param index the rendering group index to get the information for
  36900. * @returns The auto clear setup for the requested rendering group
  36901. */
  36902. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  36903. private _blockMaterialDirtyMechanism;
  36904. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  36905. get blockMaterialDirtyMechanism(): boolean;
  36906. set blockMaterialDirtyMechanism(value: boolean);
  36907. /**
  36908. * Will flag all materials as dirty to trigger new shader compilation
  36909. * @param flag defines the flag used to specify which material part must be marked as dirty
  36910. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  36911. */
  36912. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  36913. /** @hidden */
  36914. _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;
  36915. /** @hidden */
  36916. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36917. /** @hidden */
  36918. _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;
  36919. /** @hidden */
  36920. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  36921. /** @hidden */
  36922. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  36923. /** @hidden */
  36924. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  36925. }
  36926. }
  36927. declare module BABYLON {
  36928. /**
  36929. * Set of assets to keep when moving a scene into an asset container.
  36930. */
  36931. export class KeepAssets extends AbstractScene {
  36932. }
  36933. /**
  36934. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  36935. */
  36936. export class InstantiatedEntries {
  36937. /**
  36938. * List of new root nodes (eg. nodes with no parent)
  36939. */
  36940. rootNodes: TransformNode[];
  36941. /**
  36942. * List of new skeletons
  36943. */
  36944. skeletons: Skeleton[];
  36945. /**
  36946. * List of new animation groups
  36947. */
  36948. animationGroups: AnimationGroup[];
  36949. }
  36950. /**
  36951. * Container with a set of assets that can be added or removed from a scene.
  36952. */
  36953. export class AssetContainer extends AbstractScene {
  36954. /**
  36955. * The scene the AssetContainer belongs to.
  36956. */
  36957. scene: Scene;
  36958. /**
  36959. * Instantiates an AssetContainer.
  36960. * @param scene The scene the AssetContainer belongs to.
  36961. */
  36962. constructor(scene: Scene);
  36963. /**
  36964. * Instantiate or clone all meshes and add the new ones to the scene.
  36965. * Skeletons and animation groups will all be cloned
  36966. * @param nameFunction defines an optional function used to get new names for clones
  36967. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  36968. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  36969. */
  36970. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  36971. /**
  36972. * Adds all the assets from the container to the scene.
  36973. */
  36974. addAllToScene(): void;
  36975. /**
  36976. * Removes all the assets in the container from the scene
  36977. */
  36978. removeAllFromScene(): void;
  36979. /**
  36980. * Disposes all the assets in the container
  36981. */
  36982. dispose(): void;
  36983. private _moveAssets;
  36984. /**
  36985. * Removes all the assets contained in the scene and adds them to the container.
  36986. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  36987. */
  36988. moveAllFromScene(keepAssets?: KeepAssets): void;
  36989. /**
  36990. * 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.
  36991. * @returns the root mesh
  36992. */
  36993. createRootMesh(): Mesh;
  36994. /**
  36995. * Merge animations from this asset container into a scene
  36996. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  36997. * @param animatables set of animatables to retarget to a node from the scene
  36998. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  36999. */
  37000. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  37001. }
  37002. }
  37003. declare module BABYLON {
  37004. /**
  37005. * Defines how the parser contract is defined.
  37006. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  37007. */
  37008. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  37009. /**
  37010. * Defines how the individual parser contract is defined.
  37011. * These parser can parse an individual asset
  37012. */
  37013. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  37014. /**
  37015. * Base class of the scene acting as a container for the different elements composing a scene.
  37016. * This class is dynamically extended by the different components of the scene increasing
  37017. * flexibility and reducing coupling
  37018. */
  37019. export abstract class AbstractScene {
  37020. /**
  37021. * Stores the list of available parsers in the application.
  37022. */
  37023. private static _BabylonFileParsers;
  37024. /**
  37025. * Stores the list of available individual parsers in the application.
  37026. */
  37027. private static _IndividualBabylonFileParsers;
  37028. /**
  37029. * Adds a parser in the list of available ones
  37030. * @param name Defines the name of the parser
  37031. * @param parser Defines the parser to add
  37032. */
  37033. static AddParser(name: string, parser: BabylonFileParser): void;
  37034. /**
  37035. * Gets a general parser from the list of avaialble ones
  37036. * @param name Defines the name of the parser
  37037. * @returns the requested parser or null
  37038. */
  37039. static GetParser(name: string): Nullable<BabylonFileParser>;
  37040. /**
  37041. * Adds n individual parser in the list of available ones
  37042. * @param name Defines the name of the parser
  37043. * @param parser Defines the parser to add
  37044. */
  37045. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  37046. /**
  37047. * Gets an individual parser from the list of avaialble ones
  37048. * @param name Defines the name of the parser
  37049. * @returns the requested parser or null
  37050. */
  37051. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  37052. /**
  37053. * Parser json data and populate both a scene and its associated container object
  37054. * @param jsonData Defines the data to parse
  37055. * @param scene Defines the scene to parse the data for
  37056. * @param container Defines the container attached to the parsing sequence
  37057. * @param rootUrl Defines the root url of the data
  37058. */
  37059. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  37060. /**
  37061. * Gets the list of root nodes (ie. nodes with no parent)
  37062. */
  37063. rootNodes: Node[];
  37064. /** All of the cameras added to this scene
  37065. * @see http://doc.babylonjs.com/babylon101/cameras
  37066. */
  37067. cameras: Camera[];
  37068. /**
  37069. * All of the lights added to this scene
  37070. * @see http://doc.babylonjs.com/babylon101/lights
  37071. */
  37072. lights: Light[];
  37073. /**
  37074. * All of the (abstract) meshes added to this scene
  37075. */
  37076. meshes: AbstractMesh[];
  37077. /**
  37078. * The list of skeletons added to the scene
  37079. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37080. */
  37081. skeletons: Skeleton[];
  37082. /**
  37083. * All of the particle systems added to this scene
  37084. * @see http://doc.babylonjs.com/babylon101/particles
  37085. */
  37086. particleSystems: IParticleSystem[];
  37087. /**
  37088. * Gets a list of Animations associated with the scene
  37089. */
  37090. animations: Animation[];
  37091. /**
  37092. * All of the animation groups added to this scene
  37093. * @see http://doc.babylonjs.com/how_to/group
  37094. */
  37095. animationGroups: AnimationGroup[];
  37096. /**
  37097. * All of the multi-materials added to this scene
  37098. * @see http://doc.babylonjs.com/how_to/multi_materials
  37099. */
  37100. multiMaterials: MultiMaterial[];
  37101. /**
  37102. * All of the materials added to this scene
  37103. * In the context of a Scene, it is not supposed to be modified manually.
  37104. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  37105. * Note also that the order of the Material within the array is not significant and might change.
  37106. * @see http://doc.babylonjs.com/babylon101/materials
  37107. */
  37108. materials: Material[];
  37109. /**
  37110. * The list of morph target managers added to the scene
  37111. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  37112. */
  37113. morphTargetManagers: MorphTargetManager[];
  37114. /**
  37115. * The list of geometries used in the scene.
  37116. */
  37117. geometries: Geometry[];
  37118. /**
  37119. * All of the tranform nodes added to this scene
  37120. * In the context of a Scene, it is not supposed to be modified manually.
  37121. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  37122. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  37123. * @see http://doc.babylonjs.com/how_to/transformnode
  37124. */
  37125. transformNodes: TransformNode[];
  37126. /**
  37127. * ActionManagers available on the scene.
  37128. */
  37129. actionManagers: AbstractActionManager[];
  37130. /**
  37131. * Textures to keep.
  37132. */
  37133. textures: BaseTexture[];
  37134. /**
  37135. * Environment texture for the scene
  37136. */
  37137. environmentTexture: Nullable<BaseTexture>;
  37138. /**
  37139. * @returns all meshes, lights, cameras, transformNodes and bones
  37140. */
  37141. getNodes(): Array<Node>;
  37142. }
  37143. }
  37144. declare module BABYLON {
  37145. /**
  37146. * Interface used to define options for Sound class
  37147. */
  37148. export interface ISoundOptions {
  37149. /**
  37150. * Does the sound autoplay once loaded.
  37151. */
  37152. autoplay?: boolean;
  37153. /**
  37154. * Does the sound loop after it finishes playing once.
  37155. */
  37156. loop?: boolean;
  37157. /**
  37158. * Sound's volume
  37159. */
  37160. volume?: number;
  37161. /**
  37162. * Is it a spatial sound?
  37163. */
  37164. spatialSound?: boolean;
  37165. /**
  37166. * Maximum distance to hear that sound
  37167. */
  37168. maxDistance?: number;
  37169. /**
  37170. * Uses user defined attenuation function
  37171. */
  37172. useCustomAttenuation?: boolean;
  37173. /**
  37174. * Define the roll off factor of spatial sounds.
  37175. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37176. */
  37177. rolloffFactor?: number;
  37178. /**
  37179. * Define the reference distance the sound should be heard perfectly.
  37180. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37181. */
  37182. refDistance?: number;
  37183. /**
  37184. * Define the distance attenuation model the sound will follow.
  37185. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37186. */
  37187. distanceModel?: string;
  37188. /**
  37189. * Defines the playback speed (1 by default)
  37190. */
  37191. playbackRate?: number;
  37192. /**
  37193. * Defines if the sound is from a streaming source
  37194. */
  37195. streaming?: boolean;
  37196. /**
  37197. * Defines an optional length (in seconds) inside the sound file
  37198. */
  37199. length?: number;
  37200. /**
  37201. * Defines an optional offset (in seconds) inside the sound file
  37202. */
  37203. offset?: number;
  37204. /**
  37205. * If true, URLs will not be required to state the audio file codec to use.
  37206. */
  37207. skipCodecCheck?: boolean;
  37208. }
  37209. /**
  37210. * Defines a sound that can be played in the application.
  37211. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  37212. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37213. */
  37214. export class Sound {
  37215. /**
  37216. * The name of the sound in the scene.
  37217. */
  37218. name: string;
  37219. /**
  37220. * Does the sound autoplay once loaded.
  37221. */
  37222. autoplay: boolean;
  37223. /**
  37224. * Does the sound loop after it finishes playing once.
  37225. */
  37226. loop: boolean;
  37227. /**
  37228. * Does the sound use a custom attenuation curve to simulate the falloff
  37229. * happening when the source gets further away from the camera.
  37230. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37231. */
  37232. useCustomAttenuation: boolean;
  37233. /**
  37234. * The sound track id this sound belongs to.
  37235. */
  37236. soundTrackId: number;
  37237. /**
  37238. * Is this sound currently played.
  37239. */
  37240. isPlaying: boolean;
  37241. /**
  37242. * Is this sound currently paused.
  37243. */
  37244. isPaused: boolean;
  37245. /**
  37246. * Does this sound enables spatial sound.
  37247. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37248. */
  37249. spatialSound: boolean;
  37250. /**
  37251. * Define the reference distance the sound should be heard perfectly.
  37252. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37253. */
  37254. refDistance: number;
  37255. /**
  37256. * Define the roll off factor of spatial sounds.
  37257. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37258. */
  37259. rolloffFactor: number;
  37260. /**
  37261. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  37262. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37263. */
  37264. maxDistance: number;
  37265. /**
  37266. * Define the distance attenuation model the sound will follow.
  37267. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37268. */
  37269. distanceModel: string;
  37270. /**
  37271. * @hidden
  37272. * Back Compat
  37273. **/
  37274. onended: () => any;
  37275. /**
  37276. * Observable event when the current playing sound finishes.
  37277. */
  37278. onEndedObservable: Observable<Sound>;
  37279. private _panningModel;
  37280. private _playbackRate;
  37281. private _streaming;
  37282. private _startTime;
  37283. private _startOffset;
  37284. private _position;
  37285. /** @hidden */
  37286. _positionInEmitterSpace: boolean;
  37287. private _localDirection;
  37288. private _volume;
  37289. private _isReadyToPlay;
  37290. private _isDirectional;
  37291. private _readyToPlayCallback;
  37292. private _audioBuffer;
  37293. private _soundSource;
  37294. private _streamingSource;
  37295. private _soundPanner;
  37296. private _soundGain;
  37297. private _inputAudioNode;
  37298. private _outputAudioNode;
  37299. private _coneInnerAngle;
  37300. private _coneOuterAngle;
  37301. private _coneOuterGain;
  37302. private _scene;
  37303. private _connectedTransformNode;
  37304. private _customAttenuationFunction;
  37305. private _registerFunc;
  37306. private _isOutputConnected;
  37307. private _htmlAudioElement;
  37308. private _urlType;
  37309. private _length?;
  37310. private _offset?;
  37311. /** @hidden */
  37312. static _SceneComponentInitialization: (scene: Scene) => void;
  37313. /**
  37314. * Create a sound and attach it to a scene
  37315. * @param name Name of your sound
  37316. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  37317. * @param scene defines the scene the sound belongs to
  37318. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  37319. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  37320. */
  37321. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  37322. /**
  37323. * Release the sound and its associated resources
  37324. */
  37325. dispose(): void;
  37326. /**
  37327. * Gets if the sounds is ready to be played or not.
  37328. * @returns true if ready, otherwise false
  37329. */
  37330. isReady(): boolean;
  37331. private _soundLoaded;
  37332. /**
  37333. * Sets the data of the sound from an audiobuffer
  37334. * @param audioBuffer The audioBuffer containing the data
  37335. */
  37336. setAudioBuffer(audioBuffer: AudioBuffer): void;
  37337. /**
  37338. * Updates the current sounds options such as maxdistance, loop...
  37339. * @param options A JSON object containing values named as the object properties
  37340. */
  37341. updateOptions(options: ISoundOptions): void;
  37342. private _createSpatialParameters;
  37343. private _updateSpatialParameters;
  37344. /**
  37345. * Switch the panning model to HRTF:
  37346. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37347. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37348. */
  37349. switchPanningModelToHRTF(): void;
  37350. /**
  37351. * Switch the panning model to Equal Power:
  37352. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37353. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37354. */
  37355. switchPanningModelToEqualPower(): void;
  37356. private _switchPanningModel;
  37357. /**
  37358. * Connect this sound to a sound track audio node like gain...
  37359. * @param soundTrackAudioNode the sound track audio node to connect to
  37360. */
  37361. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  37362. /**
  37363. * Transform this sound into a directional source
  37364. * @param coneInnerAngle Size of the inner cone in degree
  37365. * @param coneOuterAngle Size of the outer cone in degree
  37366. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  37367. */
  37368. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  37369. /**
  37370. * Gets or sets the inner angle for the directional cone.
  37371. */
  37372. get directionalConeInnerAngle(): number;
  37373. /**
  37374. * Gets or sets the inner angle for the directional cone.
  37375. */
  37376. set directionalConeInnerAngle(value: number);
  37377. /**
  37378. * Gets or sets the outer angle for the directional cone.
  37379. */
  37380. get directionalConeOuterAngle(): number;
  37381. /**
  37382. * Gets or sets the outer angle for the directional cone.
  37383. */
  37384. set directionalConeOuterAngle(value: number);
  37385. /**
  37386. * Sets the position of the emitter if spatial sound is enabled
  37387. * @param newPosition Defines the new posisiton
  37388. */
  37389. setPosition(newPosition: Vector3): void;
  37390. /**
  37391. * Sets the local direction of the emitter if spatial sound is enabled
  37392. * @param newLocalDirection Defines the new local direction
  37393. */
  37394. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  37395. private _updateDirection;
  37396. /** @hidden */
  37397. updateDistanceFromListener(): void;
  37398. /**
  37399. * Sets a new custom attenuation function for the sound.
  37400. * @param callback Defines the function used for the attenuation
  37401. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  37402. */
  37403. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  37404. /**
  37405. * Play the sound
  37406. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  37407. * @param offset (optional) Start the sound at a specific time in seconds
  37408. * @param length (optional) Sound duration (in seconds)
  37409. */
  37410. play(time?: number, offset?: number, length?: number): void;
  37411. private _onended;
  37412. /**
  37413. * Stop the sound
  37414. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  37415. */
  37416. stop(time?: number): void;
  37417. /**
  37418. * Put the sound in pause
  37419. */
  37420. pause(): void;
  37421. /**
  37422. * Sets a dedicated volume for this sounds
  37423. * @param newVolume Define the new volume of the sound
  37424. * @param time Define time for gradual change to new volume
  37425. */
  37426. setVolume(newVolume: number, time?: number): void;
  37427. /**
  37428. * Set the sound play back rate
  37429. * @param newPlaybackRate Define the playback rate the sound should be played at
  37430. */
  37431. setPlaybackRate(newPlaybackRate: number): void;
  37432. /**
  37433. * Gets the volume of the sound.
  37434. * @returns the volume of the sound
  37435. */
  37436. getVolume(): number;
  37437. /**
  37438. * Attach the sound to a dedicated mesh
  37439. * @param transformNode The transform node to connect the sound with
  37440. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37441. */
  37442. attachToMesh(transformNode: TransformNode): void;
  37443. /**
  37444. * Detach the sound from the previously attached mesh
  37445. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  37446. */
  37447. detachFromMesh(): void;
  37448. private _onRegisterAfterWorldMatrixUpdate;
  37449. /**
  37450. * Clone the current sound in the scene.
  37451. * @returns the new sound clone
  37452. */
  37453. clone(): Nullable<Sound>;
  37454. /**
  37455. * Gets the current underlying audio buffer containing the data
  37456. * @returns the audio buffer
  37457. */
  37458. getAudioBuffer(): Nullable<AudioBuffer>;
  37459. /**
  37460. * Serializes the Sound in a JSON representation
  37461. * @returns the JSON representation of the sound
  37462. */
  37463. serialize(): any;
  37464. /**
  37465. * Parse a JSON representation of a sound to innstantiate in a given scene
  37466. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  37467. * @param scene Define the scene the new parsed sound should be created in
  37468. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  37469. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  37470. * @returns the newly parsed sound
  37471. */
  37472. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  37473. }
  37474. }
  37475. declare module BABYLON {
  37476. /**
  37477. * This defines an action helpful to play a defined sound on a triggered action.
  37478. */
  37479. export class PlaySoundAction extends Action {
  37480. private _sound;
  37481. /**
  37482. * Instantiate the action
  37483. * @param triggerOptions defines the trigger options
  37484. * @param sound defines the sound to play
  37485. * @param condition defines the trigger related conditions
  37486. */
  37487. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37488. /** @hidden */
  37489. _prepare(): void;
  37490. /**
  37491. * Execute the action and play the sound.
  37492. */
  37493. execute(): void;
  37494. /**
  37495. * Serializes the actions and its related information.
  37496. * @param parent defines the object to serialize in
  37497. * @returns the serialized object
  37498. */
  37499. serialize(parent: any): any;
  37500. }
  37501. /**
  37502. * This defines an action helpful to stop a defined sound on a triggered action.
  37503. */
  37504. export class StopSoundAction extends Action {
  37505. private _sound;
  37506. /**
  37507. * Instantiate the action
  37508. * @param triggerOptions defines the trigger options
  37509. * @param sound defines the sound to stop
  37510. * @param condition defines the trigger related conditions
  37511. */
  37512. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  37513. /** @hidden */
  37514. _prepare(): void;
  37515. /**
  37516. * Execute the action and stop the sound.
  37517. */
  37518. execute(): void;
  37519. /**
  37520. * Serializes the actions and its related information.
  37521. * @param parent defines the object to serialize in
  37522. * @returns the serialized object
  37523. */
  37524. serialize(parent: any): any;
  37525. }
  37526. }
  37527. declare module BABYLON {
  37528. /**
  37529. * This defines an action responsible to change the value of a property
  37530. * by interpolating between its current value and the newly set one once triggered.
  37531. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  37532. */
  37533. export class InterpolateValueAction extends Action {
  37534. /**
  37535. * Defines the path of the property where the value should be interpolated
  37536. */
  37537. propertyPath: string;
  37538. /**
  37539. * Defines the target value at the end of the interpolation.
  37540. */
  37541. value: any;
  37542. /**
  37543. * Defines the time it will take for the property to interpolate to the value.
  37544. */
  37545. duration: number;
  37546. /**
  37547. * Defines if the other scene animations should be stopped when the action has been triggered
  37548. */
  37549. stopOtherAnimations?: boolean;
  37550. /**
  37551. * Defines a callback raised once the interpolation animation has been done.
  37552. */
  37553. onInterpolationDone?: () => void;
  37554. /**
  37555. * Observable triggered once the interpolation animation has been done.
  37556. */
  37557. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  37558. private _target;
  37559. private _effectiveTarget;
  37560. private _property;
  37561. /**
  37562. * Instantiate the action
  37563. * @param triggerOptions defines the trigger options
  37564. * @param target defines the object containing the value to interpolate
  37565. * @param propertyPath defines the path to the property in the target object
  37566. * @param value defines the target value at the end of the interpolation
  37567. * @param duration deines the time it will take for the property to interpolate to the value.
  37568. * @param condition defines the trigger related conditions
  37569. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  37570. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  37571. */
  37572. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  37573. /** @hidden */
  37574. _prepare(): void;
  37575. /**
  37576. * Execute the action starts the value interpolation.
  37577. */
  37578. execute(): void;
  37579. /**
  37580. * Serializes the actions and its related information.
  37581. * @param parent defines the object to serialize in
  37582. * @returns the serialized object
  37583. */
  37584. serialize(parent: any): any;
  37585. }
  37586. }
  37587. declare module BABYLON {
  37588. /**
  37589. * Options allowed during the creation of a sound track.
  37590. */
  37591. export interface ISoundTrackOptions {
  37592. /**
  37593. * The volume the sound track should take during creation
  37594. */
  37595. volume?: number;
  37596. /**
  37597. * Define if the sound track is the main sound track of the scene
  37598. */
  37599. mainTrack?: boolean;
  37600. }
  37601. /**
  37602. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  37603. * It will be also used in a future release to apply effects on a specific track.
  37604. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37605. */
  37606. export class SoundTrack {
  37607. /**
  37608. * The unique identifier of the sound track in the scene.
  37609. */
  37610. id: number;
  37611. /**
  37612. * The list of sounds included in the sound track.
  37613. */
  37614. soundCollection: Array<Sound>;
  37615. private _outputAudioNode;
  37616. private _scene;
  37617. private _connectedAnalyser;
  37618. private _options;
  37619. private _isInitialized;
  37620. /**
  37621. * Creates a new sound track.
  37622. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  37623. * @param scene Define the scene the sound track belongs to
  37624. * @param options
  37625. */
  37626. constructor(scene: Scene, options?: ISoundTrackOptions);
  37627. private _initializeSoundTrackAudioGraph;
  37628. /**
  37629. * Release the sound track and its associated resources
  37630. */
  37631. dispose(): void;
  37632. /**
  37633. * Adds a sound to this sound track
  37634. * @param sound define the cound to add
  37635. * @ignoreNaming
  37636. */
  37637. AddSound(sound: Sound): void;
  37638. /**
  37639. * Removes a sound to this sound track
  37640. * @param sound define the cound to remove
  37641. * @ignoreNaming
  37642. */
  37643. RemoveSound(sound: Sound): void;
  37644. /**
  37645. * Set a global volume for the full sound track.
  37646. * @param newVolume Define the new volume of the sound track
  37647. */
  37648. setVolume(newVolume: number): void;
  37649. /**
  37650. * Switch the panning model to HRTF:
  37651. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  37652. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37653. */
  37654. switchPanningModelToHRTF(): void;
  37655. /**
  37656. * Switch the panning model to Equal Power:
  37657. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  37658. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  37659. */
  37660. switchPanningModelToEqualPower(): void;
  37661. /**
  37662. * Connect the sound track to an audio analyser allowing some amazing
  37663. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37664. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37665. * @param analyser The analyser to connect to the engine
  37666. */
  37667. connectToAnalyser(analyser: Analyser): void;
  37668. }
  37669. }
  37670. declare module BABYLON {
  37671. interface AbstractScene {
  37672. /**
  37673. * The list of sounds used in the scene.
  37674. */
  37675. sounds: Nullable<Array<Sound>>;
  37676. }
  37677. interface Scene {
  37678. /**
  37679. * @hidden
  37680. * Backing field
  37681. */
  37682. _mainSoundTrack: SoundTrack;
  37683. /**
  37684. * The main sound track played by the scene.
  37685. * It cotains your primary collection of sounds.
  37686. */
  37687. mainSoundTrack: SoundTrack;
  37688. /**
  37689. * The list of sound tracks added to the scene
  37690. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37691. */
  37692. soundTracks: Nullable<Array<SoundTrack>>;
  37693. /**
  37694. * Gets a sound using a given name
  37695. * @param name defines the name to search for
  37696. * @return the found sound or null if not found at all.
  37697. */
  37698. getSoundByName(name: string): Nullable<Sound>;
  37699. /**
  37700. * Gets or sets if audio support is enabled
  37701. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37702. */
  37703. audioEnabled: boolean;
  37704. /**
  37705. * Gets or sets if audio will be output to headphones
  37706. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37707. */
  37708. headphone: boolean;
  37709. /**
  37710. * Gets or sets custom audio listener position provider
  37711. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  37712. */
  37713. audioListenerPositionProvider: Nullable<() => Vector3>;
  37714. /**
  37715. * Gets or sets a refresh rate when using 3D audio positioning
  37716. */
  37717. audioPositioningRefreshRate: number;
  37718. }
  37719. /**
  37720. * Defines the sound scene component responsible to manage any sounds
  37721. * in a given scene.
  37722. */
  37723. export class AudioSceneComponent implements ISceneSerializableComponent {
  37724. /**
  37725. * The component name helpfull to identify the component in the list of scene components.
  37726. */
  37727. readonly name: string;
  37728. /**
  37729. * The scene the component belongs to.
  37730. */
  37731. scene: Scene;
  37732. private _audioEnabled;
  37733. /**
  37734. * Gets whether audio is enabled or not.
  37735. * Please use related enable/disable method to switch state.
  37736. */
  37737. get audioEnabled(): boolean;
  37738. private _headphone;
  37739. /**
  37740. * Gets whether audio is outputing to headphone or not.
  37741. * Please use the according Switch methods to change output.
  37742. */
  37743. get headphone(): boolean;
  37744. /**
  37745. * Gets or sets a refresh rate when using 3D audio positioning
  37746. */
  37747. audioPositioningRefreshRate: number;
  37748. private _audioListenerPositionProvider;
  37749. /**
  37750. * Gets the current audio listener position provider
  37751. */
  37752. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  37753. /**
  37754. * Sets a custom listener position for all sounds in the scene
  37755. * By default, this is the position of the first active camera
  37756. */
  37757. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  37758. /**
  37759. * Creates a new instance of the component for the given scene
  37760. * @param scene Defines the scene to register the component in
  37761. */
  37762. constructor(scene: Scene);
  37763. /**
  37764. * Registers the component in a given scene
  37765. */
  37766. register(): void;
  37767. /**
  37768. * Rebuilds the elements related to this component in case of
  37769. * context lost for instance.
  37770. */
  37771. rebuild(): void;
  37772. /**
  37773. * Serializes the component data to the specified json object
  37774. * @param serializationObject The object to serialize to
  37775. */
  37776. serialize(serializationObject: any): void;
  37777. /**
  37778. * Adds all the elements from the container to the scene
  37779. * @param container the container holding the elements
  37780. */
  37781. addFromContainer(container: AbstractScene): void;
  37782. /**
  37783. * Removes all the elements in the container from the scene
  37784. * @param container contains the elements to remove
  37785. * @param dispose if the removed element should be disposed (default: false)
  37786. */
  37787. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  37788. /**
  37789. * Disposes the component and the associated ressources.
  37790. */
  37791. dispose(): void;
  37792. /**
  37793. * Disables audio in the associated scene.
  37794. */
  37795. disableAudio(): void;
  37796. /**
  37797. * Enables audio in the associated scene.
  37798. */
  37799. enableAudio(): void;
  37800. /**
  37801. * Switch audio to headphone output.
  37802. */
  37803. switchAudioModeForHeadphones(): void;
  37804. /**
  37805. * Switch audio to normal speakers.
  37806. */
  37807. switchAudioModeForNormalSpeakers(): void;
  37808. private _cachedCameraDirection;
  37809. private _cachedCameraPosition;
  37810. private _lastCheck;
  37811. private _afterRender;
  37812. }
  37813. }
  37814. declare module BABYLON {
  37815. /**
  37816. * Wraps one or more Sound objects and selects one with random weight for playback.
  37817. */
  37818. export class WeightedSound {
  37819. /** When true a Sound will be selected and played when the current playing Sound completes. */
  37820. loop: boolean;
  37821. private _coneInnerAngle;
  37822. private _coneOuterAngle;
  37823. private _volume;
  37824. /** A Sound is currently playing. */
  37825. isPlaying: boolean;
  37826. /** A Sound is currently paused. */
  37827. isPaused: boolean;
  37828. private _sounds;
  37829. private _weights;
  37830. private _currentIndex?;
  37831. /**
  37832. * Creates a new WeightedSound from the list of sounds given.
  37833. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  37834. * @param sounds Array of Sounds that will be selected from.
  37835. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  37836. */
  37837. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  37838. /**
  37839. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  37840. */
  37841. get directionalConeInnerAngle(): number;
  37842. /**
  37843. * The size of cone in degress for a directional sound in which there will be no attenuation.
  37844. */
  37845. set directionalConeInnerAngle(value: number);
  37846. /**
  37847. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37848. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37849. */
  37850. get directionalConeOuterAngle(): number;
  37851. /**
  37852. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  37853. * Listener angles between innerAngle and outerAngle will falloff linearly.
  37854. */
  37855. set directionalConeOuterAngle(value: number);
  37856. /**
  37857. * Playback volume.
  37858. */
  37859. get volume(): number;
  37860. /**
  37861. * Playback volume.
  37862. */
  37863. set volume(value: number);
  37864. private _onended;
  37865. /**
  37866. * Suspend playback
  37867. */
  37868. pause(): void;
  37869. /**
  37870. * Stop playback
  37871. */
  37872. stop(): void;
  37873. /**
  37874. * Start playback.
  37875. * @param startOffset Position the clip head at a specific time in seconds.
  37876. */
  37877. play(startOffset?: number): void;
  37878. }
  37879. }
  37880. declare module BABYLON {
  37881. /**
  37882. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  37883. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37884. */
  37885. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  37886. /**
  37887. * Gets the name of the behavior.
  37888. */
  37889. get name(): string;
  37890. /**
  37891. * The easing function used by animations
  37892. */
  37893. static EasingFunction: BackEase;
  37894. /**
  37895. * The easing mode used by animations
  37896. */
  37897. static EasingMode: number;
  37898. /**
  37899. * The duration of the animation, in milliseconds
  37900. */
  37901. transitionDuration: number;
  37902. /**
  37903. * Length of the distance animated by the transition when lower radius is reached
  37904. */
  37905. lowerRadiusTransitionRange: number;
  37906. /**
  37907. * Length of the distance animated by the transition when upper radius is reached
  37908. */
  37909. upperRadiusTransitionRange: number;
  37910. private _autoTransitionRange;
  37911. /**
  37912. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37913. */
  37914. get autoTransitionRange(): boolean;
  37915. /**
  37916. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  37917. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  37918. */
  37919. set autoTransitionRange(value: boolean);
  37920. private _attachedCamera;
  37921. private _onAfterCheckInputsObserver;
  37922. private _onMeshTargetChangedObserver;
  37923. /**
  37924. * Initializes the behavior.
  37925. */
  37926. init(): void;
  37927. /**
  37928. * Attaches the behavior to its arc rotate camera.
  37929. * @param camera Defines the camera to attach the behavior to
  37930. */
  37931. attach(camera: ArcRotateCamera): void;
  37932. /**
  37933. * Detaches the behavior from its current arc rotate camera.
  37934. */
  37935. detach(): void;
  37936. private _radiusIsAnimating;
  37937. private _radiusBounceTransition;
  37938. private _animatables;
  37939. private _cachedWheelPrecision;
  37940. /**
  37941. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  37942. * @param radiusLimit The limit to check against.
  37943. * @return Bool to indicate if at limit.
  37944. */
  37945. private _isRadiusAtLimit;
  37946. /**
  37947. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  37948. * @param radiusDelta The delta by which to animate to. Can be negative.
  37949. */
  37950. private _applyBoundRadiusAnimation;
  37951. /**
  37952. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  37953. */
  37954. protected _clearAnimationLocks(): void;
  37955. /**
  37956. * Stops and removes all animations that have been applied to the camera
  37957. */
  37958. stopAllAnimations(): void;
  37959. }
  37960. }
  37961. declare module BABYLON {
  37962. /**
  37963. * 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.
  37964. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37965. */
  37966. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  37967. /**
  37968. * Gets the name of the behavior.
  37969. */
  37970. get name(): string;
  37971. private _mode;
  37972. private _radiusScale;
  37973. private _positionScale;
  37974. private _defaultElevation;
  37975. private _elevationReturnTime;
  37976. private _elevationReturnWaitTime;
  37977. private _zoomStopsAnimation;
  37978. private _framingTime;
  37979. /**
  37980. * The easing function used by animations
  37981. */
  37982. static EasingFunction: ExponentialEase;
  37983. /**
  37984. * The easing mode used by animations
  37985. */
  37986. static EasingMode: number;
  37987. /**
  37988. * Sets the current mode used by the behavior
  37989. */
  37990. set mode(mode: number);
  37991. /**
  37992. * Gets current mode used by the behavior.
  37993. */
  37994. get mode(): number;
  37995. /**
  37996. * Sets the scale applied to the radius (1 by default)
  37997. */
  37998. set radiusScale(radius: number);
  37999. /**
  38000. * Gets the scale applied to the radius
  38001. */
  38002. get radiusScale(): number;
  38003. /**
  38004. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38005. */
  38006. set positionScale(scale: number);
  38007. /**
  38008. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  38009. */
  38010. get positionScale(): number;
  38011. /**
  38012. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38013. * behaviour is triggered, in radians.
  38014. */
  38015. set defaultElevation(elevation: number);
  38016. /**
  38017. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  38018. * behaviour is triggered, in radians.
  38019. */
  38020. get defaultElevation(): number;
  38021. /**
  38022. * Sets the time (in milliseconds) taken to return to the default beta position.
  38023. * Negative value indicates camera should not return to default.
  38024. */
  38025. set elevationReturnTime(speed: number);
  38026. /**
  38027. * Gets the time (in milliseconds) taken to return to the default beta position.
  38028. * Negative value indicates camera should not return to default.
  38029. */
  38030. get elevationReturnTime(): number;
  38031. /**
  38032. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38033. */
  38034. set elevationReturnWaitTime(time: number);
  38035. /**
  38036. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  38037. */
  38038. get elevationReturnWaitTime(): number;
  38039. /**
  38040. * Sets the flag that indicates if user zooming should stop animation.
  38041. */
  38042. set zoomStopsAnimation(flag: boolean);
  38043. /**
  38044. * Gets the flag that indicates if user zooming should stop animation.
  38045. */
  38046. get zoomStopsAnimation(): boolean;
  38047. /**
  38048. * Sets the transition time when framing the mesh, in milliseconds
  38049. */
  38050. set framingTime(time: number);
  38051. /**
  38052. * Gets the transition time when framing the mesh, in milliseconds
  38053. */
  38054. get framingTime(): number;
  38055. /**
  38056. * Define if the behavior should automatically change the configured
  38057. * camera limits and sensibilities.
  38058. */
  38059. autoCorrectCameraLimitsAndSensibility: boolean;
  38060. private _onPrePointerObservableObserver;
  38061. private _onAfterCheckInputsObserver;
  38062. private _onMeshTargetChangedObserver;
  38063. private _attachedCamera;
  38064. private _isPointerDown;
  38065. private _lastInteractionTime;
  38066. /**
  38067. * Initializes the behavior.
  38068. */
  38069. init(): void;
  38070. /**
  38071. * Attaches the behavior to its arc rotate camera.
  38072. * @param camera Defines the camera to attach the behavior to
  38073. */
  38074. attach(camera: ArcRotateCamera): void;
  38075. /**
  38076. * Detaches the behavior from its current arc rotate camera.
  38077. */
  38078. detach(): void;
  38079. private _animatables;
  38080. private _betaIsAnimating;
  38081. private _betaTransition;
  38082. private _radiusTransition;
  38083. private _vectorTransition;
  38084. /**
  38085. * Targets the given mesh and updates zoom level accordingly.
  38086. * @param mesh The mesh to target.
  38087. * @param radius Optional. If a cached radius position already exists, overrides default.
  38088. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  38089. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38090. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38091. */
  38092. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38093. /**
  38094. * Targets the given mesh with its children and updates zoom level accordingly.
  38095. * @param mesh The mesh to target.
  38096. * @param radius Optional. If a cached radius position already exists, overrides default.
  38097. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  38098. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38099. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38100. */
  38101. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38102. /**
  38103. * Targets the given meshes with their children and updates zoom level accordingly.
  38104. * @param meshes The mesh to target.
  38105. * @param radius Optional. If a cached radius position already exists, overrides default.
  38106. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  38107. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38108. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38109. */
  38110. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38111. /**
  38112. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  38113. * @param minimumWorld Determines the smaller position of the bounding box extend
  38114. * @param maximumWorld Determines the bigger position of the bounding box extend
  38115. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  38116. * @param onAnimationEnd Callback triggered at the end of the framing animation
  38117. */
  38118. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  38119. /**
  38120. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  38121. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  38122. * frustum width.
  38123. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  38124. * to fully enclose the mesh in the viewing frustum.
  38125. */
  38126. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  38127. /**
  38128. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  38129. * is automatically returned to its default position (expected to be above ground plane).
  38130. */
  38131. private _maintainCameraAboveGround;
  38132. /**
  38133. * Returns the frustum slope based on the canvas ratio and camera FOV
  38134. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  38135. */
  38136. private _getFrustumSlope;
  38137. /**
  38138. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  38139. */
  38140. private _clearAnimationLocks;
  38141. /**
  38142. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38143. */
  38144. private _applyUserInteraction;
  38145. /**
  38146. * Stops and removes all animations that have been applied to the camera
  38147. */
  38148. stopAllAnimations(): void;
  38149. /**
  38150. * Gets a value indicating if the user is moving the camera
  38151. */
  38152. get isUserIsMoving(): boolean;
  38153. /**
  38154. * The camera can move all the way towards the mesh.
  38155. */
  38156. static IgnoreBoundsSizeMode: number;
  38157. /**
  38158. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  38159. */
  38160. static FitFrustumSidesMode: number;
  38161. }
  38162. }
  38163. declare module BABYLON {
  38164. /**
  38165. * Base class for Camera Pointer Inputs.
  38166. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  38167. * for example usage.
  38168. */
  38169. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  38170. /**
  38171. * Defines the camera the input is attached to.
  38172. */
  38173. abstract camera: Camera;
  38174. /**
  38175. * Whether keyboard modifier keys are pressed at time of last mouse event.
  38176. */
  38177. protected _altKey: boolean;
  38178. protected _ctrlKey: boolean;
  38179. protected _metaKey: boolean;
  38180. protected _shiftKey: boolean;
  38181. /**
  38182. * Which mouse buttons were pressed at time of last mouse event.
  38183. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  38184. */
  38185. protected _buttonsPressed: number;
  38186. /**
  38187. * Defines the buttons associated with the input to handle camera move.
  38188. */
  38189. buttons: number[];
  38190. /**
  38191. * Attach the input controls to a specific dom element to get the input from.
  38192. * @param element Defines the element the controls should be listened from
  38193. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38194. */
  38195. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38196. /**
  38197. * Detach the current controls from the specified dom element.
  38198. * @param element Defines the element to stop listening the inputs from
  38199. */
  38200. detachControl(element: Nullable<HTMLElement>): void;
  38201. /**
  38202. * Gets the class name of the current input.
  38203. * @returns the class name
  38204. */
  38205. getClassName(): string;
  38206. /**
  38207. * Get the friendly name associated with the input class.
  38208. * @returns the input friendly name
  38209. */
  38210. getSimpleName(): string;
  38211. /**
  38212. * Called on pointer POINTERDOUBLETAP event.
  38213. * Override this method to provide functionality on POINTERDOUBLETAP event.
  38214. */
  38215. protected onDoubleTap(type: string): void;
  38216. /**
  38217. * Called on pointer POINTERMOVE event if only a single touch is active.
  38218. * Override this method to provide functionality.
  38219. */
  38220. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38221. /**
  38222. * Called on pointer POINTERMOVE event if multiple touches are active.
  38223. * Override this method to provide functionality.
  38224. */
  38225. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38226. /**
  38227. * Called on JS contextmenu event.
  38228. * Override this method to provide functionality.
  38229. */
  38230. protected onContextMenu(evt: PointerEvent): void;
  38231. /**
  38232. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38233. * press.
  38234. * Override this method to provide functionality.
  38235. */
  38236. protected onButtonDown(evt: PointerEvent): void;
  38237. /**
  38238. * Called each time a new POINTERUP event occurs. Ie, for each button
  38239. * release.
  38240. * Override this method to provide functionality.
  38241. */
  38242. protected onButtonUp(evt: PointerEvent): void;
  38243. /**
  38244. * Called when window becomes inactive.
  38245. * Override this method to provide functionality.
  38246. */
  38247. protected onLostFocus(): void;
  38248. private _pointerInput;
  38249. private _observer;
  38250. private _onLostFocus;
  38251. private pointA;
  38252. private pointB;
  38253. }
  38254. }
  38255. declare module BABYLON {
  38256. /**
  38257. * Manage the pointers inputs to control an arc rotate camera.
  38258. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38259. */
  38260. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  38261. /**
  38262. * Defines the camera the input is attached to.
  38263. */
  38264. camera: ArcRotateCamera;
  38265. /**
  38266. * Gets the class name of the current input.
  38267. * @returns the class name
  38268. */
  38269. getClassName(): string;
  38270. /**
  38271. * Defines the buttons associated with the input to handle camera move.
  38272. */
  38273. buttons: number[];
  38274. /**
  38275. * Defines the pointer angular sensibility along the X axis or how fast is
  38276. * the camera rotating.
  38277. */
  38278. angularSensibilityX: number;
  38279. /**
  38280. * Defines the pointer angular sensibility along the Y axis or how fast is
  38281. * the camera rotating.
  38282. */
  38283. angularSensibilityY: number;
  38284. /**
  38285. * Defines the pointer pinch precision or how fast is the camera zooming.
  38286. */
  38287. pinchPrecision: number;
  38288. /**
  38289. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  38290. * from 0.
  38291. * It defines the percentage of current camera.radius to use as delta when
  38292. * pinch zoom is used.
  38293. */
  38294. pinchDeltaPercentage: number;
  38295. /**
  38296. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  38297. * that any object in the plane at the camera's target point will scale
  38298. * perfectly with finger motion.
  38299. * Overrides pinchDeltaPercentage and pinchPrecision.
  38300. */
  38301. useNaturalPinchZoom: boolean;
  38302. /**
  38303. * Defines the pointer panning sensibility or how fast is the camera moving.
  38304. */
  38305. panningSensibility: number;
  38306. /**
  38307. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  38308. */
  38309. multiTouchPanning: boolean;
  38310. /**
  38311. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  38312. * zoom (pinch) through multitouch.
  38313. */
  38314. multiTouchPanAndZoom: boolean;
  38315. /**
  38316. * Revers pinch action direction.
  38317. */
  38318. pinchInwards: boolean;
  38319. private _isPanClick;
  38320. private _twoFingerActivityCount;
  38321. private _isPinching;
  38322. /**
  38323. * Called on pointer POINTERMOVE event if only a single touch is active.
  38324. */
  38325. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  38326. /**
  38327. * Called on pointer POINTERDOUBLETAP event.
  38328. */
  38329. protected onDoubleTap(type: string): void;
  38330. /**
  38331. * Called on pointer POINTERMOVE event if multiple touches are active.
  38332. */
  38333. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  38334. /**
  38335. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  38336. * press.
  38337. */
  38338. protected onButtonDown(evt: PointerEvent): void;
  38339. /**
  38340. * Called each time a new POINTERUP event occurs. Ie, for each button
  38341. * release.
  38342. */
  38343. protected onButtonUp(evt: PointerEvent): void;
  38344. /**
  38345. * Called when window becomes inactive.
  38346. */
  38347. protected onLostFocus(): void;
  38348. }
  38349. }
  38350. declare module BABYLON {
  38351. /**
  38352. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  38353. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38354. */
  38355. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  38356. /**
  38357. * Defines the camera the input is attached to.
  38358. */
  38359. camera: ArcRotateCamera;
  38360. /**
  38361. * Defines the list of key codes associated with the up action (increase alpha)
  38362. */
  38363. keysUp: number[];
  38364. /**
  38365. * Defines the list of key codes associated with the down action (decrease alpha)
  38366. */
  38367. keysDown: number[];
  38368. /**
  38369. * Defines the list of key codes associated with the left action (increase beta)
  38370. */
  38371. keysLeft: number[];
  38372. /**
  38373. * Defines the list of key codes associated with the right action (decrease beta)
  38374. */
  38375. keysRight: number[];
  38376. /**
  38377. * Defines the list of key codes associated with the reset action.
  38378. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  38379. */
  38380. keysReset: number[];
  38381. /**
  38382. * Defines the panning sensibility of the inputs.
  38383. * (How fast is the camera panning)
  38384. */
  38385. panningSensibility: number;
  38386. /**
  38387. * Defines the zooming sensibility of the inputs.
  38388. * (How fast is the camera zooming)
  38389. */
  38390. zoomingSensibility: number;
  38391. /**
  38392. * Defines whether maintaining the alt key down switch the movement mode from
  38393. * orientation to zoom.
  38394. */
  38395. useAltToZoom: boolean;
  38396. /**
  38397. * Rotation speed of the camera
  38398. */
  38399. angularSpeed: number;
  38400. private _keys;
  38401. private _ctrlPressed;
  38402. private _altPressed;
  38403. private _onCanvasBlurObserver;
  38404. private _onKeyboardObserver;
  38405. private _engine;
  38406. private _scene;
  38407. /**
  38408. * Attach the input controls to a specific dom element to get the input from.
  38409. * @param element Defines the element the controls should be listened from
  38410. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38411. */
  38412. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38413. /**
  38414. * Detach the current controls from the specified dom element.
  38415. * @param element Defines the element to stop listening the inputs from
  38416. */
  38417. detachControl(element: Nullable<HTMLElement>): void;
  38418. /**
  38419. * Update the current camera state depending on the inputs that have been used this frame.
  38420. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38421. */
  38422. checkInputs(): void;
  38423. /**
  38424. * Gets the class name of the current intput.
  38425. * @returns the class name
  38426. */
  38427. getClassName(): string;
  38428. /**
  38429. * Get the friendly name associated with the input class.
  38430. * @returns the input friendly name
  38431. */
  38432. getSimpleName(): string;
  38433. }
  38434. }
  38435. declare module BABYLON {
  38436. /**
  38437. * Manage the mouse wheel inputs to control an arc rotate camera.
  38438. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38439. */
  38440. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  38441. /**
  38442. * Defines the camera the input is attached to.
  38443. */
  38444. camera: ArcRotateCamera;
  38445. /**
  38446. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38447. */
  38448. wheelPrecision: number;
  38449. /**
  38450. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38451. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  38452. */
  38453. wheelDeltaPercentage: number;
  38454. private _wheel;
  38455. private _observer;
  38456. private computeDeltaFromMouseWheelLegacyEvent;
  38457. /**
  38458. * Attach the input controls to a specific dom element to get the input from.
  38459. * @param element Defines the element the controls should be listened from
  38460. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38461. */
  38462. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38463. /**
  38464. * Detach the current controls from the specified dom element.
  38465. * @param element Defines the element to stop listening the inputs from
  38466. */
  38467. detachControl(element: Nullable<HTMLElement>): void;
  38468. /**
  38469. * Gets the class name of the current intput.
  38470. * @returns the class name
  38471. */
  38472. getClassName(): string;
  38473. /**
  38474. * Get the friendly name associated with the input class.
  38475. * @returns the input friendly name
  38476. */
  38477. getSimpleName(): string;
  38478. }
  38479. }
  38480. declare module BABYLON {
  38481. /**
  38482. * Default Inputs manager for the ArcRotateCamera.
  38483. * It groups all the default supported inputs for ease of use.
  38484. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38485. */
  38486. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  38487. /**
  38488. * Instantiates a new ArcRotateCameraInputsManager.
  38489. * @param camera Defines the camera the inputs belong to
  38490. */
  38491. constructor(camera: ArcRotateCamera);
  38492. /**
  38493. * Add mouse wheel input support to the input manager.
  38494. * @returns the current input manager
  38495. */
  38496. addMouseWheel(): ArcRotateCameraInputsManager;
  38497. /**
  38498. * Add pointers input support to the input manager.
  38499. * @returns the current input manager
  38500. */
  38501. addPointers(): ArcRotateCameraInputsManager;
  38502. /**
  38503. * Add keyboard input support to the input manager.
  38504. * @returns the current input manager
  38505. */
  38506. addKeyboard(): ArcRotateCameraInputsManager;
  38507. }
  38508. }
  38509. declare module BABYLON {
  38510. /**
  38511. * This represents an orbital type of camera.
  38512. *
  38513. * 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.
  38514. * 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.
  38515. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  38516. */
  38517. export class ArcRotateCamera extends TargetCamera {
  38518. /**
  38519. * Defines the rotation angle of the camera along the longitudinal axis.
  38520. */
  38521. alpha: number;
  38522. /**
  38523. * Defines the rotation angle of the camera along the latitudinal axis.
  38524. */
  38525. beta: number;
  38526. /**
  38527. * Defines the radius of the camera from it s target point.
  38528. */
  38529. radius: number;
  38530. protected _target: Vector3;
  38531. protected _targetHost: Nullable<AbstractMesh>;
  38532. /**
  38533. * Defines the target point of the camera.
  38534. * The camera looks towards it form the radius distance.
  38535. */
  38536. get target(): Vector3;
  38537. set target(value: Vector3);
  38538. /**
  38539. * Define the current local position of the camera in the scene
  38540. */
  38541. get position(): Vector3;
  38542. set position(newPosition: Vector3);
  38543. protected _upVector: Vector3;
  38544. protected _upToYMatrix: Matrix;
  38545. protected _YToUpMatrix: Matrix;
  38546. /**
  38547. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  38548. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  38549. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  38550. */
  38551. set upVector(vec: Vector3);
  38552. get upVector(): Vector3;
  38553. /**
  38554. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  38555. */
  38556. setMatUp(): void;
  38557. /**
  38558. * Current inertia value on the longitudinal axis.
  38559. * The bigger this number the longer it will take for the camera to stop.
  38560. */
  38561. inertialAlphaOffset: number;
  38562. /**
  38563. * Current inertia value on the latitudinal axis.
  38564. * The bigger this number the longer it will take for the camera to stop.
  38565. */
  38566. inertialBetaOffset: number;
  38567. /**
  38568. * Current inertia value on the radius axis.
  38569. * The bigger this number the longer it will take for the camera to stop.
  38570. */
  38571. inertialRadiusOffset: number;
  38572. /**
  38573. * Minimum allowed angle on the longitudinal axis.
  38574. * This can help limiting how the Camera is able to move in the scene.
  38575. */
  38576. lowerAlphaLimit: Nullable<number>;
  38577. /**
  38578. * Maximum allowed angle on the longitudinal axis.
  38579. * This can help limiting how the Camera is able to move in the scene.
  38580. */
  38581. upperAlphaLimit: Nullable<number>;
  38582. /**
  38583. * Minimum allowed angle on the latitudinal axis.
  38584. * This can help limiting how the Camera is able to move in the scene.
  38585. */
  38586. lowerBetaLimit: number;
  38587. /**
  38588. * Maximum allowed angle on the latitudinal axis.
  38589. * This can help limiting how the Camera is able to move in the scene.
  38590. */
  38591. upperBetaLimit: number;
  38592. /**
  38593. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  38594. * This can help limiting how the Camera is able to move in the scene.
  38595. */
  38596. lowerRadiusLimit: Nullable<number>;
  38597. /**
  38598. * Maximum allowed distance of the camera to the target (The camera can not get further).
  38599. * This can help limiting how the Camera is able to move in the scene.
  38600. */
  38601. upperRadiusLimit: Nullable<number>;
  38602. /**
  38603. * Defines the current inertia value used during panning of the camera along the X axis.
  38604. */
  38605. inertialPanningX: number;
  38606. /**
  38607. * Defines the current inertia value used during panning of the camera along the Y axis.
  38608. */
  38609. inertialPanningY: number;
  38610. /**
  38611. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  38612. * Basically if your fingers moves away from more than this distance you will be considered
  38613. * in pinch mode.
  38614. */
  38615. pinchToPanMaxDistance: number;
  38616. /**
  38617. * Defines the maximum distance the camera can pan.
  38618. * This could help keeping the cammera always in your scene.
  38619. */
  38620. panningDistanceLimit: Nullable<number>;
  38621. /**
  38622. * Defines the target of the camera before paning.
  38623. */
  38624. panningOriginTarget: Vector3;
  38625. /**
  38626. * Defines the value of the inertia used during panning.
  38627. * 0 would mean stop inertia and one would mean no decelleration at all.
  38628. */
  38629. panningInertia: number;
  38630. /**
  38631. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  38632. */
  38633. get angularSensibilityX(): number;
  38634. set angularSensibilityX(value: number);
  38635. /**
  38636. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  38637. */
  38638. get angularSensibilityY(): number;
  38639. set angularSensibilityY(value: number);
  38640. /**
  38641. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  38642. */
  38643. get pinchPrecision(): number;
  38644. set pinchPrecision(value: number);
  38645. /**
  38646. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  38647. * It will be used instead of pinchDeltaPrecision if different from 0.
  38648. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38649. */
  38650. get pinchDeltaPercentage(): number;
  38651. set pinchDeltaPercentage(value: number);
  38652. /**
  38653. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  38654. * and pinch delta percentage.
  38655. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  38656. * that any object in the plane at the camera's target point will scale
  38657. * perfectly with finger motion.
  38658. */
  38659. get useNaturalPinchZoom(): boolean;
  38660. set useNaturalPinchZoom(value: boolean);
  38661. /**
  38662. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  38663. */
  38664. get panningSensibility(): number;
  38665. set panningSensibility(value: number);
  38666. /**
  38667. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  38668. */
  38669. get keysUp(): number[];
  38670. set keysUp(value: number[]);
  38671. /**
  38672. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  38673. */
  38674. get keysDown(): number[];
  38675. set keysDown(value: number[]);
  38676. /**
  38677. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  38678. */
  38679. get keysLeft(): number[];
  38680. set keysLeft(value: number[]);
  38681. /**
  38682. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  38683. */
  38684. get keysRight(): number[];
  38685. set keysRight(value: number[]);
  38686. /**
  38687. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  38688. */
  38689. get wheelPrecision(): number;
  38690. set wheelPrecision(value: number);
  38691. /**
  38692. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  38693. * It will be used instead of pinchDeltaPrecision if different from 0.
  38694. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  38695. */
  38696. get wheelDeltaPercentage(): number;
  38697. set wheelDeltaPercentage(value: number);
  38698. /**
  38699. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  38700. */
  38701. zoomOnFactor: number;
  38702. /**
  38703. * Defines a screen offset for the camera position.
  38704. */
  38705. targetScreenOffset: Vector2;
  38706. /**
  38707. * Allows the camera to be completely reversed.
  38708. * If false the camera can not arrive upside down.
  38709. */
  38710. allowUpsideDown: boolean;
  38711. /**
  38712. * Define if double tap/click is used to restore the previously saved state of the camera.
  38713. */
  38714. useInputToRestoreState: boolean;
  38715. /** @hidden */
  38716. _viewMatrix: Matrix;
  38717. /** @hidden */
  38718. _useCtrlForPanning: boolean;
  38719. /** @hidden */
  38720. _panningMouseButton: number;
  38721. /**
  38722. * Defines the input associated to the camera.
  38723. */
  38724. inputs: ArcRotateCameraInputsManager;
  38725. /** @hidden */
  38726. _reset: () => void;
  38727. /**
  38728. * Defines the allowed panning axis.
  38729. */
  38730. panningAxis: Vector3;
  38731. protected _localDirection: Vector3;
  38732. protected _transformedDirection: Vector3;
  38733. private _bouncingBehavior;
  38734. /**
  38735. * Gets the bouncing behavior of the camera if it has been enabled.
  38736. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38737. */
  38738. get bouncingBehavior(): Nullable<BouncingBehavior>;
  38739. /**
  38740. * Defines if the bouncing behavior of the camera is enabled on the camera.
  38741. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  38742. */
  38743. get useBouncingBehavior(): boolean;
  38744. set useBouncingBehavior(value: boolean);
  38745. private _framingBehavior;
  38746. /**
  38747. * Gets the framing behavior of the camera if it has been enabled.
  38748. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38749. */
  38750. get framingBehavior(): Nullable<FramingBehavior>;
  38751. /**
  38752. * Defines if the framing behavior of the camera is enabled on the camera.
  38753. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  38754. */
  38755. get useFramingBehavior(): boolean;
  38756. set useFramingBehavior(value: boolean);
  38757. private _autoRotationBehavior;
  38758. /**
  38759. * Gets the auto rotation behavior of the camera if it has been enabled.
  38760. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38761. */
  38762. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  38763. /**
  38764. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  38765. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38766. */
  38767. get useAutoRotationBehavior(): boolean;
  38768. set useAutoRotationBehavior(value: boolean);
  38769. /**
  38770. * Observable triggered when the mesh target has been changed on the camera.
  38771. */
  38772. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  38773. /**
  38774. * Event raised when the camera is colliding with a mesh.
  38775. */
  38776. onCollide: (collidedMesh: AbstractMesh) => void;
  38777. /**
  38778. * Defines whether the camera should check collision with the objects oh the scene.
  38779. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  38780. */
  38781. checkCollisions: boolean;
  38782. /**
  38783. * Defines the collision radius of the camera.
  38784. * This simulates a sphere around the camera.
  38785. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38786. */
  38787. collisionRadius: Vector3;
  38788. protected _collider: Collider;
  38789. protected _previousPosition: Vector3;
  38790. protected _collisionVelocity: Vector3;
  38791. protected _newPosition: Vector3;
  38792. protected _previousAlpha: number;
  38793. protected _previousBeta: number;
  38794. protected _previousRadius: number;
  38795. protected _collisionTriggered: boolean;
  38796. protected _targetBoundingCenter: Nullable<Vector3>;
  38797. private _computationVector;
  38798. /**
  38799. * Instantiates a new ArcRotateCamera in a given scene
  38800. * @param name Defines the name of the camera
  38801. * @param alpha Defines the camera rotation along the logitudinal axis
  38802. * @param beta Defines the camera rotation along the latitudinal axis
  38803. * @param radius Defines the camera distance from its target
  38804. * @param target Defines the camera target
  38805. * @param scene Defines the scene the camera belongs to
  38806. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  38807. */
  38808. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38809. /** @hidden */
  38810. _initCache(): void;
  38811. /** @hidden */
  38812. _updateCache(ignoreParentClass?: boolean): void;
  38813. protected _getTargetPosition(): Vector3;
  38814. private _storedAlpha;
  38815. private _storedBeta;
  38816. private _storedRadius;
  38817. private _storedTarget;
  38818. private _storedTargetScreenOffset;
  38819. /**
  38820. * Stores the current state of the camera (alpha, beta, radius and target)
  38821. * @returns the camera itself
  38822. */
  38823. storeState(): Camera;
  38824. /**
  38825. * @hidden
  38826. * Restored camera state. You must call storeState() first
  38827. */
  38828. _restoreStateValues(): boolean;
  38829. /** @hidden */
  38830. _isSynchronizedViewMatrix(): boolean;
  38831. /**
  38832. * Attached controls to the current camera.
  38833. * @param element Defines the element the controls should be listened from
  38834. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38835. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  38836. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  38837. */
  38838. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  38839. /**
  38840. * Detach the current controls from the camera.
  38841. * The camera will stop reacting to inputs.
  38842. * @param element Defines the element to stop listening the inputs from
  38843. */
  38844. detachControl(element: HTMLElement): void;
  38845. /** @hidden */
  38846. _checkInputs(): void;
  38847. protected _checkLimits(): void;
  38848. /**
  38849. * Rebuilds angles (alpha, beta) and radius from the give position and target
  38850. */
  38851. rebuildAnglesAndRadius(): void;
  38852. /**
  38853. * Use a position to define the current camera related information like alpha, beta and radius
  38854. * @param position Defines the position to set the camera at
  38855. */
  38856. setPosition(position: Vector3): void;
  38857. /**
  38858. * Defines the target the camera should look at.
  38859. * This will automatically adapt alpha beta and radius to fit within the new target.
  38860. * @param target Defines the new target as a Vector or a mesh
  38861. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  38862. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  38863. */
  38864. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  38865. /** @hidden */
  38866. _getViewMatrix(): Matrix;
  38867. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  38868. /**
  38869. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  38870. * @param meshes Defines the mesh to zoom on
  38871. * @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)
  38872. */
  38873. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  38874. /**
  38875. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  38876. * The target will be changed but the radius
  38877. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  38878. * @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)
  38879. */
  38880. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  38881. min: Vector3;
  38882. max: Vector3;
  38883. distance: number;
  38884. }, doNotUpdateMaxZ?: boolean): void;
  38885. /**
  38886. * @override
  38887. * Override Camera.createRigCamera
  38888. */
  38889. createRigCamera(name: string, cameraIndex: number): Camera;
  38890. /**
  38891. * @hidden
  38892. * @override
  38893. * Override Camera._updateRigCameras
  38894. */
  38895. _updateRigCameras(): void;
  38896. /**
  38897. * Destroy the camera and release the current resources hold by it.
  38898. */
  38899. dispose(): void;
  38900. /**
  38901. * Gets the current object class name.
  38902. * @return the class name
  38903. */
  38904. getClassName(): string;
  38905. }
  38906. }
  38907. declare module BABYLON {
  38908. /**
  38909. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  38910. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  38911. */
  38912. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  38913. /**
  38914. * Gets the name of the behavior.
  38915. */
  38916. get name(): string;
  38917. private _zoomStopsAnimation;
  38918. private _idleRotationSpeed;
  38919. private _idleRotationWaitTime;
  38920. private _idleRotationSpinupTime;
  38921. /**
  38922. * Sets the flag that indicates if user zooming should stop animation.
  38923. */
  38924. set zoomStopsAnimation(flag: boolean);
  38925. /**
  38926. * Gets the flag that indicates if user zooming should stop animation.
  38927. */
  38928. get zoomStopsAnimation(): boolean;
  38929. /**
  38930. * Sets the default speed at which the camera rotates around the model.
  38931. */
  38932. set idleRotationSpeed(speed: number);
  38933. /**
  38934. * Gets the default speed at which the camera rotates around the model.
  38935. */
  38936. get idleRotationSpeed(): number;
  38937. /**
  38938. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  38939. */
  38940. set idleRotationWaitTime(time: number);
  38941. /**
  38942. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  38943. */
  38944. get idleRotationWaitTime(): number;
  38945. /**
  38946. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38947. */
  38948. set idleRotationSpinupTime(time: number);
  38949. /**
  38950. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  38951. */
  38952. get idleRotationSpinupTime(): number;
  38953. /**
  38954. * Gets a value indicating if the camera is currently rotating because of this behavior
  38955. */
  38956. get rotationInProgress(): boolean;
  38957. private _onPrePointerObservableObserver;
  38958. private _onAfterCheckInputsObserver;
  38959. private _attachedCamera;
  38960. private _isPointerDown;
  38961. private _lastFrameTime;
  38962. private _lastInteractionTime;
  38963. private _cameraRotationSpeed;
  38964. /**
  38965. * Initializes the behavior.
  38966. */
  38967. init(): void;
  38968. /**
  38969. * Attaches the behavior to its arc rotate camera.
  38970. * @param camera Defines the camera to attach the behavior to
  38971. */
  38972. attach(camera: ArcRotateCamera): void;
  38973. /**
  38974. * Detaches the behavior from its current arc rotate camera.
  38975. */
  38976. detach(): void;
  38977. /**
  38978. * Returns true if user is scrolling.
  38979. * @return true if user is scrolling.
  38980. */
  38981. private _userIsZooming;
  38982. private _lastFrameRadius;
  38983. private _shouldAnimationStopForInteraction;
  38984. /**
  38985. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  38986. */
  38987. private _applyUserInteraction;
  38988. private _userIsMoving;
  38989. }
  38990. }
  38991. declare module BABYLON {
  38992. /**
  38993. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  38994. */
  38995. export class AttachToBoxBehavior implements Behavior<Mesh> {
  38996. private ui;
  38997. /**
  38998. * The name of the behavior
  38999. */
  39000. name: string;
  39001. /**
  39002. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  39003. */
  39004. distanceAwayFromFace: number;
  39005. /**
  39006. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  39007. */
  39008. distanceAwayFromBottomOfFace: number;
  39009. private _faceVectors;
  39010. private _target;
  39011. private _scene;
  39012. private _onRenderObserver;
  39013. private _tmpMatrix;
  39014. private _tmpVector;
  39015. /**
  39016. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  39017. * @param ui The transform node that should be attched to the mesh
  39018. */
  39019. constructor(ui: TransformNode);
  39020. /**
  39021. * Initializes the behavior
  39022. */
  39023. init(): void;
  39024. private _closestFace;
  39025. private _zeroVector;
  39026. private _lookAtTmpMatrix;
  39027. private _lookAtToRef;
  39028. /**
  39029. * Attaches the AttachToBoxBehavior to the passed in mesh
  39030. * @param target The mesh that the specified node will be attached to
  39031. */
  39032. attach(target: Mesh): void;
  39033. /**
  39034. * Detaches the behavior from the mesh
  39035. */
  39036. detach(): void;
  39037. }
  39038. }
  39039. declare module BABYLON {
  39040. /**
  39041. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  39042. */
  39043. export class FadeInOutBehavior implements Behavior<Mesh> {
  39044. /**
  39045. * Time in milliseconds to delay before fading in (Default: 0)
  39046. */
  39047. delay: number;
  39048. /**
  39049. * Time in milliseconds for the mesh to fade in (Default: 300)
  39050. */
  39051. fadeInTime: number;
  39052. private _millisecondsPerFrame;
  39053. private _hovered;
  39054. private _hoverValue;
  39055. private _ownerNode;
  39056. /**
  39057. * Instatiates the FadeInOutBehavior
  39058. */
  39059. constructor();
  39060. /**
  39061. * The name of the behavior
  39062. */
  39063. get name(): string;
  39064. /**
  39065. * Initializes the behavior
  39066. */
  39067. init(): void;
  39068. /**
  39069. * Attaches the fade behavior on the passed in mesh
  39070. * @param ownerNode The mesh that will be faded in/out once attached
  39071. */
  39072. attach(ownerNode: Mesh): void;
  39073. /**
  39074. * Detaches the behavior from the mesh
  39075. */
  39076. detach(): void;
  39077. /**
  39078. * Triggers the mesh to begin fading in or out
  39079. * @param value if the object should fade in or out (true to fade in)
  39080. */
  39081. fadeIn(value: boolean): void;
  39082. private _update;
  39083. private _setAllVisibility;
  39084. }
  39085. }
  39086. declare module BABYLON {
  39087. /**
  39088. * Class containing a set of static utilities functions for managing Pivots
  39089. * @hidden
  39090. */
  39091. export class PivotTools {
  39092. private static _PivotCached;
  39093. private static _OldPivotPoint;
  39094. private static _PivotTranslation;
  39095. private static _PivotTmpVector;
  39096. /** @hidden */
  39097. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  39098. /** @hidden */
  39099. static _RestorePivotPoint(mesh: AbstractMesh): void;
  39100. }
  39101. }
  39102. declare module BABYLON {
  39103. /**
  39104. * Class containing static functions to help procedurally build meshes
  39105. */
  39106. export class PlaneBuilder {
  39107. /**
  39108. * Creates a plane mesh
  39109. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  39110. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  39111. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  39112. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39113. * * 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
  39114. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39115. * @param name defines the name of the mesh
  39116. * @param options defines the options used to create the mesh
  39117. * @param scene defines the hosting scene
  39118. * @returns the plane mesh
  39119. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  39120. */
  39121. static CreatePlane(name: string, options: {
  39122. size?: number;
  39123. width?: number;
  39124. height?: number;
  39125. sideOrientation?: number;
  39126. frontUVs?: Vector4;
  39127. backUVs?: Vector4;
  39128. updatable?: boolean;
  39129. sourcePlane?: Plane;
  39130. }, scene?: Nullable<Scene>): Mesh;
  39131. }
  39132. }
  39133. declare module BABYLON {
  39134. /**
  39135. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  39136. */
  39137. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  39138. private static _AnyMouseID;
  39139. /**
  39140. * Abstract mesh the behavior is set on
  39141. */
  39142. attachedNode: AbstractMesh;
  39143. private _dragPlane;
  39144. private _scene;
  39145. private _pointerObserver;
  39146. private _beforeRenderObserver;
  39147. private static _planeScene;
  39148. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  39149. /**
  39150. * 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)
  39151. */
  39152. maxDragAngle: number;
  39153. /**
  39154. * @hidden
  39155. */
  39156. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  39157. /**
  39158. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39159. */
  39160. currentDraggingPointerID: number;
  39161. /**
  39162. * The last position where the pointer hit the drag plane in world space
  39163. */
  39164. lastDragPosition: Vector3;
  39165. /**
  39166. * If the behavior is currently in a dragging state
  39167. */
  39168. dragging: boolean;
  39169. /**
  39170. * 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)
  39171. */
  39172. dragDeltaRatio: number;
  39173. /**
  39174. * If the drag plane orientation should be updated during the dragging (Default: true)
  39175. */
  39176. updateDragPlane: boolean;
  39177. private _debugMode;
  39178. private _moving;
  39179. /**
  39180. * Fires each time the attached mesh is dragged with the pointer
  39181. * * delta between last drag position and current drag position in world space
  39182. * * dragDistance along the drag axis
  39183. * * dragPlaneNormal normal of the current drag plane used during the drag
  39184. * * dragPlanePoint in world space where the drag intersects the drag plane
  39185. */
  39186. onDragObservable: Observable<{
  39187. delta: Vector3;
  39188. dragPlanePoint: Vector3;
  39189. dragPlaneNormal: Vector3;
  39190. dragDistance: number;
  39191. pointerId: number;
  39192. }>;
  39193. /**
  39194. * Fires each time a drag begins (eg. mouse down on mesh)
  39195. */
  39196. onDragStartObservable: Observable<{
  39197. dragPlanePoint: Vector3;
  39198. pointerId: number;
  39199. }>;
  39200. /**
  39201. * Fires each time a drag ends (eg. mouse release after drag)
  39202. */
  39203. onDragEndObservable: Observable<{
  39204. dragPlanePoint: Vector3;
  39205. pointerId: number;
  39206. }>;
  39207. /**
  39208. * If the attached mesh should be moved when dragged
  39209. */
  39210. moveAttached: boolean;
  39211. /**
  39212. * If the drag behavior will react to drag events (Default: true)
  39213. */
  39214. enabled: boolean;
  39215. /**
  39216. * If pointer events should start and release the drag (Default: true)
  39217. */
  39218. startAndReleaseDragOnPointerEvents: boolean;
  39219. /**
  39220. * If camera controls should be detached during the drag
  39221. */
  39222. detachCameraControls: boolean;
  39223. /**
  39224. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  39225. */
  39226. useObjectOrientationForDragging: boolean;
  39227. private _options;
  39228. /**
  39229. * Gets the options used by the behavior
  39230. */
  39231. get options(): {
  39232. dragAxis?: Vector3;
  39233. dragPlaneNormal?: Vector3;
  39234. };
  39235. /**
  39236. * Sets the options used by the behavior
  39237. */
  39238. set options(options: {
  39239. dragAxis?: Vector3;
  39240. dragPlaneNormal?: Vector3;
  39241. });
  39242. /**
  39243. * Creates a pointer drag behavior that can be attached to a mesh
  39244. * @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)
  39245. */
  39246. constructor(options?: {
  39247. dragAxis?: Vector3;
  39248. dragPlaneNormal?: Vector3;
  39249. });
  39250. /**
  39251. * Predicate to determine if it is valid to move the object to a new position when it is moved
  39252. */
  39253. validateDrag: (targetPosition: Vector3) => boolean;
  39254. /**
  39255. * The name of the behavior
  39256. */
  39257. get name(): string;
  39258. /**
  39259. * Initializes the behavior
  39260. */
  39261. init(): void;
  39262. private _tmpVector;
  39263. private _alternatePickedPoint;
  39264. private _worldDragAxis;
  39265. private _targetPosition;
  39266. private _attachedElement;
  39267. /**
  39268. * Attaches the drag behavior the passed in mesh
  39269. * @param ownerNode The mesh that will be dragged around once attached
  39270. * @param predicate Predicate to use for pick filtering
  39271. */
  39272. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  39273. /**
  39274. * Force relase the drag action by code.
  39275. */
  39276. releaseDrag(): void;
  39277. private _startDragRay;
  39278. private _lastPointerRay;
  39279. /**
  39280. * Simulates the start of a pointer drag event on the behavior
  39281. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  39282. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  39283. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  39284. */
  39285. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  39286. private _startDrag;
  39287. private _dragDelta;
  39288. private _moveDrag;
  39289. private _pickWithRayOnDragPlane;
  39290. private _pointA;
  39291. private _pointB;
  39292. private _pointC;
  39293. private _lineA;
  39294. private _lineB;
  39295. private _localAxis;
  39296. private _lookAt;
  39297. private _updateDragPlanePosition;
  39298. /**
  39299. * Detaches the behavior from the mesh
  39300. */
  39301. detach(): void;
  39302. }
  39303. }
  39304. declare module BABYLON {
  39305. /**
  39306. * A behavior that when attached to a mesh will allow the mesh to be scaled
  39307. */
  39308. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  39309. private _dragBehaviorA;
  39310. private _dragBehaviorB;
  39311. private _startDistance;
  39312. private _initialScale;
  39313. private _targetScale;
  39314. private _ownerNode;
  39315. private _sceneRenderObserver;
  39316. /**
  39317. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  39318. */
  39319. constructor();
  39320. /**
  39321. * The name of the behavior
  39322. */
  39323. get name(): string;
  39324. /**
  39325. * Initializes the behavior
  39326. */
  39327. init(): void;
  39328. private _getCurrentDistance;
  39329. /**
  39330. * Attaches the scale behavior the passed in mesh
  39331. * @param ownerNode The mesh that will be scaled around once attached
  39332. */
  39333. attach(ownerNode: Mesh): void;
  39334. /**
  39335. * Detaches the behavior from the mesh
  39336. */
  39337. detach(): void;
  39338. }
  39339. }
  39340. declare module BABYLON {
  39341. /**
  39342. * 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
  39343. */
  39344. export class SixDofDragBehavior implements Behavior<Mesh> {
  39345. private static _virtualScene;
  39346. private _ownerNode;
  39347. private _sceneRenderObserver;
  39348. private _scene;
  39349. private _targetPosition;
  39350. private _virtualOriginMesh;
  39351. private _virtualDragMesh;
  39352. private _pointerObserver;
  39353. private _moving;
  39354. private _startingOrientation;
  39355. /**
  39356. * 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)
  39357. */
  39358. private zDragFactor;
  39359. /**
  39360. * If the object should rotate to face the drag origin
  39361. */
  39362. rotateDraggedObject: boolean;
  39363. /**
  39364. * If the behavior is currently in a dragging state
  39365. */
  39366. dragging: boolean;
  39367. /**
  39368. * 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)
  39369. */
  39370. dragDeltaRatio: number;
  39371. /**
  39372. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  39373. */
  39374. currentDraggingPointerID: number;
  39375. /**
  39376. * If camera controls should be detached during the drag
  39377. */
  39378. detachCameraControls: boolean;
  39379. /**
  39380. * Fires each time a drag starts
  39381. */
  39382. onDragStartObservable: Observable<{}>;
  39383. /**
  39384. * Fires each time a drag ends (eg. mouse release after drag)
  39385. */
  39386. onDragEndObservable: Observable<{}>;
  39387. /**
  39388. * 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
  39389. */
  39390. constructor();
  39391. /**
  39392. * The name of the behavior
  39393. */
  39394. get name(): string;
  39395. /**
  39396. * Initializes the behavior
  39397. */
  39398. init(): void;
  39399. /**
  39400. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  39401. */
  39402. private get _pointerCamera();
  39403. /**
  39404. * Attaches the scale behavior the passed in mesh
  39405. * @param ownerNode The mesh that will be scaled around once attached
  39406. */
  39407. attach(ownerNode: Mesh): void;
  39408. /**
  39409. * Detaches the behavior from the mesh
  39410. */
  39411. detach(): void;
  39412. }
  39413. }
  39414. declare module BABYLON {
  39415. /**
  39416. * Class used to apply inverse kinematics to bones
  39417. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  39418. */
  39419. export class BoneIKController {
  39420. private static _tmpVecs;
  39421. private static _tmpQuat;
  39422. private static _tmpMats;
  39423. /**
  39424. * Gets or sets the target mesh
  39425. */
  39426. targetMesh: AbstractMesh;
  39427. /** Gets or sets the mesh used as pole */
  39428. poleTargetMesh: AbstractMesh;
  39429. /**
  39430. * Gets or sets the bone used as pole
  39431. */
  39432. poleTargetBone: Nullable<Bone>;
  39433. /**
  39434. * Gets or sets the target position
  39435. */
  39436. targetPosition: Vector3;
  39437. /**
  39438. * Gets or sets the pole target position
  39439. */
  39440. poleTargetPosition: Vector3;
  39441. /**
  39442. * Gets or sets the pole target local offset
  39443. */
  39444. poleTargetLocalOffset: Vector3;
  39445. /**
  39446. * Gets or sets the pole angle
  39447. */
  39448. poleAngle: number;
  39449. /**
  39450. * Gets or sets the mesh associated with the controller
  39451. */
  39452. mesh: AbstractMesh;
  39453. /**
  39454. * 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)
  39455. */
  39456. slerpAmount: number;
  39457. private _bone1Quat;
  39458. private _bone1Mat;
  39459. private _bone2Ang;
  39460. private _bone1;
  39461. private _bone2;
  39462. private _bone1Length;
  39463. private _bone2Length;
  39464. private _maxAngle;
  39465. private _maxReach;
  39466. private _rightHandedSystem;
  39467. private _bendAxis;
  39468. private _slerping;
  39469. private _adjustRoll;
  39470. /**
  39471. * Gets or sets maximum allowed angle
  39472. */
  39473. get maxAngle(): number;
  39474. set maxAngle(value: number);
  39475. /**
  39476. * Creates a new BoneIKController
  39477. * @param mesh defines the mesh to control
  39478. * @param bone defines the bone to control
  39479. * @param options defines options to set up the controller
  39480. */
  39481. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  39482. targetMesh?: AbstractMesh;
  39483. poleTargetMesh?: AbstractMesh;
  39484. poleTargetBone?: Bone;
  39485. poleTargetLocalOffset?: Vector3;
  39486. poleAngle?: number;
  39487. bendAxis?: Vector3;
  39488. maxAngle?: number;
  39489. slerpAmount?: number;
  39490. });
  39491. private _setMaxAngle;
  39492. /**
  39493. * Force the controller to update the bones
  39494. */
  39495. update(): void;
  39496. }
  39497. }
  39498. declare module BABYLON {
  39499. /**
  39500. * Class used to make a bone look toward a point in space
  39501. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  39502. */
  39503. export class BoneLookController {
  39504. private static _tmpVecs;
  39505. private static _tmpQuat;
  39506. private static _tmpMats;
  39507. /**
  39508. * The target Vector3 that the bone will look at
  39509. */
  39510. target: Vector3;
  39511. /**
  39512. * The mesh that the bone is attached to
  39513. */
  39514. mesh: AbstractMesh;
  39515. /**
  39516. * The bone that will be looking to the target
  39517. */
  39518. bone: Bone;
  39519. /**
  39520. * The up axis of the coordinate system that is used when the bone is rotated
  39521. */
  39522. upAxis: Vector3;
  39523. /**
  39524. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  39525. */
  39526. upAxisSpace: Space;
  39527. /**
  39528. * Used to make an adjustment to the yaw of the bone
  39529. */
  39530. adjustYaw: number;
  39531. /**
  39532. * Used to make an adjustment to the pitch of the bone
  39533. */
  39534. adjustPitch: number;
  39535. /**
  39536. * Used to make an adjustment to the roll of the bone
  39537. */
  39538. adjustRoll: number;
  39539. /**
  39540. * 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)
  39541. */
  39542. slerpAmount: number;
  39543. private _minYaw;
  39544. private _maxYaw;
  39545. private _minPitch;
  39546. private _maxPitch;
  39547. private _minYawSin;
  39548. private _minYawCos;
  39549. private _maxYawSin;
  39550. private _maxYawCos;
  39551. private _midYawConstraint;
  39552. private _minPitchTan;
  39553. private _maxPitchTan;
  39554. private _boneQuat;
  39555. private _slerping;
  39556. private _transformYawPitch;
  39557. private _transformYawPitchInv;
  39558. private _firstFrameSkipped;
  39559. private _yawRange;
  39560. private _fowardAxis;
  39561. /**
  39562. * Gets or sets the minimum yaw angle that the bone can look to
  39563. */
  39564. get minYaw(): number;
  39565. set minYaw(value: number);
  39566. /**
  39567. * Gets or sets the maximum yaw angle that the bone can look to
  39568. */
  39569. get maxYaw(): number;
  39570. set maxYaw(value: number);
  39571. /**
  39572. * Gets or sets the minimum pitch angle that the bone can look to
  39573. */
  39574. get minPitch(): number;
  39575. set minPitch(value: number);
  39576. /**
  39577. * Gets or sets the maximum pitch angle that the bone can look to
  39578. */
  39579. get maxPitch(): number;
  39580. set maxPitch(value: number);
  39581. /**
  39582. * Create a BoneLookController
  39583. * @param mesh the mesh that the bone belongs to
  39584. * @param bone the bone that will be looking to the target
  39585. * @param target the target Vector3 to look at
  39586. * @param options optional settings:
  39587. * * maxYaw: the maximum angle the bone will yaw to
  39588. * * minYaw: the minimum angle the bone will yaw to
  39589. * * maxPitch: the maximum angle the bone will pitch to
  39590. * * minPitch: the minimum angle the bone will yaw to
  39591. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  39592. * * upAxis: the up axis of the coordinate system
  39593. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  39594. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  39595. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  39596. * * adjustYaw: used to make an adjustment to the yaw of the bone
  39597. * * adjustPitch: used to make an adjustment to the pitch of the bone
  39598. * * adjustRoll: used to make an adjustment to the roll of the bone
  39599. **/
  39600. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  39601. maxYaw?: number;
  39602. minYaw?: number;
  39603. maxPitch?: number;
  39604. minPitch?: number;
  39605. slerpAmount?: number;
  39606. upAxis?: Vector3;
  39607. upAxisSpace?: Space;
  39608. yawAxis?: Vector3;
  39609. pitchAxis?: Vector3;
  39610. adjustYaw?: number;
  39611. adjustPitch?: number;
  39612. adjustRoll?: number;
  39613. });
  39614. /**
  39615. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  39616. */
  39617. update(): void;
  39618. private _getAngleDiff;
  39619. private _getAngleBetween;
  39620. private _isAngleBetween;
  39621. }
  39622. }
  39623. declare module BABYLON {
  39624. /**
  39625. * Manage the gamepad inputs to control an arc rotate camera.
  39626. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39627. */
  39628. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  39629. /**
  39630. * Defines the camera the input is attached to.
  39631. */
  39632. camera: ArcRotateCamera;
  39633. /**
  39634. * Defines the gamepad the input is gathering event from.
  39635. */
  39636. gamepad: Nullable<Gamepad>;
  39637. /**
  39638. * Defines the gamepad rotation sensiblity.
  39639. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39640. */
  39641. gamepadRotationSensibility: number;
  39642. /**
  39643. * Defines the gamepad move sensiblity.
  39644. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39645. */
  39646. gamepadMoveSensibility: number;
  39647. private _yAxisScale;
  39648. /**
  39649. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  39650. */
  39651. get invertYAxis(): boolean;
  39652. set invertYAxis(value: boolean);
  39653. private _onGamepadConnectedObserver;
  39654. private _onGamepadDisconnectedObserver;
  39655. /**
  39656. * Attach the input controls to a specific dom element to get the input from.
  39657. * @param element Defines the element the controls should be listened from
  39658. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39659. */
  39660. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39661. /**
  39662. * Detach the current controls from the specified dom element.
  39663. * @param element Defines the element to stop listening the inputs from
  39664. */
  39665. detachControl(element: Nullable<HTMLElement>): void;
  39666. /**
  39667. * Update the current camera state depending on the inputs that have been used this frame.
  39668. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39669. */
  39670. checkInputs(): void;
  39671. /**
  39672. * Gets the class name of the current intput.
  39673. * @returns the class name
  39674. */
  39675. getClassName(): string;
  39676. /**
  39677. * Get the friendly name associated with the input class.
  39678. * @returns the input friendly name
  39679. */
  39680. getSimpleName(): string;
  39681. }
  39682. }
  39683. declare module BABYLON {
  39684. interface ArcRotateCameraInputsManager {
  39685. /**
  39686. * Add orientation input support to the input manager.
  39687. * @returns the current input manager
  39688. */
  39689. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  39690. }
  39691. /**
  39692. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  39693. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39694. */
  39695. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  39696. /**
  39697. * Defines the camera the input is attached to.
  39698. */
  39699. camera: ArcRotateCamera;
  39700. /**
  39701. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  39702. */
  39703. alphaCorrection: number;
  39704. /**
  39705. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  39706. */
  39707. gammaCorrection: number;
  39708. private _alpha;
  39709. private _gamma;
  39710. private _dirty;
  39711. private _deviceOrientationHandler;
  39712. /**
  39713. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  39714. */
  39715. constructor();
  39716. /**
  39717. * Attach the input controls to a specific dom element to get the input from.
  39718. * @param element Defines the element the controls should be listened from
  39719. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39720. */
  39721. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39722. /** @hidden */
  39723. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  39724. /**
  39725. * Update the current camera state depending on the inputs that have been used this frame.
  39726. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39727. */
  39728. checkInputs(): void;
  39729. /**
  39730. * Detach the current controls from the specified dom element.
  39731. * @param element Defines the element to stop listening the inputs from
  39732. */
  39733. detachControl(element: Nullable<HTMLElement>): void;
  39734. /**
  39735. * Gets the class name of the current intput.
  39736. * @returns the class name
  39737. */
  39738. getClassName(): string;
  39739. /**
  39740. * Get the friendly name associated with the input class.
  39741. * @returns the input friendly name
  39742. */
  39743. getSimpleName(): string;
  39744. }
  39745. }
  39746. declare module BABYLON {
  39747. /**
  39748. * Listen to mouse events to control the camera.
  39749. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39750. */
  39751. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  39752. /**
  39753. * Defines the camera the input is attached to.
  39754. */
  39755. camera: FlyCamera;
  39756. /**
  39757. * Defines if touch is enabled. (Default is true.)
  39758. */
  39759. touchEnabled: boolean;
  39760. /**
  39761. * Defines the buttons associated with the input to handle camera rotation.
  39762. */
  39763. buttons: number[];
  39764. /**
  39765. * Assign buttons for Yaw control.
  39766. */
  39767. buttonsYaw: number[];
  39768. /**
  39769. * Assign buttons for Pitch control.
  39770. */
  39771. buttonsPitch: number[];
  39772. /**
  39773. * Assign buttons for Roll control.
  39774. */
  39775. buttonsRoll: number[];
  39776. /**
  39777. * Detect if any button is being pressed while mouse is moved.
  39778. * -1 = Mouse locked.
  39779. * 0 = Left button.
  39780. * 1 = Middle Button.
  39781. * 2 = Right Button.
  39782. */
  39783. activeButton: number;
  39784. /**
  39785. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  39786. * Higher values reduce its sensitivity.
  39787. */
  39788. angularSensibility: number;
  39789. private _mousemoveCallback;
  39790. private _observer;
  39791. private _rollObserver;
  39792. private previousPosition;
  39793. private noPreventDefault;
  39794. private element;
  39795. /**
  39796. * Listen to mouse events to control the camera.
  39797. * @param touchEnabled Define if touch is enabled. (Default is true.)
  39798. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39799. */
  39800. constructor(touchEnabled?: boolean);
  39801. /**
  39802. * Attach the mouse control to the HTML DOM element.
  39803. * @param element Defines the element that listens to the input events.
  39804. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  39805. */
  39806. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39807. /**
  39808. * Detach the current controls from the specified dom element.
  39809. * @param element Defines the element to stop listening the inputs from
  39810. */
  39811. detachControl(element: Nullable<HTMLElement>): void;
  39812. /**
  39813. * Gets the class name of the current input.
  39814. * @returns the class name.
  39815. */
  39816. getClassName(): string;
  39817. /**
  39818. * Get the friendly name associated with the input class.
  39819. * @returns the input's friendly name.
  39820. */
  39821. getSimpleName(): string;
  39822. private _pointerInput;
  39823. private _onMouseMove;
  39824. /**
  39825. * Rotate camera by mouse offset.
  39826. */
  39827. private rotateCamera;
  39828. }
  39829. }
  39830. declare module BABYLON {
  39831. /**
  39832. * Default Inputs manager for the FlyCamera.
  39833. * It groups all the default supported inputs for ease of use.
  39834. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39835. */
  39836. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  39837. /**
  39838. * Instantiates a new FlyCameraInputsManager.
  39839. * @param camera Defines the camera the inputs belong to.
  39840. */
  39841. constructor(camera: FlyCamera);
  39842. /**
  39843. * Add keyboard input support to the input manager.
  39844. * @returns the new FlyCameraKeyboardMoveInput().
  39845. */
  39846. addKeyboard(): FlyCameraInputsManager;
  39847. /**
  39848. * Add mouse input support to the input manager.
  39849. * @param touchEnabled Enable touch screen support.
  39850. * @returns the new FlyCameraMouseInput().
  39851. */
  39852. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  39853. }
  39854. }
  39855. declare module BABYLON {
  39856. /**
  39857. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39858. * such as in a 3D Space Shooter or a Flight Simulator.
  39859. */
  39860. export class FlyCamera extends TargetCamera {
  39861. /**
  39862. * Define the collision ellipsoid of the camera.
  39863. * This is helpful for simulating a camera body, like a player's body.
  39864. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39865. */
  39866. ellipsoid: Vector3;
  39867. /**
  39868. * Define an offset for the position of the ellipsoid around the camera.
  39869. * This can be helpful if the camera is attached away from the player's body center,
  39870. * such as at its head.
  39871. */
  39872. ellipsoidOffset: Vector3;
  39873. /**
  39874. * Enable or disable collisions of the camera with the rest of the scene objects.
  39875. */
  39876. checkCollisions: boolean;
  39877. /**
  39878. * Enable or disable gravity on the camera.
  39879. */
  39880. applyGravity: boolean;
  39881. /**
  39882. * Define the current direction the camera is moving to.
  39883. */
  39884. cameraDirection: Vector3;
  39885. /**
  39886. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  39887. * This overrides and empties cameraRotation.
  39888. */
  39889. rotationQuaternion: Quaternion;
  39890. /**
  39891. * Track Roll to maintain the wanted Rolling when looking around.
  39892. */
  39893. _trackRoll: number;
  39894. /**
  39895. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  39896. */
  39897. rollCorrect: number;
  39898. /**
  39899. * Mimic a banked turn, Rolling the camera when Yawing.
  39900. * It's recommended to use rollCorrect = 10 for faster banking correction.
  39901. */
  39902. bankedTurn: boolean;
  39903. /**
  39904. * Limit in radians for how much Roll banking will add. (Default: 90°)
  39905. */
  39906. bankedTurnLimit: number;
  39907. /**
  39908. * Value of 0 disables the banked Roll.
  39909. * Value of 1 is equal to the Yaw angle in radians.
  39910. */
  39911. bankedTurnMultiplier: number;
  39912. /**
  39913. * The inputs manager loads all the input sources, such as keyboard and mouse.
  39914. */
  39915. inputs: FlyCameraInputsManager;
  39916. /**
  39917. * Gets the input sensibility for mouse input.
  39918. * Higher values reduce sensitivity.
  39919. */
  39920. get angularSensibility(): number;
  39921. /**
  39922. * Sets the input sensibility for a mouse input.
  39923. * Higher values reduce sensitivity.
  39924. */
  39925. set angularSensibility(value: number);
  39926. /**
  39927. * Get the keys for camera movement forward.
  39928. */
  39929. get keysForward(): number[];
  39930. /**
  39931. * Set the keys for camera movement forward.
  39932. */
  39933. set keysForward(value: number[]);
  39934. /**
  39935. * Get the keys for camera movement backward.
  39936. */
  39937. get keysBackward(): number[];
  39938. set keysBackward(value: number[]);
  39939. /**
  39940. * Get the keys for camera movement up.
  39941. */
  39942. get keysUp(): number[];
  39943. /**
  39944. * Set the keys for camera movement up.
  39945. */
  39946. set keysUp(value: number[]);
  39947. /**
  39948. * Get the keys for camera movement down.
  39949. */
  39950. get keysDown(): number[];
  39951. /**
  39952. * Set the keys for camera movement down.
  39953. */
  39954. set keysDown(value: number[]);
  39955. /**
  39956. * Get the keys for camera movement left.
  39957. */
  39958. get keysLeft(): number[];
  39959. /**
  39960. * Set the keys for camera movement left.
  39961. */
  39962. set keysLeft(value: number[]);
  39963. /**
  39964. * Set the keys for camera movement right.
  39965. */
  39966. get keysRight(): number[];
  39967. /**
  39968. * Set the keys for camera movement right.
  39969. */
  39970. set keysRight(value: number[]);
  39971. /**
  39972. * Event raised when the camera collides with a mesh in the scene.
  39973. */
  39974. onCollide: (collidedMesh: AbstractMesh) => void;
  39975. private _collider;
  39976. private _needMoveForGravity;
  39977. private _oldPosition;
  39978. private _diffPosition;
  39979. private _newPosition;
  39980. /** @hidden */
  39981. _localDirection: Vector3;
  39982. /** @hidden */
  39983. _transformedDirection: Vector3;
  39984. /**
  39985. * Instantiates a FlyCamera.
  39986. * This is a flying camera, designed for 3D movement and rotation in all directions,
  39987. * such as in a 3D Space Shooter or a Flight Simulator.
  39988. * @param name Define the name of the camera in the scene.
  39989. * @param position Define the starting position of the camera in the scene.
  39990. * @param scene Define the scene the camera belongs to.
  39991. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  39992. */
  39993. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39994. /**
  39995. * Attach a control to the HTML DOM element.
  39996. * @param element Defines the element that listens to the input events.
  39997. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  39998. */
  39999. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40000. /**
  40001. * Detach a control from the HTML DOM element.
  40002. * The camera will stop reacting to that input.
  40003. * @param element Defines the element that listens to the input events.
  40004. */
  40005. detachControl(element: HTMLElement): void;
  40006. private _collisionMask;
  40007. /**
  40008. * Get the mask that the camera ignores in collision events.
  40009. */
  40010. get collisionMask(): number;
  40011. /**
  40012. * Set the mask that the camera ignores in collision events.
  40013. */
  40014. set collisionMask(mask: number);
  40015. /** @hidden */
  40016. _collideWithWorld(displacement: Vector3): void;
  40017. /** @hidden */
  40018. private _onCollisionPositionChange;
  40019. /** @hidden */
  40020. _checkInputs(): void;
  40021. /** @hidden */
  40022. _decideIfNeedsToMove(): boolean;
  40023. /** @hidden */
  40024. _updatePosition(): void;
  40025. /**
  40026. * Restore the Roll to its target value at the rate specified.
  40027. * @param rate - Higher means slower restoring.
  40028. * @hidden
  40029. */
  40030. restoreRoll(rate: number): void;
  40031. /**
  40032. * Destroy the camera and release the current resources held by it.
  40033. */
  40034. dispose(): void;
  40035. /**
  40036. * Get the current object class name.
  40037. * @returns the class name.
  40038. */
  40039. getClassName(): string;
  40040. }
  40041. }
  40042. declare module BABYLON {
  40043. /**
  40044. * Listen to keyboard events to control the camera.
  40045. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40046. */
  40047. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  40048. /**
  40049. * Defines the camera the input is attached to.
  40050. */
  40051. camera: FlyCamera;
  40052. /**
  40053. * The list of keyboard keys used to control the forward move of the camera.
  40054. */
  40055. keysForward: number[];
  40056. /**
  40057. * The list of keyboard keys used to control the backward move of the camera.
  40058. */
  40059. keysBackward: number[];
  40060. /**
  40061. * The list of keyboard keys used to control the forward move of the camera.
  40062. */
  40063. keysUp: number[];
  40064. /**
  40065. * The list of keyboard keys used to control the backward move of the camera.
  40066. */
  40067. keysDown: number[];
  40068. /**
  40069. * The list of keyboard keys used to control the right strafe move of the camera.
  40070. */
  40071. keysRight: number[];
  40072. /**
  40073. * The list of keyboard keys used to control the left strafe move of the camera.
  40074. */
  40075. keysLeft: number[];
  40076. private _keys;
  40077. private _onCanvasBlurObserver;
  40078. private _onKeyboardObserver;
  40079. private _engine;
  40080. private _scene;
  40081. /**
  40082. * Attach the input controls to a specific dom element to get the input from.
  40083. * @param element Defines the element the controls should be listened from
  40084. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40085. */
  40086. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40087. /**
  40088. * Detach the current controls from the specified dom element.
  40089. * @param element Defines the element to stop listening the inputs from
  40090. */
  40091. detachControl(element: Nullable<HTMLElement>): void;
  40092. /**
  40093. * Gets the class name of the current intput.
  40094. * @returns the class name
  40095. */
  40096. getClassName(): string;
  40097. /** @hidden */
  40098. _onLostFocus(e: FocusEvent): void;
  40099. /**
  40100. * Get the friendly name associated with the input class.
  40101. * @returns the input friendly name
  40102. */
  40103. getSimpleName(): string;
  40104. /**
  40105. * Update the current camera state depending on the inputs that have been used this frame.
  40106. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40107. */
  40108. checkInputs(): void;
  40109. }
  40110. }
  40111. declare module BABYLON {
  40112. /**
  40113. * Manage the mouse wheel inputs to control a follow camera.
  40114. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40115. */
  40116. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  40117. /**
  40118. * Defines the camera the input is attached to.
  40119. */
  40120. camera: FollowCamera;
  40121. /**
  40122. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  40123. */
  40124. axisControlRadius: boolean;
  40125. /**
  40126. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  40127. */
  40128. axisControlHeight: boolean;
  40129. /**
  40130. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  40131. */
  40132. axisControlRotation: boolean;
  40133. /**
  40134. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  40135. * relation to mouseWheel events.
  40136. */
  40137. wheelPrecision: number;
  40138. /**
  40139. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40140. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40141. */
  40142. wheelDeltaPercentage: number;
  40143. private _wheel;
  40144. private _observer;
  40145. /**
  40146. * Attach the input controls to a specific dom element to get the input from.
  40147. * @param element Defines the element the controls should be listened from
  40148. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40149. */
  40150. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40151. /**
  40152. * Detach the current controls from the specified dom element.
  40153. * @param element Defines the element to stop listening the inputs from
  40154. */
  40155. detachControl(element: Nullable<HTMLElement>): void;
  40156. /**
  40157. * Gets the class name of the current intput.
  40158. * @returns the class name
  40159. */
  40160. getClassName(): string;
  40161. /**
  40162. * Get the friendly name associated with the input class.
  40163. * @returns the input friendly name
  40164. */
  40165. getSimpleName(): string;
  40166. }
  40167. }
  40168. declare module BABYLON {
  40169. /**
  40170. * Manage the pointers inputs to control an follow camera.
  40171. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40172. */
  40173. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  40174. /**
  40175. * Defines the camera the input is attached to.
  40176. */
  40177. camera: FollowCamera;
  40178. /**
  40179. * Gets the class name of the current input.
  40180. * @returns the class name
  40181. */
  40182. getClassName(): string;
  40183. /**
  40184. * Defines the pointer angular sensibility along the X axis or how fast is
  40185. * the camera rotating.
  40186. * A negative number will reverse the axis direction.
  40187. */
  40188. angularSensibilityX: number;
  40189. /**
  40190. * Defines the pointer angular sensibility along the Y axis or how fast is
  40191. * the camera rotating.
  40192. * A negative number will reverse the axis direction.
  40193. */
  40194. angularSensibilityY: number;
  40195. /**
  40196. * Defines the pointer pinch precision or how fast is the camera zooming.
  40197. * A negative number will reverse the axis direction.
  40198. */
  40199. pinchPrecision: number;
  40200. /**
  40201. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  40202. * from 0.
  40203. * It defines the percentage of current camera.radius to use as delta when
  40204. * pinch zoom is used.
  40205. */
  40206. pinchDeltaPercentage: number;
  40207. /**
  40208. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  40209. */
  40210. axisXControlRadius: boolean;
  40211. /**
  40212. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  40213. */
  40214. axisXControlHeight: boolean;
  40215. /**
  40216. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  40217. */
  40218. axisXControlRotation: boolean;
  40219. /**
  40220. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  40221. */
  40222. axisYControlRadius: boolean;
  40223. /**
  40224. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  40225. */
  40226. axisYControlHeight: boolean;
  40227. /**
  40228. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  40229. */
  40230. axisYControlRotation: boolean;
  40231. /**
  40232. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  40233. */
  40234. axisPinchControlRadius: boolean;
  40235. /**
  40236. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  40237. */
  40238. axisPinchControlHeight: boolean;
  40239. /**
  40240. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  40241. */
  40242. axisPinchControlRotation: boolean;
  40243. /**
  40244. * Log error messages if basic misconfiguration has occurred.
  40245. */
  40246. warningEnable: boolean;
  40247. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  40248. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  40249. private _warningCounter;
  40250. private _warning;
  40251. }
  40252. }
  40253. declare module BABYLON {
  40254. /**
  40255. * Default Inputs manager for the FollowCamera.
  40256. * It groups all the default supported inputs for ease of use.
  40257. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40258. */
  40259. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  40260. /**
  40261. * Instantiates a new FollowCameraInputsManager.
  40262. * @param camera Defines the camera the inputs belong to
  40263. */
  40264. constructor(camera: FollowCamera);
  40265. /**
  40266. * Add keyboard input support to the input manager.
  40267. * @returns the current input manager
  40268. */
  40269. addKeyboard(): FollowCameraInputsManager;
  40270. /**
  40271. * Add mouse wheel input support to the input manager.
  40272. * @returns the current input manager
  40273. */
  40274. addMouseWheel(): FollowCameraInputsManager;
  40275. /**
  40276. * Add pointers input support to the input manager.
  40277. * @returns the current input manager
  40278. */
  40279. addPointers(): FollowCameraInputsManager;
  40280. /**
  40281. * Add orientation input support to the input manager.
  40282. * @returns the current input manager
  40283. */
  40284. addVRDeviceOrientation(): FollowCameraInputsManager;
  40285. }
  40286. }
  40287. declare module BABYLON {
  40288. /**
  40289. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  40290. * an arc rotate version arcFollowCamera are available.
  40291. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40292. */
  40293. export class FollowCamera extends TargetCamera {
  40294. /**
  40295. * Distance the follow camera should follow an object at
  40296. */
  40297. radius: number;
  40298. /**
  40299. * Minimum allowed distance of the camera to the axis of rotation
  40300. * (The camera can not get closer).
  40301. * This can help limiting how the Camera is able to move in the scene.
  40302. */
  40303. lowerRadiusLimit: Nullable<number>;
  40304. /**
  40305. * Maximum allowed distance of the camera to the axis of rotation
  40306. * (The camera can not get further).
  40307. * This can help limiting how the Camera is able to move in the scene.
  40308. */
  40309. upperRadiusLimit: Nullable<number>;
  40310. /**
  40311. * Define a rotation offset between the camera and the object it follows
  40312. */
  40313. rotationOffset: number;
  40314. /**
  40315. * Minimum allowed angle to camera position relative to target object.
  40316. * This can help limiting how the Camera is able to move in the scene.
  40317. */
  40318. lowerRotationOffsetLimit: Nullable<number>;
  40319. /**
  40320. * Maximum allowed angle to camera position relative to target object.
  40321. * This can help limiting how the Camera is able to move in the scene.
  40322. */
  40323. upperRotationOffsetLimit: Nullable<number>;
  40324. /**
  40325. * Define a height offset between the camera and the object it follows.
  40326. * It can help following an object from the top (like a car chaing a plane)
  40327. */
  40328. heightOffset: number;
  40329. /**
  40330. * Minimum allowed height of camera position relative to target object.
  40331. * This can help limiting how the Camera is able to move in the scene.
  40332. */
  40333. lowerHeightOffsetLimit: Nullable<number>;
  40334. /**
  40335. * Maximum allowed height of camera position relative to target object.
  40336. * This can help limiting how the Camera is able to move in the scene.
  40337. */
  40338. upperHeightOffsetLimit: Nullable<number>;
  40339. /**
  40340. * Define how fast the camera can accelerate to follow it s target.
  40341. */
  40342. cameraAcceleration: number;
  40343. /**
  40344. * Define the speed limit of the camera following an object.
  40345. */
  40346. maxCameraSpeed: number;
  40347. /**
  40348. * Define the target of the camera.
  40349. */
  40350. lockedTarget: Nullable<AbstractMesh>;
  40351. /**
  40352. * Defines the input associated with the camera.
  40353. */
  40354. inputs: FollowCameraInputsManager;
  40355. /**
  40356. * Instantiates the follow camera.
  40357. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40358. * @param name Define the name of the camera in the scene
  40359. * @param position Define the position of the camera
  40360. * @param scene Define the scene the camera belong to
  40361. * @param lockedTarget Define the target of the camera
  40362. */
  40363. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  40364. private _follow;
  40365. /**
  40366. * Attached controls to the current camera.
  40367. * @param element Defines the element the controls should be listened from
  40368. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40369. */
  40370. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40371. /**
  40372. * Detach the current controls from the camera.
  40373. * The camera will stop reacting to inputs.
  40374. * @param element Defines the element to stop listening the inputs from
  40375. */
  40376. detachControl(element: HTMLElement): void;
  40377. /** @hidden */
  40378. _checkInputs(): void;
  40379. private _checkLimits;
  40380. /**
  40381. * Gets the camera class name.
  40382. * @returns the class name
  40383. */
  40384. getClassName(): string;
  40385. }
  40386. /**
  40387. * Arc Rotate version of the follow camera.
  40388. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  40389. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40390. */
  40391. export class ArcFollowCamera extends TargetCamera {
  40392. /** The longitudinal angle of the camera */
  40393. alpha: number;
  40394. /** The latitudinal angle of the camera */
  40395. beta: number;
  40396. /** The radius of the camera from its target */
  40397. radius: number;
  40398. /** Define the camera target (the messh it should follow) */
  40399. target: Nullable<AbstractMesh>;
  40400. private _cartesianCoordinates;
  40401. /**
  40402. * Instantiates a new ArcFollowCamera
  40403. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  40404. * @param name Define the name of the camera
  40405. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  40406. * @param beta Define the rotation angle of the camera around the elevation axis
  40407. * @param radius Define the radius of the camera from its target point
  40408. * @param target Define the target of the camera
  40409. * @param scene Define the scene the camera belongs to
  40410. */
  40411. constructor(name: string,
  40412. /** The longitudinal angle of the camera */
  40413. alpha: number,
  40414. /** The latitudinal angle of the camera */
  40415. beta: number,
  40416. /** The radius of the camera from its target */
  40417. radius: number,
  40418. /** Define the camera target (the messh it should follow) */
  40419. target: Nullable<AbstractMesh>, scene: Scene);
  40420. private _follow;
  40421. /** @hidden */
  40422. _checkInputs(): void;
  40423. /**
  40424. * Returns the class name of the object.
  40425. * It is mostly used internally for serialization purposes.
  40426. */
  40427. getClassName(): string;
  40428. }
  40429. }
  40430. declare module BABYLON {
  40431. /**
  40432. * Manage the keyboard inputs to control the movement of a follow camera.
  40433. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40434. */
  40435. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  40436. /**
  40437. * Defines the camera the input is attached to.
  40438. */
  40439. camera: FollowCamera;
  40440. /**
  40441. * Defines the list of key codes associated with the up action (increase heightOffset)
  40442. */
  40443. keysHeightOffsetIncr: number[];
  40444. /**
  40445. * Defines the list of key codes associated with the down action (decrease heightOffset)
  40446. */
  40447. keysHeightOffsetDecr: number[];
  40448. /**
  40449. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  40450. */
  40451. keysHeightOffsetModifierAlt: boolean;
  40452. /**
  40453. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  40454. */
  40455. keysHeightOffsetModifierCtrl: boolean;
  40456. /**
  40457. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  40458. */
  40459. keysHeightOffsetModifierShift: boolean;
  40460. /**
  40461. * Defines the list of key codes associated with the left action (increase rotationOffset)
  40462. */
  40463. keysRotationOffsetIncr: number[];
  40464. /**
  40465. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  40466. */
  40467. keysRotationOffsetDecr: number[];
  40468. /**
  40469. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  40470. */
  40471. keysRotationOffsetModifierAlt: boolean;
  40472. /**
  40473. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  40474. */
  40475. keysRotationOffsetModifierCtrl: boolean;
  40476. /**
  40477. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  40478. */
  40479. keysRotationOffsetModifierShift: boolean;
  40480. /**
  40481. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  40482. */
  40483. keysRadiusIncr: number[];
  40484. /**
  40485. * Defines the list of key codes associated with the zoom-out action (increase radius)
  40486. */
  40487. keysRadiusDecr: number[];
  40488. /**
  40489. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  40490. */
  40491. keysRadiusModifierAlt: boolean;
  40492. /**
  40493. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  40494. */
  40495. keysRadiusModifierCtrl: boolean;
  40496. /**
  40497. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  40498. */
  40499. keysRadiusModifierShift: boolean;
  40500. /**
  40501. * Defines the rate of change of heightOffset.
  40502. */
  40503. heightSensibility: number;
  40504. /**
  40505. * Defines the rate of change of rotationOffset.
  40506. */
  40507. rotationSensibility: number;
  40508. /**
  40509. * Defines the rate of change of radius.
  40510. */
  40511. radiusSensibility: number;
  40512. private _keys;
  40513. private _ctrlPressed;
  40514. private _altPressed;
  40515. private _shiftPressed;
  40516. private _onCanvasBlurObserver;
  40517. private _onKeyboardObserver;
  40518. private _engine;
  40519. private _scene;
  40520. /**
  40521. * Attach the input controls to a specific dom element to get the input from.
  40522. * @param element Defines the element the controls should be listened from
  40523. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40524. */
  40525. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40526. /**
  40527. * Detach the current controls from the specified dom element.
  40528. * @param element Defines the element to stop listening the inputs from
  40529. */
  40530. detachControl(element: Nullable<HTMLElement>): void;
  40531. /**
  40532. * Update the current camera state depending on the inputs that have been used this frame.
  40533. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40534. */
  40535. checkInputs(): void;
  40536. /**
  40537. * Gets the class name of the current input.
  40538. * @returns the class name
  40539. */
  40540. getClassName(): string;
  40541. /**
  40542. * Get the friendly name associated with the input class.
  40543. * @returns the input friendly name
  40544. */
  40545. getSimpleName(): string;
  40546. /**
  40547. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40548. * allow modification of the heightOffset value.
  40549. */
  40550. private _modifierHeightOffset;
  40551. /**
  40552. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40553. * allow modification of the rotationOffset value.
  40554. */
  40555. private _modifierRotationOffset;
  40556. /**
  40557. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  40558. * allow modification of the radius value.
  40559. */
  40560. private _modifierRadius;
  40561. }
  40562. }
  40563. declare module BABYLON {
  40564. interface FreeCameraInputsManager {
  40565. /**
  40566. * @hidden
  40567. */
  40568. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  40569. /**
  40570. * Add orientation input support to the input manager.
  40571. * @returns the current input manager
  40572. */
  40573. addDeviceOrientation(): FreeCameraInputsManager;
  40574. }
  40575. /**
  40576. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  40577. * Screen rotation is taken into account.
  40578. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40579. */
  40580. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  40581. private _camera;
  40582. private _screenOrientationAngle;
  40583. private _constantTranform;
  40584. private _screenQuaternion;
  40585. private _alpha;
  40586. private _beta;
  40587. private _gamma;
  40588. /**
  40589. * Can be used to detect if a device orientation sensor is available on a device
  40590. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  40591. * @returns a promise that will resolve on orientation change
  40592. */
  40593. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  40594. /**
  40595. * @hidden
  40596. */
  40597. _onDeviceOrientationChangedObservable: Observable<void>;
  40598. /**
  40599. * Instantiates a new input
  40600. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40601. */
  40602. constructor();
  40603. /**
  40604. * Define the camera controlled by the input.
  40605. */
  40606. get camera(): FreeCamera;
  40607. set camera(camera: FreeCamera);
  40608. /**
  40609. * Attach the input controls to a specific dom element to get the input from.
  40610. * @param element Defines the element the controls should be listened from
  40611. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40612. */
  40613. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40614. private _orientationChanged;
  40615. private _deviceOrientation;
  40616. /**
  40617. * Detach the current controls from the specified dom element.
  40618. * @param element Defines the element to stop listening the inputs from
  40619. */
  40620. detachControl(element: Nullable<HTMLElement>): void;
  40621. /**
  40622. * Update the current camera state depending on the inputs that have been used this frame.
  40623. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40624. */
  40625. checkInputs(): void;
  40626. /**
  40627. * Gets the class name of the current intput.
  40628. * @returns the class name
  40629. */
  40630. getClassName(): string;
  40631. /**
  40632. * Get the friendly name associated with the input class.
  40633. * @returns the input friendly name
  40634. */
  40635. getSimpleName(): string;
  40636. }
  40637. }
  40638. declare module BABYLON {
  40639. /**
  40640. * Manage the gamepad inputs to control a free camera.
  40641. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40642. */
  40643. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  40644. /**
  40645. * Define the camera the input is attached to.
  40646. */
  40647. camera: FreeCamera;
  40648. /**
  40649. * Define the Gamepad controlling the input
  40650. */
  40651. gamepad: Nullable<Gamepad>;
  40652. /**
  40653. * Defines the gamepad rotation sensiblity.
  40654. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40655. */
  40656. gamepadAngularSensibility: number;
  40657. /**
  40658. * Defines the gamepad move sensiblity.
  40659. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40660. */
  40661. gamepadMoveSensibility: number;
  40662. private _yAxisScale;
  40663. /**
  40664. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40665. */
  40666. get invertYAxis(): boolean;
  40667. set invertYAxis(value: boolean);
  40668. private _onGamepadConnectedObserver;
  40669. private _onGamepadDisconnectedObserver;
  40670. private _cameraTransform;
  40671. private _deltaTransform;
  40672. private _vector3;
  40673. private _vector2;
  40674. /**
  40675. * Attach the input controls to a specific dom element to get the input from.
  40676. * @param element Defines the element the controls should be listened from
  40677. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40678. */
  40679. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40680. /**
  40681. * Detach the current controls from the specified dom element.
  40682. * @param element Defines the element to stop listening the inputs from
  40683. */
  40684. detachControl(element: Nullable<HTMLElement>): void;
  40685. /**
  40686. * Update the current camera state depending on the inputs that have been used this frame.
  40687. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40688. */
  40689. checkInputs(): void;
  40690. /**
  40691. * Gets the class name of the current intput.
  40692. * @returns the class name
  40693. */
  40694. getClassName(): string;
  40695. /**
  40696. * Get the friendly name associated with the input class.
  40697. * @returns the input friendly name
  40698. */
  40699. getSimpleName(): string;
  40700. }
  40701. }
  40702. declare module BABYLON {
  40703. /**
  40704. * Defines the potential axis of a Joystick
  40705. */
  40706. export enum JoystickAxis {
  40707. /** X axis */
  40708. X = 0,
  40709. /** Y axis */
  40710. Y = 1,
  40711. /** Z axis */
  40712. Z = 2
  40713. }
  40714. /**
  40715. * Class used to define virtual joystick (used in touch mode)
  40716. */
  40717. export class VirtualJoystick {
  40718. /**
  40719. * Gets or sets a boolean indicating that left and right values must be inverted
  40720. */
  40721. reverseLeftRight: boolean;
  40722. /**
  40723. * Gets or sets a boolean indicating that up and down values must be inverted
  40724. */
  40725. reverseUpDown: boolean;
  40726. /**
  40727. * Gets the offset value for the position (ie. the change of the position value)
  40728. */
  40729. deltaPosition: Vector3;
  40730. /**
  40731. * Gets a boolean indicating if the virtual joystick was pressed
  40732. */
  40733. pressed: boolean;
  40734. /**
  40735. * Canvas the virtual joystick will render onto, default z-index of this is 5
  40736. */
  40737. static Canvas: Nullable<HTMLCanvasElement>;
  40738. private static _globalJoystickIndex;
  40739. private static vjCanvasContext;
  40740. private static vjCanvasWidth;
  40741. private static vjCanvasHeight;
  40742. private static halfWidth;
  40743. private _action;
  40744. private _axisTargetedByLeftAndRight;
  40745. private _axisTargetedByUpAndDown;
  40746. private _joystickSensibility;
  40747. private _inversedSensibility;
  40748. private _joystickPointerID;
  40749. private _joystickColor;
  40750. private _joystickPointerPos;
  40751. private _joystickPreviousPointerPos;
  40752. private _joystickPointerStartPos;
  40753. private _deltaJoystickVector;
  40754. private _leftJoystick;
  40755. private _touches;
  40756. private _onPointerDownHandlerRef;
  40757. private _onPointerMoveHandlerRef;
  40758. private _onPointerUpHandlerRef;
  40759. private _onResize;
  40760. /**
  40761. * Creates a new virtual joystick
  40762. * @param leftJoystick defines that the joystick is for left hand (false by default)
  40763. */
  40764. constructor(leftJoystick?: boolean);
  40765. /**
  40766. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  40767. * @param newJoystickSensibility defines the new sensibility
  40768. */
  40769. setJoystickSensibility(newJoystickSensibility: number): void;
  40770. private _onPointerDown;
  40771. private _onPointerMove;
  40772. private _onPointerUp;
  40773. /**
  40774. * Change the color of the virtual joystick
  40775. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  40776. */
  40777. setJoystickColor(newColor: string): void;
  40778. /**
  40779. * Defines a callback to call when the joystick is touched
  40780. * @param action defines the callback
  40781. */
  40782. setActionOnTouch(action: () => any): void;
  40783. /**
  40784. * Defines which axis you'd like to control for left & right
  40785. * @param axis defines the axis to use
  40786. */
  40787. setAxisForLeftRight(axis: JoystickAxis): void;
  40788. /**
  40789. * Defines which axis you'd like to control for up & down
  40790. * @param axis defines the axis to use
  40791. */
  40792. setAxisForUpDown(axis: JoystickAxis): void;
  40793. private _drawVirtualJoystick;
  40794. /**
  40795. * Release internal HTML canvas
  40796. */
  40797. releaseCanvas(): void;
  40798. }
  40799. }
  40800. declare module BABYLON {
  40801. interface FreeCameraInputsManager {
  40802. /**
  40803. * Add virtual joystick input support to the input manager.
  40804. * @returns the current input manager
  40805. */
  40806. addVirtualJoystick(): FreeCameraInputsManager;
  40807. }
  40808. /**
  40809. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  40810. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40811. */
  40812. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  40813. /**
  40814. * Defines the camera the input is attached to.
  40815. */
  40816. camera: FreeCamera;
  40817. private _leftjoystick;
  40818. private _rightjoystick;
  40819. /**
  40820. * Gets the left stick of the virtual joystick.
  40821. * @returns The virtual Joystick
  40822. */
  40823. getLeftJoystick(): VirtualJoystick;
  40824. /**
  40825. * Gets the right stick of the virtual joystick.
  40826. * @returns The virtual Joystick
  40827. */
  40828. getRightJoystick(): VirtualJoystick;
  40829. /**
  40830. * Update the current camera state depending on the inputs that have been used this frame.
  40831. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40832. */
  40833. checkInputs(): void;
  40834. /**
  40835. * Attach the input controls to a specific dom element to get the input from.
  40836. * @param element Defines the element the controls should be listened from
  40837. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40838. */
  40839. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40840. /**
  40841. * Detach the current controls from the specified dom element.
  40842. * @param element Defines the element to stop listening the inputs from
  40843. */
  40844. detachControl(element: Nullable<HTMLElement>): void;
  40845. /**
  40846. * Gets the class name of the current intput.
  40847. * @returns the class name
  40848. */
  40849. getClassName(): string;
  40850. /**
  40851. * Get the friendly name associated with the input class.
  40852. * @returns the input friendly name
  40853. */
  40854. getSimpleName(): string;
  40855. }
  40856. }
  40857. declare module BABYLON {
  40858. /**
  40859. * This represents a FPS type of camera controlled by touch.
  40860. * This is like a universal camera minus the Gamepad controls.
  40861. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40862. */
  40863. export class TouchCamera extends FreeCamera {
  40864. /**
  40865. * Defines the touch sensibility for rotation.
  40866. * The higher the faster.
  40867. */
  40868. get touchAngularSensibility(): number;
  40869. set touchAngularSensibility(value: number);
  40870. /**
  40871. * Defines the touch sensibility for move.
  40872. * The higher the faster.
  40873. */
  40874. get touchMoveSensibility(): number;
  40875. set touchMoveSensibility(value: number);
  40876. /**
  40877. * Instantiates a new touch camera.
  40878. * This represents a FPS type of camera controlled by touch.
  40879. * This is like a universal camera minus the Gamepad controls.
  40880. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40881. * @param name Define the name of the camera in the scene
  40882. * @param position Define the start position of the camera in the scene
  40883. * @param scene Define the scene the camera belongs to
  40884. */
  40885. constructor(name: string, position: Vector3, scene: Scene);
  40886. /**
  40887. * Gets the current object class name.
  40888. * @return the class name
  40889. */
  40890. getClassName(): string;
  40891. /** @hidden */
  40892. _setupInputs(): void;
  40893. }
  40894. }
  40895. declare module BABYLON {
  40896. /**
  40897. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  40898. * being tilted forward or back and left or right.
  40899. */
  40900. export class DeviceOrientationCamera extends FreeCamera {
  40901. private _initialQuaternion;
  40902. private _quaternionCache;
  40903. private _tmpDragQuaternion;
  40904. private _disablePointerInputWhenUsingDeviceOrientation;
  40905. /**
  40906. * Creates a new device orientation camera
  40907. * @param name The name of the camera
  40908. * @param position The start position camera
  40909. * @param scene The scene the camera belongs to
  40910. */
  40911. constructor(name: string, position: Vector3, scene: Scene);
  40912. /**
  40913. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  40914. */
  40915. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  40916. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  40917. private _dragFactor;
  40918. /**
  40919. * Enabled turning on the y axis when the orientation sensor is active
  40920. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  40921. */
  40922. enableHorizontalDragging(dragFactor?: number): void;
  40923. /**
  40924. * Gets the current instance class name ("DeviceOrientationCamera").
  40925. * This helps avoiding instanceof at run time.
  40926. * @returns the class name
  40927. */
  40928. getClassName(): string;
  40929. /**
  40930. * @hidden
  40931. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  40932. */
  40933. _checkInputs(): void;
  40934. /**
  40935. * Reset the camera to its default orientation on the specified axis only.
  40936. * @param axis The axis to reset
  40937. */
  40938. resetToCurrentRotation(axis?: Axis): void;
  40939. }
  40940. }
  40941. declare module BABYLON {
  40942. /**
  40943. * Defines supported buttons for XBox360 compatible gamepads
  40944. */
  40945. export enum Xbox360Button {
  40946. /** A */
  40947. A = 0,
  40948. /** B */
  40949. B = 1,
  40950. /** X */
  40951. X = 2,
  40952. /** Y */
  40953. Y = 3,
  40954. /** Start */
  40955. Start = 4,
  40956. /** Back */
  40957. Back = 5,
  40958. /** Left button */
  40959. LB = 6,
  40960. /** Right button */
  40961. RB = 7,
  40962. /** Left stick */
  40963. LeftStick = 8,
  40964. /** Right stick */
  40965. RightStick = 9
  40966. }
  40967. /** Defines values for XBox360 DPad */
  40968. export enum Xbox360Dpad {
  40969. /** Up */
  40970. Up = 0,
  40971. /** Down */
  40972. Down = 1,
  40973. /** Left */
  40974. Left = 2,
  40975. /** Right */
  40976. Right = 3
  40977. }
  40978. /**
  40979. * Defines a XBox360 gamepad
  40980. */
  40981. export class Xbox360Pad extends Gamepad {
  40982. private _leftTrigger;
  40983. private _rightTrigger;
  40984. private _onlefttriggerchanged;
  40985. private _onrighttriggerchanged;
  40986. private _onbuttondown;
  40987. private _onbuttonup;
  40988. private _ondpaddown;
  40989. private _ondpadup;
  40990. /** Observable raised when a button is pressed */
  40991. onButtonDownObservable: Observable<Xbox360Button>;
  40992. /** Observable raised when a button is released */
  40993. onButtonUpObservable: Observable<Xbox360Button>;
  40994. /** Observable raised when a pad is pressed */
  40995. onPadDownObservable: Observable<Xbox360Dpad>;
  40996. /** Observable raised when a pad is released */
  40997. onPadUpObservable: Observable<Xbox360Dpad>;
  40998. private _buttonA;
  40999. private _buttonB;
  41000. private _buttonX;
  41001. private _buttonY;
  41002. private _buttonBack;
  41003. private _buttonStart;
  41004. private _buttonLB;
  41005. private _buttonRB;
  41006. private _buttonLeftStick;
  41007. private _buttonRightStick;
  41008. private _dPadUp;
  41009. private _dPadDown;
  41010. private _dPadLeft;
  41011. private _dPadRight;
  41012. private _isXboxOnePad;
  41013. /**
  41014. * Creates a new XBox360 gamepad object
  41015. * @param id defines the id of this gamepad
  41016. * @param index defines its index
  41017. * @param gamepad defines the internal HTML gamepad object
  41018. * @param xboxOne defines if it is a XBox One gamepad
  41019. */
  41020. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  41021. /**
  41022. * Defines the callback to call when left trigger is pressed
  41023. * @param callback defines the callback to use
  41024. */
  41025. onlefttriggerchanged(callback: (value: number) => void): void;
  41026. /**
  41027. * Defines the callback to call when right trigger is pressed
  41028. * @param callback defines the callback to use
  41029. */
  41030. onrighttriggerchanged(callback: (value: number) => void): void;
  41031. /**
  41032. * Gets the left trigger value
  41033. */
  41034. get leftTrigger(): number;
  41035. /**
  41036. * Sets the left trigger value
  41037. */
  41038. set leftTrigger(newValue: number);
  41039. /**
  41040. * Gets the right trigger value
  41041. */
  41042. get rightTrigger(): number;
  41043. /**
  41044. * Sets the right trigger value
  41045. */
  41046. set rightTrigger(newValue: number);
  41047. /**
  41048. * Defines the callback to call when a button is pressed
  41049. * @param callback defines the callback to use
  41050. */
  41051. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  41052. /**
  41053. * Defines the callback to call when a button is released
  41054. * @param callback defines the callback to use
  41055. */
  41056. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  41057. /**
  41058. * Defines the callback to call when a pad is pressed
  41059. * @param callback defines the callback to use
  41060. */
  41061. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  41062. /**
  41063. * Defines the callback to call when a pad is released
  41064. * @param callback defines the callback to use
  41065. */
  41066. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  41067. private _setButtonValue;
  41068. private _setDPadValue;
  41069. /**
  41070. * Gets the value of the `A` button
  41071. */
  41072. get buttonA(): number;
  41073. /**
  41074. * Sets the value of the `A` button
  41075. */
  41076. set buttonA(value: number);
  41077. /**
  41078. * Gets the value of the `B` button
  41079. */
  41080. get buttonB(): number;
  41081. /**
  41082. * Sets the value of the `B` button
  41083. */
  41084. set buttonB(value: number);
  41085. /**
  41086. * Gets the value of the `X` button
  41087. */
  41088. get buttonX(): number;
  41089. /**
  41090. * Sets the value of the `X` button
  41091. */
  41092. set buttonX(value: number);
  41093. /**
  41094. * Gets the value of the `Y` button
  41095. */
  41096. get buttonY(): number;
  41097. /**
  41098. * Sets the value of the `Y` button
  41099. */
  41100. set buttonY(value: number);
  41101. /**
  41102. * Gets the value of the `Start` button
  41103. */
  41104. get buttonStart(): number;
  41105. /**
  41106. * Sets the value of the `Start` button
  41107. */
  41108. set buttonStart(value: number);
  41109. /**
  41110. * Gets the value of the `Back` button
  41111. */
  41112. get buttonBack(): number;
  41113. /**
  41114. * Sets the value of the `Back` button
  41115. */
  41116. set buttonBack(value: number);
  41117. /**
  41118. * Gets the value of the `Left` button
  41119. */
  41120. get buttonLB(): number;
  41121. /**
  41122. * Sets the value of the `Left` button
  41123. */
  41124. set buttonLB(value: number);
  41125. /**
  41126. * Gets the value of the `Right` button
  41127. */
  41128. get buttonRB(): number;
  41129. /**
  41130. * Sets the value of the `Right` button
  41131. */
  41132. set buttonRB(value: number);
  41133. /**
  41134. * Gets the value of the Left joystick
  41135. */
  41136. get buttonLeftStick(): number;
  41137. /**
  41138. * Sets the value of the Left joystick
  41139. */
  41140. set buttonLeftStick(value: number);
  41141. /**
  41142. * Gets the value of the Right joystick
  41143. */
  41144. get buttonRightStick(): number;
  41145. /**
  41146. * Sets the value of the Right joystick
  41147. */
  41148. set buttonRightStick(value: number);
  41149. /**
  41150. * Gets the value of D-pad up
  41151. */
  41152. get dPadUp(): number;
  41153. /**
  41154. * Sets the value of D-pad up
  41155. */
  41156. set dPadUp(value: number);
  41157. /**
  41158. * Gets the value of D-pad down
  41159. */
  41160. get dPadDown(): number;
  41161. /**
  41162. * Sets the value of D-pad down
  41163. */
  41164. set dPadDown(value: number);
  41165. /**
  41166. * Gets the value of D-pad left
  41167. */
  41168. get dPadLeft(): number;
  41169. /**
  41170. * Sets the value of D-pad left
  41171. */
  41172. set dPadLeft(value: number);
  41173. /**
  41174. * Gets the value of D-pad right
  41175. */
  41176. get dPadRight(): number;
  41177. /**
  41178. * Sets the value of D-pad right
  41179. */
  41180. set dPadRight(value: number);
  41181. /**
  41182. * Force the gamepad to synchronize with device values
  41183. */
  41184. update(): void;
  41185. /**
  41186. * Disposes the gamepad
  41187. */
  41188. dispose(): void;
  41189. }
  41190. }
  41191. declare module BABYLON {
  41192. /**
  41193. * Defines supported buttons for DualShock compatible gamepads
  41194. */
  41195. export enum DualShockButton {
  41196. /** Cross */
  41197. Cross = 0,
  41198. /** Circle */
  41199. Circle = 1,
  41200. /** Square */
  41201. Square = 2,
  41202. /** Triangle */
  41203. Triangle = 3,
  41204. /** Options */
  41205. Options = 4,
  41206. /** Share */
  41207. Share = 5,
  41208. /** L1 */
  41209. L1 = 6,
  41210. /** R1 */
  41211. R1 = 7,
  41212. /** Left stick */
  41213. LeftStick = 8,
  41214. /** Right stick */
  41215. RightStick = 9
  41216. }
  41217. /** Defines values for DualShock DPad */
  41218. export enum DualShockDpad {
  41219. /** Up */
  41220. Up = 0,
  41221. /** Down */
  41222. Down = 1,
  41223. /** Left */
  41224. Left = 2,
  41225. /** Right */
  41226. Right = 3
  41227. }
  41228. /**
  41229. * Defines a DualShock gamepad
  41230. */
  41231. export class DualShockPad extends Gamepad {
  41232. private _leftTrigger;
  41233. private _rightTrigger;
  41234. private _onlefttriggerchanged;
  41235. private _onrighttriggerchanged;
  41236. private _onbuttondown;
  41237. private _onbuttonup;
  41238. private _ondpaddown;
  41239. private _ondpadup;
  41240. /** Observable raised when a button is pressed */
  41241. onButtonDownObservable: Observable<DualShockButton>;
  41242. /** Observable raised when a button is released */
  41243. onButtonUpObservable: Observable<DualShockButton>;
  41244. /** Observable raised when a pad is pressed */
  41245. onPadDownObservable: Observable<DualShockDpad>;
  41246. /** Observable raised when a pad is released */
  41247. onPadUpObservable: Observable<DualShockDpad>;
  41248. private _buttonCross;
  41249. private _buttonCircle;
  41250. private _buttonSquare;
  41251. private _buttonTriangle;
  41252. private _buttonShare;
  41253. private _buttonOptions;
  41254. private _buttonL1;
  41255. private _buttonR1;
  41256. private _buttonLeftStick;
  41257. private _buttonRightStick;
  41258. private _dPadUp;
  41259. private _dPadDown;
  41260. private _dPadLeft;
  41261. private _dPadRight;
  41262. /**
  41263. * Creates a new DualShock gamepad object
  41264. * @param id defines the id of this gamepad
  41265. * @param index defines its index
  41266. * @param gamepad defines the internal HTML gamepad object
  41267. */
  41268. constructor(id: string, index: number, gamepad: any);
  41269. /**
  41270. * Defines the callback to call when left trigger is pressed
  41271. * @param callback defines the callback to use
  41272. */
  41273. onlefttriggerchanged(callback: (value: number) => void): void;
  41274. /**
  41275. * Defines the callback to call when right trigger is pressed
  41276. * @param callback defines the callback to use
  41277. */
  41278. onrighttriggerchanged(callback: (value: number) => void): void;
  41279. /**
  41280. * Gets the left trigger value
  41281. */
  41282. get leftTrigger(): number;
  41283. /**
  41284. * Sets the left trigger value
  41285. */
  41286. set leftTrigger(newValue: number);
  41287. /**
  41288. * Gets the right trigger value
  41289. */
  41290. get rightTrigger(): number;
  41291. /**
  41292. * Sets the right trigger value
  41293. */
  41294. set rightTrigger(newValue: number);
  41295. /**
  41296. * Defines the callback to call when a button is pressed
  41297. * @param callback defines the callback to use
  41298. */
  41299. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  41300. /**
  41301. * Defines the callback to call when a button is released
  41302. * @param callback defines the callback to use
  41303. */
  41304. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  41305. /**
  41306. * Defines the callback to call when a pad is pressed
  41307. * @param callback defines the callback to use
  41308. */
  41309. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  41310. /**
  41311. * Defines the callback to call when a pad is released
  41312. * @param callback defines the callback to use
  41313. */
  41314. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  41315. private _setButtonValue;
  41316. private _setDPadValue;
  41317. /**
  41318. * Gets the value of the `Cross` button
  41319. */
  41320. get buttonCross(): number;
  41321. /**
  41322. * Sets the value of the `Cross` button
  41323. */
  41324. set buttonCross(value: number);
  41325. /**
  41326. * Gets the value of the `Circle` button
  41327. */
  41328. get buttonCircle(): number;
  41329. /**
  41330. * Sets the value of the `Circle` button
  41331. */
  41332. set buttonCircle(value: number);
  41333. /**
  41334. * Gets the value of the `Square` button
  41335. */
  41336. get buttonSquare(): number;
  41337. /**
  41338. * Sets the value of the `Square` button
  41339. */
  41340. set buttonSquare(value: number);
  41341. /**
  41342. * Gets the value of the `Triangle` button
  41343. */
  41344. get buttonTriangle(): number;
  41345. /**
  41346. * Sets the value of the `Triangle` button
  41347. */
  41348. set buttonTriangle(value: number);
  41349. /**
  41350. * Gets the value of the `Options` button
  41351. */
  41352. get buttonOptions(): number;
  41353. /**
  41354. * Sets the value of the `Options` button
  41355. */
  41356. set buttonOptions(value: number);
  41357. /**
  41358. * Gets the value of the `Share` button
  41359. */
  41360. get buttonShare(): number;
  41361. /**
  41362. * Sets the value of the `Share` button
  41363. */
  41364. set buttonShare(value: number);
  41365. /**
  41366. * Gets the value of the `L1` button
  41367. */
  41368. get buttonL1(): number;
  41369. /**
  41370. * Sets the value of the `L1` button
  41371. */
  41372. set buttonL1(value: number);
  41373. /**
  41374. * Gets the value of the `R1` button
  41375. */
  41376. get buttonR1(): number;
  41377. /**
  41378. * Sets the value of the `R1` button
  41379. */
  41380. set buttonR1(value: number);
  41381. /**
  41382. * Gets the value of the Left joystick
  41383. */
  41384. get buttonLeftStick(): number;
  41385. /**
  41386. * Sets the value of the Left joystick
  41387. */
  41388. set buttonLeftStick(value: number);
  41389. /**
  41390. * Gets the value of the Right joystick
  41391. */
  41392. get buttonRightStick(): number;
  41393. /**
  41394. * Sets the value of the Right joystick
  41395. */
  41396. set buttonRightStick(value: number);
  41397. /**
  41398. * Gets the value of D-pad up
  41399. */
  41400. get dPadUp(): number;
  41401. /**
  41402. * Sets the value of D-pad up
  41403. */
  41404. set dPadUp(value: number);
  41405. /**
  41406. * Gets the value of D-pad down
  41407. */
  41408. get dPadDown(): number;
  41409. /**
  41410. * Sets the value of D-pad down
  41411. */
  41412. set dPadDown(value: number);
  41413. /**
  41414. * Gets the value of D-pad left
  41415. */
  41416. get dPadLeft(): number;
  41417. /**
  41418. * Sets the value of D-pad left
  41419. */
  41420. set dPadLeft(value: number);
  41421. /**
  41422. * Gets the value of D-pad right
  41423. */
  41424. get dPadRight(): number;
  41425. /**
  41426. * Sets the value of D-pad right
  41427. */
  41428. set dPadRight(value: number);
  41429. /**
  41430. * Force the gamepad to synchronize with device values
  41431. */
  41432. update(): void;
  41433. /**
  41434. * Disposes the gamepad
  41435. */
  41436. dispose(): void;
  41437. }
  41438. }
  41439. declare module BABYLON {
  41440. /**
  41441. * Manager for handling gamepads
  41442. */
  41443. export class GamepadManager {
  41444. private _scene?;
  41445. private _babylonGamepads;
  41446. private _oneGamepadConnected;
  41447. /** @hidden */
  41448. _isMonitoring: boolean;
  41449. private _gamepadEventSupported;
  41450. private _gamepadSupport?;
  41451. /**
  41452. * observable to be triggered when the gamepad controller has been connected
  41453. */
  41454. onGamepadConnectedObservable: Observable<Gamepad>;
  41455. /**
  41456. * observable to be triggered when the gamepad controller has been disconnected
  41457. */
  41458. onGamepadDisconnectedObservable: Observable<Gamepad>;
  41459. private _onGamepadConnectedEvent;
  41460. private _onGamepadDisconnectedEvent;
  41461. /**
  41462. * Initializes the gamepad manager
  41463. * @param _scene BabylonJS scene
  41464. */
  41465. constructor(_scene?: Scene | undefined);
  41466. /**
  41467. * The gamepads in the game pad manager
  41468. */
  41469. get gamepads(): Gamepad[];
  41470. /**
  41471. * Get the gamepad controllers based on type
  41472. * @param type The type of gamepad controller
  41473. * @returns Nullable gamepad
  41474. */
  41475. getGamepadByType(type?: number): Nullable<Gamepad>;
  41476. /**
  41477. * Disposes the gamepad manager
  41478. */
  41479. dispose(): void;
  41480. private _addNewGamepad;
  41481. private _startMonitoringGamepads;
  41482. private _stopMonitoringGamepads;
  41483. /** @hidden */
  41484. _checkGamepadsStatus(): void;
  41485. private _updateGamepadObjects;
  41486. }
  41487. }
  41488. declare module BABYLON {
  41489. interface Scene {
  41490. /** @hidden */
  41491. _gamepadManager: Nullable<GamepadManager>;
  41492. /**
  41493. * Gets the gamepad manager associated with the scene
  41494. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  41495. */
  41496. gamepadManager: GamepadManager;
  41497. }
  41498. /**
  41499. * Interface representing a free camera inputs manager
  41500. */
  41501. interface FreeCameraInputsManager {
  41502. /**
  41503. * Adds gamepad input support to the FreeCameraInputsManager.
  41504. * @returns the FreeCameraInputsManager
  41505. */
  41506. addGamepad(): FreeCameraInputsManager;
  41507. }
  41508. /**
  41509. * Interface representing an arc rotate camera inputs manager
  41510. */
  41511. interface ArcRotateCameraInputsManager {
  41512. /**
  41513. * Adds gamepad input support to the ArcRotateCamera InputManager.
  41514. * @returns the camera inputs manager
  41515. */
  41516. addGamepad(): ArcRotateCameraInputsManager;
  41517. }
  41518. /**
  41519. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  41520. */
  41521. export class GamepadSystemSceneComponent implements ISceneComponent {
  41522. /**
  41523. * The component name helpfull to identify the component in the list of scene components.
  41524. */
  41525. readonly name: string;
  41526. /**
  41527. * The scene the component belongs to.
  41528. */
  41529. scene: Scene;
  41530. /**
  41531. * Creates a new instance of the component for the given scene
  41532. * @param scene Defines the scene to register the component in
  41533. */
  41534. constructor(scene: Scene);
  41535. /**
  41536. * Registers the component in a given scene
  41537. */
  41538. register(): void;
  41539. /**
  41540. * Rebuilds the elements related to this component in case of
  41541. * context lost for instance.
  41542. */
  41543. rebuild(): void;
  41544. /**
  41545. * Disposes the component and the associated ressources
  41546. */
  41547. dispose(): void;
  41548. private _beforeCameraUpdate;
  41549. }
  41550. }
  41551. declare module BABYLON {
  41552. /**
  41553. * 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,
  41554. * which still works and will still be found in many Playgrounds.
  41555. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41556. */
  41557. export class UniversalCamera extends TouchCamera {
  41558. /**
  41559. * Defines the gamepad rotation sensiblity.
  41560. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41561. */
  41562. get gamepadAngularSensibility(): number;
  41563. set gamepadAngularSensibility(value: number);
  41564. /**
  41565. * Defines the gamepad move sensiblity.
  41566. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41567. */
  41568. get gamepadMoveSensibility(): number;
  41569. set gamepadMoveSensibility(value: number);
  41570. /**
  41571. * 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,
  41572. * which still works and will still be found in many Playgrounds.
  41573. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41574. * @param name Define the name of the camera in the scene
  41575. * @param position Define the start position of the camera in the scene
  41576. * @param scene Define the scene the camera belongs to
  41577. */
  41578. constructor(name: string, position: Vector3, scene: Scene);
  41579. /**
  41580. * Gets the current object class name.
  41581. * @return the class name
  41582. */
  41583. getClassName(): string;
  41584. }
  41585. }
  41586. declare module BABYLON {
  41587. /**
  41588. * This represents a FPS type of camera. This is only here for back compat purpose.
  41589. * Please use the UniversalCamera instead as both are identical.
  41590. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41591. */
  41592. export class GamepadCamera extends UniversalCamera {
  41593. /**
  41594. * Instantiates a new Gamepad Camera
  41595. * This represents a FPS type of camera. This is only here for back compat purpose.
  41596. * Please use the UniversalCamera instead as both are identical.
  41597. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  41598. * @param name Define the name of the camera in the scene
  41599. * @param position Define the start position of the camera in the scene
  41600. * @param scene Define the scene the camera belongs to
  41601. */
  41602. constructor(name: string, position: Vector3, scene: Scene);
  41603. /**
  41604. * Gets the current object class name.
  41605. * @return the class name
  41606. */
  41607. getClassName(): string;
  41608. }
  41609. }
  41610. declare module BABYLON {
  41611. /** @hidden */
  41612. export var passPixelShader: {
  41613. name: string;
  41614. shader: string;
  41615. };
  41616. }
  41617. declare module BABYLON {
  41618. /** @hidden */
  41619. export var passCubePixelShader: {
  41620. name: string;
  41621. shader: string;
  41622. };
  41623. }
  41624. declare module BABYLON {
  41625. /**
  41626. * PassPostProcess which produces an output the same as it's input
  41627. */
  41628. export class PassPostProcess extends PostProcess {
  41629. /**
  41630. * Creates the PassPostProcess
  41631. * @param name The name of the effect.
  41632. * @param options The required width/height ratio to downsize to before computing the render pass.
  41633. * @param camera The camera to apply the render pass to.
  41634. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41635. * @param engine The engine which the post process will be applied. (default: current engine)
  41636. * @param reusable If the post process can be reused on the same frame. (default: false)
  41637. * @param textureType The type of texture to be used when performing the post processing.
  41638. * @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)
  41639. */
  41640. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41641. }
  41642. /**
  41643. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  41644. */
  41645. export class PassCubePostProcess extends PostProcess {
  41646. private _face;
  41647. /**
  41648. * Gets or sets the cube face to display.
  41649. * * 0 is +X
  41650. * * 1 is -X
  41651. * * 2 is +Y
  41652. * * 3 is -Y
  41653. * * 4 is +Z
  41654. * * 5 is -Z
  41655. */
  41656. get face(): number;
  41657. set face(value: number);
  41658. /**
  41659. * Creates the PassCubePostProcess
  41660. * @param name The name of the effect.
  41661. * @param options The required width/height ratio to downsize to before computing the render pass.
  41662. * @param camera The camera to apply the render pass to.
  41663. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41664. * @param engine The engine which the post process will be applied. (default: current engine)
  41665. * @param reusable If the post process can be reused on the same frame. (default: false)
  41666. * @param textureType The type of texture to be used when performing the post processing.
  41667. * @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)
  41668. */
  41669. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  41670. }
  41671. }
  41672. declare module BABYLON {
  41673. /** @hidden */
  41674. export var anaglyphPixelShader: {
  41675. name: string;
  41676. shader: string;
  41677. };
  41678. }
  41679. declare module BABYLON {
  41680. /**
  41681. * Postprocess used to generate anaglyphic rendering
  41682. */
  41683. export class AnaglyphPostProcess extends PostProcess {
  41684. private _passedProcess;
  41685. /**
  41686. * Creates a new AnaglyphPostProcess
  41687. * @param name defines postprocess name
  41688. * @param options defines creation options or target ratio scale
  41689. * @param rigCameras defines cameras using this postprocess
  41690. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  41691. * @param engine defines hosting engine
  41692. * @param reusable defines if the postprocess will be reused multiple times per frame
  41693. */
  41694. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  41695. }
  41696. }
  41697. declare module BABYLON {
  41698. /**
  41699. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  41700. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41701. */
  41702. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  41703. /**
  41704. * Creates a new AnaglyphArcRotateCamera
  41705. * @param name defines camera name
  41706. * @param alpha defines alpha angle (in radians)
  41707. * @param beta defines beta angle (in radians)
  41708. * @param radius defines radius
  41709. * @param target defines camera target
  41710. * @param interaxialDistance defines distance between each color axis
  41711. * @param scene defines the hosting scene
  41712. */
  41713. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  41714. /**
  41715. * Gets camera class name
  41716. * @returns AnaglyphArcRotateCamera
  41717. */
  41718. getClassName(): string;
  41719. }
  41720. }
  41721. declare module BABYLON {
  41722. /**
  41723. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  41724. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41725. */
  41726. export class AnaglyphFreeCamera extends FreeCamera {
  41727. /**
  41728. * Creates a new AnaglyphFreeCamera
  41729. * @param name defines camera name
  41730. * @param position defines initial position
  41731. * @param interaxialDistance defines distance between each color axis
  41732. * @param scene defines the hosting scene
  41733. */
  41734. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41735. /**
  41736. * Gets camera class name
  41737. * @returns AnaglyphFreeCamera
  41738. */
  41739. getClassName(): string;
  41740. }
  41741. }
  41742. declare module BABYLON {
  41743. /**
  41744. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  41745. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41746. */
  41747. export class AnaglyphGamepadCamera extends GamepadCamera {
  41748. /**
  41749. * Creates a new AnaglyphGamepadCamera
  41750. * @param name defines camera name
  41751. * @param position defines initial position
  41752. * @param interaxialDistance defines distance between each color axis
  41753. * @param scene defines the hosting scene
  41754. */
  41755. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41756. /**
  41757. * Gets camera class name
  41758. * @returns AnaglyphGamepadCamera
  41759. */
  41760. getClassName(): string;
  41761. }
  41762. }
  41763. declare module BABYLON {
  41764. /**
  41765. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  41766. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  41767. */
  41768. export class AnaglyphUniversalCamera extends UniversalCamera {
  41769. /**
  41770. * Creates a new AnaglyphUniversalCamera
  41771. * @param name defines camera name
  41772. * @param position defines initial position
  41773. * @param interaxialDistance defines distance between each color axis
  41774. * @param scene defines the hosting scene
  41775. */
  41776. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  41777. /**
  41778. * Gets camera class name
  41779. * @returns AnaglyphUniversalCamera
  41780. */
  41781. getClassName(): string;
  41782. }
  41783. }
  41784. declare module BABYLON {
  41785. /** @hidden */
  41786. export var stereoscopicInterlacePixelShader: {
  41787. name: string;
  41788. shader: string;
  41789. };
  41790. }
  41791. declare module BABYLON {
  41792. /**
  41793. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  41794. */
  41795. export class StereoscopicInterlacePostProcessI extends PostProcess {
  41796. private _stepSize;
  41797. private _passedProcess;
  41798. /**
  41799. * Initializes a StereoscopicInterlacePostProcessI
  41800. * @param name The name of the effect.
  41801. * @param rigCameras The rig cameras to be appled to the post process
  41802. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  41803. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  41804. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41805. * @param engine The engine which the post process will be applied. (default: current engine)
  41806. * @param reusable If the post process can be reused on the same frame. (default: false)
  41807. */
  41808. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  41809. }
  41810. /**
  41811. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  41812. */
  41813. export class StereoscopicInterlacePostProcess extends PostProcess {
  41814. private _stepSize;
  41815. private _passedProcess;
  41816. /**
  41817. * Initializes a StereoscopicInterlacePostProcess
  41818. * @param name The name of the effect.
  41819. * @param rigCameras The rig cameras to be appled to the post process
  41820. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  41821. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  41822. * @param engine The engine which the post process will be applied. (default: current engine)
  41823. * @param reusable If the post process can be reused on the same frame. (default: false)
  41824. */
  41825. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  41826. }
  41827. }
  41828. declare module BABYLON {
  41829. /**
  41830. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  41831. * @see http://doc.babylonjs.com/features/cameras
  41832. */
  41833. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  41834. /**
  41835. * Creates a new StereoscopicArcRotateCamera
  41836. * @param name defines camera name
  41837. * @param alpha defines alpha angle (in radians)
  41838. * @param beta defines beta angle (in radians)
  41839. * @param radius defines radius
  41840. * @param target defines camera target
  41841. * @param interaxialDistance defines distance between each color axis
  41842. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41843. * @param scene defines the hosting scene
  41844. */
  41845. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41846. /**
  41847. * Gets camera class name
  41848. * @returns StereoscopicArcRotateCamera
  41849. */
  41850. getClassName(): string;
  41851. }
  41852. }
  41853. declare module BABYLON {
  41854. /**
  41855. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  41856. * @see http://doc.babylonjs.com/features/cameras
  41857. */
  41858. export class StereoscopicFreeCamera extends FreeCamera {
  41859. /**
  41860. * Creates a new StereoscopicFreeCamera
  41861. * @param name defines camera name
  41862. * @param position defines initial position
  41863. * @param interaxialDistance defines distance between each color axis
  41864. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41865. * @param scene defines the hosting scene
  41866. */
  41867. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41868. /**
  41869. * Gets camera class name
  41870. * @returns StereoscopicFreeCamera
  41871. */
  41872. getClassName(): string;
  41873. }
  41874. }
  41875. declare module BABYLON {
  41876. /**
  41877. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  41878. * @see http://doc.babylonjs.com/features/cameras
  41879. */
  41880. export class StereoscopicGamepadCamera extends GamepadCamera {
  41881. /**
  41882. * Creates a new StereoscopicGamepadCamera
  41883. * @param name defines camera name
  41884. * @param position defines initial position
  41885. * @param interaxialDistance defines distance between each color axis
  41886. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41887. * @param scene defines the hosting scene
  41888. */
  41889. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41890. /**
  41891. * Gets camera class name
  41892. * @returns StereoscopicGamepadCamera
  41893. */
  41894. getClassName(): string;
  41895. }
  41896. }
  41897. declare module BABYLON {
  41898. /**
  41899. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  41900. * @see http://doc.babylonjs.com/features/cameras
  41901. */
  41902. export class StereoscopicUniversalCamera extends UniversalCamera {
  41903. /**
  41904. * Creates a new StereoscopicUniversalCamera
  41905. * @param name defines camera name
  41906. * @param position defines initial position
  41907. * @param interaxialDistance defines distance between each color axis
  41908. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  41909. * @param scene defines the hosting scene
  41910. */
  41911. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  41912. /**
  41913. * Gets camera class name
  41914. * @returns StereoscopicUniversalCamera
  41915. */
  41916. getClassName(): string;
  41917. }
  41918. }
  41919. declare module BABYLON {
  41920. /**
  41921. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  41922. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41923. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41924. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41925. */
  41926. export class VirtualJoysticksCamera extends FreeCamera {
  41927. /**
  41928. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  41929. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  41930. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  41931. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  41932. * @param name Define the name of the camera in the scene
  41933. * @param position Define the start position of the camera in the scene
  41934. * @param scene Define the scene the camera belongs to
  41935. */
  41936. constructor(name: string, position: Vector3, scene: Scene);
  41937. /**
  41938. * Gets the current object class name.
  41939. * @return the class name
  41940. */
  41941. getClassName(): string;
  41942. }
  41943. }
  41944. declare module BABYLON {
  41945. /**
  41946. * This represents all the required metrics to create a VR camera.
  41947. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  41948. */
  41949. export class VRCameraMetrics {
  41950. /**
  41951. * Define the horizontal resolution off the screen.
  41952. */
  41953. hResolution: number;
  41954. /**
  41955. * Define the vertical resolution off the screen.
  41956. */
  41957. vResolution: number;
  41958. /**
  41959. * Define the horizontal screen size.
  41960. */
  41961. hScreenSize: number;
  41962. /**
  41963. * Define the vertical screen size.
  41964. */
  41965. vScreenSize: number;
  41966. /**
  41967. * Define the vertical screen center position.
  41968. */
  41969. vScreenCenter: number;
  41970. /**
  41971. * Define the distance of the eyes to the screen.
  41972. */
  41973. eyeToScreenDistance: number;
  41974. /**
  41975. * Define the distance between both lenses
  41976. */
  41977. lensSeparationDistance: number;
  41978. /**
  41979. * Define the distance between both viewer's eyes.
  41980. */
  41981. interpupillaryDistance: number;
  41982. /**
  41983. * Define the distortion factor of the VR postprocess.
  41984. * Please, touch with care.
  41985. */
  41986. distortionK: number[];
  41987. /**
  41988. * Define the chromatic aberration correction factors for the VR post process.
  41989. */
  41990. chromaAbCorrection: number[];
  41991. /**
  41992. * Define the scale factor of the post process.
  41993. * The smaller the better but the slower.
  41994. */
  41995. postProcessScaleFactor: number;
  41996. /**
  41997. * Define an offset for the lens center.
  41998. */
  41999. lensCenterOffset: number;
  42000. /**
  42001. * Define if the current vr camera should compensate the distortion of the lense or not.
  42002. */
  42003. compensateDistortion: boolean;
  42004. /**
  42005. * Defines if multiview should be enabled when rendering (Default: false)
  42006. */
  42007. multiviewEnabled: boolean;
  42008. /**
  42009. * Gets the rendering aspect ratio based on the provided resolutions.
  42010. */
  42011. get aspectRatio(): number;
  42012. /**
  42013. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  42014. */
  42015. get aspectRatioFov(): number;
  42016. /**
  42017. * @hidden
  42018. */
  42019. get leftHMatrix(): Matrix;
  42020. /**
  42021. * @hidden
  42022. */
  42023. get rightHMatrix(): Matrix;
  42024. /**
  42025. * @hidden
  42026. */
  42027. get leftPreViewMatrix(): Matrix;
  42028. /**
  42029. * @hidden
  42030. */
  42031. get rightPreViewMatrix(): Matrix;
  42032. /**
  42033. * Get the default VRMetrics based on the most generic setup.
  42034. * @returns the default vr metrics
  42035. */
  42036. static GetDefault(): VRCameraMetrics;
  42037. }
  42038. }
  42039. declare module BABYLON {
  42040. /** @hidden */
  42041. export var vrDistortionCorrectionPixelShader: {
  42042. name: string;
  42043. shader: string;
  42044. };
  42045. }
  42046. declare module BABYLON {
  42047. /**
  42048. * VRDistortionCorrectionPostProcess used for mobile VR
  42049. */
  42050. export class VRDistortionCorrectionPostProcess extends PostProcess {
  42051. private _isRightEye;
  42052. private _distortionFactors;
  42053. private _postProcessScaleFactor;
  42054. private _lensCenterOffset;
  42055. private _scaleIn;
  42056. private _scaleFactor;
  42057. private _lensCenter;
  42058. /**
  42059. * Initializes the VRDistortionCorrectionPostProcess
  42060. * @param name The name of the effect.
  42061. * @param camera The camera to apply the render pass to.
  42062. * @param isRightEye If this is for the right eye distortion
  42063. * @param vrMetrics All the required metrics for the VR camera
  42064. */
  42065. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  42066. }
  42067. }
  42068. declare module BABYLON {
  42069. /**
  42070. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  42071. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42072. */
  42073. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  42074. /**
  42075. * Creates a new VRDeviceOrientationArcRotateCamera
  42076. * @param name defines camera name
  42077. * @param alpha defines the camera rotation along the logitudinal axis
  42078. * @param beta defines the camera rotation along the latitudinal axis
  42079. * @param radius defines the camera distance from its target
  42080. * @param target defines the camera target
  42081. * @param scene defines the scene the camera belongs to
  42082. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42083. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42084. */
  42085. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42086. /**
  42087. * Gets camera class name
  42088. * @returns VRDeviceOrientationArcRotateCamera
  42089. */
  42090. getClassName(): string;
  42091. }
  42092. }
  42093. declare module BABYLON {
  42094. /**
  42095. * Camera used to simulate VR rendering (based on FreeCamera)
  42096. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42097. */
  42098. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  42099. /**
  42100. * Creates a new VRDeviceOrientationFreeCamera
  42101. * @param name defines camera name
  42102. * @param position defines the start position of the camera
  42103. * @param scene defines the scene the camera belongs to
  42104. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42105. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42106. */
  42107. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42108. /**
  42109. * Gets camera class name
  42110. * @returns VRDeviceOrientationFreeCamera
  42111. */
  42112. getClassName(): string;
  42113. }
  42114. }
  42115. declare module BABYLON {
  42116. /**
  42117. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  42118. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  42119. */
  42120. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  42121. /**
  42122. * Creates a new VRDeviceOrientationGamepadCamera
  42123. * @param name defines camera name
  42124. * @param position defines the start position of the camera
  42125. * @param scene defines the scene the camera belongs to
  42126. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  42127. * @param vrCameraMetrics defines the vr metrics associated to the camera
  42128. */
  42129. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  42130. /**
  42131. * Gets camera class name
  42132. * @returns VRDeviceOrientationGamepadCamera
  42133. */
  42134. getClassName(): string;
  42135. }
  42136. }
  42137. declare module BABYLON {
  42138. /** @hidden */
  42139. export var imageProcessingPixelShader: {
  42140. name: string;
  42141. shader: string;
  42142. };
  42143. }
  42144. declare module BABYLON {
  42145. /**
  42146. * ImageProcessingPostProcess
  42147. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42148. */
  42149. export class ImageProcessingPostProcess extends PostProcess {
  42150. /**
  42151. * Default configuration related to image processing available in the PBR Material.
  42152. */
  42153. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42154. /**
  42155. * Gets the image processing configuration used either in this material.
  42156. */
  42157. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  42158. /**
  42159. * Sets the Default image processing configuration used either in the this material.
  42160. *
  42161. * If sets to null, the scene one is in use.
  42162. */
  42163. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  42164. /**
  42165. * Keep track of the image processing observer to allow dispose and replace.
  42166. */
  42167. private _imageProcessingObserver;
  42168. /**
  42169. * Attaches a new image processing configuration to the PBR Material.
  42170. * @param configuration
  42171. */
  42172. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42173. /**
  42174. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42175. */
  42176. get colorCurves(): Nullable<ColorCurves>;
  42177. /**
  42178. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42179. */
  42180. set colorCurves(value: Nullable<ColorCurves>);
  42181. /**
  42182. * Gets wether the color curves effect is enabled.
  42183. */
  42184. get colorCurvesEnabled(): boolean;
  42185. /**
  42186. * Sets wether the color curves effect is enabled.
  42187. */
  42188. set colorCurvesEnabled(value: boolean);
  42189. /**
  42190. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42191. */
  42192. get colorGradingTexture(): Nullable<BaseTexture>;
  42193. /**
  42194. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42195. */
  42196. set colorGradingTexture(value: Nullable<BaseTexture>);
  42197. /**
  42198. * Gets wether the color grading effect is enabled.
  42199. */
  42200. get colorGradingEnabled(): boolean;
  42201. /**
  42202. * Gets wether the color grading effect is enabled.
  42203. */
  42204. set colorGradingEnabled(value: boolean);
  42205. /**
  42206. * Gets exposure used in the effect.
  42207. */
  42208. get exposure(): number;
  42209. /**
  42210. * Sets exposure used in the effect.
  42211. */
  42212. set exposure(value: number);
  42213. /**
  42214. * Gets wether tonemapping is enabled or not.
  42215. */
  42216. get toneMappingEnabled(): boolean;
  42217. /**
  42218. * Sets wether tonemapping is enabled or not
  42219. */
  42220. set toneMappingEnabled(value: boolean);
  42221. /**
  42222. * Gets the type of tone mapping effect.
  42223. */
  42224. get toneMappingType(): number;
  42225. /**
  42226. * Sets the type of tone mapping effect.
  42227. */
  42228. set toneMappingType(value: number);
  42229. /**
  42230. * Gets contrast used in the effect.
  42231. */
  42232. get contrast(): number;
  42233. /**
  42234. * Sets contrast used in the effect.
  42235. */
  42236. set contrast(value: number);
  42237. /**
  42238. * Gets Vignette stretch size.
  42239. */
  42240. get vignetteStretch(): number;
  42241. /**
  42242. * Sets Vignette stretch size.
  42243. */
  42244. set vignetteStretch(value: number);
  42245. /**
  42246. * Gets Vignette centre X Offset.
  42247. */
  42248. get vignetteCentreX(): number;
  42249. /**
  42250. * Sets Vignette centre X Offset.
  42251. */
  42252. set vignetteCentreX(value: number);
  42253. /**
  42254. * Gets Vignette centre Y Offset.
  42255. */
  42256. get vignetteCentreY(): number;
  42257. /**
  42258. * Sets Vignette centre Y Offset.
  42259. */
  42260. set vignetteCentreY(value: number);
  42261. /**
  42262. * Gets Vignette weight or intensity of the vignette effect.
  42263. */
  42264. get vignetteWeight(): number;
  42265. /**
  42266. * Sets Vignette weight or intensity of the vignette effect.
  42267. */
  42268. set vignetteWeight(value: number);
  42269. /**
  42270. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42271. * if vignetteEnabled is set to true.
  42272. */
  42273. get vignetteColor(): Color4;
  42274. /**
  42275. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42276. * if vignetteEnabled is set to true.
  42277. */
  42278. set vignetteColor(value: Color4);
  42279. /**
  42280. * Gets Camera field of view used by the Vignette effect.
  42281. */
  42282. get vignetteCameraFov(): number;
  42283. /**
  42284. * Sets Camera field of view used by the Vignette effect.
  42285. */
  42286. set vignetteCameraFov(value: number);
  42287. /**
  42288. * Gets the vignette blend mode allowing different kind of effect.
  42289. */
  42290. get vignetteBlendMode(): number;
  42291. /**
  42292. * Sets the vignette blend mode allowing different kind of effect.
  42293. */
  42294. set vignetteBlendMode(value: number);
  42295. /**
  42296. * Gets wether the vignette effect is enabled.
  42297. */
  42298. get vignetteEnabled(): boolean;
  42299. /**
  42300. * Sets wether the vignette effect is enabled.
  42301. */
  42302. set vignetteEnabled(value: boolean);
  42303. private _fromLinearSpace;
  42304. /**
  42305. * Gets wether the input of the processing is in Gamma or Linear Space.
  42306. */
  42307. get fromLinearSpace(): boolean;
  42308. /**
  42309. * Sets wether the input of the processing is in Gamma or Linear Space.
  42310. */
  42311. set fromLinearSpace(value: boolean);
  42312. /**
  42313. * Defines cache preventing GC.
  42314. */
  42315. private _defines;
  42316. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42317. /**
  42318. * "ImageProcessingPostProcess"
  42319. * @returns "ImageProcessingPostProcess"
  42320. */
  42321. getClassName(): string;
  42322. protected _updateParameters(): void;
  42323. dispose(camera?: Camera): void;
  42324. }
  42325. }
  42326. declare module BABYLON {
  42327. /**
  42328. * Class containing static functions to help procedurally build meshes
  42329. */
  42330. export class GroundBuilder {
  42331. /**
  42332. * Creates a ground mesh
  42333. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42334. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42335. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42336. * @param name defines the name of the mesh
  42337. * @param options defines the options used to create the mesh
  42338. * @param scene defines the hosting scene
  42339. * @returns the ground mesh
  42340. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42341. */
  42342. static CreateGround(name: string, options: {
  42343. width?: number;
  42344. height?: number;
  42345. subdivisions?: number;
  42346. subdivisionsX?: number;
  42347. subdivisionsY?: number;
  42348. updatable?: boolean;
  42349. }, scene: any): Mesh;
  42350. /**
  42351. * Creates a tiled ground mesh
  42352. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42353. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42354. * * 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
  42355. * * 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
  42356. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42357. * @param name defines the name of the mesh
  42358. * @param options defines the options used to create the mesh
  42359. * @param scene defines the hosting scene
  42360. * @returns the tiled ground mesh
  42361. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42362. */
  42363. static CreateTiledGround(name: string, options: {
  42364. xmin: number;
  42365. zmin: number;
  42366. xmax: number;
  42367. zmax: number;
  42368. subdivisions?: {
  42369. w: number;
  42370. h: number;
  42371. };
  42372. precision?: {
  42373. w: number;
  42374. h: number;
  42375. };
  42376. updatable?: boolean;
  42377. }, scene?: Nullable<Scene>): Mesh;
  42378. /**
  42379. * Creates a ground mesh from a height map
  42380. * * The parameter `url` sets the URL of the height map image resource.
  42381. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42382. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42383. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42384. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42385. * * 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.
  42386. * * 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).
  42387. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42388. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42389. * @param name defines the name of the mesh
  42390. * @param url defines the url to the height map
  42391. * @param options defines the options used to create the mesh
  42392. * @param scene defines the hosting scene
  42393. * @returns the ground mesh
  42394. * @see https://doc.babylonjs.com/babylon101/height_map
  42395. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42396. */
  42397. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42398. width?: number;
  42399. height?: number;
  42400. subdivisions?: number;
  42401. minHeight?: number;
  42402. maxHeight?: number;
  42403. colorFilter?: Color3;
  42404. alphaFilter?: number;
  42405. updatable?: boolean;
  42406. onReady?: (mesh: GroundMesh) => void;
  42407. }, scene?: Nullable<Scene>): GroundMesh;
  42408. }
  42409. }
  42410. declare module BABYLON {
  42411. /**
  42412. * Class containing static functions to help procedurally build meshes
  42413. */
  42414. export class TorusBuilder {
  42415. /**
  42416. * Creates a torus mesh
  42417. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42418. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42419. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42420. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42421. * * 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
  42422. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42423. * @param name defines the name of the mesh
  42424. * @param options defines the options used to create the mesh
  42425. * @param scene defines the hosting scene
  42426. * @returns the torus mesh
  42427. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42428. */
  42429. static CreateTorus(name: string, options: {
  42430. diameter?: number;
  42431. thickness?: number;
  42432. tessellation?: number;
  42433. updatable?: boolean;
  42434. sideOrientation?: number;
  42435. frontUVs?: Vector4;
  42436. backUVs?: Vector4;
  42437. }, scene: any): Mesh;
  42438. }
  42439. }
  42440. declare module BABYLON {
  42441. /**
  42442. * Class containing static functions to help procedurally build meshes
  42443. */
  42444. export class CylinderBuilder {
  42445. /**
  42446. * Creates a cylinder or a cone mesh
  42447. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42448. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42449. * * 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.
  42450. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42451. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42452. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42453. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42454. * * 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).
  42455. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42456. * * 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).
  42457. * * 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
  42458. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42459. * * 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
  42460. * * 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.
  42461. * * If `enclose` is false, a ring surface is one element.
  42462. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42463. * * 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
  42464. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42465. * * 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
  42466. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42467. * @param name defines the name of the mesh
  42468. * @param options defines the options used to create the mesh
  42469. * @param scene defines the hosting scene
  42470. * @returns the cylinder mesh
  42471. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42472. */
  42473. static CreateCylinder(name: string, options: {
  42474. height?: number;
  42475. diameterTop?: number;
  42476. diameterBottom?: number;
  42477. diameter?: number;
  42478. tessellation?: number;
  42479. subdivisions?: number;
  42480. arc?: number;
  42481. faceColors?: Color4[];
  42482. faceUV?: Vector4[];
  42483. updatable?: boolean;
  42484. hasRings?: boolean;
  42485. enclose?: boolean;
  42486. cap?: number;
  42487. sideOrientation?: number;
  42488. frontUVs?: Vector4;
  42489. backUVs?: Vector4;
  42490. }, scene: any): Mesh;
  42491. }
  42492. }
  42493. declare module BABYLON {
  42494. /**
  42495. * States of the webXR experience
  42496. */
  42497. export enum WebXRState {
  42498. /**
  42499. * Transitioning to being in XR mode
  42500. */
  42501. ENTERING_XR = 0,
  42502. /**
  42503. * Transitioning to non XR mode
  42504. */
  42505. EXITING_XR = 1,
  42506. /**
  42507. * In XR mode and presenting
  42508. */
  42509. IN_XR = 2,
  42510. /**
  42511. * Not entered XR mode
  42512. */
  42513. NOT_IN_XR = 3
  42514. }
  42515. /**
  42516. * Abstraction of the XR render target
  42517. */
  42518. export interface WebXRRenderTarget extends IDisposable {
  42519. /**
  42520. * xrpresent context of the canvas which can be used to display/mirror xr content
  42521. */
  42522. canvasContext: WebGLRenderingContext;
  42523. /**
  42524. * xr layer for the canvas
  42525. */
  42526. xrLayer: Nullable<XRWebGLLayer>;
  42527. /**
  42528. * Initializes the xr layer for the session
  42529. * @param xrSession xr session
  42530. * @returns a promise that will resolve once the XR Layer has been created
  42531. */
  42532. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  42533. }
  42534. }
  42535. declare module BABYLON {
  42536. /**
  42537. * COnfiguration object for WebXR output canvas
  42538. */
  42539. export class WebXRManagedOutputCanvasOptions {
  42540. /**
  42541. * Options for this XR Layer output
  42542. */
  42543. canvasOptions?: XRWebGLLayerOptions;
  42544. /**
  42545. * CSS styling for a newly created canvas (if not provided)
  42546. */
  42547. newCanvasCssStyle?: string;
  42548. /**
  42549. * An optional canvas in case you wish to create it yourself and provide it here.
  42550. * If not provided, a new canvas will be created
  42551. */
  42552. canvasElement?: HTMLCanvasElement;
  42553. /**
  42554. * Get the default values of the configuration object
  42555. * @returns default values of this configuration object
  42556. */
  42557. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  42558. }
  42559. /**
  42560. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42561. */
  42562. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  42563. private _options;
  42564. private _engine;
  42565. private _canvas;
  42566. /**
  42567. * Rendering context of the canvas which can be used to display/mirror xr content
  42568. */
  42569. canvasContext: WebGLRenderingContext;
  42570. /**
  42571. * xr layer for the canvas
  42572. */
  42573. xrLayer: Nullable<XRWebGLLayer>;
  42574. /**
  42575. * Initializes the xr layer for the session
  42576. * @param xrSession xr session
  42577. * @returns a promise that will resolve once the XR Layer has been created
  42578. */
  42579. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  42580. /**
  42581. * Initializes the canvas to be added/removed upon entering/exiting xr
  42582. * @param _xrSessionManager The XR Session manager
  42583. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  42584. */
  42585. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  42586. /**
  42587. * Disposes of the object
  42588. */
  42589. dispose(): void;
  42590. private _setManagedOutputCanvas;
  42591. private _addCanvas;
  42592. private _removeCanvas;
  42593. }
  42594. }
  42595. declare module BABYLON {
  42596. /**
  42597. * Manages an XRSession to work with Babylon's engine
  42598. * @see https://doc.babylonjs.com/how_to/webxr
  42599. */
  42600. export class WebXRSessionManager implements IDisposable {
  42601. /** The scene which the session should be created for */
  42602. scene: Scene;
  42603. /**
  42604. * Fires every time a new xrFrame arrives which can be used to update the camera
  42605. */
  42606. onXRFrameObservable: Observable<XRFrame>;
  42607. /**
  42608. * Fires when the xr session is ended either by the device or manually done
  42609. */
  42610. onXRSessionEnded: Observable<any>;
  42611. /**
  42612. * Fires when the xr session is ended either by the device or manually done
  42613. */
  42614. onXRSessionInit: Observable<XRSession>;
  42615. /**
  42616. * Fires when the reference space changed
  42617. */
  42618. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  42619. /**
  42620. * Underlying xr session
  42621. */
  42622. session: XRSession;
  42623. /**
  42624. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  42625. * or get the offset the player is currently at.
  42626. */
  42627. viewerReferenceSpace: XRReferenceSpace;
  42628. private _referenceSpace;
  42629. /**
  42630. * The current reference space used in this session. This reference space can constantly change!
  42631. * It is mainly used to offset the camera's position.
  42632. */
  42633. get referenceSpace(): XRReferenceSpace;
  42634. /**
  42635. * Set a new reference space and triggers the observable
  42636. */
  42637. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  42638. /**
  42639. * The base reference space from which the session started. good if you want to reset your
  42640. * reference space
  42641. */
  42642. baseReferenceSpace: XRReferenceSpace;
  42643. /**
  42644. * Used just in case of a failure to initialize an immersive session.
  42645. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  42646. */
  42647. defaultHeightCompensation: number;
  42648. /**
  42649. * Current XR frame
  42650. */
  42651. currentFrame: Nullable<XRFrame>;
  42652. /** WebXR timestamp updated every frame */
  42653. currentTimestamp: number;
  42654. private _xrNavigator;
  42655. private baseLayer;
  42656. private _rttProvider;
  42657. private _sessionEnded;
  42658. /**
  42659. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42660. * @param scene The scene which the session should be created for
  42661. */
  42662. constructor(
  42663. /** The scene which the session should be created for */
  42664. scene: Scene);
  42665. /**
  42666. * Initializes the manager
  42667. * After initialization enterXR can be called to start an XR session
  42668. * @returns Promise which resolves after it is initialized
  42669. */
  42670. initializeAsync(): Promise<void>;
  42671. /**
  42672. * Initializes an xr session
  42673. * @param xrSessionMode mode to initialize
  42674. * @param xrSessionInit defines optional and required values to pass to the session builder
  42675. * @returns a promise which will resolve once the session has been initialized
  42676. */
  42677. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  42678. /**
  42679. * Sets the reference space on the xr session
  42680. * @param referenceSpaceType space to set
  42681. * @returns a promise that will resolve once the reference space has been set
  42682. */
  42683. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  42684. /**
  42685. * Resets the reference space to the one started the session
  42686. */
  42687. resetReferenceSpace(): void;
  42688. /**
  42689. * Updates the render state of the session
  42690. * @param state state to set
  42691. * @returns a promise that resolves once the render state has been updated
  42692. */
  42693. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42694. /**
  42695. * Starts rendering to the xr layer
  42696. */
  42697. runXRRenderLoop(): void;
  42698. /**
  42699. * Gets the correct render target texture to be rendered this frame for this eye
  42700. * @param eye the eye for which to get the render target
  42701. * @returns the render target for the specified eye
  42702. */
  42703. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  42704. /**
  42705. * Stops the xrSession and restores the renderloop
  42706. * @returns Promise which resolves after it exits XR
  42707. */
  42708. exitXRAsync(): Promise<void>;
  42709. /**
  42710. * Checks if a session would be supported for the creation options specified
  42711. * @param sessionMode session mode to check if supported eg. immersive-vr
  42712. * @returns A Promise that resolves to true if supported and false if not
  42713. */
  42714. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  42715. /**
  42716. * Creates a WebXRRenderTarget object for the XR session
  42717. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  42718. * @param options optional options to provide when creating a new render target
  42719. * @returns a WebXR render target to which the session can render
  42720. */
  42721. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  42722. /**
  42723. * @hidden
  42724. * Converts the render layer of xrSession to a render target
  42725. * @param session session to create render target for
  42726. * @param scene scene the new render target should be created for
  42727. * @param baseLayer the webgl layer to create the render target for
  42728. */
  42729. static _CreateRenderTargetTextureFromSession(_session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42730. /**
  42731. * Disposes of the session manager
  42732. */
  42733. dispose(): void;
  42734. /**
  42735. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  42736. * @param sessionMode defines the session to test
  42737. * @returns a promise with boolean as final value
  42738. */
  42739. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  42740. }
  42741. }
  42742. declare module BABYLON {
  42743. /**
  42744. * WebXR Camera which holds the views for the xrSession
  42745. * @see https://doc.babylonjs.com/how_to/webxr_camera
  42746. */
  42747. export class WebXRCamera extends FreeCamera {
  42748. private _xrSessionManager;
  42749. private _firstFrame;
  42750. private _referenceQuaternion;
  42751. private _referencedPosition;
  42752. private _xrInvPositionCache;
  42753. private _xrInvQuaternionCache;
  42754. /**
  42755. * Should position compensation execute on first frame.
  42756. * This is used when copying the position from a native (non XR) camera
  42757. */
  42758. compensateOnFirstFrame: boolean;
  42759. /**
  42760. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42761. * @param name the name of the camera
  42762. * @param scene the scene to add the camera to
  42763. * @param _xrSessionManager a constructed xr session manager
  42764. */
  42765. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  42766. /**
  42767. * Return the user's height, unrelated to the current ground.
  42768. * This will be the y position of this camera, when ground level is 0.
  42769. */
  42770. get realWorldHeight(): number;
  42771. /** @hidden */
  42772. _updateForDualEyeDebugging(): void;
  42773. /**
  42774. * Sets this camera's transformation based on a non-vr camera
  42775. * @param otherCamera the non-vr camera to copy the transformation from
  42776. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  42777. */
  42778. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  42779. private _updateFromXRSession;
  42780. private _updateNumberOfRigCameras;
  42781. private _updateReferenceSpace;
  42782. private _updateReferenceSpaceOffset;
  42783. }
  42784. }
  42785. declare module BABYLON {
  42786. /**
  42787. * Defining the interface required for a (webxr) feature
  42788. */
  42789. export interface IWebXRFeature extends IDisposable {
  42790. /**
  42791. * Is this feature attached
  42792. */
  42793. attached: boolean;
  42794. /**
  42795. * Should auto-attach be disabled?
  42796. */
  42797. disableAutoAttach: boolean;
  42798. /**
  42799. * Attach the feature to the session
  42800. * Will usually be called by the features manager
  42801. *
  42802. * @param force should attachment be forced (even when already attached)
  42803. * @returns true if successful.
  42804. */
  42805. attach(force?: boolean): boolean;
  42806. /**
  42807. * Detach the feature from the session
  42808. * Will usually be called by the features manager
  42809. *
  42810. * @returns true if successful.
  42811. */
  42812. detach(): boolean;
  42813. }
  42814. /**
  42815. * A list of the currently available features without referencing them
  42816. */
  42817. export class WebXRFeatureName {
  42818. /**
  42819. * The name of the hit test feature
  42820. */
  42821. static HIT_TEST: string;
  42822. /**
  42823. * The name of the anchor system feature
  42824. */
  42825. static ANCHOR_SYSTEM: string;
  42826. /**
  42827. * The name of the background remover feature
  42828. */
  42829. static BACKGROUND_REMOVER: string;
  42830. /**
  42831. * The name of the pointer selection feature
  42832. */
  42833. static POINTER_SELECTION: string;
  42834. /**
  42835. * The name of the teleportation feature
  42836. */
  42837. static TELEPORTATION: string;
  42838. /**
  42839. * The name of the plane detection feature
  42840. */
  42841. static PLANE_DETECTION: string;
  42842. /**
  42843. * physics impostors for xr controllers feature
  42844. */
  42845. static PHYSICS_CONTROLLERS: string;
  42846. }
  42847. /**
  42848. * Defining the constructor of a feature. Used to register the modules.
  42849. */
  42850. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  42851. /**
  42852. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  42853. * It is mainly used in AR sessions.
  42854. *
  42855. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  42856. */
  42857. export class WebXRFeaturesManager implements IDisposable {
  42858. private _xrSessionManager;
  42859. private static readonly _AvailableFeatures;
  42860. /**
  42861. * Used to register a module. After calling this function a developer can use this feature in the scene.
  42862. * Mainly used internally.
  42863. *
  42864. * @param featureName the name of the feature to register
  42865. * @param constructorFunction the function used to construct the module
  42866. * @param version the (babylon) version of the module
  42867. * @param stable is that a stable version of this module
  42868. */
  42869. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  42870. /**
  42871. * Returns a constructor of a specific feature.
  42872. *
  42873. * @param featureName the name of the feature to construct
  42874. * @param version the version of the feature to load
  42875. * @param xrSessionManager the xrSessionManager. Used to construct the module
  42876. * @param options optional options provided to the module.
  42877. * @returns a function that, when called, will return a new instance of this feature
  42878. */
  42879. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  42880. /**
  42881. * Return the latest unstable version of this feature
  42882. * @param featureName the name of the feature to search
  42883. * @returns the version number. if not found will return -1
  42884. */
  42885. static GetLatestVersionOfFeature(featureName: string): number;
  42886. /**
  42887. * Return the latest stable version of this feature
  42888. * @param featureName the name of the feature to search
  42889. * @returns the version number. if not found will return -1
  42890. */
  42891. static GetStableVersionOfFeature(featureName: string): number;
  42892. /**
  42893. * Can be used to return the list of features currently registered
  42894. *
  42895. * @returns an Array of available features
  42896. */
  42897. static GetAvailableFeatures(): string[];
  42898. /**
  42899. * Gets the versions available for a specific feature
  42900. * @param featureName the name of the feature
  42901. * @returns an array with the available versions
  42902. */
  42903. static GetAvailableVersions(featureName: string): string[];
  42904. private _features;
  42905. /**
  42906. * constructs a new features manages.
  42907. *
  42908. * @param _xrSessionManager an instance of WebXRSessionManager
  42909. */
  42910. constructor(_xrSessionManager: WebXRSessionManager);
  42911. /**
  42912. * 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.
  42913. * If used twice, the old version will be disposed and a new one will be constructed. This way you can re-enable with different configuration.
  42914. *
  42915. * @param featureName the name of the feature to load or the class of the feature
  42916. * @param version optional version to load. if not provided the latest version will be enabled
  42917. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  42918. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  42919. * @returns a new constructed feature or throws an error if feature not found.
  42920. */
  42921. enableFeature(featureName: string | {
  42922. Name: string;
  42923. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  42924. /**
  42925. * Used to disable an already-enabled feature
  42926. * The feature will be disposed and will be recreated once enabled.
  42927. * @param featureName the feature to disable
  42928. * @returns true if disable was successful
  42929. */
  42930. disableFeature(featureName: string | {
  42931. Name: string;
  42932. }): boolean;
  42933. /**
  42934. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  42935. * Can be used during a session to start a feature
  42936. * @param featureName the name of feature to attach
  42937. */
  42938. attachFeature(featureName: string): void;
  42939. /**
  42940. * Can be used inside a session or when the session ends to detach a specific feature
  42941. * @param featureName the name of the feature to detach
  42942. */
  42943. detachFeature(featureName: string): void;
  42944. /**
  42945. * Get the list of enabled features
  42946. * @returns an array of enabled features
  42947. */
  42948. getEnabledFeatures(): string[];
  42949. /**
  42950. * get the implementation of an enabled feature.
  42951. * @param featureName the name of the feature to load
  42952. * @returns the feature class, if found
  42953. */
  42954. getEnabledFeature(featureName: string): IWebXRFeature;
  42955. /**
  42956. * dispose this features manager
  42957. */
  42958. dispose(): void;
  42959. }
  42960. }
  42961. declare module BABYLON {
  42962. /**
  42963. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  42964. * @see https://doc.babylonjs.com/how_to/webxr
  42965. */
  42966. export class WebXRExperienceHelper implements IDisposable {
  42967. private scene;
  42968. /**
  42969. * Camera used to render xr content
  42970. */
  42971. camera: WebXRCamera;
  42972. /**
  42973. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42974. */
  42975. state: WebXRState;
  42976. private _setState;
  42977. /**
  42978. * Fires when the state of the experience helper has changed
  42979. */
  42980. onStateChangedObservable: Observable<WebXRState>;
  42981. /**
  42982. * Observers registered here will be triggered after the camera's initial transformation is set
  42983. * This can be used to set a different ground level or an extra rotation.
  42984. *
  42985. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  42986. * to the position set after this observable is done executing.
  42987. */
  42988. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  42989. /** Session manager used to keep track of xr session */
  42990. sessionManager: WebXRSessionManager;
  42991. /** A features manager for this xr session */
  42992. featuresManager: WebXRFeaturesManager;
  42993. private _nonVRCamera;
  42994. private _originalSceneAutoClear;
  42995. private _supported;
  42996. /**
  42997. * Creates the experience helper
  42998. * @param scene the scene to attach the experience helper to
  42999. * @returns a promise for the experience helper
  43000. */
  43001. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43002. /**
  43003. * Creates a WebXRExperienceHelper
  43004. * @param scene The scene the helper should be created in
  43005. */
  43006. private constructor();
  43007. /**
  43008. * Exits XR mode and returns the scene to its original state
  43009. * @returns promise that resolves after xr mode has exited
  43010. */
  43011. exitXRAsync(): Promise<void>;
  43012. /**
  43013. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43014. * @param sessionMode options for the XR session
  43015. * @param referenceSpaceType frame of reference of the XR session
  43016. * @param renderTarget the output canvas that will be used to enter XR mode
  43017. * @returns promise that resolves after xr mode has entered
  43018. */
  43019. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  43020. /**
  43021. * Disposes of the experience helper
  43022. */
  43023. dispose(): void;
  43024. private _nonXRToXRCamera;
  43025. }
  43026. }
  43027. declare module BABYLON {
  43028. /**
  43029. * X-Y values for axes in WebXR
  43030. */
  43031. export interface IWebXRMotionControllerAxesValue {
  43032. /**
  43033. * The value of the x axis
  43034. */
  43035. x: number;
  43036. /**
  43037. * The value of the y-axis
  43038. */
  43039. y: number;
  43040. }
  43041. /**
  43042. * changed / previous values for the values of this component
  43043. */
  43044. export interface IWebXRMotionControllerComponentChangesValues<T> {
  43045. /**
  43046. * current (this frame) value
  43047. */
  43048. current: T;
  43049. /**
  43050. * previous (last change) value
  43051. */
  43052. previous: T;
  43053. }
  43054. /**
  43055. * Represents changes in the component between current frame and last values recorded
  43056. */
  43057. export interface IWebXRMotionControllerComponentChanges {
  43058. /**
  43059. * will be populated with previous and current values if touched changed
  43060. */
  43061. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43062. /**
  43063. * will be populated with previous and current values if pressed changed
  43064. */
  43065. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  43066. /**
  43067. * will be populated with previous and current values if value changed
  43068. */
  43069. value?: IWebXRMotionControllerComponentChangesValues<number>;
  43070. /**
  43071. * will be populated with previous and current values if axes changed
  43072. */
  43073. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  43074. }
  43075. /**
  43076. * This class represents a single component (for example button or thumbstick) of a motion controller
  43077. */
  43078. export class WebXRControllerComponent implements IDisposable {
  43079. /**
  43080. * the id of this component
  43081. */
  43082. id: string;
  43083. /**
  43084. * the type of the component
  43085. */
  43086. type: MotionControllerComponentType;
  43087. private _buttonIndex;
  43088. private _axesIndices;
  43089. /**
  43090. * Thumbstick component type
  43091. */
  43092. static THUMBSTICK: MotionControllerComponentType;
  43093. /**
  43094. * Touchpad component type
  43095. */
  43096. static TOUCHPAD: MotionControllerComponentType;
  43097. /**
  43098. * trigger component type
  43099. */
  43100. static TRIGGER: MotionControllerComponentType;
  43101. /**
  43102. * squeeze component type
  43103. */
  43104. static SQUEEZE: MotionControllerComponentType;
  43105. /**
  43106. * button component type
  43107. */
  43108. static BUTTON: MotionControllerComponentType;
  43109. /**
  43110. * Observers registered here will be triggered when the state of a button changes
  43111. * State change is either pressed / touched / value
  43112. */
  43113. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  43114. /**
  43115. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  43116. * the axes data changes
  43117. */
  43118. onAxisValueChangedObservable: Observable<{
  43119. x: number;
  43120. y: number;
  43121. }>;
  43122. private _currentValue;
  43123. private _touched;
  43124. private _pressed;
  43125. private _axes;
  43126. private _changes;
  43127. private _hasChanges;
  43128. /**
  43129. * Return whether or not the component changed the last frame
  43130. */
  43131. get hasChanges(): boolean;
  43132. /**
  43133. * Creates a new component for a motion controller.
  43134. * It is created by the motion controller itself
  43135. *
  43136. * @param id the id of this component
  43137. * @param type the type of the component
  43138. * @param _buttonIndex index in the buttons array of the gamepad
  43139. * @param _axesIndices indices of the values in the axes array of the gamepad
  43140. */
  43141. constructor(
  43142. /**
  43143. * the id of this component
  43144. */
  43145. id: string,
  43146. /**
  43147. * the type of the component
  43148. */
  43149. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  43150. /**
  43151. * Get the current value of this component
  43152. */
  43153. get value(): number;
  43154. /**
  43155. * is the button currently pressed
  43156. */
  43157. get pressed(): boolean;
  43158. /**
  43159. * is the button currently touched
  43160. */
  43161. get touched(): boolean;
  43162. /**
  43163. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  43164. */
  43165. get axes(): IWebXRMotionControllerAxesValue;
  43166. /**
  43167. * Get the changes. Elements will be populated only if they changed with their previous and current value
  43168. */
  43169. get changes(): IWebXRMotionControllerComponentChanges;
  43170. /**
  43171. * Is this component a button (hence - pressable)
  43172. * @returns true if can be pressed
  43173. */
  43174. isButton(): boolean;
  43175. /**
  43176. * Are there axes correlating to this component
  43177. * @return true is axes data is available
  43178. */
  43179. isAxes(): boolean;
  43180. /**
  43181. * update this component using the gamepad object it is in. Called on every frame
  43182. * @param nativeController the native gamepad controller object
  43183. */
  43184. update(nativeController: IMinimalMotionControllerObject): void;
  43185. /**
  43186. * Dispose this component
  43187. */
  43188. dispose(): void;
  43189. }
  43190. }
  43191. declare module BABYLON {
  43192. /**
  43193. * Class used to represent data loading progression
  43194. */
  43195. export class SceneLoaderProgressEvent {
  43196. /** defines if data length to load can be evaluated */
  43197. readonly lengthComputable: boolean;
  43198. /** defines the loaded data length */
  43199. readonly loaded: number;
  43200. /** defines the data length to load */
  43201. readonly total: number;
  43202. /**
  43203. * Create a new progress event
  43204. * @param lengthComputable defines if data length to load can be evaluated
  43205. * @param loaded defines the loaded data length
  43206. * @param total defines the data length to load
  43207. */
  43208. constructor(
  43209. /** defines if data length to load can be evaluated */
  43210. lengthComputable: boolean,
  43211. /** defines the loaded data length */
  43212. loaded: number,
  43213. /** defines the data length to load */
  43214. total: number);
  43215. /**
  43216. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43217. * @param event defines the source event
  43218. * @returns a new SceneLoaderProgressEvent
  43219. */
  43220. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43221. }
  43222. /**
  43223. * Interface used by SceneLoader plugins to define supported file extensions
  43224. */
  43225. export interface ISceneLoaderPluginExtensions {
  43226. /**
  43227. * Defines the list of supported extensions
  43228. */
  43229. [extension: string]: {
  43230. isBinary: boolean;
  43231. };
  43232. }
  43233. /**
  43234. * Interface used by SceneLoader plugin factory
  43235. */
  43236. export interface ISceneLoaderPluginFactory {
  43237. /**
  43238. * Defines the name of the factory
  43239. */
  43240. name: string;
  43241. /**
  43242. * Function called to create a new plugin
  43243. * @return the new plugin
  43244. */
  43245. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43246. /**
  43247. * The callback that returns true if the data can be directly loaded.
  43248. * @param data string containing the file data
  43249. * @returns if the data can be loaded directly
  43250. */
  43251. canDirectLoad?(data: string): boolean;
  43252. }
  43253. /**
  43254. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  43255. */
  43256. export interface ISceneLoaderPluginBase {
  43257. /**
  43258. * The friendly name of this plugin.
  43259. */
  43260. name: string;
  43261. /**
  43262. * The file extensions supported by this plugin.
  43263. */
  43264. extensions: string | ISceneLoaderPluginExtensions;
  43265. /**
  43266. * The callback called when loading from a url.
  43267. * @param scene scene loading this url
  43268. * @param url url to load
  43269. * @param onSuccess callback called when the file successfully loads
  43270. * @param onProgress callback called while file is loading (if the server supports this mode)
  43271. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43272. * @param onError callback called when the file fails to load
  43273. * @returns a file request object
  43274. */
  43275. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43276. /**
  43277. * The callback called when loading from a file object.
  43278. * @param scene scene loading this file
  43279. * @param file defines the file to load
  43280. * @param onSuccess defines the callback to call when data is loaded
  43281. * @param onProgress defines the callback to call during loading process
  43282. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43283. * @param onError defines the callback to call when an error occurs
  43284. * @returns a file request object
  43285. */
  43286. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  43287. /**
  43288. * The callback that returns true if the data can be directly loaded.
  43289. * @param data string containing the file data
  43290. * @returns if the data can be loaded directly
  43291. */
  43292. canDirectLoad?(data: string): boolean;
  43293. /**
  43294. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  43295. * @param scene scene loading this data
  43296. * @param data string containing the data
  43297. * @returns data to pass to the plugin
  43298. */
  43299. directLoad?(scene: Scene, data: string): any;
  43300. /**
  43301. * The callback that allows custom handling of the root url based on the response url.
  43302. * @param rootUrl the original root url
  43303. * @param responseURL the response url if available
  43304. * @returns the new root url
  43305. */
  43306. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  43307. }
  43308. /**
  43309. * Interface used to define a SceneLoader plugin
  43310. */
  43311. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  43312. /**
  43313. * Import meshes into a scene.
  43314. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43315. * @param scene The scene to import into
  43316. * @param data The data to import
  43317. * @param rootUrl The root url for scene and resources
  43318. * @param meshes The meshes array to import into
  43319. * @param particleSystems The particle systems array to import into
  43320. * @param skeletons The skeletons array to import into
  43321. * @param onError The callback when import fails
  43322. * @returns True if successful or false otherwise
  43323. */
  43324. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43325. /**
  43326. * Load into a scene.
  43327. * @param scene The scene to load into
  43328. * @param data The data to import
  43329. * @param rootUrl The root url for scene and resources
  43330. * @param onError The callback when import fails
  43331. * @returns True if successful or false otherwise
  43332. */
  43333. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43334. /**
  43335. * Load into an asset container.
  43336. * @param scene The scene to load into
  43337. * @param data The data to import
  43338. * @param rootUrl The root url for scene and resources
  43339. * @param onError The callback when import fails
  43340. * @returns The loaded asset container
  43341. */
  43342. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43343. }
  43344. /**
  43345. * Interface used to define an async SceneLoader plugin
  43346. */
  43347. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  43348. /**
  43349. * Import meshes into a scene.
  43350. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43351. * @param scene The scene to import into
  43352. * @param data The data to import
  43353. * @param rootUrl The root url for scene and resources
  43354. * @param onProgress The callback when the load progresses
  43355. * @param fileName Defines the name of the file to load
  43356. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43357. */
  43358. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43359. meshes: AbstractMesh[];
  43360. particleSystems: IParticleSystem[];
  43361. skeletons: Skeleton[];
  43362. animationGroups: AnimationGroup[];
  43363. }>;
  43364. /**
  43365. * Load into a scene.
  43366. * @param scene The scene to load into
  43367. * @param data The data to import
  43368. * @param rootUrl The root url for scene and resources
  43369. * @param onProgress The callback when the load progresses
  43370. * @param fileName Defines the name of the file to load
  43371. * @returns Nothing
  43372. */
  43373. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43374. /**
  43375. * Load into an asset container.
  43376. * @param scene The scene to load into
  43377. * @param data The data to import
  43378. * @param rootUrl The root url for scene and resources
  43379. * @param onProgress The callback when the load progresses
  43380. * @param fileName Defines the name of the file to load
  43381. * @returns The loaded asset container
  43382. */
  43383. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43384. }
  43385. /**
  43386. * Mode that determines how to handle old animation groups before loading new ones.
  43387. */
  43388. export enum SceneLoaderAnimationGroupLoadingMode {
  43389. /**
  43390. * Reset all old animations to initial state then dispose them.
  43391. */
  43392. Clean = 0,
  43393. /**
  43394. * Stop all old animations.
  43395. */
  43396. Stop = 1,
  43397. /**
  43398. * Restart old animations from first frame.
  43399. */
  43400. Sync = 2,
  43401. /**
  43402. * Old animations remains untouched.
  43403. */
  43404. NoSync = 3
  43405. }
  43406. /**
  43407. * Class used to load scene from various file formats using registered plugins
  43408. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43409. */
  43410. export class SceneLoader {
  43411. /**
  43412. * No logging while loading
  43413. */
  43414. static readonly NO_LOGGING: number;
  43415. /**
  43416. * Minimal logging while loading
  43417. */
  43418. static readonly MINIMAL_LOGGING: number;
  43419. /**
  43420. * Summary logging while loading
  43421. */
  43422. static readonly SUMMARY_LOGGING: number;
  43423. /**
  43424. * Detailled logging while loading
  43425. */
  43426. static readonly DETAILED_LOGGING: number;
  43427. /**
  43428. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43429. */
  43430. static get ForceFullSceneLoadingForIncremental(): boolean;
  43431. static set ForceFullSceneLoadingForIncremental(value: boolean);
  43432. /**
  43433. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43434. */
  43435. static get ShowLoadingScreen(): boolean;
  43436. static set ShowLoadingScreen(value: boolean);
  43437. /**
  43438. * Defines the current logging level (while loading the scene)
  43439. * @ignorenaming
  43440. */
  43441. static get loggingLevel(): number;
  43442. static set loggingLevel(value: number);
  43443. /**
  43444. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43445. */
  43446. static get CleanBoneMatrixWeights(): boolean;
  43447. static set CleanBoneMatrixWeights(value: boolean);
  43448. /**
  43449. * Event raised when a plugin is used to load a scene
  43450. */
  43451. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43452. private static _registeredPlugins;
  43453. private static _getDefaultPlugin;
  43454. private static _getPluginForExtension;
  43455. private static _getPluginForDirectLoad;
  43456. private static _getPluginForFilename;
  43457. private static _getDirectLoad;
  43458. private static _loadData;
  43459. private static _getFileInfo;
  43460. /**
  43461. * Gets a plugin that can load the given extension
  43462. * @param extension defines the extension to load
  43463. * @returns a plugin or null if none works
  43464. */
  43465. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43466. /**
  43467. * Gets a boolean indicating that the given extension can be loaded
  43468. * @param extension defines the extension to load
  43469. * @returns true if the extension is supported
  43470. */
  43471. static IsPluginForExtensionAvailable(extension: string): boolean;
  43472. /**
  43473. * Adds a new plugin to the list of registered plugins
  43474. * @param plugin defines the plugin to add
  43475. */
  43476. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43477. /**
  43478. * Import meshes into a scene
  43479. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43480. * @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)
  43481. * @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)
  43482. * @param scene the instance of BABYLON.Scene to append to
  43483. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43484. * @param onProgress a callback with a progress event for each file being loaded
  43485. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43486. * @param pluginExtension the extension used to determine the plugin
  43487. * @returns The loaded plugin
  43488. */
  43489. 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>;
  43490. /**
  43491. * Import meshes into a scene
  43492. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43493. * @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)
  43494. * @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)
  43495. * @param scene the instance of BABYLON.Scene to append to
  43496. * @param onProgress a callback with a progress event for each file being loaded
  43497. * @param pluginExtension the extension used to determine the plugin
  43498. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43499. */
  43500. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43501. meshes: AbstractMesh[];
  43502. particleSystems: IParticleSystem[];
  43503. skeletons: Skeleton[];
  43504. animationGroups: AnimationGroup[];
  43505. }>;
  43506. /**
  43507. * Load a scene
  43508. * @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)
  43509. * @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)
  43510. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43511. * @param onSuccess a callback with the scene when import succeeds
  43512. * @param onProgress a callback with a progress event for each file being loaded
  43513. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43514. * @param pluginExtension the extension used to determine the plugin
  43515. * @returns The loaded plugin
  43516. */
  43517. 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>;
  43518. /**
  43519. * Load a scene
  43520. * @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)
  43521. * @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)
  43522. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43523. * @param onProgress a callback with a progress event for each file being loaded
  43524. * @param pluginExtension the extension used to determine the plugin
  43525. * @returns The loaded scene
  43526. */
  43527. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43528. /**
  43529. * Append a scene
  43530. * @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)
  43531. * @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)
  43532. * @param scene is the instance of BABYLON.Scene to append to
  43533. * @param onSuccess a callback with the scene when import succeeds
  43534. * @param onProgress a callback with a progress event for each file being loaded
  43535. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43536. * @param pluginExtension the extension used to determine the plugin
  43537. * @returns The loaded plugin
  43538. */
  43539. 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>;
  43540. /**
  43541. * Append a scene
  43542. * @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)
  43543. * @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)
  43544. * @param scene is the instance of BABYLON.Scene to append to
  43545. * @param onProgress a callback with a progress event for each file being loaded
  43546. * @param pluginExtension the extension used to determine the plugin
  43547. * @returns The given scene
  43548. */
  43549. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43550. /**
  43551. * Load a scene into an asset container
  43552. * @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)
  43553. * @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)
  43554. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43555. * @param onSuccess a callback with the scene when import succeeds
  43556. * @param onProgress a callback with a progress event for each file being loaded
  43557. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43558. * @param pluginExtension the extension used to determine the plugin
  43559. * @returns The loaded plugin
  43560. */
  43561. 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>;
  43562. /**
  43563. * Load a scene into an asset container
  43564. * @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)
  43565. * @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)
  43566. * @param scene is the instance of Scene to append to
  43567. * @param onProgress a callback with a progress event for each file being loaded
  43568. * @param pluginExtension the extension used to determine the plugin
  43569. * @returns The loaded asset container
  43570. */
  43571. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43572. /**
  43573. * Import animations from a file into a scene
  43574. * @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)
  43575. * @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)
  43576. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43577. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43578. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43579. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43580. * @param onSuccess a callback with the scene when import succeeds
  43581. * @param onProgress a callback with a progress event for each file being loaded
  43582. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43583. */
  43584. 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;
  43585. /**
  43586. * Import animations from a file into a scene
  43587. * @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)
  43588. * @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)
  43589. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43590. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  43591. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  43592. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  43593. * @param onSuccess a callback with the scene when import succeeds
  43594. * @param onProgress a callback with a progress event for each file being loaded
  43595. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43596. * @returns the updated scene with imported animations
  43597. */
  43598. 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>;
  43599. }
  43600. }
  43601. declare module BABYLON {
  43602. /**
  43603. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  43604. */
  43605. export type MotionControllerHandness = "none" | "left" | "right";
  43606. /**
  43607. * The type of components available in motion controllers.
  43608. * This is not the name of the component.
  43609. */
  43610. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  43611. /**
  43612. * The state of a controller component
  43613. */
  43614. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  43615. /**
  43616. * The schema of motion controller layout.
  43617. * No object will be initialized using this interface
  43618. * This is used just to define the profile.
  43619. */
  43620. export interface IMotionControllerLayout {
  43621. /**
  43622. * Defines the main button component id
  43623. */
  43624. selectComponentId: string;
  43625. /**
  43626. * Available components (unsorted)
  43627. */
  43628. components: {
  43629. /**
  43630. * A map of component Ids
  43631. */
  43632. [componentId: string]: {
  43633. /**
  43634. * The type of input the component outputs
  43635. */
  43636. type: MotionControllerComponentType;
  43637. /**
  43638. * The indices of this component in the gamepad object
  43639. */
  43640. gamepadIndices: {
  43641. /**
  43642. * Index of button
  43643. */
  43644. button?: number;
  43645. /**
  43646. * If available, index of x-axis
  43647. */
  43648. xAxis?: number;
  43649. /**
  43650. * If available, index of y-axis
  43651. */
  43652. yAxis?: number;
  43653. };
  43654. /**
  43655. * The mesh's root node name
  43656. */
  43657. rootNodeName: string;
  43658. /**
  43659. * Animation definitions for this model
  43660. */
  43661. visualResponses: {
  43662. [stateKey: string]: {
  43663. /**
  43664. * What property will be animated
  43665. */
  43666. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  43667. /**
  43668. * What states influence this visual reponse
  43669. */
  43670. states: MotionControllerComponentStateType[];
  43671. /**
  43672. * Type of animation - movement or visibility
  43673. */
  43674. valueNodeProperty: "transform" | "visibility";
  43675. /**
  43676. * Base node name to move. Its position will be calculated according to the min and max nodes
  43677. */
  43678. valueNodeName?: string;
  43679. /**
  43680. * Minimum movement node
  43681. */
  43682. minNodeName?: string;
  43683. /**
  43684. * Max movement node
  43685. */
  43686. maxNodeName?: string;
  43687. };
  43688. };
  43689. /**
  43690. * If touch enabled, what is the name of node to display user feedback
  43691. */
  43692. touchPointNodeName?: string;
  43693. };
  43694. };
  43695. /**
  43696. * Is it xr standard mapping or not
  43697. */
  43698. gamepadMapping: "" | "xr-standard";
  43699. /**
  43700. * Base root node of this entire model
  43701. */
  43702. rootNodeName: string;
  43703. /**
  43704. * Path to load the assets. Usually relative to the base path
  43705. */
  43706. assetPath: string;
  43707. }
  43708. /**
  43709. * A definition for the layout map in the input profile
  43710. */
  43711. export interface IMotionControllerLayoutMap {
  43712. /**
  43713. * Layouts with handness type as a key
  43714. */
  43715. [handness: string]: IMotionControllerLayout;
  43716. }
  43717. /**
  43718. * The XR Input profile schema
  43719. * Profiles can be found here:
  43720. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  43721. */
  43722. export interface IMotionControllerProfile {
  43723. /**
  43724. * The id of this profile
  43725. * correlates to the profile(s) in the xrInput.profiles array
  43726. */
  43727. profileId: string;
  43728. /**
  43729. * fallback profiles for this profileId
  43730. */
  43731. fallbackProfileIds: string[];
  43732. /**
  43733. * The layout map, with handness as key
  43734. */
  43735. layouts: IMotionControllerLayoutMap;
  43736. }
  43737. /**
  43738. * A helper-interface for the 3 meshes needed for controller button animation
  43739. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  43740. */
  43741. export interface IMotionControllerButtonMeshMap {
  43742. /**
  43743. * The mesh that will be changed when value changes
  43744. */
  43745. valueMesh: AbstractMesh;
  43746. /**
  43747. * the mesh that defines the pressed value mesh position.
  43748. * This is used to find the max-position of this button
  43749. */
  43750. pressedMesh: AbstractMesh;
  43751. /**
  43752. * the mesh that defines the unpressed value mesh position.
  43753. * This is used to find the min (or initial) position of this button
  43754. */
  43755. unpressedMesh: AbstractMesh;
  43756. }
  43757. /**
  43758. * A helper-interface for the 3 meshes needed for controller axis animation.
  43759. * This will be expanded when touchpad animations are fully supported
  43760. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  43761. */
  43762. export interface IMotionControllerMeshMap {
  43763. /**
  43764. * The mesh that will be changed when axis value changes
  43765. */
  43766. valueMesh: AbstractMesh;
  43767. /**
  43768. * the mesh that defines the minimum value mesh position.
  43769. */
  43770. minMesh?: AbstractMesh;
  43771. /**
  43772. * the mesh that defines the maximum value mesh position.
  43773. */
  43774. maxMesh?: AbstractMesh;
  43775. }
  43776. /**
  43777. * The elements needed for change-detection of the gamepad objects in motion controllers
  43778. */
  43779. export interface IMinimalMotionControllerObject {
  43780. /**
  43781. * An array of available buttons
  43782. */
  43783. buttons: Array<{
  43784. /**
  43785. * Value of the button/trigger
  43786. */
  43787. value: number;
  43788. /**
  43789. * If the button/trigger is currently touched
  43790. */
  43791. touched: boolean;
  43792. /**
  43793. * If the button/trigger is currently pressed
  43794. */
  43795. pressed: boolean;
  43796. }>;
  43797. /**
  43798. * Available axes of this controller
  43799. */
  43800. axes: number[];
  43801. }
  43802. /**
  43803. * An Abstract Motion controller
  43804. * This class receives an xrInput and a profile layout and uses those to initialize the components
  43805. * Each component has an observable to check for changes in value and state
  43806. */
  43807. export abstract class WebXRAbstractMotionController implements IDisposable {
  43808. protected scene: Scene;
  43809. protected layout: IMotionControllerLayout;
  43810. /**
  43811. * The gamepad object correlating to this controller
  43812. */
  43813. gamepadObject: IMinimalMotionControllerObject;
  43814. /**
  43815. * handness (left/right/none) of this controller
  43816. */
  43817. handness: MotionControllerHandness;
  43818. /**
  43819. * The profile id of this motion controller
  43820. */
  43821. abstract profileId: string;
  43822. /**
  43823. * A map of components (WebXRControllerComponent) in this motion controller
  43824. * Components have a ComponentType and can also have both button and axis definitions
  43825. */
  43826. readonly components: {
  43827. [id: string]: WebXRControllerComponent;
  43828. };
  43829. /**
  43830. * Observers registered here will be triggered when the model of this controller is done loading
  43831. */
  43832. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  43833. /**
  43834. * The root mesh of the model. It is null if the model was not yet initialized
  43835. */
  43836. rootMesh: Nullable<AbstractMesh>;
  43837. /**
  43838. * Disable the model's animation. Can be set at any time.
  43839. */
  43840. disableAnimation: boolean;
  43841. private _modelReady;
  43842. /**
  43843. * constructs a new abstract motion controller
  43844. * @param scene the scene to which the model of the controller will be added
  43845. * @param layout The profile layout to load
  43846. * @param gamepadObject The gamepad object correlating to this controller
  43847. * @param handness handness (left/right/none) of this controller
  43848. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  43849. */
  43850. constructor(scene: Scene, layout: IMotionControllerLayout,
  43851. /**
  43852. * The gamepad object correlating to this controller
  43853. */
  43854. gamepadObject: IMinimalMotionControllerObject,
  43855. /**
  43856. * handness (left/right/none) of this controller
  43857. */
  43858. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  43859. private _initComponent;
  43860. /**
  43861. * Update this model using the current XRFrame
  43862. * @param xrFrame the current xr frame to use and update the model
  43863. */
  43864. updateFromXRFrame(xrFrame: XRFrame): void;
  43865. /**
  43866. * Get the list of components available in this motion controller
  43867. * @returns an array of strings correlating to available components
  43868. */
  43869. getComponentIds(): string[];
  43870. /**
  43871. * Get the main (Select) component of this controller as defined in the layout
  43872. * @returns the main component of this controller
  43873. */
  43874. getMainComponent(): WebXRControllerComponent;
  43875. /**
  43876. * get a component based an its component id as defined in layout.components
  43877. * @param id the id of the component
  43878. * @returns the component correlates to the id or undefined if not found
  43879. */
  43880. getComponent(id: string): WebXRControllerComponent;
  43881. /**
  43882. * Get the first component of specific type
  43883. * @param type type of component to find
  43884. * @return a controller component or null if not found
  43885. */
  43886. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  43887. /**
  43888. * Returns all components of specific type
  43889. * @param type the type to search for
  43890. * @return an array of components with this type
  43891. */
  43892. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  43893. /**
  43894. * Loads the model correlating to this controller
  43895. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  43896. * @returns A promise fulfilled with the result of the model loading
  43897. */
  43898. loadModel(): Promise<boolean>;
  43899. /**
  43900. * Update the model itself with the current frame data
  43901. * @param xrFrame the frame to use for updating the model mesh
  43902. */
  43903. protected updateModel(xrFrame: XRFrame): void;
  43904. /**
  43905. * Moves the axis on the controller mesh based on its current state
  43906. * @param axis the index of the axis
  43907. * @param axisValue the value of the axis which determines the meshes new position
  43908. * @hidden
  43909. */
  43910. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  43911. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  43912. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  43913. private _getGenericFilenameAndPath;
  43914. private _getGenericParentMesh;
  43915. /**
  43916. * Get the filename and path for this controller's model
  43917. * @returns a map of filename and path
  43918. */
  43919. protected abstract _getFilenameAndPath(): {
  43920. filename: string;
  43921. path: string;
  43922. };
  43923. /**
  43924. * This function will be called after the model was successfully loaded and can be used
  43925. * for mesh transformations before it is available for the user
  43926. * @param meshes the loaded meshes
  43927. */
  43928. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  43929. /**
  43930. * Set the root mesh for this controller. Important for the WebXR controller class
  43931. * @param meshes the loaded meshes
  43932. */
  43933. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  43934. /**
  43935. * A function executed each frame that updates the mesh (if needed)
  43936. * @param xrFrame the current xrFrame
  43937. */
  43938. protected abstract _updateModel(xrFrame: XRFrame): void;
  43939. /**
  43940. * This function is called before the mesh is loaded. It checks for loading constraints.
  43941. * For example, this function can check if the GLB loader is available
  43942. * If this function returns false, the generic controller will be loaded instead
  43943. * @returns Is the client ready to load the mesh
  43944. */
  43945. protected abstract _getModelLoadingConstraints(): boolean;
  43946. /**
  43947. * Dispose this controller, the model mesh and all its components
  43948. */
  43949. dispose(): void;
  43950. }
  43951. }
  43952. declare module BABYLON {
  43953. /**
  43954. * A generic trigger-only motion controller for WebXR
  43955. */
  43956. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  43957. /**
  43958. * Static version of the profile id of this controller
  43959. */
  43960. static ProfileId: string;
  43961. profileId: string;
  43962. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  43963. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  43964. protected _updateModel(): void;
  43965. protected _getFilenameAndPath(): {
  43966. filename: string;
  43967. path: string;
  43968. };
  43969. protected _setRootMesh(meshes: AbstractMesh[]): void;
  43970. protected _getModelLoadingConstraints(): boolean;
  43971. }
  43972. }
  43973. declare module BABYLON {
  43974. /**
  43975. * Class containing static functions to help procedurally build meshes
  43976. */
  43977. export class SphereBuilder {
  43978. /**
  43979. * Creates a sphere mesh
  43980. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  43981. * * 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`)
  43982. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  43983. * * 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
  43984. * * 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)
  43985. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43986. * * 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
  43987. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43988. * @param name defines the name of the mesh
  43989. * @param options defines the options used to create the mesh
  43990. * @param scene defines the hosting scene
  43991. * @returns the sphere mesh
  43992. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  43993. */
  43994. static CreateSphere(name: string, options: {
  43995. segments?: number;
  43996. diameter?: number;
  43997. diameterX?: number;
  43998. diameterY?: number;
  43999. diameterZ?: number;
  44000. arc?: number;
  44001. slice?: number;
  44002. sideOrientation?: number;
  44003. frontUVs?: Vector4;
  44004. backUVs?: Vector4;
  44005. updatable?: boolean;
  44006. }, scene?: Nullable<Scene>): Mesh;
  44007. }
  44008. }
  44009. declare module BABYLON {
  44010. /**
  44011. * A profiled motion controller has its profile loaded from an online repository.
  44012. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  44013. */
  44014. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  44015. private _repositoryUrl;
  44016. /**
  44017. * The profile ID of this controller. Will be populated when the controller initializes.
  44018. */
  44019. profileId: string;
  44020. private _buttonMeshMapping;
  44021. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  44022. protected _getFilenameAndPath(): {
  44023. filename: string;
  44024. path: string;
  44025. };
  44026. private _touchDots;
  44027. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  44028. protected _setRootMesh(meshes: AbstractMesh[]): void;
  44029. protected _updateModel(_xrFrame: XRFrame): void;
  44030. protected _getModelLoadingConstraints(): boolean;
  44031. dispose(): void;
  44032. }
  44033. }
  44034. declare module BABYLON {
  44035. /**
  44036. * A construction function type to create a new controller based on an xrInput object
  44037. */
  44038. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  44039. /**
  44040. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  44041. *
  44042. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  44043. * it should be replaced with auto-loaded controllers.
  44044. *
  44045. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  44046. */
  44047. export class WebXRMotionControllerManager {
  44048. /**
  44049. * The base URL of the online controller repository. Can be changed at any time.
  44050. */
  44051. static BaseRepositoryUrl: string;
  44052. /**
  44053. * Use the online repository, or use only locally-defined controllers
  44054. */
  44055. static UseOnlineRepository: boolean;
  44056. /**
  44057. * Which repository gets priority - local or online
  44058. */
  44059. static PrioritizeOnlineRepository: boolean;
  44060. private static _AvailableControllers;
  44061. private static _Fallbacks;
  44062. /**
  44063. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  44064. *
  44065. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  44066. *
  44067. * @param type the profile type to register
  44068. * @param constructFunction the function to be called when loading this profile
  44069. */
  44070. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  44071. /**
  44072. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  44073. * The order of search:
  44074. *
  44075. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  44076. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  44077. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  44078. * 4) return the generic trigger controller if none were found
  44079. *
  44080. * @param xrInput the xrInput to which a new controller is initialized
  44081. * @param scene the scene to which the model will be added
  44082. * @param forceProfile force a certain profile for this controller
  44083. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  44084. */
  44085. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  44086. private static _LoadProfilesFromAvailableControllers;
  44087. private static _ProfilesList;
  44088. private static _ProfileLoadingPromises;
  44089. private static _LoadProfileFromRepository;
  44090. /**
  44091. * Clear the cache used for profile loading and reload when requested again
  44092. */
  44093. static ClearProfilesCache(): void;
  44094. /**
  44095. * Will update the list of profiles available in the repository
  44096. * @return a promise that resolves to a map of profiles available online
  44097. */
  44098. static UpdateProfilesList(): Promise<{
  44099. [profile: string]: string;
  44100. }>;
  44101. /**
  44102. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  44103. * @param profileId the profile to which a fallback needs to be found
  44104. * @return an array with corresponding fallback profiles
  44105. */
  44106. static FindFallbackWithProfileId(profileId: string): string[];
  44107. /**
  44108. * Register a fallback to a specific profile.
  44109. * @param profileId the profileId that will receive the fallbacks
  44110. * @param fallbacks A list of fallback profiles
  44111. */
  44112. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  44113. /**
  44114. * Register the default fallbacks.
  44115. * This function is called automatically when this file is imported.
  44116. */
  44117. static DefaultFallbacks(): void;
  44118. }
  44119. }
  44120. declare module BABYLON {
  44121. /**
  44122. * Configuration options for the WebXR controller creation
  44123. */
  44124. export interface IWebXRControllerOptions {
  44125. /**
  44126. * Force a specific controller type for this controller.
  44127. * This can be used when creating your own profile or when testing different controllers
  44128. */
  44129. forceControllerProfile?: string;
  44130. /**
  44131. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  44132. */
  44133. doNotLoadControllerMesh?: boolean;
  44134. /**
  44135. * Should the controller mesh be animated when a user interacts with it
  44136. * The pressed buttons / thumbstick and touchpad animations will be disabled
  44137. */
  44138. disableMotionControllerAnimation?: boolean;
  44139. }
  44140. /**
  44141. * Represents an XR controller
  44142. */
  44143. export class WebXRInputSource {
  44144. private _scene;
  44145. /** The underlying input source for the controller */
  44146. inputSource: XRInputSource;
  44147. private _options;
  44148. /**
  44149. * 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
  44150. */
  44151. grip?: AbstractMesh;
  44152. /**
  44153. * Pointer which can be used to select objects or attach a visible laser to
  44154. */
  44155. pointer: AbstractMesh;
  44156. /**
  44157. * If available, this is the gamepad object related to this controller.
  44158. * Using this object it is possible to get click events and trackpad changes of the
  44159. * webxr controller that is currently being used.
  44160. */
  44161. motionController?: WebXRAbstractMotionController;
  44162. /**
  44163. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  44164. */
  44165. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  44166. /**
  44167. * Will be triggered when the mesh associated with the motion controller is done loading.
  44168. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  44169. * A shortened version of controller -> motion controller -> on mesh loaded.
  44170. */
  44171. onMeshLoadedObservable: Observable<AbstractMesh>;
  44172. /**
  44173. * Event that fires when the controller is removed/disposed.
  44174. * The object provided as event data is this controller, after associated assets were disposed.
  44175. * uniqueId is still available.
  44176. */
  44177. onDisposeObservable: Observable<WebXRInputSource>;
  44178. private _tmpQuaternion;
  44179. private _tmpVector;
  44180. private _uniqueId;
  44181. /**
  44182. * Creates the controller
  44183. * @see https://doc.babylonjs.com/how_to/webxr
  44184. * @param _scene the scene which the controller should be associated to
  44185. * @param inputSource the underlying input source for the controller
  44186. * @param _options options for this controller creation
  44187. */
  44188. constructor(_scene: Scene,
  44189. /** The underlying input source for the controller */
  44190. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  44191. /**
  44192. * Get this controllers unique id
  44193. */
  44194. get uniqueId(): string;
  44195. /**
  44196. * Updates the controller pose based on the given XRFrame
  44197. * @param xrFrame xr frame to update the pose with
  44198. * @param referenceSpace reference space to use
  44199. */
  44200. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  44201. /**
  44202. * Gets a world space ray coming from the pointer or grip
  44203. * @param result the resulting ray
  44204. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  44205. */
  44206. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  44207. /**
  44208. * Disposes of the object
  44209. */
  44210. dispose(): void;
  44211. }
  44212. }
  44213. declare module BABYLON {
  44214. /**
  44215. * The schema for initialization options of the XR Input class
  44216. */
  44217. export interface IWebXRInputOptions {
  44218. /**
  44219. * If set to true no model will be automatically loaded
  44220. */
  44221. doNotLoadControllerMeshes?: boolean;
  44222. /**
  44223. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  44224. * If not found, the xr input profile data will be used.
  44225. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  44226. */
  44227. forceInputProfile?: string;
  44228. /**
  44229. * Do not send a request to the controlle repository to load the profile.
  44230. *
  44231. * Instead, use the controllers available in babylon itself.
  44232. */
  44233. disableOnlineControllerRepository?: boolean;
  44234. /**
  44235. * A custom URL for the controllers repository
  44236. */
  44237. customControllersRepositoryURL?: string;
  44238. /**
  44239. * Should the controller model's components not move according to the user input
  44240. */
  44241. disableControllerAnimation?: boolean;
  44242. }
  44243. /**
  44244. * XR input used to track XR inputs such as controllers/rays
  44245. */
  44246. export class WebXRInput implements IDisposable {
  44247. /**
  44248. * the xr session manager for this session
  44249. */
  44250. xrSessionManager: WebXRSessionManager;
  44251. /**
  44252. * the WebXR camera for this session. Mainly used for teleportation
  44253. */
  44254. xrCamera: WebXRCamera;
  44255. private readonly options;
  44256. /**
  44257. * XR controllers being tracked
  44258. */
  44259. controllers: Array<WebXRInputSource>;
  44260. private _frameObserver;
  44261. private _sessionEndedObserver;
  44262. private _sessionInitObserver;
  44263. /**
  44264. * Event when a controller has been connected/added
  44265. */
  44266. onControllerAddedObservable: Observable<WebXRInputSource>;
  44267. /**
  44268. * Event when a controller has been removed/disconnected
  44269. */
  44270. onControllerRemovedObservable: Observable<WebXRInputSource>;
  44271. /**
  44272. * Initializes the WebXRInput
  44273. * @param xrSessionManager the xr session manager for this session
  44274. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  44275. * @param options = initialization options for this xr input
  44276. */
  44277. constructor(
  44278. /**
  44279. * the xr session manager for this session
  44280. */
  44281. xrSessionManager: WebXRSessionManager,
  44282. /**
  44283. * the WebXR camera for this session. Mainly used for teleportation
  44284. */
  44285. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  44286. private _onInputSourcesChange;
  44287. private _addAndRemoveControllers;
  44288. /**
  44289. * Disposes of the object
  44290. */
  44291. dispose(): void;
  44292. }
  44293. }
  44294. declare module BABYLON {
  44295. /**
  44296. * This is the base class for all WebXR features.
  44297. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  44298. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  44299. */
  44300. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  44301. protected _xrSessionManager: WebXRSessionManager;
  44302. /**
  44303. * Construct a new (abstract) webxr feature
  44304. * @param _xrSessionManager the xr session manager for this feature
  44305. */
  44306. constructor(_xrSessionManager: WebXRSessionManager);
  44307. private _attached;
  44308. private _removeOnDetach;
  44309. /**
  44310. * Is this feature attached
  44311. */
  44312. get attached(): boolean;
  44313. /**
  44314. * Should auto-attach be disabled?
  44315. */
  44316. disableAutoAttach: boolean;
  44317. /**
  44318. * attach this feature
  44319. *
  44320. * @param force should attachment be forced (even when already attached)
  44321. * @returns true if successful, false is failed or already attached
  44322. */
  44323. attach(force?: boolean): boolean;
  44324. /**
  44325. * detach this feature.
  44326. *
  44327. * @returns true if successful, false if failed or already detached
  44328. */
  44329. detach(): boolean;
  44330. /**
  44331. * Dispose this feature and all of the resources attached
  44332. */
  44333. dispose(): void;
  44334. /**
  44335. * Code in this function will be executed on each xrFrame received from the browser.
  44336. * This function will not execute after the feature is detached.
  44337. * @param _xrFrame the current frame
  44338. */
  44339. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  44340. /**
  44341. * This is used to register callbacks that will automatically be removed when detach is called.
  44342. * @param observable the observable to which the observer will be attached
  44343. * @param callback the callback to register
  44344. */
  44345. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  44346. }
  44347. }
  44348. declare module BABYLON {
  44349. /**
  44350. * Renders a layer on top of an existing scene
  44351. */
  44352. export class UtilityLayerRenderer implements IDisposable {
  44353. /** the original scene that will be rendered on top of */
  44354. originalScene: Scene;
  44355. private _pointerCaptures;
  44356. private _lastPointerEvents;
  44357. private static _DefaultUtilityLayer;
  44358. private static _DefaultKeepDepthUtilityLayer;
  44359. private _sharedGizmoLight;
  44360. private _renderCamera;
  44361. /**
  44362. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44363. * @returns the camera that is used when rendering the utility layer
  44364. */
  44365. getRenderCamera(): Camera;
  44366. /**
  44367. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44368. * @param cam the camera that should be used when rendering the utility layer
  44369. */
  44370. setRenderCamera(cam: Nullable<Camera>): void;
  44371. /**
  44372. * @hidden
  44373. * Light which used by gizmos to get light shading
  44374. */
  44375. _getSharedGizmoLight(): HemisphericLight;
  44376. /**
  44377. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44378. */
  44379. pickUtilitySceneFirst: boolean;
  44380. /**
  44381. * 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)
  44382. */
  44383. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  44384. /**
  44385. * 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)
  44386. */
  44387. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  44388. /**
  44389. * The scene that is rendered on top of the original scene
  44390. */
  44391. utilityLayerScene: Scene;
  44392. /**
  44393. * If the utility layer should automatically be rendered on top of existing scene
  44394. */
  44395. shouldRender: boolean;
  44396. /**
  44397. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44398. */
  44399. onlyCheckPointerDownEvents: boolean;
  44400. /**
  44401. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44402. */
  44403. processAllEvents: boolean;
  44404. /**
  44405. * Observable raised when the pointer move from the utility layer scene to the main scene
  44406. */
  44407. onPointerOutObservable: Observable<number>;
  44408. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44409. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44410. private _afterRenderObserver;
  44411. private _sceneDisposeObserver;
  44412. private _originalPointerObserver;
  44413. /**
  44414. * Instantiates a UtilityLayerRenderer
  44415. * @param originalScene the original scene that will be rendered on top of
  44416. * @param handleEvents boolean indicating if the utility layer should handle events
  44417. */
  44418. constructor(
  44419. /** the original scene that will be rendered on top of */
  44420. originalScene: Scene, handleEvents?: boolean);
  44421. private _notifyObservers;
  44422. /**
  44423. * Renders the utility layers scene on top of the original scene
  44424. */
  44425. render(): void;
  44426. /**
  44427. * Disposes of the renderer
  44428. */
  44429. dispose(): void;
  44430. private _updateCamera;
  44431. }
  44432. }
  44433. declare module BABYLON {
  44434. /**
  44435. * Options interface for the pointer selection module
  44436. */
  44437. export interface IWebXRControllerPointerSelectionOptions {
  44438. /**
  44439. * the xr input to use with this pointer selection
  44440. */
  44441. xrInput: WebXRInput;
  44442. /**
  44443. * Different button type to use instead of the main component
  44444. */
  44445. overrideButtonId?: string;
  44446. /**
  44447. * The amount of time in miliseconds it takes between pick found something to a pointer down event.
  44448. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  44449. * 3000 means 3 seconds between pointing at something and selecting it
  44450. */
  44451. timeToSelect?: number;
  44452. /**
  44453. * 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)
  44454. * If not disabled, the last picked point will be used to execute a pointer up event
  44455. * If disabled, pointer up event will be triggered right after the pointer down event.
  44456. * Used in screen and gaze target ray mode only
  44457. */
  44458. disablePointerUpOnTouchOut: boolean;
  44459. /**
  44460. * For gaze mode (time to select instead of press)
  44461. */
  44462. forceGazeMode: boolean;
  44463. /**
  44464. * 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
  44465. * to start a new countdown to the pointer down event.
  44466. * Defaults to 1.
  44467. */
  44468. gazeModePointerMovedFactor?: number;
  44469. /**
  44470. * Should meshes created here be added to a utility layer or the main scene
  44471. */
  44472. useUtilityLayer?: boolean;
  44473. /**
  44474. * if provided, this scene will be used to render meshes.
  44475. */
  44476. customUtilityLayerScene?: Scene;
  44477. }
  44478. /**
  44479. * A module that will enable pointer selection for motion controllers of XR Input Sources
  44480. */
  44481. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  44482. private readonly _options;
  44483. /**
  44484. * The module's name
  44485. */
  44486. static readonly Name: string;
  44487. /**
  44488. * The (Babylon) version of this module.
  44489. * This is an integer representing the implementation version.
  44490. * This number does not correspond to the webxr specs version
  44491. */
  44492. static readonly Version: number;
  44493. /**
  44494. * This color will be set to the laser pointer when selection is triggered
  44495. */
  44496. laserPointerPickedColor: Color3;
  44497. /**
  44498. * This color will be applied to the selection ring when selection is triggered
  44499. */
  44500. selectionMeshPickedColor: Color3;
  44501. /**
  44502. * default color of the selection ring
  44503. */
  44504. selectionMeshDefaultColor: Color3;
  44505. /**
  44506. * Default color of the laser pointer
  44507. */
  44508. lasterPointerDefaultColor: Color3;
  44509. /**
  44510. * Should the laser pointer be displayed
  44511. */
  44512. displayLaserPointer: boolean;
  44513. /**
  44514. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  44515. */
  44516. displaySelectionMesh: boolean;
  44517. /**
  44518. * Disable lighting on the laser pointer (so it will always be visible)
  44519. */
  44520. disablePointerLighting: boolean;
  44521. /**
  44522. * Disable lighting on the selection mesh (so it will always be visible)
  44523. */
  44524. disableSelectionMeshLighting: boolean;
  44525. private static _idCounter;
  44526. private _tmpRay;
  44527. private _controllers;
  44528. private _scene;
  44529. /**
  44530. * constructs a new background remover module
  44531. * @param _xrSessionManager the session manager for this module
  44532. * @param _options read-only options to be used in this module
  44533. */
  44534. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  44535. /**
  44536. * attach this feature
  44537. * Will usually be called by the features manager
  44538. *
  44539. * @returns true if successful.
  44540. */
  44541. attach(): boolean;
  44542. /**
  44543. * detach this feature.
  44544. * Will usually be called by the features manager
  44545. *
  44546. * @returns true if successful.
  44547. */
  44548. detach(): boolean;
  44549. /**
  44550. * Get the xr controller that correlates to the pointer id in the pointer event
  44551. *
  44552. * @param id the pointer id to search for
  44553. * @returns the controller that correlates to this id or null if not found
  44554. */
  44555. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  44556. protected _onXRFrame(_xrFrame: XRFrame): void;
  44557. private _attachController;
  44558. private _attachScreenRayMode;
  44559. private _attachGazeMode;
  44560. private _tmpVectorForPickCompare;
  44561. private _pickingMoved;
  44562. private _attachTrackedPointerRayMode;
  44563. private _detachController;
  44564. private _generateNewMeshPair;
  44565. private _convertNormalToDirectionOfRay;
  44566. private _updatePointerDistance;
  44567. }
  44568. }
  44569. declare module BABYLON {
  44570. /**
  44571. * Button which can be used to enter a different mode of XR
  44572. */
  44573. export class WebXREnterExitUIButton {
  44574. /** button element */
  44575. element: HTMLElement;
  44576. /** XR initialization options for the button */
  44577. sessionMode: XRSessionMode;
  44578. /** Reference space type */
  44579. referenceSpaceType: XRReferenceSpaceType;
  44580. /**
  44581. * Creates a WebXREnterExitUIButton
  44582. * @param element button element
  44583. * @param sessionMode XR initialization session mode
  44584. * @param referenceSpaceType the type of reference space to be used
  44585. */
  44586. constructor(
  44587. /** button element */
  44588. element: HTMLElement,
  44589. /** XR initialization options for the button */
  44590. sessionMode: XRSessionMode,
  44591. /** Reference space type */
  44592. referenceSpaceType: XRReferenceSpaceType);
  44593. /**
  44594. * Overwritable function which can be used to update the button's visuals when the state changes
  44595. * @param activeButton the current active button in the UI
  44596. */
  44597. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  44598. }
  44599. /**
  44600. * Options to create the webXR UI
  44601. */
  44602. export class WebXREnterExitUIOptions {
  44603. /**
  44604. * Context to enter xr with
  44605. */
  44606. renderTarget?: Nullable<WebXRRenderTarget>;
  44607. /**
  44608. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  44609. */
  44610. customButtons?: Array<WebXREnterExitUIButton>;
  44611. /**
  44612. * A session mode to use when creating the default button.
  44613. * Default is immersive-vr
  44614. */
  44615. sessionMode?: XRSessionMode;
  44616. /**
  44617. * A reference space type to use when creating the default button.
  44618. * Default is local-floor
  44619. */
  44620. referenceSpaceType?: XRReferenceSpaceType;
  44621. }
  44622. /**
  44623. * UI to allow the user to enter/exit XR mode
  44624. */
  44625. export class WebXREnterExitUI implements IDisposable {
  44626. private scene;
  44627. /** version of the options passed to this UI */
  44628. options: WebXREnterExitUIOptions;
  44629. private _overlay;
  44630. private _buttons;
  44631. private _activeButton;
  44632. /**
  44633. * Fired every time the active button is changed.
  44634. *
  44635. * When xr is entered via a button that launches xr that button will be the callback parameter
  44636. *
  44637. * When exiting xr the callback parameter will be null)
  44638. */
  44639. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  44640. /**
  44641. * Creates UI to allow the user to enter/exit XR mode
  44642. * @param scene the scene to add the ui to
  44643. * @param helper the xr experience helper to enter/exit xr with
  44644. * @param options options to configure the UI
  44645. * @returns the created ui
  44646. */
  44647. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  44648. /**
  44649. *
  44650. * @param scene babylon scene object to use
  44651. * @param options (read-only) version of the options passed to this UI
  44652. */
  44653. private constructor();
  44654. private _updateButtons;
  44655. /**
  44656. * Disposes of the object
  44657. */
  44658. dispose(): void;
  44659. }
  44660. }
  44661. declare module BABYLON {
  44662. /**
  44663. * Class containing static functions to help procedurally build meshes
  44664. */
  44665. export class LinesBuilder {
  44666. /**
  44667. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  44668. * * 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
  44669. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  44670. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  44671. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  44672. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  44673. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44674. * * 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
  44675. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  44676. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44677. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  44678. * @param name defines the name of the new line system
  44679. * @param options defines the options used to create the line system
  44680. * @param scene defines the hosting scene
  44681. * @returns a new line system mesh
  44682. */
  44683. static CreateLineSystem(name: string, options: {
  44684. lines: Vector3[][];
  44685. updatable?: boolean;
  44686. instance?: Nullable<LinesMesh>;
  44687. colors?: Nullable<Color4[][]>;
  44688. useVertexAlpha?: boolean;
  44689. }, scene: Nullable<Scene>): LinesMesh;
  44690. /**
  44691. * Creates a line mesh
  44692. * 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
  44693. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44694. * * The parameter `points` is an array successive Vector3
  44695. * * 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
  44696. * * The optional parameter `colors` is an array of successive Color4, one per line point
  44697. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  44698. * * When updating an instance, remember that only point positions can change, not the number of points
  44699. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44700. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  44701. * @param name defines the name of the new line system
  44702. * @param options defines the options used to create the line system
  44703. * @param scene defines the hosting scene
  44704. * @returns a new line mesh
  44705. */
  44706. static CreateLines(name: string, options: {
  44707. points: Vector3[];
  44708. updatable?: boolean;
  44709. instance?: Nullable<LinesMesh>;
  44710. colors?: Color4[];
  44711. useVertexAlpha?: boolean;
  44712. }, scene?: Nullable<Scene>): LinesMesh;
  44713. /**
  44714. * Creates a dashed line mesh
  44715. * * 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
  44716. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  44717. * * The parameter `points` is an array successive Vector3
  44718. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  44719. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  44720. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  44721. * * 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
  44722. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  44723. * * When updating an instance, remember that only point positions can change, not the number of points
  44724. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44725. * @param name defines the name of the mesh
  44726. * @param options defines the options used to create the mesh
  44727. * @param scene defines the hosting scene
  44728. * @returns the dashed line mesh
  44729. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  44730. */
  44731. static CreateDashedLines(name: string, options: {
  44732. points: Vector3[];
  44733. dashSize?: number;
  44734. gapSize?: number;
  44735. dashNb?: number;
  44736. updatable?: boolean;
  44737. instance?: LinesMesh;
  44738. useVertexAlpha?: boolean;
  44739. }, scene?: Nullable<Scene>): LinesMesh;
  44740. }
  44741. }
  44742. declare module BABYLON {
  44743. /**
  44744. * The options container for the teleportation module
  44745. */
  44746. export interface IWebXRTeleportationOptions {
  44747. /**
  44748. * Babylon XR Input class for controller
  44749. */
  44750. xrInput: WebXRInput;
  44751. /**
  44752. * A list of meshes to use as floor meshes.
  44753. * Meshes can be added and removed after initializing the feature using the
  44754. * addFloorMesh and removeFloorMesh functions
  44755. * If empty, rotation will still work
  44756. */
  44757. floorMeshes?: AbstractMesh[];
  44758. /**
  44759. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  44760. * If you want to support rotation, make sure your mesh has a direction indicator.
  44761. *
  44762. * When left untouched, the default mesh will be initialized.
  44763. */
  44764. teleportationTargetMesh?: AbstractMesh;
  44765. /**
  44766. * Values to configure the default target mesh
  44767. */
  44768. defaultTargetMeshOptions?: {
  44769. /**
  44770. * Fill color of the teleportation area
  44771. */
  44772. teleportationFillColor?: string;
  44773. /**
  44774. * Border color for the teleportation area
  44775. */
  44776. teleportationBorderColor?: string;
  44777. /**
  44778. * Disable the mesh's animation sequence
  44779. */
  44780. disableAnimation?: boolean;
  44781. /**
  44782. * Disable lighting on the material or the ring and arrow
  44783. */
  44784. disableLighting?: boolean;
  44785. /**
  44786. * Override the default material of the torus and arrow
  44787. */
  44788. torusArrowMaterial?: Material;
  44789. };
  44790. /**
  44791. * Disable using the thumbstick and use the main component (usuallly trigger) on long press.
  44792. * This will be automatically true if the controller doesnt have a thumbstick or touchpad.
  44793. */
  44794. useMainComponentOnly?: boolean;
  44795. /**
  44796. * If main component is used (no thumbstick), how long should the "long press" take before teleporting
  44797. */
  44798. timeToTeleport?: number;
  44799. /**
  44800. * Should meshes created here be added to a utility layer or the main scene
  44801. */
  44802. useUtilityLayer?: boolean;
  44803. /**
  44804. * if provided, this scene will be used to render meshes.
  44805. */
  44806. customUtilityLayerScene?: Scene;
  44807. }
  44808. /**
  44809. * This is a teleportation feature to be used with webxr-enabled motion controllers.
  44810. * When enabled and attached, the feature will allow a user to move aroundand rotate in the scene using
  44811. * the input of the attached controllers.
  44812. */
  44813. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  44814. private _options;
  44815. /**
  44816. * The module's name
  44817. */
  44818. static readonly Name: string;
  44819. /**
  44820. * The (Babylon) version of this module.
  44821. * This is an integer representing the implementation version.
  44822. * This number does not correspond to the webxr specs version
  44823. */
  44824. static readonly Version: number;
  44825. /**
  44826. * Is rotation enabled when moving forward?
  44827. * Disabling this feature will prevent the user from deciding the direction when teleporting
  44828. */
  44829. rotationEnabled: boolean;
  44830. /**
  44831. * Should the module support parabolic ray on top of direct ray
  44832. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  44833. * Very helpful when moving between floors / different heights
  44834. */
  44835. parabolicRayEnabled: boolean;
  44836. /**
  44837. * The distance from the user to the inspection point in the direction of the controller
  44838. * A higher number will allow the user to move further
  44839. * defaults to 5 (meters, in xr units)
  44840. */
  44841. parabolicCheckRadius: number;
  44842. /**
  44843. * How much rotation should be applied when rotating right and left
  44844. */
  44845. rotationAngle: number;
  44846. /**
  44847. * Is movement backwards enabled
  44848. */
  44849. backwardsMovementEnabled: boolean;
  44850. /**
  44851. * Distance to travel when moving backwards
  44852. */
  44853. backwardsTeleportationDistance: number;
  44854. /**
  44855. * Add a new mesh to the floor meshes array
  44856. * @param mesh the mesh to use as floor mesh
  44857. */
  44858. addFloorMesh(mesh: AbstractMesh): void;
  44859. /**
  44860. * Remove a mesh from the floor meshes array
  44861. * @param mesh the mesh to remove
  44862. */
  44863. removeFloorMesh(mesh: AbstractMesh): void;
  44864. /**
  44865. * Remove a mesh from the floor meshes array using its name
  44866. * @param name the mesh name to remove
  44867. */
  44868. removeFloorMeshByName(name: string): void;
  44869. private _tmpRay;
  44870. private _tmpVector;
  44871. private _floorMeshes;
  44872. private _controllers;
  44873. /**
  44874. * constructs a new anchor system
  44875. * @param _xrSessionManager an instance of WebXRSessionManager
  44876. * @param _options configuration object for this feature
  44877. */
  44878. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  44879. private _selectionFeature;
  44880. /**
  44881. * This function sets a selection feature that will be disabled when
  44882. * the forward ray is shown and will be reattached when hidden.
  44883. * This is used to remove the selection rays when moving.
  44884. * @param selectionFeature the feature to disable when forward movement is enabled
  44885. */
  44886. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  44887. attach(): boolean;
  44888. detach(): boolean;
  44889. dispose(): void;
  44890. protected _onXRFrame(_xrFrame: XRFrame): void;
  44891. private _currentTeleportationControllerId;
  44892. private _attachController;
  44893. private _teleportForward;
  44894. private _detachController;
  44895. private createDefaultTargetMesh;
  44896. private setTargetMeshVisibility;
  44897. private setTargetMeshPosition;
  44898. private _quadraticBezierCurve;
  44899. private _showParabolicPath;
  44900. }
  44901. }
  44902. declare module BABYLON {
  44903. /**
  44904. * Options for the default xr helper
  44905. */
  44906. export class WebXRDefaultExperienceOptions {
  44907. /**
  44908. * Floor meshes that will be used for teleporting
  44909. */
  44910. floorMeshes?: Array<AbstractMesh>;
  44911. /**
  44912. * Enable or disable default UI to enter XR
  44913. */
  44914. disableDefaultUI?: boolean;
  44915. /**
  44916. * optional configuration for the output canvas
  44917. */
  44918. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  44919. /**
  44920. * optional UI options. This can be used among other to change session mode and reference space type
  44921. */
  44922. uiOptions?: WebXREnterExitUIOptions;
  44923. /**
  44924. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  44925. */
  44926. inputOptions?: IWebXRInputOptions;
  44927. /**
  44928. * Should teleportation not initialize. defaults to false.
  44929. */
  44930. disableTeleportation?: boolean;
  44931. /**
  44932. * If set to true, the first frame will not be used to reset position
  44933. * The first frame is mainly used when copying transformation from the old camera
  44934. * Mainly used in AR
  44935. */
  44936. ignoreNativeCameraTransformation?: boolean;
  44937. /**
  44938. * When loading teleportation and pointer select, use stable versions instead of latest.
  44939. */
  44940. useStablePlugins?: boolean;
  44941. }
  44942. /**
  44943. * Default experience which provides a similar setup to the previous webVRExperience
  44944. */
  44945. export class WebXRDefaultExperience {
  44946. /**
  44947. * Base experience
  44948. */
  44949. baseExperience: WebXRExperienceHelper;
  44950. /**
  44951. * Input experience extension
  44952. */
  44953. input: WebXRInput;
  44954. /**
  44955. * Enables laser pointer and selection
  44956. */
  44957. pointerSelection: WebXRControllerPointerSelection;
  44958. /**
  44959. * Enables teleportation
  44960. */
  44961. teleportation: WebXRMotionControllerTeleportation;
  44962. /**
  44963. * Enables ui for entering/exiting xr
  44964. */
  44965. enterExitUI: WebXREnterExitUI;
  44966. /**
  44967. * Default target xr should render to
  44968. */
  44969. renderTarget: WebXRRenderTarget;
  44970. /**
  44971. * Creates the default xr experience
  44972. * @param scene scene
  44973. * @param options options for basic configuration
  44974. * @returns resulting WebXRDefaultExperience
  44975. */
  44976. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  44977. private constructor();
  44978. /**
  44979. * DIsposes of the experience helper
  44980. */
  44981. dispose(): void;
  44982. }
  44983. }
  44984. declare module BABYLON {
  44985. /**
  44986. * Options to modify the vr teleportation behavior.
  44987. */
  44988. export interface VRTeleportationOptions {
  44989. /**
  44990. * The name of the mesh which should be used as the teleportation floor. (default: null)
  44991. */
  44992. floorMeshName?: string;
  44993. /**
  44994. * A list of meshes to be used as the teleportation floor. (default: empty)
  44995. */
  44996. floorMeshes?: Mesh[];
  44997. /**
  44998. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  44999. */
  45000. teleportationMode?: number;
  45001. /**
  45002. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  45003. */
  45004. teleportationTime?: number;
  45005. /**
  45006. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  45007. */
  45008. teleportationSpeed?: number;
  45009. /**
  45010. * The easing function used in the animation or null for Linear. (default CircleEase)
  45011. */
  45012. easingFunction?: EasingFunction;
  45013. }
  45014. /**
  45015. * Options to modify the vr experience helper's behavior.
  45016. */
  45017. export interface VRExperienceHelperOptions extends WebVROptions {
  45018. /**
  45019. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  45020. */
  45021. createDeviceOrientationCamera?: boolean;
  45022. /**
  45023. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  45024. */
  45025. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  45026. /**
  45027. * Uses the main button on the controller to toggle the laser casted. (default: true)
  45028. */
  45029. laserToggle?: boolean;
  45030. /**
  45031. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  45032. */
  45033. floorMeshes?: Mesh[];
  45034. /**
  45035. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  45036. */
  45037. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  45038. /**
  45039. * Defines if WebXR should be used instead of WebVR (if available)
  45040. */
  45041. useXR?: boolean;
  45042. }
  45043. /**
  45044. * Event containing information after VR has been entered
  45045. */
  45046. export class OnAfterEnteringVRObservableEvent {
  45047. /**
  45048. * If entering vr was successful
  45049. */
  45050. success: boolean;
  45051. }
  45052. /**
  45053. * Helps to quickly add VR support to an existing scene.
  45054. * See http://doc.babylonjs.com/how_to/webvr_helper
  45055. */
  45056. export class VRExperienceHelper {
  45057. /** Options to modify the vr experience helper's behavior. */
  45058. webVROptions: VRExperienceHelperOptions;
  45059. private _scene;
  45060. private _position;
  45061. private _btnVR;
  45062. private _btnVRDisplayed;
  45063. private _webVRsupported;
  45064. private _webVRready;
  45065. private _webVRrequesting;
  45066. private _webVRpresenting;
  45067. private _hasEnteredVR;
  45068. private _fullscreenVRpresenting;
  45069. private _inputElement;
  45070. private _webVRCamera;
  45071. private _vrDeviceOrientationCamera;
  45072. private _deviceOrientationCamera;
  45073. private _existingCamera;
  45074. private _onKeyDown;
  45075. private _onVrDisplayPresentChange;
  45076. private _onVRDisplayChanged;
  45077. private _onVRRequestPresentStart;
  45078. private _onVRRequestPresentComplete;
  45079. /**
  45080. * 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)
  45081. */
  45082. enableGazeEvenWhenNoPointerLock: boolean;
  45083. /**
  45084. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  45085. */
  45086. exitVROnDoubleTap: boolean;
  45087. /**
  45088. * Observable raised right before entering VR.
  45089. */
  45090. onEnteringVRObservable: Observable<VRExperienceHelper>;
  45091. /**
  45092. * Observable raised when entering VR has completed.
  45093. */
  45094. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  45095. /**
  45096. * Observable raised when exiting VR.
  45097. */
  45098. onExitingVRObservable: Observable<VRExperienceHelper>;
  45099. /**
  45100. * Observable raised when controller mesh is loaded.
  45101. */
  45102. onControllerMeshLoadedObservable: Observable<WebVRController>;
  45103. /** Return this.onEnteringVRObservable
  45104. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  45105. */
  45106. get onEnteringVR(): Observable<VRExperienceHelper>;
  45107. /** Return this.onExitingVRObservable
  45108. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  45109. */
  45110. get onExitingVR(): Observable<VRExperienceHelper>;
  45111. /** Return this.onControllerMeshLoadedObservable
  45112. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  45113. */
  45114. get onControllerMeshLoaded(): Observable<WebVRController>;
  45115. private _rayLength;
  45116. private _useCustomVRButton;
  45117. private _teleportationRequested;
  45118. private _teleportActive;
  45119. private _floorMeshName;
  45120. private _floorMeshesCollection;
  45121. private _teleportationMode;
  45122. private _teleportationTime;
  45123. private _teleportationSpeed;
  45124. private _teleportationEasing;
  45125. private _rotationAllowed;
  45126. private _teleportBackwardsVector;
  45127. private _teleportationTarget;
  45128. private _isDefaultTeleportationTarget;
  45129. private _postProcessMove;
  45130. private _teleportationFillColor;
  45131. private _teleportationBorderColor;
  45132. private _rotationAngle;
  45133. private _haloCenter;
  45134. private _cameraGazer;
  45135. private _padSensibilityUp;
  45136. private _padSensibilityDown;
  45137. private _leftController;
  45138. private _rightController;
  45139. private _gazeColor;
  45140. private _laserColor;
  45141. private _pickedLaserColor;
  45142. private _pickedGazeColor;
  45143. /**
  45144. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  45145. */
  45146. onNewMeshSelected: Observable<AbstractMesh>;
  45147. /**
  45148. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  45149. * This observable will provide the mesh and the controller used to select the mesh
  45150. */
  45151. onMeshSelectedWithController: Observable<{
  45152. mesh: AbstractMesh;
  45153. controller: WebVRController;
  45154. }>;
  45155. /**
  45156. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  45157. */
  45158. onNewMeshPicked: Observable<PickingInfo>;
  45159. private _circleEase;
  45160. /**
  45161. * Observable raised before camera teleportation
  45162. */
  45163. onBeforeCameraTeleport: Observable<Vector3>;
  45164. /**
  45165. * Observable raised after camera teleportation
  45166. */
  45167. onAfterCameraTeleport: Observable<Vector3>;
  45168. /**
  45169. * Observable raised when current selected mesh gets unselected
  45170. */
  45171. onSelectedMeshUnselected: Observable<AbstractMesh>;
  45172. private _raySelectionPredicate;
  45173. /**
  45174. * To be optionaly changed by user to define custom ray selection
  45175. */
  45176. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  45177. /**
  45178. * To be optionaly changed by user to define custom selection logic (after ray selection)
  45179. */
  45180. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  45181. /**
  45182. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  45183. */
  45184. teleportationEnabled: boolean;
  45185. private _defaultHeight;
  45186. private _teleportationInitialized;
  45187. private _interactionsEnabled;
  45188. private _interactionsRequested;
  45189. private _displayGaze;
  45190. private _displayLaserPointer;
  45191. /**
  45192. * The mesh used to display where the user is going to teleport.
  45193. */
  45194. get teleportationTarget(): Mesh;
  45195. /**
  45196. * Sets the mesh to be used to display where the user is going to teleport.
  45197. */
  45198. set teleportationTarget(value: Mesh);
  45199. /**
  45200. * 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
  45201. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  45202. * See http://doc.babylonjs.com/resources/baking_transformations
  45203. */
  45204. get gazeTrackerMesh(): Mesh;
  45205. set gazeTrackerMesh(value: Mesh);
  45206. /**
  45207. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  45208. */
  45209. updateGazeTrackerScale: boolean;
  45210. /**
  45211. * If the gaze trackers color should be updated when selecting meshes
  45212. */
  45213. updateGazeTrackerColor: boolean;
  45214. /**
  45215. * If the controller laser color should be updated when selecting meshes
  45216. */
  45217. updateControllerLaserColor: boolean;
  45218. /**
  45219. * The gaze tracking mesh corresponding to the left controller
  45220. */
  45221. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  45222. /**
  45223. * The gaze tracking mesh corresponding to the right controller
  45224. */
  45225. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  45226. /**
  45227. * If the ray of the gaze should be displayed.
  45228. */
  45229. get displayGaze(): boolean;
  45230. /**
  45231. * Sets if the ray of the gaze should be displayed.
  45232. */
  45233. set displayGaze(value: boolean);
  45234. /**
  45235. * If the ray of the LaserPointer should be displayed.
  45236. */
  45237. get displayLaserPointer(): boolean;
  45238. /**
  45239. * Sets if the ray of the LaserPointer should be displayed.
  45240. */
  45241. set displayLaserPointer(value: boolean);
  45242. /**
  45243. * The deviceOrientationCamera used as the camera when not in VR.
  45244. */
  45245. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  45246. /**
  45247. * Based on the current WebVR support, returns the current VR camera used.
  45248. */
  45249. get currentVRCamera(): Nullable<Camera>;
  45250. /**
  45251. * The webVRCamera which is used when in VR.
  45252. */
  45253. get webVRCamera(): WebVRFreeCamera;
  45254. /**
  45255. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  45256. */
  45257. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  45258. /**
  45259. * The html button that is used to trigger entering into VR.
  45260. */
  45261. get vrButton(): Nullable<HTMLButtonElement>;
  45262. private get _teleportationRequestInitiated();
  45263. /**
  45264. * Defines whether or not Pointer lock should be requested when switching to
  45265. * full screen.
  45266. */
  45267. requestPointerLockOnFullScreen: boolean;
  45268. /**
  45269. * If asking to force XR, this will be populated with the default xr experience
  45270. */
  45271. xr: WebXRDefaultExperience;
  45272. /**
  45273. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  45274. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  45275. */
  45276. xrTestDone: boolean;
  45277. /**
  45278. * Instantiates a VRExperienceHelper.
  45279. * Helps to quickly add VR support to an existing scene.
  45280. * @param scene The scene the VRExperienceHelper belongs to.
  45281. * @param webVROptions Options to modify the vr experience helper's behavior.
  45282. */
  45283. constructor(scene: Scene,
  45284. /** Options to modify the vr experience helper's behavior. */
  45285. webVROptions?: VRExperienceHelperOptions);
  45286. private completeVRInit;
  45287. private _onDefaultMeshLoaded;
  45288. private _onResize;
  45289. private _onFullscreenChange;
  45290. /**
  45291. * Gets a value indicating if we are currently in VR mode.
  45292. */
  45293. get isInVRMode(): boolean;
  45294. private onVrDisplayPresentChange;
  45295. private onVRDisplayChanged;
  45296. private moveButtonToBottomRight;
  45297. private displayVRButton;
  45298. private updateButtonVisibility;
  45299. private _cachedAngularSensibility;
  45300. /**
  45301. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  45302. * Otherwise, will use the fullscreen API.
  45303. */
  45304. enterVR(): void;
  45305. /**
  45306. * Attempt to exit VR, or fullscreen.
  45307. */
  45308. exitVR(): void;
  45309. /**
  45310. * The position of the vr experience helper.
  45311. */
  45312. get position(): Vector3;
  45313. /**
  45314. * Sets the position of the vr experience helper.
  45315. */
  45316. set position(value: Vector3);
  45317. /**
  45318. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  45319. */
  45320. enableInteractions(): void;
  45321. private get _noControllerIsActive();
  45322. private beforeRender;
  45323. private _isTeleportationFloor;
  45324. /**
  45325. * Adds a floor mesh to be used for teleportation.
  45326. * @param floorMesh the mesh to be used for teleportation.
  45327. */
  45328. addFloorMesh(floorMesh: Mesh): void;
  45329. /**
  45330. * Removes a floor mesh from being used for teleportation.
  45331. * @param floorMesh the mesh to be removed.
  45332. */
  45333. removeFloorMesh(floorMesh: Mesh): void;
  45334. /**
  45335. * Enables interactions and teleportation using the VR controllers and gaze.
  45336. * @param vrTeleportationOptions options to modify teleportation behavior.
  45337. */
  45338. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  45339. private _onNewGamepadConnected;
  45340. private _tryEnableInteractionOnController;
  45341. private _onNewGamepadDisconnected;
  45342. private _enableInteractionOnController;
  45343. private _checkTeleportWithRay;
  45344. private _checkRotate;
  45345. private _checkTeleportBackwards;
  45346. private _enableTeleportationOnController;
  45347. private _createTeleportationCircles;
  45348. private _displayTeleportationTarget;
  45349. private _hideTeleportationTarget;
  45350. private _rotateCamera;
  45351. private _moveTeleportationSelectorTo;
  45352. private _workingVector;
  45353. private _workingQuaternion;
  45354. private _workingMatrix;
  45355. /**
  45356. * Time Constant Teleportation Mode
  45357. */
  45358. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  45359. /**
  45360. * Speed Constant Teleportation Mode
  45361. */
  45362. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  45363. /**
  45364. * Teleports the users feet to the desired location
  45365. * @param location The location where the user's feet should be placed
  45366. */
  45367. teleportCamera(location: Vector3): void;
  45368. private _convertNormalToDirectionOfRay;
  45369. private _castRayAndSelectObject;
  45370. private _notifySelectedMeshUnselected;
  45371. /**
  45372. * Permanently set new colors for the laser pointer
  45373. * @param color the new laser color
  45374. * @param pickedColor the new laser color when picked mesh detected
  45375. */
  45376. setLaserColor(color: Color3, pickedColor?: Color3): void;
  45377. /**
  45378. * Set lighting enabled / disabled on the laser pointer of both controllers
  45379. * @param enabled should the lighting be enabled on the laser pointer
  45380. */
  45381. setLaserLightingState(enabled?: boolean): void;
  45382. /**
  45383. * Permanently set new colors for the gaze pointer
  45384. * @param color the new gaze color
  45385. * @param pickedColor the new gaze color when picked mesh detected
  45386. */
  45387. setGazeColor(color: Color3, pickedColor?: Color3): void;
  45388. /**
  45389. * Sets the color of the laser ray from the vr controllers.
  45390. * @param color new color for the ray.
  45391. */
  45392. changeLaserColor(color: Color3): void;
  45393. /**
  45394. * Sets the color of the ray from the vr headsets gaze.
  45395. * @param color new color for the ray.
  45396. */
  45397. changeGazeColor(color: Color3): void;
  45398. /**
  45399. * Exits VR and disposes of the vr experience helper
  45400. */
  45401. dispose(): void;
  45402. /**
  45403. * Gets the name of the VRExperienceHelper class
  45404. * @returns "VRExperienceHelper"
  45405. */
  45406. getClassName(): string;
  45407. }
  45408. }
  45409. declare module BABYLON {
  45410. /**
  45411. * Contains an array of blocks representing the octree
  45412. */
  45413. export interface IOctreeContainer<T> {
  45414. /**
  45415. * Blocks within the octree
  45416. */
  45417. blocks: Array<OctreeBlock<T>>;
  45418. }
  45419. /**
  45420. * Class used to store a cell in an octree
  45421. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45422. */
  45423. export class OctreeBlock<T> {
  45424. /**
  45425. * Gets the content of the current block
  45426. */
  45427. entries: T[];
  45428. /**
  45429. * Gets the list of block children
  45430. */
  45431. blocks: Array<OctreeBlock<T>>;
  45432. private _depth;
  45433. private _maxDepth;
  45434. private _capacity;
  45435. private _minPoint;
  45436. private _maxPoint;
  45437. private _boundingVectors;
  45438. private _creationFunc;
  45439. /**
  45440. * Creates a new block
  45441. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  45442. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  45443. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45444. * @param depth defines the current depth of this block in the octree
  45445. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  45446. * @param creationFunc defines a callback to call when an element is added to the block
  45447. */
  45448. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  45449. /**
  45450. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  45451. */
  45452. get capacity(): number;
  45453. /**
  45454. * Gets the minimum vector (in world space) of the block's bounding box
  45455. */
  45456. get minPoint(): Vector3;
  45457. /**
  45458. * Gets the maximum vector (in world space) of the block's bounding box
  45459. */
  45460. get maxPoint(): Vector3;
  45461. /**
  45462. * Add a new element to this block
  45463. * @param entry defines the element to add
  45464. */
  45465. addEntry(entry: T): void;
  45466. /**
  45467. * Remove an element from this block
  45468. * @param entry defines the element to remove
  45469. */
  45470. removeEntry(entry: T): void;
  45471. /**
  45472. * Add an array of elements to this block
  45473. * @param entries defines the array of elements to add
  45474. */
  45475. addEntries(entries: T[]): void;
  45476. /**
  45477. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  45478. * @param frustumPlanes defines the frustum planes to test
  45479. * @param selection defines the array to store current content if selection is positive
  45480. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45481. */
  45482. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45483. /**
  45484. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  45485. * @param sphereCenter defines the bounding sphere center
  45486. * @param sphereRadius defines the bounding sphere radius
  45487. * @param selection defines the array to store current content if selection is positive
  45488. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45489. */
  45490. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  45491. /**
  45492. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  45493. * @param ray defines the ray to test with
  45494. * @param selection defines the array to store current content if selection is positive
  45495. */
  45496. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  45497. /**
  45498. * Subdivide the content into child blocks (this block will then be empty)
  45499. */
  45500. createInnerBlocks(): void;
  45501. /**
  45502. * @hidden
  45503. */
  45504. 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;
  45505. }
  45506. }
  45507. declare module BABYLON {
  45508. /**
  45509. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  45510. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45511. */
  45512. export class Octree<T> {
  45513. /** 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.) */
  45514. maxDepth: number;
  45515. /**
  45516. * Blocks within the octree containing objects
  45517. */
  45518. blocks: Array<OctreeBlock<T>>;
  45519. /**
  45520. * Content stored in the octree
  45521. */
  45522. dynamicContent: T[];
  45523. private _maxBlockCapacity;
  45524. private _selectionContent;
  45525. private _creationFunc;
  45526. /**
  45527. * Creates a octree
  45528. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45529. * @param creationFunc function to be used to instatiate the octree
  45530. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  45531. * @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.)
  45532. */
  45533. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  45534. /** 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.) */
  45535. maxDepth?: number);
  45536. /**
  45537. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  45538. * @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);
  45539. * @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);
  45540. * @param entries meshes to be added to the octree blocks
  45541. */
  45542. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  45543. /**
  45544. * Adds a mesh to the octree
  45545. * @param entry Mesh to add to the octree
  45546. */
  45547. addMesh(entry: T): void;
  45548. /**
  45549. * Remove an element from the octree
  45550. * @param entry defines the element to remove
  45551. */
  45552. removeMesh(entry: T): void;
  45553. /**
  45554. * Selects an array of meshes within the frustum
  45555. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  45556. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  45557. * @returns array of meshes within the frustum
  45558. */
  45559. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  45560. /**
  45561. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  45562. * @param sphereCenter defines the bounding sphere center
  45563. * @param sphereRadius defines the bounding sphere radius
  45564. * @param allowDuplicate defines if the selection array can contains duplicated entries
  45565. * @returns an array of objects that intersect the sphere
  45566. */
  45567. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  45568. /**
  45569. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  45570. * @param ray defines the ray to test with
  45571. * @returns array of intersected objects
  45572. */
  45573. intersectsRay(ray: Ray): SmartArray<T>;
  45574. /**
  45575. * Adds a mesh into the octree block if it intersects the block
  45576. */
  45577. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  45578. /**
  45579. * Adds a submesh into the octree block if it intersects the block
  45580. */
  45581. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  45582. }
  45583. }
  45584. declare module BABYLON {
  45585. interface Scene {
  45586. /**
  45587. * @hidden
  45588. * Backing Filed
  45589. */
  45590. _selectionOctree: Octree<AbstractMesh>;
  45591. /**
  45592. * Gets the octree used to boost mesh selection (picking)
  45593. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45594. */
  45595. selectionOctree: Octree<AbstractMesh>;
  45596. /**
  45597. * Creates or updates the octree used to boost selection (picking)
  45598. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45599. * @param maxCapacity defines the maximum capacity per leaf
  45600. * @param maxDepth defines the maximum depth of the octree
  45601. * @returns an octree of AbstractMesh
  45602. */
  45603. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  45604. }
  45605. interface AbstractMesh {
  45606. /**
  45607. * @hidden
  45608. * Backing Field
  45609. */
  45610. _submeshesOctree: Octree<SubMesh>;
  45611. /**
  45612. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  45613. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  45614. * @param maxCapacity defines the maximum size of each block (64 by default)
  45615. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  45616. * @returns the new octree
  45617. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  45618. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  45619. */
  45620. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  45621. }
  45622. /**
  45623. * Defines the octree scene component responsible to manage any octrees
  45624. * in a given scene.
  45625. */
  45626. export class OctreeSceneComponent {
  45627. /**
  45628. * The component name help to identify the component in the list of scene components.
  45629. */
  45630. readonly name: string;
  45631. /**
  45632. * The scene the component belongs to.
  45633. */
  45634. scene: Scene;
  45635. /**
  45636. * Indicates if the meshes have been checked to make sure they are isEnabled()
  45637. */
  45638. readonly checksIsEnabled: boolean;
  45639. /**
  45640. * Creates a new instance of the component for the given scene
  45641. * @param scene Defines the scene to register the component in
  45642. */
  45643. constructor(scene: Scene);
  45644. /**
  45645. * Registers the component in a given scene
  45646. */
  45647. register(): void;
  45648. /**
  45649. * Return the list of active meshes
  45650. * @returns the list of active meshes
  45651. */
  45652. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  45653. /**
  45654. * Return the list of active sub meshes
  45655. * @param mesh The mesh to get the candidates sub meshes from
  45656. * @returns the list of active sub meshes
  45657. */
  45658. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  45659. private _tempRay;
  45660. /**
  45661. * Return the list of sub meshes intersecting with a given local ray
  45662. * @param mesh defines the mesh to find the submesh for
  45663. * @param localRay defines the ray in local space
  45664. * @returns the list of intersecting sub meshes
  45665. */
  45666. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  45667. /**
  45668. * Return the list of sub meshes colliding with a collider
  45669. * @param mesh defines the mesh to find the submesh for
  45670. * @param collider defines the collider to evaluate the collision against
  45671. * @returns the list of colliding sub meshes
  45672. */
  45673. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  45674. /**
  45675. * Rebuilds the elements related to this component in case of
  45676. * context lost for instance.
  45677. */
  45678. rebuild(): void;
  45679. /**
  45680. * Disposes the component and the associated ressources.
  45681. */
  45682. dispose(): void;
  45683. }
  45684. }
  45685. declare module BABYLON {
  45686. /**
  45687. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  45688. */
  45689. export class Gizmo implements IDisposable {
  45690. /** The utility layer the gizmo will be added to */
  45691. gizmoLayer: UtilityLayerRenderer;
  45692. /**
  45693. * The root mesh of the gizmo
  45694. */
  45695. _rootMesh: Mesh;
  45696. private _attachedMesh;
  45697. /**
  45698. * Ratio for the scale of the gizmo (Default: 1)
  45699. */
  45700. scaleRatio: number;
  45701. /**
  45702. * If a custom mesh has been set (Default: false)
  45703. */
  45704. protected _customMeshSet: boolean;
  45705. /**
  45706. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  45707. * * When set, interactions will be enabled
  45708. */
  45709. get attachedMesh(): Nullable<AbstractMesh>;
  45710. set attachedMesh(value: Nullable<AbstractMesh>);
  45711. /**
  45712. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  45713. * @param mesh The mesh to replace the default mesh of the gizmo
  45714. */
  45715. setCustomMesh(mesh: Mesh): void;
  45716. /**
  45717. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  45718. */
  45719. updateGizmoRotationToMatchAttachedMesh: boolean;
  45720. /**
  45721. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  45722. */
  45723. updateGizmoPositionToMatchAttachedMesh: boolean;
  45724. /**
  45725. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  45726. */
  45727. updateScale: boolean;
  45728. protected _interactionsEnabled: boolean;
  45729. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45730. private _beforeRenderObserver;
  45731. private _tempVector;
  45732. /**
  45733. * Creates a gizmo
  45734. * @param gizmoLayer The utility layer the gizmo will be added to
  45735. */
  45736. constructor(
  45737. /** The utility layer the gizmo will be added to */
  45738. gizmoLayer?: UtilityLayerRenderer);
  45739. /**
  45740. * Updates the gizmo to match the attached mesh's position/rotation
  45741. */
  45742. protected _update(): void;
  45743. /**
  45744. * Disposes of the gizmo
  45745. */
  45746. dispose(): void;
  45747. }
  45748. }
  45749. declare module BABYLON {
  45750. /**
  45751. * Single plane drag gizmo
  45752. */
  45753. export class PlaneDragGizmo extends Gizmo {
  45754. /**
  45755. * Drag behavior responsible for the gizmos dragging interactions
  45756. */
  45757. dragBehavior: PointerDragBehavior;
  45758. private _pointerObserver;
  45759. /**
  45760. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45761. */
  45762. snapDistance: number;
  45763. /**
  45764. * Event that fires each time the gizmo snaps to a new location.
  45765. * * snapDistance is the the change in distance
  45766. */
  45767. onSnapObservable: Observable<{
  45768. snapDistance: number;
  45769. }>;
  45770. private _plane;
  45771. private _coloredMaterial;
  45772. private _hoverMaterial;
  45773. private _isEnabled;
  45774. private _parent;
  45775. /** @hidden */
  45776. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  45777. /** @hidden */
  45778. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45779. /**
  45780. * Creates a PlaneDragGizmo
  45781. * @param gizmoLayer The utility layer the gizmo will be added to
  45782. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  45783. * @param color The color of the gizmo
  45784. */
  45785. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45786. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45787. /**
  45788. * If the gizmo is enabled
  45789. */
  45790. set isEnabled(value: boolean);
  45791. get isEnabled(): boolean;
  45792. /**
  45793. * Disposes of the gizmo
  45794. */
  45795. dispose(): void;
  45796. }
  45797. }
  45798. declare module BABYLON {
  45799. /**
  45800. * Gizmo that enables dragging a mesh along 3 axis
  45801. */
  45802. export class PositionGizmo extends Gizmo {
  45803. /**
  45804. * Internal gizmo used for interactions on the x axis
  45805. */
  45806. xGizmo: AxisDragGizmo;
  45807. /**
  45808. * Internal gizmo used for interactions on the y axis
  45809. */
  45810. yGizmo: AxisDragGizmo;
  45811. /**
  45812. * Internal gizmo used for interactions on the z axis
  45813. */
  45814. zGizmo: AxisDragGizmo;
  45815. /**
  45816. * Internal gizmo used for interactions on the yz plane
  45817. */
  45818. xPlaneGizmo: PlaneDragGizmo;
  45819. /**
  45820. * Internal gizmo used for interactions on the xz plane
  45821. */
  45822. yPlaneGizmo: PlaneDragGizmo;
  45823. /**
  45824. * Internal gizmo used for interactions on the xy plane
  45825. */
  45826. zPlaneGizmo: PlaneDragGizmo;
  45827. /**
  45828. * private variables
  45829. */
  45830. private _meshAttached;
  45831. private _updateGizmoRotationToMatchAttachedMesh;
  45832. private _snapDistance;
  45833. private _scaleRatio;
  45834. /** Fires an event when any of it's sub gizmos are dragged */
  45835. onDragStartObservable: Observable<unknown>;
  45836. /** Fires an event when any of it's sub gizmos are released from dragging */
  45837. onDragEndObservable: Observable<unknown>;
  45838. /**
  45839. * If set to true, planar drag is enabled
  45840. */
  45841. private _planarGizmoEnabled;
  45842. get attachedMesh(): Nullable<AbstractMesh>;
  45843. set attachedMesh(mesh: Nullable<AbstractMesh>);
  45844. /**
  45845. * Creates a PositionGizmo
  45846. * @param gizmoLayer The utility layer the gizmo will be added to
  45847. */
  45848. constructor(gizmoLayer?: UtilityLayerRenderer);
  45849. /**
  45850. * If the planar drag gizmo is enabled
  45851. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  45852. */
  45853. set planarGizmoEnabled(value: boolean);
  45854. get planarGizmoEnabled(): boolean;
  45855. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  45856. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  45857. /**
  45858. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45859. */
  45860. set snapDistance(value: number);
  45861. get snapDistance(): number;
  45862. /**
  45863. * Ratio for the scale of the gizmo (Default: 1)
  45864. */
  45865. set scaleRatio(value: number);
  45866. get scaleRatio(): number;
  45867. /**
  45868. * Disposes of the gizmo
  45869. */
  45870. dispose(): void;
  45871. /**
  45872. * CustomMeshes are not supported by this gizmo
  45873. * @param mesh The mesh to replace the default mesh of the gizmo
  45874. */
  45875. setCustomMesh(mesh: Mesh): void;
  45876. }
  45877. }
  45878. declare module BABYLON {
  45879. /**
  45880. * Single axis drag gizmo
  45881. */
  45882. export class AxisDragGizmo extends Gizmo {
  45883. /**
  45884. * Drag behavior responsible for the gizmos dragging interactions
  45885. */
  45886. dragBehavior: PointerDragBehavior;
  45887. private _pointerObserver;
  45888. /**
  45889. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  45890. */
  45891. snapDistance: number;
  45892. /**
  45893. * Event that fires each time the gizmo snaps to a new location.
  45894. * * snapDistance is the the change in distance
  45895. */
  45896. onSnapObservable: Observable<{
  45897. snapDistance: number;
  45898. }>;
  45899. private _isEnabled;
  45900. private _parent;
  45901. private _arrow;
  45902. private _coloredMaterial;
  45903. private _hoverMaterial;
  45904. /** @hidden */
  45905. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  45906. /** @hidden */
  45907. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  45908. /**
  45909. * Creates an AxisDragGizmo
  45910. * @param gizmoLayer The utility layer the gizmo will be added to
  45911. * @param dragAxis The axis which the gizmo will be able to drag on
  45912. * @param color The color of the gizmo
  45913. */
  45914. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  45915. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  45916. /**
  45917. * If the gizmo is enabled
  45918. */
  45919. set isEnabled(value: boolean);
  45920. get isEnabled(): boolean;
  45921. /**
  45922. * Disposes of the gizmo
  45923. */
  45924. dispose(): void;
  45925. }
  45926. }
  45927. declare module BABYLON.Debug {
  45928. /**
  45929. * The Axes viewer will show 3 axes in a specific point in space
  45930. */
  45931. export class AxesViewer {
  45932. private _xAxis;
  45933. private _yAxis;
  45934. private _zAxis;
  45935. private _scaleLinesFactor;
  45936. private _instanced;
  45937. /**
  45938. * Gets the hosting scene
  45939. */
  45940. scene: Scene;
  45941. /**
  45942. * Gets or sets a number used to scale line length
  45943. */
  45944. scaleLines: number;
  45945. /** Gets the node hierarchy used to render x-axis */
  45946. get xAxis(): TransformNode;
  45947. /** Gets the node hierarchy used to render y-axis */
  45948. get yAxis(): TransformNode;
  45949. /** Gets the node hierarchy used to render z-axis */
  45950. get zAxis(): TransformNode;
  45951. /**
  45952. * Creates a new AxesViewer
  45953. * @param scene defines the hosting scene
  45954. * @param scaleLines defines a number used to scale line length (1 by default)
  45955. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  45956. * @param xAxis defines the node hierarchy used to render the x-axis
  45957. * @param yAxis defines the node hierarchy used to render the y-axis
  45958. * @param zAxis defines the node hierarchy used to render the z-axis
  45959. */
  45960. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  45961. /**
  45962. * Force the viewer to update
  45963. * @param position defines the position of the viewer
  45964. * @param xaxis defines the x axis of the viewer
  45965. * @param yaxis defines the y axis of the viewer
  45966. * @param zaxis defines the z axis of the viewer
  45967. */
  45968. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  45969. /**
  45970. * Creates an instance of this axes viewer.
  45971. * @returns a new axes viewer with instanced meshes
  45972. */
  45973. createInstance(): AxesViewer;
  45974. /** Releases resources */
  45975. dispose(): void;
  45976. private static _SetRenderingGroupId;
  45977. }
  45978. }
  45979. declare module BABYLON.Debug {
  45980. /**
  45981. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  45982. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  45983. */
  45984. export class BoneAxesViewer extends AxesViewer {
  45985. /**
  45986. * Gets or sets the target mesh where to display the axes viewer
  45987. */
  45988. mesh: Nullable<Mesh>;
  45989. /**
  45990. * Gets or sets the target bone where to display the axes viewer
  45991. */
  45992. bone: Nullable<Bone>;
  45993. /** Gets current position */
  45994. pos: Vector3;
  45995. /** Gets direction of X axis */
  45996. xaxis: Vector3;
  45997. /** Gets direction of Y axis */
  45998. yaxis: Vector3;
  45999. /** Gets direction of Z axis */
  46000. zaxis: Vector3;
  46001. /**
  46002. * Creates a new BoneAxesViewer
  46003. * @param scene defines the hosting scene
  46004. * @param bone defines the target bone
  46005. * @param mesh defines the target mesh
  46006. * @param scaleLines defines a scaling factor for line length (1 by default)
  46007. */
  46008. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  46009. /**
  46010. * Force the viewer to update
  46011. */
  46012. update(): void;
  46013. /** Releases resources */
  46014. dispose(): void;
  46015. }
  46016. }
  46017. declare module BABYLON {
  46018. /**
  46019. * Interface used to define scene explorer extensibility option
  46020. */
  46021. export interface IExplorerExtensibilityOption {
  46022. /**
  46023. * Define the option label
  46024. */
  46025. label: string;
  46026. /**
  46027. * Defines the action to execute on click
  46028. */
  46029. action: (entity: any) => void;
  46030. }
  46031. /**
  46032. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  46033. */
  46034. export interface IExplorerExtensibilityGroup {
  46035. /**
  46036. * Defines a predicate to test if a given type mut be extended
  46037. */
  46038. predicate: (entity: any) => boolean;
  46039. /**
  46040. * Gets the list of options added to a type
  46041. */
  46042. entries: IExplorerExtensibilityOption[];
  46043. }
  46044. /**
  46045. * Interface used to define the options to use to create the Inspector
  46046. */
  46047. export interface IInspectorOptions {
  46048. /**
  46049. * Display in overlay mode (default: false)
  46050. */
  46051. overlay?: boolean;
  46052. /**
  46053. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  46054. */
  46055. globalRoot?: HTMLElement;
  46056. /**
  46057. * Display the Scene explorer
  46058. */
  46059. showExplorer?: boolean;
  46060. /**
  46061. * Display the property inspector
  46062. */
  46063. showInspector?: boolean;
  46064. /**
  46065. * Display in embed mode (both panes on the right)
  46066. */
  46067. embedMode?: boolean;
  46068. /**
  46069. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  46070. */
  46071. handleResize?: boolean;
  46072. /**
  46073. * Allow the panes to popup (default: true)
  46074. */
  46075. enablePopup?: boolean;
  46076. /**
  46077. * Allow the panes to be closed by users (default: true)
  46078. */
  46079. enableClose?: boolean;
  46080. /**
  46081. * Optional list of extensibility entries
  46082. */
  46083. explorerExtensibility?: IExplorerExtensibilityGroup[];
  46084. /**
  46085. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  46086. */
  46087. inspectorURL?: string;
  46088. /**
  46089. * Optional initial tab (default to DebugLayerTab.Properties)
  46090. */
  46091. initialTab?: DebugLayerTab;
  46092. }
  46093. interface Scene {
  46094. /**
  46095. * @hidden
  46096. * Backing field
  46097. */
  46098. _debugLayer: DebugLayer;
  46099. /**
  46100. * Gets the debug layer (aka Inspector) associated with the scene
  46101. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46102. */
  46103. debugLayer: DebugLayer;
  46104. }
  46105. /**
  46106. * Enum of inspector action tab
  46107. */
  46108. export enum DebugLayerTab {
  46109. /**
  46110. * Properties tag (default)
  46111. */
  46112. Properties = 0,
  46113. /**
  46114. * Debug tab
  46115. */
  46116. Debug = 1,
  46117. /**
  46118. * Statistics tab
  46119. */
  46120. Statistics = 2,
  46121. /**
  46122. * Tools tab
  46123. */
  46124. Tools = 3,
  46125. /**
  46126. * Settings tab
  46127. */
  46128. Settings = 4
  46129. }
  46130. /**
  46131. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46132. * what is happening in your scene
  46133. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46134. */
  46135. export class DebugLayer {
  46136. /**
  46137. * Define the url to get the inspector script from.
  46138. * By default it uses the babylonjs CDN.
  46139. * @ignoreNaming
  46140. */
  46141. static InspectorURL: string;
  46142. private _scene;
  46143. private BJSINSPECTOR;
  46144. private _onPropertyChangedObservable?;
  46145. /**
  46146. * Observable triggered when a property is changed through the inspector.
  46147. */
  46148. get onPropertyChangedObservable(): any;
  46149. /**
  46150. * Instantiates a new debug layer.
  46151. * The debug layer (aka Inspector) is the go to tool in order to better understand
  46152. * what is happening in your scene
  46153. * @see http://doc.babylonjs.com/features/playground_debuglayer
  46154. * @param scene Defines the scene to inspect
  46155. */
  46156. constructor(scene: Scene);
  46157. /** Creates the inspector window. */
  46158. private _createInspector;
  46159. /**
  46160. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  46161. * @param entity defines the entity to select
  46162. * @param lineContainerTitle defines the specific block to highlight
  46163. */
  46164. select(entity: any, lineContainerTitle?: string): void;
  46165. /** Get the inspector from bundle or global */
  46166. private _getGlobalInspector;
  46167. /**
  46168. * Get if the inspector is visible or not.
  46169. * @returns true if visible otherwise, false
  46170. */
  46171. isVisible(): boolean;
  46172. /**
  46173. * Hide the inspector and close its window.
  46174. */
  46175. hide(): void;
  46176. /**
  46177. * Launch the debugLayer.
  46178. * @param config Define the configuration of the inspector
  46179. * @return a promise fulfilled when the debug layer is visible
  46180. */
  46181. show(config?: IInspectorOptions): Promise<DebugLayer>;
  46182. }
  46183. }
  46184. declare module BABYLON {
  46185. /**
  46186. * Class containing static functions to help procedurally build meshes
  46187. */
  46188. export class BoxBuilder {
  46189. /**
  46190. * Creates a box mesh
  46191. * * The parameter `size` sets the size (float) of each box side (default 1)
  46192. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  46193. * * 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)
  46194. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  46195. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46196. * * 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
  46197. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46198. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  46199. * @param name defines the name of the mesh
  46200. * @param options defines the options used to create the mesh
  46201. * @param scene defines the hosting scene
  46202. * @returns the box mesh
  46203. */
  46204. static CreateBox(name: string, options: {
  46205. size?: number;
  46206. width?: number;
  46207. height?: number;
  46208. depth?: number;
  46209. faceUV?: Vector4[];
  46210. faceColors?: Color4[];
  46211. sideOrientation?: number;
  46212. frontUVs?: Vector4;
  46213. backUVs?: Vector4;
  46214. wrap?: boolean;
  46215. topBaseAt?: number;
  46216. bottomBaseAt?: number;
  46217. updatable?: boolean;
  46218. }, scene?: Nullable<Scene>): Mesh;
  46219. }
  46220. }
  46221. declare module BABYLON.Debug {
  46222. /**
  46223. * Used to show the physics impostor around the specific mesh
  46224. */
  46225. export class PhysicsViewer {
  46226. /** @hidden */
  46227. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  46228. /** @hidden */
  46229. protected _meshes: Array<Nullable<AbstractMesh>>;
  46230. /** @hidden */
  46231. protected _scene: Nullable<Scene>;
  46232. /** @hidden */
  46233. protected _numMeshes: number;
  46234. /** @hidden */
  46235. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  46236. private _renderFunction;
  46237. private _utilityLayer;
  46238. private _debugBoxMesh;
  46239. private _debugSphereMesh;
  46240. private _debugCylinderMesh;
  46241. private _debugMaterial;
  46242. private _debugMeshMeshes;
  46243. /**
  46244. * Creates a new PhysicsViewer
  46245. * @param scene defines the hosting scene
  46246. */
  46247. constructor(scene: Scene);
  46248. /** @hidden */
  46249. protected _updateDebugMeshes(): void;
  46250. /**
  46251. * Renders a specified physic impostor
  46252. * @param impostor defines the impostor to render
  46253. * @param targetMesh defines the mesh represented by the impostor
  46254. * @returns the new debug mesh used to render the impostor
  46255. */
  46256. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  46257. /**
  46258. * Hides a specified physic impostor
  46259. * @param impostor defines the impostor to hide
  46260. */
  46261. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  46262. private _getDebugMaterial;
  46263. private _getDebugBoxMesh;
  46264. private _getDebugSphereMesh;
  46265. private _getDebugCylinderMesh;
  46266. private _getDebugMeshMesh;
  46267. private _getDebugMesh;
  46268. /** Releases all resources */
  46269. dispose(): void;
  46270. }
  46271. }
  46272. declare module BABYLON {
  46273. /**
  46274. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46275. * in order to better appreciate the issue one might have.
  46276. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46277. */
  46278. export class RayHelper {
  46279. /**
  46280. * Defines the ray we are currently tryin to visualize.
  46281. */
  46282. ray: Nullable<Ray>;
  46283. private _renderPoints;
  46284. private _renderLine;
  46285. private _renderFunction;
  46286. private _scene;
  46287. private _updateToMeshFunction;
  46288. private _attachedToMesh;
  46289. private _meshSpaceDirection;
  46290. private _meshSpaceOrigin;
  46291. /**
  46292. * Helper function to create a colored helper in a scene in one line.
  46293. * @param ray Defines the ray we are currently tryin to visualize
  46294. * @param scene Defines the scene the ray is used in
  46295. * @param color Defines the color we want to see the ray in
  46296. * @returns The newly created ray helper.
  46297. */
  46298. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  46299. /**
  46300. * Instantiate a new ray helper.
  46301. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  46302. * in order to better appreciate the issue one might have.
  46303. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  46304. * @param ray Defines the ray we are currently tryin to visualize
  46305. */
  46306. constructor(ray: Ray);
  46307. /**
  46308. * Shows the ray we are willing to debug.
  46309. * @param scene Defines the scene the ray needs to be rendered in
  46310. * @param color Defines the color the ray needs to be rendered in
  46311. */
  46312. show(scene: Scene, color?: Color3): void;
  46313. /**
  46314. * Hides the ray we are debugging.
  46315. */
  46316. hide(): void;
  46317. private _render;
  46318. /**
  46319. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  46320. * @param mesh Defines the mesh we want the helper attached to
  46321. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  46322. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  46323. * @param length Defines the length of the ray
  46324. */
  46325. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  46326. /**
  46327. * Detach the ray helper from the mesh it has previously been attached to.
  46328. */
  46329. detachFromMesh(): void;
  46330. private _updateToMesh;
  46331. /**
  46332. * Dispose the helper and release its associated resources.
  46333. */
  46334. dispose(): void;
  46335. }
  46336. }
  46337. declare module BABYLON.Debug {
  46338. /**
  46339. * Class used to render a debug view of a given skeleton
  46340. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  46341. */
  46342. export class SkeletonViewer {
  46343. /** defines the skeleton to render */
  46344. skeleton: Skeleton;
  46345. /** defines the mesh attached to the skeleton */
  46346. mesh: AbstractMesh;
  46347. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46348. autoUpdateBonesMatrices: boolean;
  46349. /** defines the rendering group id to use with the viewer */
  46350. renderingGroupId: number;
  46351. /** Gets or sets the color used to render the skeleton */
  46352. color: Color3;
  46353. private _scene;
  46354. private _debugLines;
  46355. private _debugMesh;
  46356. private _isEnabled;
  46357. private _renderFunction;
  46358. private _utilityLayer;
  46359. /**
  46360. * Returns the mesh used to render the bones
  46361. */
  46362. get debugMesh(): Nullable<LinesMesh>;
  46363. /**
  46364. * Creates a new SkeletonViewer
  46365. * @param skeleton defines the skeleton to render
  46366. * @param mesh defines the mesh attached to the skeleton
  46367. * @param scene defines the hosting scene
  46368. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  46369. * @param renderingGroupId defines the rendering group id to use with the viewer
  46370. */
  46371. constructor(
  46372. /** defines the skeleton to render */
  46373. skeleton: Skeleton,
  46374. /** defines the mesh attached to the skeleton */
  46375. mesh: AbstractMesh, scene: Scene,
  46376. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  46377. autoUpdateBonesMatrices?: boolean,
  46378. /** defines the rendering group id to use with the viewer */
  46379. renderingGroupId?: number);
  46380. /** Gets or sets a boolean indicating if the viewer is enabled */
  46381. set isEnabled(value: boolean);
  46382. get isEnabled(): boolean;
  46383. private _getBonePosition;
  46384. private _getLinesForBonesWithLength;
  46385. private _getLinesForBonesNoLength;
  46386. /** Update the viewer to sync with current skeleton state */
  46387. update(): void;
  46388. /** Release associated resources */
  46389. dispose(): void;
  46390. }
  46391. }
  46392. declare module BABYLON {
  46393. /**
  46394. * Options to create the null engine
  46395. */
  46396. export class NullEngineOptions {
  46397. /**
  46398. * Render width (Default: 512)
  46399. */
  46400. renderWidth: number;
  46401. /**
  46402. * Render height (Default: 256)
  46403. */
  46404. renderHeight: number;
  46405. /**
  46406. * Texture size (Default: 512)
  46407. */
  46408. textureSize: number;
  46409. /**
  46410. * If delta time between frames should be constant
  46411. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46412. */
  46413. deterministicLockstep: boolean;
  46414. /**
  46415. * Maximum about of steps between frames (Default: 4)
  46416. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46417. */
  46418. lockstepMaxSteps: number;
  46419. }
  46420. /**
  46421. * The null engine class provides support for headless version of babylon.js.
  46422. * This can be used in server side scenario or for testing purposes
  46423. */
  46424. export class NullEngine extends Engine {
  46425. private _options;
  46426. /**
  46427. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  46428. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46429. * @returns true if engine is in deterministic lock step mode
  46430. */
  46431. isDeterministicLockStep(): boolean;
  46432. /**
  46433. * Gets the max steps when engine is running in deterministic lock step
  46434. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46435. * @returns the max steps
  46436. */
  46437. getLockstepMaxSteps(): number;
  46438. /**
  46439. * Gets the current hardware scaling level.
  46440. * By default the hardware scaling level is computed from the window device ratio.
  46441. * 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.
  46442. * @returns a number indicating the current hardware scaling level
  46443. */
  46444. getHardwareScalingLevel(): number;
  46445. constructor(options?: NullEngineOptions);
  46446. /**
  46447. * Creates a vertex buffer
  46448. * @param vertices the data for the vertex buffer
  46449. * @returns the new WebGL static buffer
  46450. */
  46451. createVertexBuffer(vertices: FloatArray): DataBuffer;
  46452. /**
  46453. * Creates a new index buffer
  46454. * @param indices defines the content of the index buffer
  46455. * @param updatable defines if the index buffer must be updatable
  46456. * @returns a new webGL buffer
  46457. */
  46458. createIndexBuffer(indices: IndicesArray): DataBuffer;
  46459. /**
  46460. * Clear the current render buffer or the current render target (if any is set up)
  46461. * @param color defines the color to use
  46462. * @param backBuffer defines if the back buffer must be cleared
  46463. * @param depth defines if the depth buffer must be cleared
  46464. * @param stencil defines if the stencil buffer must be cleared
  46465. */
  46466. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46467. /**
  46468. * Gets the current render width
  46469. * @param useScreen defines if screen size must be used (or the current render target if any)
  46470. * @returns a number defining the current render width
  46471. */
  46472. getRenderWidth(useScreen?: boolean): number;
  46473. /**
  46474. * Gets the current render height
  46475. * @param useScreen defines if screen size must be used (or the current render target if any)
  46476. * @returns a number defining the current render height
  46477. */
  46478. getRenderHeight(useScreen?: boolean): number;
  46479. /**
  46480. * Set the WebGL's viewport
  46481. * @param viewport defines the viewport element to be used
  46482. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  46483. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  46484. */
  46485. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  46486. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  46487. /**
  46488. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  46489. * @param pipelineContext defines the pipeline context to use
  46490. * @param uniformsNames defines the list of uniform names
  46491. * @returns an array of webGL uniform locations
  46492. */
  46493. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  46494. /**
  46495. * Gets the lsit of active attributes for a given webGL program
  46496. * @param pipelineContext defines the pipeline context to use
  46497. * @param attributesNames defines the list of attribute names to get
  46498. * @returns an array of indices indicating the offset of each attribute
  46499. */
  46500. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46501. /**
  46502. * Binds an effect to the webGL context
  46503. * @param effect defines the effect to bind
  46504. */
  46505. bindSamplers(effect: Effect): void;
  46506. /**
  46507. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  46508. * @param effect defines the effect to activate
  46509. */
  46510. enableEffect(effect: Effect): void;
  46511. /**
  46512. * Set various states to the webGL context
  46513. * @param culling defines backface culling state
  46514. * @param zOffset defines the value to apply to zOffset (0 by default)
  46515. * @param force defines if states must be applied even if cache is up to date
  46516. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  46517. */
  46518. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46519. /**
  46520. * Set the value of an uniform to an array of int32
  46521. * @param uniform defines the webGL uniform location where to store the value
  46522. * @param array defines the array of int32 to store
  46523. */
  46524. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46525. /**
  46526. * Set the value of an uniform to an array of int32 (stored as vec2)
  46527. * @param uniform defines the webGL uniform location where to store the value
  46528. * @param array defines the array of int32 to store
  46529. */
  46530. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46531. /**
  46532. * Set the value of an uniform to an array of int32 (stored as vec3)
  46533. * @param uniform defines the webGL uniform location where to store the value
  46534. * @param array defines the array of int32 to store
  46535. */
  46536. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46537. /**
  46538. * Set the value of an uniform to an array of int32 (stored as vec4)
  46539. * @param uniform defines the webGL uniform location where to store the value
  46540. * @param array defines the array of int32 to store
  46541. */
  46542. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46543. /**
  46544. * Set the value of an uniform to an array of float32
  46545. * @param uniform defines the webGL uniform location where to store the value
  46546. * @param array defines the array of float32 to store
  46547. */
  46548. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46549. /**
  46550. * Set the value of an uniform to an array of float32 (stored as vec2)
  46551. * @param uniform defines the webGL uniform location where to store the value
  46552. * @param array defines the array of float32 to store
  46553. */
  46554. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46555. /**
  46556. * Set the value of an uniform to an array of float32 (stored as vec3)
  46557. * @param uniform defines the webGL uniform location where to store the value
  46558. * @param array defines the array of float32 to store
  46559. */
  46560. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46561. /**
  46562. * Set the value of an uniform to an array of float32 (stored as vec4)
  46563. * @param uniform defines the webGL uniform location where to store the value
  46564. * @param array defines the array of float32 to store
  46565. */
  46566. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46567. /**
  46568. * Set the value of an uniform to an array of number
  46569. * @param uniform defines the webGL uniform location where to store the value
  46570. * @param array defines the array of number to store
  46571. */
  46572. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46573. /**
  46574. * Set the value of an uniform to an array of number (stored as vec2)
  46575. * @param uniform defines the webGL uniform location where to store the value
  46576. * @param array defines the array of number to store
  46577. */
  46578. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46579. /**
  46580. * Set the value of an uniform to an array of number (stored as vec3)
  46581. * @param uniform defines the webGL uniform location where to store the value
  46582. * @param array defines the array of number to store
  46583. */
  46584. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46585. /**
  46586. * Set the value of an uniform to an array of number (stored as vec4)
  46587. * @param uniform defines the webGL uniform location where to store the value
  46588. * @param array defines the array of number to store
  46589. */
  46590. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46591. /**
  46592. * Set the value of an uniform to an array of float32 (stored as matrices)
  46593. * @param uniform defines the webGL uniform location where to store the value
  46594. * @param matrices defines the array of float32 to store
  46595. */
  46596. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46597. /**
  46598. * Set the value of an uniform to a matrix (3x3)
  46599. * @param uniform defines the webGL uniform location where to store the value
  46600. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  46601. */
  46602. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46603. /**
  46604. * Set the value of an uniform to a matrix (2x2)
  46605. * @param uniform defines the webGL uniform location where to store the value
  46606. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  46607. */
  46608. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46609. /**
  46610. * Set the value of an uniform to a number (float)
  46611. * @param uniform defines the webGL uniform location where to store the value
  46612. * @param value defines the float number to store
  46613. */
  46614. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46615. /**
  46616. * Set the value of an uniform to a vec2
  46617. * @param uniform defines the webGL uniform location where to store the value
  46618. * @param x defines the 1st component of the value
  46619. * @param y defines the 2nd component of the value
  46620. */
  46621. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46622. /**
  46623. * Set the value of an uniform to a vec3
  46624. * @param uniform defines the webGL uniform location where to store the value
  46625. * @param x defines the 1st component of the value
  46626. * @param y defines the 2nd component of the value
  46627. * @param z defines the 3rd component of the value
  46628. */
  46629. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46630. /**
  46631. * Set the value of an uniform to a boolean
  46632. * @param uniform defines the webGL uniform location where to store the value
  46633. * @param bool defines the boolean to store
  46634. */
  46635. setBool(uniform: WebGLUniformLocation, bool: number): void;
  46636. /**
  46637. * Set the value of an uniform to a vec4
  46638. * @param uniform defines the webGL uniform location where to store the value
  46639. * @param x defines the 1st component of the value
  46640. * @param y defines the 2nd component of the value
  46641. * @param z defines the 3rd component of the value
  46642. * @param w defines the 4th component of the value
  46643. */
  46644. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46645. /**
  46646. * Sets the current alpha mode
  46647. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  46648. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46649. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46650. */
  46651. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46652. /**
  46653. * Bind webGl buffers directly to the webGL context
  46654. * @param vertexBuffers defines the vertex buffer to bind
  46655. * @param indexBuffer defines the index buffer to bind
  46656. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  46657. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  46658. * @param effect defines the effect associated with the vertex buffer
  46659. */
  46660. bindBuffers(vertexBuffers: {
  46661. [key: string]: VertexBuffer;
  46662. }, indexBuffer: DataBuffer, effect: Effect): void;
  46663. /**
  46664. * Force the entire cache to be cleared
  46665. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  46666. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  46667. */
  46668. wipeCaches(bruteForce?: boolean): void;
  46669. /**
  46670. * Send a draw order
  46671. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  46672. * @param indexStart defines the starting index
  46673. * @param indexCount defines the number of index to draw
  46674. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46675. */
  46676. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  46677. /**
  46678. * Draw a list of indexed primitives
  46679. * @param fillMode defines the primitive to use
  46680. * @param indexStart defines the starting index
  46681. * @param indexCount defines the number of index to draw
  46682. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46683. */
  46684. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46685. /**
  46686. * Draw a list of unindexed primitives
  46687. * @param fillMode defines the primitive to use
  46688. * @param verticesStart defines the index of first vertex to draw
  46689. * @param verticesCount defines the count of vertices to draw
  46690. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46691. */
  46692. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46693. /** @hidden */
  46694. _createTexture(): WebGLTexture;
  46695. /** @hidden */
  46696. _releaseTexture(texture: InternalTexture): void;
  46697. /**
  46698. * Usually called from Texture.ts.
  46699. * Passed information to create a WebGLTexture
  46700. * @param urlArg defines a value which contains one of the following:
  46701. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46702. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46703. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46704. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46705. * @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)
  46706. * @param scene needed for loading to the correct scene
  46707. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  46708. * @param onLoad optional callback to be called upon successful completion
  46709. * @param onError optional callback to be called upon failure
  46710. * @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
  46711. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46712. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46713. * @param forcedExtension defines the extension to use to pick the right loader
  46714. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  46715. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46716. */
  46717. 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;
  46718. /**
  46719. * Creates a new render target texture
  46720. * @param size defines the size of the texture
  46721. * @param options defines the options used to create the texture
  46722. * @returns a new render target texture stored in an InternalTexture
  46723. */
  46724. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46725. /**
  46726. * Update the sampling mode of a given texture
  46727. * @param samplingMode defines the required sampling mode
  46728. * @param texture defines the texture to update
  46729. */
  46730. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46731. /**
  46732. * Binds the frame buffer to the specified texture.
  46733. * @param texture The texture to render to or null for the default canvas
  46734. * @param faceIndex The face of the texture to render to in case of cube texture
  46735. * @param requiredWidth The width of the target to render to
  46736. * @param requiredHeight The height of the target to render to
  46737. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  46738. * @param lodLevel defines le lod level to bind to the frame buffer
  46739. */
  46740. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46741. /**
  46742. * Unbind the current render target texture from the webGL context
  46743. * @param texture defines the render target texture to unbind
  46744. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46745. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46746. */
  46747. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46748. /**
  46749. * Creates a dynamic vertex buffer
  46750. * @param vertices the data for the dynamic vertex buffer
  46751. * @returns the new WebGL dynamic buffer
  46752. */
  46753. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  46754. /**
  46755. * Update the content of a dynamic texture
  46756. * @param texture defines the texture to update
  46757. * @param canvas defines the canvas containing the source
  46758. * @param invertY defines if data must be stored with Y axis inverted
  46759. * @param premulAlpha defines if alpha is stored as premultiplied
  46760. * @param format defines the format of the data
  46761. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  46762. */
  46763. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  46764. /**
  46765. * Gets a boolean indicating if all created effects are ready
  46766. * @returns true if all effects are ready
  46767. */
  46768. areAllEffectsReady(): boolean;
  46769. /**
  46770. * @hidden
  46771. * Get the current error code of the webGL context
  46772. * @returns the error code
  46773. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  46774. */
  46775. getError(): number;
  46776. /** @hidden */
  46777. _getUnpackAlignement(): number;
  46778. /** @hidden */
  46779. _unpackFlipY(value: boolean): void;
  46780. /**
  46781. * Update a dynamic index buffer
  46782. * @param indexBuffer defines the target index buffer
  46783. * @param indices defines the data to update
  46784. * @param offset defines the offset in the target index buffer where update should start
  46785. */
  46786. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  46787. /**
  46788. * Updates a dynamic vertex buffer.
  46789. * @param vertexBuffer the vertex buffer to update
  46790. * @param vertices the data used to update the vertex buffer
  46791. * @param byteOffset the byte offset of the data (optional)
  46792. * @param byteLength the byte length of the data (optional)
  46793. */
  46794. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  46795. /** @hidden */
  46796. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  46797. /** @hidden */
  46798. _bindTexture(channel: number, texture: InternalTexture): void;
  46799. protected _deleteBuffer(buffer: WebGLBuffer): void;
  46800. /**
  46801. * 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
  46802. */
  46803. releaseEffects(): void;
  46804. displayLoadingUI(): void;
  46805. hideLoadingUI(): void;
  46806. /** @hidden */
  46807. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46808. /** @hidden */
  46809. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46810. /** @hidden */
  46811. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46812. /** @hidden */
  46813. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46814. }
  46815. }
  46816. declare module BABYLON {
  46817. /**
  46818. * @hidden
  46819. **/
  46820. export class _TimeToken {
  46821. _startTimeQuery: Nullable<WebGLQuery>;
  46822. _endTimeQuery: Nullable<WebGLQuery>;
  46823. _timeElapsedQuery: Nullable<WebGLQuery>;
  46824. _timeElapsedQueryEnded: boolean;
  46825. }
  46826. }
  46827. declare module BABYLON {
  46828. /** @hidden */
  46829. export class _OcclusionDataStorage {
  46830. /** @hidden */
  46831. occlusionInternalRetryCounter: number;
  46832. /** @hidden */
  46833. isOcclusionQueryInProgress: boolean;
  46834. /** @hidden */
  46835. isOccluded: boolean;
  46836. /** @hidden */
  46837. occlusionRetryCount: number;
  46838. /** @hidden */
  46839. occlusionType: number;
  46840. /** @hidden */
  46841. occlusionQueryAlgorithmType: number;
  46842. }
  46843. interface Engine {
  46844. /**
  46845. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  46846. * @return the new query
  46847. */
  46848. createQuery(): WebGLQuery;
  46849. /**
  46850. * Delete and release a webGL query
  46851. * @param query defines the query to delete
  46852. * @return the current engine
  46853. */
  46854. deleteQuery(query: WebGLQuery): Engine;
  46855. /**
  46856. * Check if a given query has resolved and got its value
  46857. * @param query defines the query to check
  46858. * @returns true if the query got its value
  46859. */
  46860. isQueryResultAvailable(query: WebGLQuery): boolean;
  46861. /**
  46862. * Gets the value of a given query
  46863. * @param query defines the query to check
  46864. * @returns the value of the query
  46865. */
  46866. getQueryResult(query: WebGLQuery): number;
  46867. /**
  46868. * Initiates an occlusion query
  46869. * @param algorithmType defines the algorithm to use
  46870. * @param query defines the query to use
  46871. * @returns the current engine
  46872. * @see http://doc.babylonjs.com/features/occlusionquery
  46873. */
  46874. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  46875. /**
  46876. * Ends an occlusion query
  46877. * @see http://doc.babylonjs.com/features/occlusionquery
  46878. * @param algorithmType defines the algorithm to use
  46879. * @returns the current engine
  46880. */
  46881. endOcclusionQuery(algorithmType: number): Engine;
  46882. /**
  46883. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  46884. * Please note that only one query can be issued at a time
  46885. * @returns a time token used to track the time span
  46886. */
  46887. startTimeQuery(): Nullable<_TimeToken>;
  46888. /**
  46889. * Ends a time query
  46890. * @param token defines the token used to measure the time span
  46891. * @returns the time spent (in ns)
  46892. */
  46893. endTimeQuery(token: _TimeToken): int;
  46894. /** @hidden */
  46895. _currentNonTimestampToken: Nullable<_TimeToken>;
  46896. /** @hidden */
  46897. _createTimeQuery(): WebGLQuery;
  46898. /** @hidden */
  46899. _deleteTimeQuery(query: WebGLQuery): void;
  46900. /** @hidden */
  46901. _getGlAlgorithmType(algorithmType: number): number;
  46902. /** @hidden */
  46903. _getTimeQueryResult(query: WebGLQuery): any;
  46904. /** @hidden */
  46905. _getTimeQueryAvailability(query: WebGLQuery): any;
  46906. }
  46907. interface AbstractMesh {
  46908. /**
  46909. * Backing filed
  46910. * @hidden
  46911. */
  46912. __occlusionDataStorage: _OcclusionDataStorage;
  46913. /**
  46914. * Access property
  46915. * @hidden
  46916. */
  46917. _occlusionDataStorage: _OcclusionDataStorage;
  46918. /**
  46919. * 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.
  46920. * The default value is -1 which means don't break the query and wait till the result
  46921. * @see http://doc.babylonjs.com/features/occlusionquery
  46922. */
  46923. occlusionRetryCount: number;
  46924. /**
  46925. * 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:
  46926. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  46927. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  46928. * * 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.
  46929. * @see http://doc.babylonjs.com/features/occlusionquery
  46930. */
  46931. occlusionType: number;
  46932. /**
  46933. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  46934. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  46935. * * 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.
  46936. * @see http://doc.babylonjs.com/features/occlusionquery
  46937. */
  46938. occlusionQueryAlgorithmType: number;
  46939. /**
  46940. * 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
  46941. * @see http://doc.babylonjs.com/features/occlusionquery
  46942. */
  46943. isOccluded: boolean;
  46944. /**
  46945. * Flag to check the progress status of the query
  46946. * @see http://doc.babylonjs.com/features/occlusionquery
  46947. */
  46948. isOcclusionQueryInProgress: boolean;
  46949. }
  46950. }
  46951. declare module BABYLON {
  46952. /** @hidden */
  46953. export var _forceTransformFeedbackToBundle: boolean;
  46954. interface Engine {
  46955. /**
  46956. * Creates a webGL transform feedback object
  46957. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  46958. * @returns the webGL transform feedback object
  46959. */
  46960. createTransformFeedback(): WebGLTransformFeedback;
  46961. /**
  46962. * Delete a webGL transform feedback object
  46963. * @param value defines the webGL transform feedback object to delete
  46964. */
  46965. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  46966. /**
  46967. * Bind a webGL transform feedback object to the webgl context
  46968. * @param value defines the webGL transform feedback object to bind
  46969. */
  46970. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  46971. /**
  46972. * Begins a transform feedback operation
  46973. * @param usePoints defines if points or triangles must be used
  46974. */
  46975. beginTransformFeedback(usePoints: boolean): void;
  46976. /**
  46977. * Ends a transform feedback operation
  46978. */
  46979. endTransformFeedback(): void;
  46980. /**
  46981. * Specify the varyings to use with transform feedback
  46982. * @param program defines the associated webGL program
  46983. * @param value defines the list of strings representing the varying names
  46984. */
  46985. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  46986. /**
  46987. * Bind a webGL buffer for a transform feedback operation
  46988. * @param value defines the webGL buffer to bind
  46989. */
  46990. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  46991. }
  46992. }
  46993. declare module BABYLON {
  46994. /**
  46995. * Creation options of the multi render target texture.
  46996. */
  46997. export interface IMultiRenderTargetOptions {
  46998. /**
  46999. * Define if the texture needs to create mip maps after render.
  47000. */
  47001. generateMipMaps?: boolean;
  47002. /**
  47003. * Define the types of all the draw buffers we want to create
  47004. */
  47005. types?: number[];
  47006. /**
  47007. * Define the sampling modes of all the draw buffers we want to create
  47008. */
  47009. samplingModes?: number[];
  47010. /**
  47011. * Define if a depth buffer is required
  47012. */
  47013. generateDepthBuffer?: boolean;
  47014. /**
  47015. * Define if a stencil buffer is required
  47016. */
  47017. generateStencilBuffer?: boolean;
  47018. /**
  47019. * Define if a depth texture is required instead of a depth buffer
  47020. */
  47021. generateDepthTexture?: boolean;
  47022. /**
  47023. * Define the number of desired draw buffers
  47024. */
  47025. textureCount?: number;
  47026. /**
  47027. * Define if aspect ratio should be adapted to the texture or stay the scene one
  47028. */
  47029. doNotChangeAspectRatio?: boolean;
  47030. /**
  47031. * Define the default type of the buffers we are creating
  47032. */
  47033. defaultType?: number;
  47034. }
  47035. /**
  47036. * A multi render target, like a render target provides the ability to render to a texture.
  47037. * Unlike the render target, it can render to several draw buffers in one draw.
  47038. * This is specially interesting in deferred rendering or for any effects requiring more than
  47039. * just one color from a single pass.
  47040. */
  47041. export class MultiRenderTarget extends RenderTargetTexture {
  47042. private _internalTextures;
  47043. private _textures;
  47044. private _multiRenderTargetOptions;
  47045. /**
  47046. * Get if draw buffers are currently supported by the used hardware and browser.
  47047. */
  47048. get isSupported(): boolean;
  47049. /**
  47050. * Get the list of textures generated by the multi render target.
  47051. */
  47052. get textures(): Texture[];
  47053. /**
  47054. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  47055. */
  47056. get depthTexture(): Texture;
  47057. /**
  47058. * Set the wrapping mode on U of all the textures we are rendering to.
  47059. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47060. */
  47061. set wrapU(wrap: number);
  47062. /**
  47063. * Set the wrapping mode on V of all the textures we are rendering to.
  47064. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  47065. */
  47066. set wrapV(wrap: number);
  47067. /**
  47068. * Instantiate a new multi render target texture.
  47069. * A multi render target, like a render target provides the ability to render to a texture.
  47070. * Unlike the render target, it can render to several draw buffers in one draw.
  47071. * This is specially interesting in deferred rendering or for any effects requiring more than
  47072. * just one color from a single pass.
  47073. * @param name Define the name of the texture
  47074. * @param size Define the size of the buffers to render to
  47075. * @param count Define the number of target we are rendering into
  47076. * @param scene Define the scene the texture belongs to
  47077. * @param options Define the options used to create the multi render target
  47078. */
  47079. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  47080. /** @hidden */
  47081. _rebuild(): void;
  47082. private _createInternalTextures;
  47083. private _createTextures;
  47084. /**
  47085. * Define the number of samples used if MSAA is enabled.
  47086. */
  47087. get samples(): number;
  47088. set samples(value: number);
  47089. /**
  47090. * Resize all the textures in the multi render target.
  47091. * Be carrefull as it will recreate all the data in the new texture.
  47092. * @param size Define the new size
  47093. */
  47094. resize(size: any): void;
  47095. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  47096. /**
  47097. * Dispose the render targets and their associated resources
  47098. */
  47099. dispose(): void;
  47100. /**
  47101. * Release all the underlying texture used as draw buffers.
  47102. */
  47103. releaseInternalTextures(): void;
  47104. }
  47105. }
  47106. declare module BABYLON {
  47107. interface ThinEngine {
  47108. /**
  47109. * Unbind a list of render target textures from the webGL context
  47110. * This is used only when drawBuffer extension or webGL2 are active
  47111. * @param textures defines the render target textures to unbind
  47112. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  47113. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  47114. */
  47115. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  47116. /**
  47117. * Create a multi render target texture
  47118. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  47119. * @param size defines the size of the texture
  47120. * @param options defines the creation options
  47121. * @returns the cube texture as an InternalTexture
  47122. */
  47123. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  47124. /**
  47125. * Update the sample count for a given multiple render target texture
  47126. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  47127. * @param textures defines the textures to update
  47128. * @param samples defines the sample count to set
  47129. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  47130. */
  47131. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  47132. }
  47133. }
  47134. declare module BABYLON {
  47135. /**
  47136. * Class used to define an additional view for the engine
  47137. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47138. */
  47139. export class EngineView {
  47140. /** Defines the canvas where to render the view */
  47141. target: HTMLCanvasElement;
  47142. /** Defines an optional camera used to render the view (will use active camera else) */
  47143. camera?: Camera;
  47144. }
  47145. interface Engine {
  47146. /**
  47147. * Gets or sets the HTML element to use for attaching events
  47148. */
  47149. inputElement: Nullable<HTMLElement>;
  47150. /**
  47151. * Gets the current engine view
  47152. * @see https://doc.babylonjs.com/how_to/multi_canvases
  47153. */
  47154. activeView: Nullable<EngineView>;
  47155. /** Gets or sets the list of views */
  47156. views: EngineView[];
  47157. /**
  47158. * Register a new child canvas
  47159. * @param canvas defines the canvas to register
  47160. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  47161. * @returns the associated view
  47162. */
  47163. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  47164. /**
  47165. * Remove a registered child canvas
  47166. * @param canvas defines the canvas to remove
  47167. * @returns the current engine
  47168. */
  47169. unRegisterView(canvas: HTMLCanvasElement): Engine;
  47170. }
  47171. }
  47172. declare module BABYLON {
  47173. /**
  47174. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  47175. */
  47176. export interface CubeMapInfo {
  47177. /**
  47178. * The pixel array for the front face.
  47179. * This is stored in format, left to right, up to down format.
  47180. */
  47181. front: Nullable<ArrayBufferView>;
  47182. /**
  47183. * The pixel array for the back face.
  47184. * This is stored in format, left to right, up to down format.
  47185. */
  47186. back: Nullable<ArrayBufferView>;
  47187. /**
  47188. * The pixel array for the left face.
  47189. * This is stored in format, left to right, up to down format.
  47190. */
  47191. left: Nullable<ArrayBufferView>;
  47192. /**
  47193. * The pixel array for the right face.
  47194. * This is stored in format, left to right, up to down format.
  47195. */
  47196. right: Nullable<ArrayBufferView>;
  47197. /**
  47198. * The pixel array for the up face.
  47199. * This is stored in format, left to right, up to down format.
  47200. */
  47201. up: Nullable<ArrayBufferView>;
  47202. /**
  47203. * The pixel array for the down face.
  47204. * This is stored in format, left to right, up to down format.
  47205. */
  47206. down: Nullable<ArrayBufferView>;
  47207. /**
  47208. * The size of the cubemap stored.
  47209. *
  47210. * Each faces will be size * size pixels.
  47211. */
  47212. size: number;
  47213. /**
  47214. * The format of the texture.
  47215. *
  47216. * RGBA, RGB.
  47217. */
  47218. format: number;
  47219. /**
  47220. * The type of the texture data.
  47221. *
  47222. * UNSIGNED_INT, FLOAT.
  47223. */
  47224. type: number;
  47225. /**
  47226. * Specifies whether the texture is in gamma space.
  47227. */
  47228. gammaSpace: boolean;
  47229. }
  47230. /**
  47231. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  47232. */
  47233. export class PanoramaToCubeMapTools {
  47234. private static FACE_FRONT;
  47235. private static FACE_BACK;
  47236. private static FACE_RIGHT;
  47237. private static FACE_LEFT;
  47238. private static FACE_DOWN;
  47239. private static FACE_UP;
  47240. /**
  47241. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  47242. *
  47243. * @param float32Array The source data.
  47244. * @param inputWidth The width of the input panorama.
  47245. * @param inputHeight The height of the input panorama.
  47246. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  47247. * @return The cubemap data
  47248. */
  47249. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  47250. private static CreateCubemapTexture;
  47251. private static CalcProjectionSpherical;
  47252. }
  47253. }
  47254. declare module BABYLON {
  47255. /**
  47256. * Helper class dealing with the extraction of spherical polynomial dataArray
  47257. * from a cube map.
  47258. */
  47259. export class CubeMapToSphericalPolynomialTools {
  47260. private static FileFaces;
  47261. /**
  47262. * Converts a texture to the according Spherical Polynomial data.
  47263. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47264. *
  47265. * @param texture The texture to extract the information from.
  47266. * @return The Spherical Polynomial data.
  47267. */
  47268. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  47269. /**
  47270. * Converts a cubemap to the according Spherical Polynomial data.
  47271. * This extracts the first 3 orders only as they are the only one used in the lighting.
  47272. *
  47273. * @param cubeInfo The Cube map to extract the information from.
  47274. * @return The Spherical Polynomial data.
  47275. */
  47276. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  47277. }
  47278. }
  47279. declare module BABYLON {
  47280. interface BaseTexture {
  47281. /**
  47282. * Get the polynomial representation of the texture data.
  47283. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  47284. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  47285. */
  47286. sphericalPolynomial: Nullable<SphericalPolynomial>;
  47287. }
  47288. }
  47289. declare module BABYLON {
  47290. /** @hidden */
  47291. export var rgbdEncodePixelShader: {
  47292. name: string;
  47293. shader: string;
  47294. };
  47295. }
  47296. declare module BABYLON {
  47297. /** @hidden */
  47298. export var rgbdDecodePixelShader: {
  47299. name: string;
  47300. shader: string;
  47301. };
  47302. }
  47303. declare module BABYLON {
  47304. /**
  47305. * Raw texture data and descriptor sufficient for WebGL texture upload
  47306. */
  47307. export interface EnvironmentTextureInfo {
  47308. /**
  47309. * Version of the environment map
  47310. */
  47311. version: number;
  47312. /**
  47313. * Width of image
  47314. */
  47315. width: number;
  47316. /**
  47317. * Irradiance information stored in the file.
  47318. */
  47319. irradiance: any;
  47320. /**
  47321. * Specular information stored in the file.
  47322. */
  47323. specular: any;
  47324. }
  47325. /**
  47326. * Defines One Image in the file. It requires only the position in the file
  47327. * as well as the length.
  47328. */
  47329. interface BufferImageData {
  47330. /**
  47331. * Length of the image data.
  47332. */
  47333. length: number;
  47334. /**
  47335. * Position of the data from the null terminator delimiting the end of the JSON.
  47336. */
  47337. position: number;
  47338. }
  47339. /**
  47340. * Defines the specular data enclosed in the file.
  47341. * This corresponds to the version 1 of the data.
  47342. */
  47343. export interface EnvironmentTextureSpecularInfoV1 {
  47344. /**
  47345. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  47346. */
  47347. specularDataPosition?: number;
  47348. /**
  47349. * This contains all the images data needed to reconstruct the cubemap.
  47350. */
  47351. mipmaps: Array<BufferImageData>;
  47352. /**
  47353. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  47354. */
  47355. lodGenerationScale: number;
  47356. }
  47357. /**
  47358. * Sets of helpers addressing the serialization and deserialization of environment texture
  47359. * stored in a BabylonJS env file.
  47360. * Those files are usually stored as .env files.
  47361. */
  47362. export class EnvironmentTextureTools {
  47363. /**
  47364. * Magic number identifying the env file.
  47365. */
  47366. private static _MagicBytes;
  47367. /**
  47368. * Gets the environment info from an env file.
  47369. * @param data The array buffer containing the .env bytes.
  47370. * @returns the environment file info (the json header) if successfully parsed.
  47371. */
  47372. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  47373. /**
  47374. * Creates an environment texture from a loaded cube texture.
  47375. * @param texture defines the cube texture to convert in env file
  47376. * @return a promise containing the environment data if succesfull.
  47377. */
  47378. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47379. /**
  47380. * Creates a JSON representation of the spherical data.
  47381. * @param texture defines the texture containing the polynomials
  47382. * @return the JSON representation of the spherical info
  47383. */
  47384. private static _CreateEnvTextureIrradiance;
  47385. /**
  47386. * Creates the ArrayBufferViews used for initializing environment texture image data.
  47387. * @param data the image data
  47388. * @param info parameters that determine what views will be created for accessing the underlying buffer
  47389. * @return the views described by info providing access to the underlying buffer
  47390. */
  47391. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  47392. /**
  47393. * Uploads the texture info contained in the env file to the GPU.
  47394. * @param texture defines the internal texture to upload to
  47395. * @param data defines the data to load
  47396. * @param info defines the texture info retrieved through the GetEnvInfo method
  47397. * @returns a promise
  47398. */
  47399. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  47400. private static _OnImageReadyAsync;
  47401. /**
  47402. * Uploads the levels of image data to the GPU.
  47403. * @param texture defines the internal texture to upload to
  47404. * @param imageData defines the array buffer views of image data [mipmap][face]
  47405. * @returns a promise
  47406. */
  47407. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47408. /**
  47409. * Uploads spherical polynomials information to the texture.
  47410. * @param texture defines the texture we are trying to upload the information to
  47411. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47412. */
  47413. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47414. /** @hidden */
  47415. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47416. }
  47417. }
  47418. declare module BABYLON {
  47419. /**
  47420. * Contains position and normal vectors for a vertex
  47421. */
  47422. export class PositionNormalVertex {
  47423. /** the position of the vertex (defaut: 0,0,0) */
  47424. position: Vector3;
  47425. /** the normal of the vertex (defaut: 0,1,0) */
  47426. normal: Vector3;
  47427. /**
  47428. * Creates a PositionNormalVertex
  47429. * @param position the position of the vertex (defaut: 0,0,0)
  47430. * @param normal the normal of the vertex (defaut: 0,1,0)
  47431. */
  47432. constructor(
  47433. /** the position of the vertex (defaut: 0,0,0) */
  47434. position?: Vector3,
  47435. /** the normal of the vertex (defaut: 0,1,0) */
  47436. normal?: Vector3);
  47437. /**
  47438. * Clones the PositionNormalVertex
  47439. * @returns the cloned PositionNormalVertex
  47440. */
  47441. clone(): PositionNormalVertex;
  47442. }
  47443. /**
  47444. * Contains position, normal and uv vectors for a vertex
  47445. */
  47446. export class PositionNormalTextureVertex {
  47447. /** the position of the vertex (defaut: 0,0,0) */
  47448. position: Vector3;
  47449. /** the normal of the vertex (defaut: 0,1,0) */
  47450. normal: Vector3;
  47451. /** the uv of the vertex (default: 0,0) */
  47452. uv: Vector2;
  47453. /**
  47454. * Creates a PositionNormalTextureVertex
  47455. * @param position the position of the vertex (defaut: 0,0,0)
  47456. * @param normal the normal of the vertex (defaut: 0,1,0)
  47457. * @param uv the uv of the vertex (default: 0,0)
  47458. */
  47459. constructor(
  47460. /** the position of the vertex (defaut: 0,0,0) */
  47461. position?: Vector3,
  47462. /** the normal of the vertex (defaut: 0,1,0) */
  47463. normal?: Vector3,
  47464. /** the uv of the vertex (default: 0,0) */
  47465. uv?: Vector2);
  47466. /**
  47467. * Clones the PositionNormalTextureVertex
  47468. * @returns the cloned PositionNormalTextureVertex
  47469. */
  47470. clone(): PositionNormalTextureVertex;
  47471. }
  47472. }
  47473. declare module BABYLON {
  47474. /** @hidden */
  47475. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  47476. private _genericAttributeLocation;
  47477. private _varyingLocationCount;
  47478. private _varyingLocationMap;
  47479. private _replacements;
  47480. private _textureCount;
  47481. private _uniforms;
  47482. lineProcessor(line: string): string;
  47483. attributeProcessor(attribute: string): string;
  47484. varyingProcessor(varying: string, isFragment: boolean): string;
  47485. uniformProcessor(uniform: string): string;
  47486. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  47487. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  47488. }
  47489. }
  47490. declare module BABYLON {
  47491. /**
  47492. * Container for accessors for natively-stored mesh data buffers.
  47493. */
  47494. class NativeDataBuffer extends DataBuffer {
  47495. /**
  47496. * Accessor value used to identify/retrieve a natively-stored index buffer.
  47497. */
  47498. nativeIndexBuffer?: any;
  47499. /**
  47500. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  47501. */
  47502. nativeVertexBuffer?: any;
  47503. }
  47504. /** @hidden */
  47505. class NativeTexture extends InternalTexture {
  47506. getInternalTexture(): InternalTexture;
  47507. getViewCount(): number;
  47508. }
  47509. /** @hidden */
  47510. export class NativeEngine extends Engine {
  47511. private readonly _native;
  47512. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  47513. private readonly INVALID_HANDLE;
  47514. getHardwareScalingLevel(): number;
  47515. constructor();
  47516. /**
  47517. * Can be used to override the current requestAnimationFrame requester.
  47518. * @hidden
  47519. */
  47520. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  47521. /**
  47522. * Override default engine behavior.
  47523. * @param color
  47524. * @param backBuffer
  47525. * @param depth
  47526. * @param stencil
  47527. */
  47528. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  47529. /**
  47530. * Gets host document
  47531. * @returns the host document object
  47532. */
  47533. getHostDocument(): Nullable<Document>;
  47534. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  47535. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  47536. createVertexBuffer(data: DataArray): NativeDataBuffer;
  47537. recordVertexArrayObject(vertexBuffers: {
  47538. [key: string]: VertexBuffer;
  47539. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  47540. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47541. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  47542. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  47543. /**
  47544. * Draw a list of indexed primitives
  47545. * @param fillMode defines the primitive to use
  47546. * @param indexStart defines the starting index
  47547. * @param indexCount defines the number of index to draw
  47548. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47549. */
  47550. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  47551. /**
  47552. * Draw a list of unindexed primitives
  47553. * @param fillMode defines the primitive to use
  47554. * @param verticesStart defines the index of first vertex to draw
  47555. * @param verticesCount defines the count of vertices to draw
  47556. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  47557. */
  47558. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  47559. createPipelineContext(): IPipelineContext;
  47560. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  47561. /** @hidden */
  47562. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  47563. /** @hidden */
  47564. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  47565. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47566. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  47567. protected _setProgram(program: WebGLProgram): void;
  47568. _releaseEffect(effect: Effect): void;
  47569. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  47570. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  47571. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  47572. bindSamplers(effect: Effect): void;
  47573. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  47574. getRenderWidth(useScreen?: boolean): number;
  47575. getRenderHeight(useScreen?: boolean): number;
  47576. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  47577. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  47578. /**
  47579. * Set the z offset to apply to current rendering
  47580. * @param value defines the offset to apply
  47581. */
  47582. setZOffset(value: number): void;
  47583. /**
  47584. * Gets the current value of the zOffset
  47585. * @returns the current zOffset state
  47586. */
  47587. getZOffset(): number;
  47588. /**
  47589. * Enable or disable depth buffering
  47590. * @param enable defines the state to set
  47591. */
  47592. setDepthBuffer(enable: boolean): void;
  47593. /**
  47594. * Gets a boolean indicating if depth writing is enabled
  47595. * @returns the current depth writing state
  47596. */
  47597. getDepthWrite(): boolean;
  47598. /**
  47599. * Enable or disable depth writing
  47600. * @param enable defines the state to set
  47601. */
  47602. setDepthWrite(enable: boolean): void;
  47603. /**
  47604. * Enable or disable color writing
  47605. * @param enable defines the state to set
  47606. */
  47607. setColorWrite(enable: boolean): void;
  47608. /**
  47609. * Gets a boolean indicating if color writing is enabled
  47610. * @returns the current color writing state
  47611. */
  47612. getColorWrite(): boolean;
  47613. /**
  47614. * Sets alpha constants used by some alpha blending modes
  47615. * @param r defines the red component
  47616. * @param g defines the green component
  47617. * @param b defines the blue component
  47618. * @param a defines the alpha component
  47619. */
  47620. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  47621. /**
  47622. * Sets the current alpha mode
  47623. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  47624. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  47625. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47626. */
  47627. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  47628. /**
  47629. * Gets the current alpha mode
  47630. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  47631. * @returns the current alpha mode
  47632. */
  47633. getAlphaMode(): number;
  47634. setInt(uniform: WebGLUniformLocation, int: number): void;
  47635. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  47636. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  47637. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  47638. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  47639. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  47640. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  47641. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  47642. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  47643. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  47644. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  47645. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  47646. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  47647. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  47648. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47649. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  47650. setFloat(uniform: WebGLUniformLocation, value: number): void;
  47651. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  47652. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  47653. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  47654. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  47655. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  47656. wipeCaches(bruteForce?: boolean): void;
  47657. _createTexture(): WebGLTexture;
  47658. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  47659. /**
  47660. * Usually called from BABYLON.Texture.ts.
  47661. * Passed information to create a WebGLTexture
  47662. * @param urlArg defines a value which contains one of the following:
  47663. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  47664. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  47665. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  47666. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  47667. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  47668. * @param scene needed for loading to the correct scene
  47669. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  47670. * @param onLoad optional callback to be called upon successful completion
  47671. * @param onError optional callback to be called upon failure
  47672. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  47673. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  47674. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  47675. * @param forcedExtension defines the extension to use to pick the right loader
  47676. * @returns a InternalTexture for assignment back into BABYLON.Texture
  47677. */
  47678. 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;
  47679. /**
  47680. * Creates a cube texture
  47681. * @param rootUrl defines the url where the files to load is located
  47682. * @param scene defines the current scene
  47683. * @param files defines the list of files to load (1 per face)
  47684. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  47685. * @param onLoad defines an optional callback raised when the texture is loaded
  47686. * @param onError defines an optional callback raised if there is an issue to load the texture
  47687. * @param format defines the format of the data
  47688. * @param forcedExtension defines the extension to use to pick the right loader
  47689. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  47690. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  47691. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  47692. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  47693. * @returns the cube texture as an InternalTexture
  47694. */
  47695. 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;
  47696. private _getSamplingFilter;
  47697. private static _GetNativeTextureFormat;
  47698. createRenderTargetTexture(size: number | {
  47699. width: number;
  47700. height: number;
  47701. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  47702. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  47703. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  47704. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  47705. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  47706. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  47707. /**
  47708. * Updates a dynamic vertex buffer.
  47709. * @param vertexBuffer the vertex buffer to update
  47710. * @param data the data used to update the vertex buffer
  47711. * @param byteOffset the byte offset of the data (optional)
  47712. * @param byteLength the byte length of the data (optional)
  47713. */
  47714. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  47715. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  47716. private _updateAnisotropicLevel;
  47717. private _getAddressMode;
  47718. /** @hidden */
  47719. _bindTexture(channel: number, texture: InternalTexture): void;
  47720. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  47721. releaseEffects(): void;
  47722. /** @hidden */
  47723. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47724. /** @hidden */
  47725. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47726. /** @hidden */
  47727. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  47728. /** @hidden */
  47729. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  47730. }
  47731. }
  47732. declare module BABYLON {
  47733. /**
  47734. * Gather the list of clipboard event types as constants.
  47735. */
  47736. export class ClipboardEventTypes {
  47737. /**
  47738. * The clipboard event is fired when a copy command is active (pressed).
  47739. */
  47740. static readonly COPY: number;
  47741. /**
  47742. * The clipboard event is fired when a cut command is active (pressed).
  47743. */
  47744. static readonly CUT: number;
  47745. /**
  47746. * The clipboard event is fired when a paste command is active (pressed).
  47747. */
  47748. static readonly PASTE: number;
  47749. }
  47750. /**
  47751. * This class is used to store clipboard related info for the onClipboardObservable event.
  47752. */
  47753. export class ClipboardInfo {
  47754. /**
  47755. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47756. */
  47757. type: number;
  47758. /**
  47759. * Defines the related dom event
  47760. */
  47761. event: ClipboardEvent;
  47762. /**
  47763. *Creates an instance of ClipboardInfo.
  47764. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  47765. * @param event Defines the related dom event
  47766. */
  47767. constructor(
  47768. /**
  47769. * Defines the type of event (BABYLON.ClipboardEventTypes)
  47770. */
  47771. type: number,
  47772. /**
  47773. * Defines the related dom event
  47774. */
  47775. event: ClipboardEvent);
  47776. /**
  47777. * Get the clipboard event's type from the keycode.
  47778. * @param keyCode Defines the keyCode for the current keyboard event.
  47779. * @return {number}
  47780. */
  47781. static GetTypeFromCharacter(keyCode: number): number;
  47782. }
  47783. }
  47784. declare module BABYLON {
  47785. /**
  47786. * Google Daydream controller
  47787. */
  47788. export class DaydreamController extends WebVRController {
  47789. /**
  47790. * Base Url for the controller model.
  47791. */
  47792. static MODEL_BASE_URL: string;
  47793. /**
  47794. * File name for the controller model.
  47795. */
  47796. static MODEL_FILENAME: string;
  47797. /**
  47798. * Gamepad Id prefix used to identify Daydream Controller.
  47799. */
  47800. static readonly GAMEPAD_ID_PREFIX: string;
  47801. /**
  47802. * Creates a new DaydreamController from a gamepad
  47803. * @param vrGamepad the gamepad that the controller should be created from
  47804. */
  47805. constructor(vrGamepad: any);
  47806. /**
  47807. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47808. * @param scene scene in which to add meshes
  47809. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47810. */
  47811. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47812. /**
  47813. * Called once for each button that changed state since the last frame
  47814. * @param buttonIdx Which button index changed
  47815. * @param state New state of the button
  47816. * @param changes Which properties on the state changed since last frame
  47817. */
  47818. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47819. }
  47820. }
  47821. declare module BABYLON {
  47822. /**
  47823. * Gear VR Controller
  47824. */
  47825. export class GearVRController extends WebVRController {
  47826. /**
  47827. * Base Url for the controller model.
  47828. */
  47829. static MODEL_BASE_URL: string;
  47830. /**
  47831. * File name for the controller model.
  47832. */
  47833. static MODEL_FILENAME: string;
  47834. /**
  47835. * Gamepad Id prefix used to identify this controller.
  47836. */
  47837. static readonly GAMEPAD_ID_PREFIX: string;
  47838. private readonly _buttonIndexToObservableNameMap;
  47839. /**
  47840. * Creates a new GearVRController from a gamepad
  47841. * @param vrGamepad the gamepad that the controller should be created from
  47842. */
  47843. constructor(vrGamepad: any);
  47844. /**
  47845. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47846. * @param scene scene in which to add meshes
  47847. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47848. */
  47849. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47850. /**
  47851. * Called once for each button that changed state since the last frame
  47852. * @param buttonIdx Which button index changed
  47853. * @param state New state of the button
  47854. * @param changes Which properties on the state changed since last frame
  47855. */
  47856. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47857. }
  47858. }
  47859. declare module BABYLON {
  47860. /**
  47861. * Generic Controller
  47862. */
  47863. export class GenericController extends WebVRController {
  47864. /**
  47865. * Base Url for the controller model.
  47866. */
  47867. static readonly MODEL_BASE_URL: string;
  47868. /**
  47869. * File name for the controller model.
  47870. */
  47871. static readonly MODEL_FILENAME: string;
  47872. /**
  47873. * Creates a new GenericController from a gamepad
  47874. * @param vrGamepad the gamepad that the controller should be created from
  47875. */
  47876. constructor(vrGamepad: any);
  47877. /**
  47878. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47879. * @param scene scene in which to add meshes
  47880. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47881. */
  47882. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47883. /**
  47884. * Called once for each button that changed state since the last frame
  47885. * @param buttonIdx Which button index changed
  47886. * @param state New state of the button
  47887. * @param changes Which properties on the state changed since last frame
  47888. */
  47889. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47890. }
  47891. }
  47892. declare module BABYLON {
  47893. /**
  47894. * Oculus Touch Controller
  47895. */
  47896. export class OculusTouchController extends WebVRController {
  47897. /**
  47898. * Base Url for the controller model.
  47899. */
  47900. static MODEL_BASE_URL: string;
  47901. /**
  47902. * File name for the left controller model.
  47903. */
  47904. static MODEL_LEFT_FILENAME: string;
  47905. /**
  47906. * File name for the right controller model.
  47907. */
  47908. static MODEL_RIGHT_FILENAME: string;
  47909. /**
  47910. * Base Url for the Quest controller model.
  47911. */
  47912. static QUEST_MODEL_BASE_URL: string;
  47913. /**
  47914. * @hidden
  47915. * If the controllers are running on a device that needs the updated Quest controller models
  47916. */
  47917. static _IsQuest: boolean;
  47918. /**
  47919. * Fired when the secondary trigger on this controller is modified
  47920. */
  47921. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  47922. /**
  47923. * Fired when the thumb rest on this controller is modified
  47924. */
  47925. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  47926. /**
  47927. * Creates a new OculusTouchController 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. * Fired when the A button on this controller is modified
  47939. */
  47940. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  47941. /**
  47942. * Fired when the B button on this controller is modified
  47943. */
  47944. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  47945. /**
  47946. * Fired when the X button on this controller is modified
  47947. */
  47948. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  47949. /**
  47950. * Fired when the Y button on this controller is modified
  47951. */
  47952. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  47953. /**
  47954. * Called once for each button that changed state since the last frame
  47955. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  47956. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  47957. * 2) secondary trigger (same)
  47958. * 3) A (right) X (left), touch, pressed = value
  47959. * 4) B / Y
  47960. * 5) thumb rest
  47961. * @param buttonIdx Which button index changed
  47962. * @param state New state of the button
  47963. * @param changes Which properties on the state changed since last frame
  47964. */
  47965. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  47966. }
  47967. }
  47968. declare module BABYLON {
  47969. /**
  47970. * Vive Controller
  47971. */
  47972. export class ViveController extends WebVRController {
  47973. /**
  47974. * Base Url for the controller model.
  47975. */
  47976. static MODEL_BASE_URL: string;
  47977. /**
  47978. * File name for the controller model.
  47979. */
  47980. static MODEL_FILENAME: string;
  47981. /**
  47982. * Creates a new ViveController from a gamepad
  47983. * @param vrGamepad the gamepad that the controller should be created from
  47984. */
  47985. constructor(vrGamepad: any);
  47986. /**
  47987. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  47988. * @param scene scene in which to add meshes
  47989. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  47990. */
  47991. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  47992. /**
  47993. * Fired when the left button on this controller is modified
  47994. */
  47995. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  47996. /**
  47997. * Fired when the right button on this controller is modified
  47998. */
  47999. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48000. /**
  48001. * Fired when the menu button on this controller is modified
  48002. */
  48003. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48004. /**
  48005. * Called once for each button that changed state since the last frame
  48006. * Vive mapping:
  48007. * 0: touchpad
  48008. * 1: trigger
  48009. * 2: left AND right buttons
  48010. * 3: menu button
  48011. * @param buttonIdx Which button index changed
  48012. * @param state New state of the button
  48013. * @param changes Which properties on the state changed since last frame
  48014. */
  48015. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48016. }
  48017. }
  48018. declare module BABYLON {
  48019. /**
  48020. * Defines the WindowsMotionController object that the state of the windows motion controller
  48021. */
  48022. export class WindowsMotionController extends WebVRController {
  48023. /**
  48024. * The base url used to load the left and right controller models
  48025. */
  48026. static MODEL_BASE_URL: string;
  48027. /**
  48028. * The name of the left controller model file
  48029. */
  48030. static MODEL_LEFT_FILENAME: string;
  48031. /**
  48032. * The name of the right controller model file
  48033. */
  48034. static MODEL_RIGHT_FILENAME: string;
  48035. /**
  48036. * The controller name prefix for this controller type
  48037. */
  48038. static readonly GAMEPAD_ID_PREFIX: string;
  48039. /**
  48040. * The controller id pattern for this controller type
  48041. */
  48042. private static readonly GAMEPAD_ID_PATTERN;
  48043. private _loadedMeshInfo;
  48044. protected readonly _mapping: {
  48045. buttons: string[];
  48046. buttonMeshNames: {
  48047. 'trigger': string;
  48048. 'menu': string;
  48049. 'grip': string;
  48050. 'thumbstick': string;
  48051. 'trackpad': string;
  48052. };
  48053. buttonObservableNames: {
  48054. 'trigger': string;
  48055. 'menu': string;
  48056. 'grip': string;
  48057. 'thumbstick': string;
  48058. 'trackpad': string;
  48059. };
  48060. axisMeshNames: string[];
  48061. pointingPoseMeshName: string;
  48062. };
  48063. /**
  48064. * Fired when the trackpad on this controller is clicked
  48065. */
  48066. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48067. /**
  48068. * Fired when the trackpad on this controller is modified
  48069. */
  48070. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48071. /**
  48072. * The current x and y values of this controller's trackpad
  48073. */
  48074. trackpad: StickValues;
  48075. /**
  48076. * Creates a new WindowsMotionController from a gamepad
  48077. * @param vrGamepad the gamepad that the controller should be created from
  48078. */
  48079. constructor(vrGamepad: any);
  48080. /**
  48081. * Fired when the trigger on this controller is modified
  48082. */
  48083. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48084. /**
  48085. * Fired when the menu button on this controller is modified
  48086. */
  48087. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48088. /**
  48089. * Fired when the grip button on this controller is modified
  48090. */
  48091. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48092. /**
  48093. * Fired when the thumbstick button on this controller is modified
  48094. */
  48095. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48096. /**
  48097. * Fired when the touchpad button on this controller is modified
  48098. */
  48099. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48100. /**
  48101. * Fired when the touchpad values on this controller are modified
  48102. */
  48103. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  48104. protected _updateTrackpad(): void;
  48105. /**
  48106. * Called once per frame by the engine.
  48107. */
  48108. update(): void;
  48109. /**
  48110. * Called once for each button that changed state since the last frame
  48111. * @param buttonIdx Which button index changed
  48112. * @param state New state of the button
  48113. * @param changes Which properties on the state changed since last frame
  48114. */
  48115. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  48116. /**
  48117. * Moves the buttons on the controller mesh based on their current state
  48118. * @param buttonName the name of the button to move
  48119. * @param buttonValue the value of the button which determines the buttons new position
  48120. */
  48121. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  48122. /**
  48123. * Moves the axis on the controller mesh based on its current state
  48124. * @param axis the index of the axis
  48125. * @param axisValue the value of the axis which determines the meshes new position
  48126. * @hidden
  48127. */
  48128. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  48129. /**
  48130. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  48131. * @param scene scene in which to add meshes
  48132. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  48133. */
  48134. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  48135. /**
  48136. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  48137. * can be transformed by button presses and axes values, based on this._mapping.
  48138. *
  48139. * @param scene scene in which the meshes exist
  48140. * @param meshes list of meshes that make up the controller model to process
  48141. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  48142. */
  48143. private processModel;
  48144. private createMeshInfo;
  48145. /**
  48146. * Gets the ray of the controller in the direction the controller is pointing
  48147. * @param length the length the resulting ray should be
  48148. * @returns a ray in the direction the controller is pointing
  48149. */
  48150. getForwardRay(length?: number): Ray;
  48151. /**
  48152. * Disposes of the controller
  48153. */
  48154. dispose(): void;
  48155. }
  48156. /**
  48157. * This class represents a new windows motion controller in XR.
  48158. */
  48159. export class XRWindowsMotionController extends WindowsMotionController {
  48160. /**
  48161. * Changing the original WIndowsMotionController mapping to fir the new mapping
  48162. */
  48163. protected readonly _mapping: {
  48164. buttons: string[];
  48165. buttonMeshNames: {
  48166. 'trigger': string;
  48167. 'menu': string;
  48168. 'grip': string;
  48169. 'thumbstick': string;
  48170. 'trackpad': string;
  48171. };
  48172. buttonObservableNames: {
  48173. 'trigger': string;
  48174. 'menu': string;
  48175. 'grip': string;
  48176. 'thumbstick': string;
  48177. 'trackpad': string;
  48178. };
  48179. axisMeshNames: string[];
  48180. pointingPoseMeshName: string;
  48181. };
  48182. /**
  48183. * Construct a new XR-Based windows motion controller
  48184. *
  48185. * @param gamepadInfo the gamepad object from the browser
  48186. */
  48187. constructor(gamepadInfo: any);
  48188. /**
  48189. * holds the thumbstick values (X,Y)
  48190. */
  48191. thumbstickValues: StickValues;
  48192. /**
  48193. * Fired when the thumbstick on this controller is clicked
  48194. */
  48195. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  48196. /**
  48197. * Fired when the thumbstick on this controller is modified
  48198. */
  48199. onThumbstickValuesChangedObservable: Observable<StickValues>;
  48200. /**
  48201. * Fired when the touchpad button on this controller is modified
  48202. */
  48203. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  48204. /**
  48205. * Fired when the touchpad values on this controller are modified
  48206. */
  48207. onTrackpadValuesChangedObservable: Observable<StickValues>;
  48208. /**
  48209. * Fired when the thumbstick button on this controller is modified
  48210. * here to prevent breaking changes
  48211. */
  48212. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  48213. /**
  48214. * updating the thumbstick(!) and not the trackpad.
  48215. * This is named this way due to the difference between WebVR and XR and to avoid
  48216. * changing the parent class.
  48217. */
  48218. protected _updateTrackpad(): void;
  48219. /**
  48220. * Disposes the class with joy
  48221. */
  48222. dispose(): void;
  48223. }
  48224. }
  48225. declare module BABYLON {
  48226. /**
  48227. * Class containing static functions to help procedurally build meshes
  48228. */
  48229. export class PolyhedronBuilder {
  48230. /**
  48231. * Creates a polyhedron mesh
  48232. * * 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
  48233. * * The parameter `size` (positive float, default 1) sets the polygon size
  48234. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  48235. * * 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`
  48236. * * 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
  48237. * * 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)`)
  48238. * * 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
  48239. * * 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
  48240. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48241. * * 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
  48242. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48243. * @param name defines the name of the mesh
  48244. * @param options defines the options used to create the mesh
  48245. * @param scene defines the hosting scene
  48246. * @returns the polyhedron mesh
  48247. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  48248. */
  48249. static CreatePolyhedron(name: string, options: {
  48250. type?: number;
  48251. size?: number;
  48252. sizeX?: number;
  48253. sizeY?: number;
  48254. sizeZ?: number;
  48255. custom?: any;
  48256. faceUV?: Vector4[];
  48257. faceColors?: Color4[];
  48258. flat?: boolean;
  48259. updatable?: boolean;
  48260. sideOrientation?: number;
  48261. frontUVs?: Vector4;
  48262. backUVs?: Vector4;
  48263. }, scene?: Nullable<Scene>): Mesh;
  48264. }
  48265. }
  48266. declare module BABYLON {
  48267. /**
  48268. * Gizmo that enables scaling a mesh along 3 axis
  48269. */
  48270. export class ScaleGizmo extends Gizmo {
  48271. /**
  48272. * Internal gizmo used for interactions on the x axis
  48273. */
  48274. xGizmo: AxisScaleGizmo;
  48275. /**
  48276. * Internal gizmo used for interactions on the y axis
  48277. */
  48278. yGizmo: AxisScaleGizmo;
  48279. /**
  48280. * Internal gizmo used for interactions on the z axis
  48281. */
  48282. zGizmo: AxisScaleGizmo;
  48283. /**
  48284. * Internal gizmo used to scale all axis equally
  48285. */
  48286. uniformScaleGizmo: AxisScaleGizmo;
  48287. private _meshAttached;
  48288. private _updateGizmoRotationToMatchAttachedMesh;
  48289. private _snapDistance;
  48290. private _scaleRatio;
  48291. private _uniformScalingMesh;
  48292. private _octahedron;
  48293. private _sensitivity;
  48294. /** Fires an event when any of it's sub gizmos are dragged */
  48295. onDragStartObservable: Observable<unknown>;
  48296. /** Fires an event when any of it's sub gizmos are released from dragging */
  48297. onDragEndObservable: Observable<unknown>;
  48298. get attachedMesh(): Nullable<AbstractMesh>;
  48299. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48300. /**
  48301. * Creates a ScaleGizmo
  48302. * @param gizmoLayer The utility layer the gizmo will be added to
  48303. */
  48304. constructor(gizmoLayer?: UtilityLayerRenderer);
  48305. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48306. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48307. /**
  48308. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48309. */
  48310. set snapDistance(value: number);
  48311. get snapDistance(): number;
  48312. /**
  48313. * Ratio for the scale of the gizmo (Default: 1)
  48314. */
  48315. set scaleRatio(value: number);
  48316. get scaleRatio(): number;
  48317. /**
  48318. * Sensitivity factor for dragging (Default: 1)
  48319. */
  48320. set sensitivity(value: number);
  48321. get sensitivity(): number;
  48322. /**
  48323. * Disposes of the gizmo
  48324. */
  48325. dispose(): void;
  48326. }
  48327. }
  48328. declare module BABYLON {
  48329. /**
  48330. * Single axis scale gizmo
  48331. */
  48332. export class AxisScaleGizmo extends Gizmo {
  48333. /**
  48334. * Drag behavior responsible for the gizmos dragging interactions
  48335. */
  48336. dragBehavior: PointerDragBehavior;
  48337. private _pointerObserver;
  48338. /**
  48339. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48340. */
  48341. snapDistance: number;
  48342. /**
  48343. * Event that fires each time the gizmo snaps to a new location.
  48344. * * snapDistance is the the change in distance
  48345. */
  48346. onSnapObservable: Observable<{
  48347. snapDistance: number;
  48348. }>;
  48349. /**
  48350. * If the scaling operation should be done on all axis (default: false)
  48351. */
  48352. uniformScaling: boolean;
  48353. /**
  48354. * Custom sensitivity value for the drag strength
  48355. */
  48356. sensitivity: number;
  48357. private _isEnabled;
  48358. private _parent;
  48359. private _arrow;
  48360. private _coloredMaterial;
  48361. private _hoverMaterial;
  48362. /**
  48363. * Creates an AxisScaleGizmo
  48364. * @param gizmoLayer The utility layer the gizmo will be added to
  48365. * @param dragAxis The axis which the gizmo will be able to scale on
  48366. * @param color The color of the gizmo
  48367. */
  48368. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  48369. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48370. /**
  48371. * If the gizmo is enabled
  48372. */
  48373. set isEnabled(value: boolean);
  48374. get isEnabled(): boolean;
  48375. /**
  48376. * Disposes of the gizmo
  48377. */
  48378. dispose(): void;
  48379. /**
  48380. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  48381. * @param mesh The mesh to replace the default mesh of the gizmo
  48382. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  48383. */
  48384. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  48385. }
  48386. }
  48387. declare module BABYLON {
  48388. /**
  48389. * Bounding box gizmo
  48390. */
  48391. export class BoundingBoxGizmo extends Gizmo {
  48392. private _lineBoundingBox;
  48393. private _rotateSpheresParent;
  48394. private _scaleBoxesParent;
  48395. private _boundingDimensions;
  48396. private _renderObserver;
  48397. private _pointerObserver;
  48398. private _scaleDragSpeed;
  48399. private _tmpQuaternion;
  48400. private _tmpVector;
  48401. private _tmpRotationMatrix;
  48402. /**
  48403. * 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)
  48404. */
  48405. ignoreChildren: boolean;
  48406. /**
  48407. * 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)
  48408. */
  48409. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  48410. /**
  48411. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  48412. */
  48413. rotationSphereSize: number;
  48414. /**
  48415. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  48416. */
  48417. scaleBoxSize: number;
  48418. /**
  48419. * 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)
  48420. */
  48421. fixedDragMeshScreenSize: boolean;
  48422. /**
  48423. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  48424. */
  48425. fixedDragMeshScreenSizeDistanceFactor: number;
  48426. /**
  48427. * Fired when a rotation sphere or scale box is dragged
  48428. */
  48429. onDragStartObservable: Observable<{}>;
  48430. /**
  48431. * Fired when a scale box is dragged
  48432. */
  48433. onScaleBoxDragObservable: Observable<{}>;
  48434. /**
  48435. * Fired when a scale box drag is ended
  48436. */
  48437. onScaleBoxDragEndObservable: Observable<{}>;
  48438. /**
  48439. * Fired when a rotation sphere is dragged
  48440. */
  48441. onRotationSphereDragObservable: Observable<{}>;
  48442. /**
  48443. * Fired when a rotation sphere drag is ended
  48444. */
  48445. onRotationSphereDragEndObservable: Observable<{}>;
  48446. /**
  48447. * 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)
  48448. */
  48449. scalePivot: Nullable<Vector3>;
  48450. /**
  48451. * Mesh used as a pivot to rotate the attached mesh
  48452. */
  48453. private _anchorMesh;
  48454. private _existingMeshScale;
  48455. private _dragMesh;
  48456. private pointerDragBehavior;
  48457. private coloredMaterial;
  48458. private hoverColoredMaterial;
  48459. /**
  48460. * Sets the color of the bounding box gizmo
  48461. * @param color the color to set
  48462. */
  48463. setColor(color: Color3): void;
  48464. /**
  48465. * Creates an BoundingBoxGizmo
  48466. * @param gizmoLayer The utility layer the gizmo will be added to
  48467. * @param color The color of the gizmo
  48468. */
  48469. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  48470. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48471. private _selectNode;
  48472. /**
  48473. * Updates the bounding box information for the Gizmo
  48474. */
  48475. updateBoundingBox(): void;
  48476. private _updateRotationSpheres;
  48477. private _updateScaleBoxes;
  48478. /**
  48479. * Enables rotation on the specified axis and disables rotation on the others
  48480. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  48481. */
  48482. setEnabledRotationAxis(axis: string): void;
  48483. /**
  48484. * Enables/disables scaling
  48485. * @param enable if scaling should be enabled
  48486. */
  48487. setEnabledScaling(enable: boolean): void;
  48488. private _updateDummy;
  48489. /**
  48490. * Enables a pointer drag behavior on the bounding box of the gizmo
  48491. */
  48492. enableDragBehavior(): void;
  48493. /**
  48494. * Disposes of the gizmo
  48495. */
  48496. dispose(): void;
  48497. /**
  48498. * 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)
  48499. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  48500. * @returns the bounding box mesh with the passed in mesh as a child
  48501. */
  48502. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  48503. /**
  48504. * CustomMeshes are not supported by this gizmo
  48505. * @param mesh The mesh to replace the default mesh of the gizmo
  48506. */
  48507. setCustomMesh(mesh: Mesh): void;
  48508. }
  48509. }
  48510. declare module BABYLON {
  48511. /**
  48512. * Single plane rotation gizmo
  48513. */
  48514. export class PlaneRotationGizmo extends Gizmo {
  48515. /**
  48516. * Drag behavior responsible for the gizmos dragging interactions
  48517. */
  48518. dragBehavior: PointerDragBehavior;
  48519. private _pointerObserver;
  48520. /**
  48521. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  48522. */
  48523. snapDistance: number;
  48524. /**
  48525. * Event that fires each time the gizmo snaps to a new location.
  48526. * * snapDistance is the the change in distance
  48527. */
  48528. onSnapObservable: Observable<{
  48529. snapDistance: number;
  48530. }>;
  48531. private _isEnabled;
  48532. private _parent;
  48533. /**
  48534. * Creates a PlaneRotationGizmo
  48535. * @param gizmoLayer The utility layer the gizmo will be added to
  48536. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  48537. * @param color The color of the gizmo
  48538. * @param tessellation Amount of tessellation to be used when creating rotation circles
  48539. * @param useEulerRotation Use and update Euler angle instead of quaternion
  48540. */
  48541. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  48542. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48543. /**
  48544. * If the gizmo is enabled
  48545. */
  48546. set isEnabled(value: boolean);
  48547. get isEnabled(): boolean;
  48548. /**
  48549. * Disposes of the gizmo
  48550. */
  48551. dispose(): void;
  48552. }
  48553. }
  48554. declare module BABYLON {
  48555. /**
  48556. * Gizmo that enables rotating a mesh along 3 axis
  48557. */
  48558. export class RotationGizmo extends Gizmo {
  48559. /**
  48560. * Internal gizmo used for interactions on the x axis
  48561. */
  48562. xGizmo: PlaneRotationGizmo;
  48563. /**
  48564. * Internal gizmo used for interactions on the y axis
  48565. */
  48566. yGizmo: PlaneRotationGizmo;
  48567. /**
  48568. * Internal gizmo used for interactions on the z axis
  48569. */
  48570. zGizmo: PlaneRotationGizmo;
  48571. /** Fires an event when any of it's sub gizmos are dragged */
  48572. onDragStartObservable: Observable<unknown>;
  48573. /** Fires an event when any of it's sub gizmos are released from dragging */
  48574. onDragEndObservable: Observable<unknown>;
  48575. private _meshAttached;
  48576. get attachedMesh(): Nullable<AbstractMesh>;
  48577. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48578. /**
  48579. * Creates a RotationGizmo
  48580. * @param gizmoLayer The utility layer the gizmo will be added to
  48581. * @param tessellation Amount of tessellation to be used when creating rotation circles
  48582. * @param useEulerRotation Use and update Euler angle instead of quaternion
  48583. */
  48584. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  48585. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48586. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48587. /**
  48588. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48589. */
  48590. set snapDistance(value: number);
  48591. get snapDistance(): number;
  48592. /**
  48593. * Ratio for the scale of the gizmo (Default: 1)
  48594. */
  48595. set scaleRatio(value: number);
  48596. get scaleRatio(): number;
  48597. /**
  48598. * Disposes of the gizmo
  48599. */
  48600. dispose(): void;
  48601. /**
  48602. * CustomMeshes are not supported by this gizmo
  48603. * @param mesh The mesh to replace the default mesh of the gizmo
  48604. */
  48605. setCustomMesh(mesh: Mesh): void;
  48606. }
  48607. }
  48608. declare module BABYLON {
  48609. /**
  48610. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  48611. */
  48612. export class GizmoManager implements IDisposable {
  48613. private scene;
  48614. /**
  48615. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  48616. */
  48617. gizmos: {
  48618. positionGizmo: Nullable<PositionGizmo>;
  48619. rotationGizmo: Nullable<RotationGizmo>;
  48620. scaleGizmo: Nullable<ScaleGizmo>;
  48621. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  48622. };
  48623. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  48624. clearGizmoOnEmptyPointerEvent: boolean;
  48625. /** Fires an event when the manager is attached to a mesh */
  48626. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  48627. private _gizmosEnabled;
  48628. private _pointerObserver;
  48629. private _attachedMesh;
  48630. private _boundingBoxColor;
  48631. private _defaultUtilityLayer;
  48632. private _defaultKeepDepthUtilityLayer;
  48633. /**
  48634. * When bounding box gizmo is enabled, this can be used to track drag/end events
  48635. */
  48636. boundingBoxDragBehavior: SixDofDragBehavior;
  48637. /**
  48638. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  48639. */
  48640. attachableMeshes: Nullable<Array<AbstractMesh>>;
  48641. /**
  48642. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  48643. */
  48644. usePointerToAttachGizmos: boolean;
  48645. /**
  48646. * Utility layer that the bounding box gizmo belongs to
  48647. */
  48648. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  48649. /**
  48650. * Utility layer that all gizmos besides bounding box belong to
  48651. */
  48652. get utilityLayer(): UtilityLayerRenderer;
  48653. /**
  48654. * Instatiates a gizmo manager
  48655. * @param scene the scene to overlay the gizmos on top of
  48656. */
  48657. constructor(scene: Scene);
  48658. /**
  48659. * Attaches a set of gizmos to the specified mesh
  48660. * @param mesh The mesh the gizmo's should be attached to
  48661. */
  48662. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  48663. /**
  48664. * If the position gizmo is enabled
  48665. */
  48666. set positionGizmoEnabled(value: boolean);
  48667. get positionGizmoEnabled(): boolean;
  48668. /**
  48669. * If the rotation gizmo is enabled
  48670. */
  48671. set rotationGizmoEnabled(value: boolean);
  48672. get rotationGizmoEnabled(): boolean;
  48673. /**
  48674. * If the scale gizmo is enabled
  48675. */
  48676. set scaleGizmoEnabled(value: boolean);
  48677. get scaleGizmoEnabled(): boolean;
  48678. /**
  48679. * If the boundingBox gizmo is enabled
  48680. */
  48681. set boundingBoxGizmoEnabled(value: boolean);
  48682. get boundingBoxGizmoEnabled(): boolean;
  48683. /**
  48684. * Disposes of the gizmo manager
  48685. */
  48686. dispose(): void;
  48687. }
  48688. }
  48689. declare module BABYLON {
  48690. /**
  48691. * A directional light is defined by a direction (what a surprise!).
  48692. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  48693. * 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.
  48694. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48695. */
  48696. export class DirectionalLight extends ShadowLight {
  48697. private _shadowFrustumSize;
  48698. /**
  48699. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  48700. */
  48701. get shadowFrustumSize(): number;
  48702. /**
  48703. * Specifies a fix frustum size for the shadow generation.
  48704. */
  48705. set shadowFrustumSize(value: number);
  48706. private _shadowOrthoScale;
  48707. /**
  48708. * Gets the shadow projection scale against the optimal computed one.
  48709. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48710. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48711. */
  48712. get shadowOrthoScale(): number;
  48713. /**
  48714. * Sets the shadow projection scale against the optimal computed one.
  48715. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  48716. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  48717. */
  48718. set shadowOrthoScale(value: number);
  48719. /**
  48720. * Automatically compute the projection matrix to best fit (including all the casters)
  48721. * on each frame.
  48722. */
  48723. autoUpdateExtends: boolean;
  48724. /**
  48725. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  48726. * on each frame. autoUpdateExtends must be set to true for this to work
  48727. */
  48728. autoCalcShadowZBounds: boolean;
  48729. private _orthoLeft;
  48730. private _orthoRight;
  48731. private _orthoTop;
  48732. private _orthoBottom;
  48733. /**
  48734. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  48735. * The directional light is emitted from everywhere in the given direction.
  48736. * It can cast shadows.
  48737. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48738. * @param name The friendly name of the light
  48739. * @param direction The direction of the light
  48740. * @param scene The scene the light belongs to
  48741. */
  48742. constructor(name: string, direction: Vector3, scene: Scene);
  48743. /**
  48744. * Returns the string "DirectionalLight".
  48745. * @return The class name
  48746. */
  48747. getClassName(): string;
  48748. /**
  48749. * Returns the integer 1.
  48750. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48751. */
  48752. getTypeID(): number;
  48753. /**
  48754. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  48755. * Returns the DirectionalLight Shadow projection matrix.
  48756. */
  48757. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48758. /**
  48759. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  48760. * Returns the DirectionalLight Shadow projection matrix.
  48761. */
  48762. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  48763. /**
  48764. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  48765. * Returns the DirectionalLight Shadow projection matrix.
  48766. */
  48767. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48768. protected _buildUniformLayout(): void;
  48769. /**
  48770. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  48771. * @param effect The effect to update
  48772. * @param lightIndex The index of the light in the effect to update
  48773. * @returns The directional light
  48774. */
  48775. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  48776. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  48777. /**
  48778. * Gets the minZ used for shadow according to both the scene and the light.
  48779. *
  48780. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48781. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48782. * @param activeCamera The camera we are returning the min for
  48783. * @returns the depth min z
  48784. */
  48785. getDepthMinZ(activeCamera: Camera): number;
  48786. /**
  48787. * Gets the maxZ used for shadow according to both the scene and the light.
  48788. *
  48789. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  48790. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  48791. * @param activeCamera The camera we are returning the max for
  48792. * @returns the depth max z
  48793. */
  48794. getDepthMaxZ(activeCamera: Camera): number;
  48795. /**
  48796. * Prepares the list of defines specific to the light type.
  48797. * @param defines the list of defines
  48798. * @param lightIndex defines the index of the light for the effect
  48799. */
  48800. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48801. }
  48802. }
  48803. declare module BABYLON {
  48804. /**
  48805. * Class containing static functions to help procedurally build meshes
  48806. */
  48807. export class HemisphereBuilder {
  48808. /**
  48809. * Creates a hemisphere mesh
  48810. * @param name defines the name of the mesh
  48811. * @param options defines the options used to create the mesh
  48812. * @param scene defines the hosting scene
  48813. * @returns the hemisphere mesh
  48814. */
  48815. static CreateHemisphere(name: string, options: {
  48816. segments?: number;
  48817. diameter?: number;
  48818. sideOrientation?: number;
  48819. }, scene: any): Mesh;
  48820. }
  48821. }
  48822. declare module BABYLON {
  48823. /**
  48824. * A spot light is defined by a position, a direction, an angle, and an exponent.
  48825. * These values define a cone of light starting from the position, emitting toward the direction.
  48826. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  48827. * and the exponent defines the speed of the decay of the light with distance (reach).
  48828. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48829. */
  48830. export class SpotLight extends ShadowLight {
  48831. private _angle;
  48832. private _innerAngle;
  48833. private _cosHalfAngle;
  48834. private _lightAngleScale;
  48835. private _lightAngleOffset;
  48836. /**
  48837. * Gets the cone angle of the spot light in Radians.
  48838. */
  48839. get angle(): number;
  48840. /**
  48841. * Sets the cone angle of the spot light in Radians.
  48842. */
  48843. set angle(value: number);
  48844. /**
  48845. * Only used in gltf falloff mode, this defines the angle where
  48846. * the directional falloff will start before cutting at angle which could be seen
  48847. * as outer angle.
  48848. */
  48849. get innerAngle(): number;
  48850. /**
  48851. * Only used in gltf falloff mode, this defines the angle where
  48852. * the directional falloff will start before cutting at angle which could be seen
  48853. * as outer angle.
  48854. */
  48855. set innerAngle(value: number);
  48856. private _shadowAngleScale;
  48857. /**
  48858. * Allows scaling the angle of the light for shadow generation only.
  48859. */
  48860. get shadowAngleScale(): number;
  48861. /**
  48862. * Allows scaling the angle of the light for shadow generation only.
  48863. */
  48864. set shadowAngleScale(value: number);
  48865. /**
  48866. * The light decay speed with the distance from the emission spot.
  48867. */
  48868. exponent: number;
  48869. private _projectionTextureMatrix;
  48870. /**
  48871. * Allows reading the projecton texture
  48872. */
  48873. get projectionTextureMatrix(): Matrix;
  48874. protected _projectionTextureLightNear: number;
  48875. /**
  48876. * Gets the near clip of the Spotlight for texture projection.
  48877. */
  48878. get projectionTextureLightNear(): number;
  48879. /**
  48880. * Sets the near clip of the Spotlight for texture projection.
  48881. */
  48882. set projectionTextureLightNear(value: number);
  48883. protected _projectionTextureLightFar: number;
  48884. /**
  48885. * Gets the far clip of the Spotlight for texture projection.
  48886. */
  48887. get projectionTextureLightFar(): number;
  48888. /**
  48889. * Sets the far clip of the Spotlight for texture projection.
  48890. */
  48891. set projectionTextureLightFar(value: number);
  48892. protected _projectionTextureUpDirection: Vector3;
  48893. /**
  48894. * Gets the Up vector of the Spotlight for texture projection.
  48895. */
  48896. get projectionTextureUpDirection(): Vector3;
  48897. /**
  48898. * Sets the Up vector of the Spotlight for texture projection.
  48899. */
  48900. set projectionTextureUpDirection(value: Vector3);
  48901. private _projectionTexture;
  48902. /**
  48903. * Gets the projection texture of the light.
  48904. */
  48905. get projectionTexture(): Nullable<BaseTexture>;
  48906. /**
  48907. * Sets the projection texture of the light.
  48908. */
  48909. set projectionTexture(value: Nullable<BaseTexture>);
  48910. private _projectionTextureViewLightDirty;
  48911. private _projectionTextureProjectionLightDirty;
  48912. private _projectionTextureDirty;
  48913. private _projectionTextureViewTargetVector;
  48914. private _projectionTextureViewLightMatrix;
  48915. private _projectionTextureProjectionLightMatrix;
  48916. private _projectionTextureScalingMatrix;
  48917. /**
  48918. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  48919. * It can cast shadows.
  48920. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48921. * @param name The light friendly name
  48922. * @param position The position of the spot light in the scene
  48923. * @param direction The direction of the light in the scene
  48924. * @param angle The cone angle of the light in Radians
  48925. * @param exponent The light decay speed with the distance from the emission spot
  48926. * @param scene The scene the lights belongs to
  48927. */
  48928. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  48929. /**
  48930. * Returns the string "SpotLight".
  48931. * @returns the class name
  48932. */
  48933. getClassName(): string;
  48934. /**
  48935. * Returns the integer 2.
  48936. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48937. */
  48938. getTypeID(): number;
  48939. /**
  48940. * Overrides the direction setter to recompute the projection texture view light Matrix.
  48941. */
  48942. protected _setDirection(value: Vector3): void;
  48943. /**
  48944. * Overrides the position setter to recompute the projection texture view light Matrix.
  48945. */
  48946. protected _setPosition(value: Vector3): void;
  48947. /**
  48948. * 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.
  48949. * Returns the SpotLight.
  48950. */
  48951. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48952. protected _computeProjectionTextureViewLightMatrix(): void;
  48953. protected _computeProjectionTextureProjectionLightMatrix(): void;
  48954. /**
  48955. * Main function for light texture projection matrix computing.
  48956. */
  48957. protected _computeProjectionTextureMatrix(): void;
  48958. protected _buildUniformLayout(): void;
  48959. private _computeAngleValues;
  48960. /**
  48961. * Sets the passed Effect "effect" with the Light textures.
  48962. * @param effect The effect to update
  48963. * @param lightIndex The index of the light in the effect to update
  48964. * @returns The light
  48965. */
  48966. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  48967. /**
  48968. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  48969. * @param effect The effect to update
  48970. * @param lightIndex The index of the light in the effect to update
  48971. * @returns The spot light
  48972. */
  48973. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  48974. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  48975. /**
  48976. * Disposes the light and the associated resources.
  48977. */
  48978. dispose(): void;
  48979. /**
  48980. * Prepares the list of defines specific to the light type.
  48981. * @param defines the list of defines
  48982. * @param lightIndex defines the index of the light for the effect
  48983. */
  48984. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48985. }
  48986. }
  48987. declare module BABYLON {
  48988. /**
  48989. * Gizmo that enables viewing a light
  48990. */
  48991. export class LightGizmo extends Gizmo {
  48992. private _lightMesh;
  48993. private _material;
  48994. private _cachedPosition;
  48995. private _cachedForward;
  48996. private _attachedMeshParent;
  48997. /**
  48998. * Creates a LightGizmo
  48999. * @param gizmoLayer The utility layer the gizmo will be added to
  49000. */
  49001. constructor(gizmoLayer?: UtilityLayerRenderer);
  49002. private _light;
  49003. /**
  49004. * The light that the gizmo is attached to
  49005. */
  49006. set light(light: Nullable<Light>);
  49007. get light(): Nullable<Light>;
  49008. /**
  49009. * Gets the material used to render the light gizmo
  49010. */
  49011. get material(): StandardMaterial;
  49012. /**
  49013. * @hidden
  49014. * Updates the gizmo to match the attached mesh's position/rotation
  49015. */
  49016. protected _update(): void;
  49017. private static _Scale;
  49018. /**
  49019. * Creates the lines for a light mesh
  49020. */
  49021. private static _CreateLightLines;
  49022. /**
  49023. * Disposes of the light gizmo
  49024. */
  49025. dispose(): void;
  49026. private static _CreateHemisphericLightMesh;
  49027. private static _CreatePointLightMesh;
  49028. private static _CreateSpotLightMesh;
  49029. private static _CreateDirectionalLightMesh;
  49030. }
  49031. }
  49032. declare module BABYLON {
  49033. /** @hidden */
  49034. export var backgroundFragmentDeclaration: {
  49035. name: string;
  49036. shader: string;
  49037. };
  49038. }
  49039. declare module BABYLON {
  49040. /** @hidden */
  49041. export var backgroundUboDeclaration: {
  49042. name: string;
  49043. shader: string;
  49044. };
  49045. }
  49046. declare module BABYLON {
  49047. /** @hidden */
  49048. export var backgroundPixelShader: {
  49049. name: string;
  49050. shader: string;
  49051. };
  49052. }
  49053. declare module BABYLON {
  49054. /** @hidden */
  49055. export var backgroundVertexDeclaration: {
  49056. name: string;
  49057. shader: string;
  49058. };
  49059. }
  49060. declare module BABYLON {
  49061. /** @hidden */
  49062. export var backgroundVertexShader: {
  49063. name: string;
  49064. shader: string;
  49065. };
  49066. }
  49067. declare module BABYLON {
  49068. /**
  49069. * Background material used to create an efficient environement around your scene.
  49070. */
  49071. export class BackgroundMaterial extends PushMaterial {
  49072. /**
  49073. * Standard reflectance value at parallel view angle.
  49074. */
  49075. static StandardReflectance0: number;
  49076. /**
  49077. * Standard reflectance value at grazing angle.
  49078. */
  49079. static StandardReflectance90: number;
  49080. protected _primaryColor: Color3;
  49081. /**
  49082. * Key light Color (multiply against the environement texture)
  49083. */
  49084. primaryColor: Color3;
  49085. protected __perceptualColor: Nullable<Color3>;
  49086. /**
  49087. * Experimental Internal Use Only.
  49088. *
  49089. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  49090. * This acts as a helper to set the primary color to a more "human friendly" value.
  49091. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  49092. * output color as close as possible from the chosen value.
  49093. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  49094. * part of lighting setup.)
  49095. */
  49096. get _perceptualColor(): Nullable<Color3>;
  49097. set _perceptualColor(value: Nullable<Color3>);
  49098. protected _primaryColorShadowLevel: float;
  49099. /**
  49100. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  49101. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  49102. */
  49103. get primaryColorShadowLevel(): float;
  49104. set primaryColorShadowLevel(value: float);
  49105. protected _primaryColorHighlightLevel: float;
  49106. /**
  49107. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  49108. * The primary color is used at the level chosen to define what the white area would look.
  49109. */
  49110. get primaryColorHighlightLevel(): float;
  49111. set primaryColorHighlightLevel(value: float);
  49112. protected _reflectionTexture: Nullable<BaseTexture>;
  49113. /**
  49114. * Reflection Texture used in the material.
  49115. * Should be author in a specific way for the best result (refer to the documentation).
  49116. */
  49117. reflectionTexture: Nullable<BaseTexture>;
  49118. protected _reflectionBlur: float;
  49119. /**
  49120. * Reflection Texture level of blur.
  49121. *
  49122. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  49123. * texture twice.
  49124. */
  49125. reflectionBlur: float;
  49126. protected _diffuseTexture: Nullable<BaseTexture>;
  49127. /**
  49128. * Diffuse Texture used in the material.
  49129. * Should be author in a specific way for the best result (refer to the documentation).
  49130. */
  49131. diffuseTexture: Nullable<BaseTexture>;
  49132. protected _shadowLights: Nullable<IShadowLight[]>;
  49133. /**
  49134. * Specify the list of lights casting shadow on the material.
  49135. * All scene shadow lights will be included if null.
  49136. */
  49137. shadowLights: Nullable<IShadowLight[]>;
  49138. protected _shadowLevel: float;
  49139. /**
  49140. * Helps adjusting the shadow to a softer level if required.
  49141. * 0 means black shadows and 1 means no shadows.
  49142. */
  49143. shadowLevel: float;
  49144. protected _sceneCenter: Vector3;
  49145. /**
  49146. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  49147. * It is usually zero but might be interesting to modify according to your setup.
  49148. */
  49149. sceneCenter: Vector3;
  49150. protected _opacityFresnel: boolean;
  49151. /**
  49152. * This helps specifying that the material is falling off to the sky box at grazing angle.
  49153. * This helps ensuring a nice transition when the camera goes under the ground.
  49154. */
  49155. opacityFresnel: boolean;
  49156. protected _reflectionFresnel: boolean;
  49157. /**
  49158. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  49159. * This helps adding a mirror texture on the ground.
  49160. */
  49161. reflectionFresnel: boolean;
  49162. protected _reflectionFalloffDistance: number;
  49163. /**
  49164. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  49165. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  49166. */
  49167. reflectionFalloffDistance: number;
  49168. protected _reflectionAmount: number;
  49169. /**
  49170. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  49171. */
  49172. reflectionAmount: number;
  49173. protected _reflectionReflectance0: number;
  49174. /**
  49175. * This specifies the weight of the reflection at grazing angle.
  49176. */
  49177. reflectionReflectance0: number;
  49178. protected _reflectionReflectance90: number;
  49179. /**
  49180. * This specifies the weight of the reflection at a perpendicular point of view.
  49181. */
  49182. reflectionReflectance90: number;
  49183. /**
  49184. * Sets the reflection reflectance fresnel values according to the default standard
  49185. * empirically know to work well :-)
  49186. */
  49187. set reflectionStandardFresnelWeight(value: number);
  49188. protected _useRGBColor: boolean;
  49189. /**
  49190. * Helps to directly use the maps channels instead of their level.
  49191. */
  49192. useRGBColor: boolean;
  49193. protected _enableNoise: boolean;
  49194. /**
  49195. * This helps reducing the banding effect that could occur on the background.
  49196. */
  49197. enableNoise: boolean;
  49198. /**
  49199. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49200. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  49201. * Recommended to be keep at 1.0 except for special cases.
  49202. */
  49203. get fovMultiplier(): number;
  49204. set fovMultiplier(value: number);
  49205. private _fovMultiplier;
  49206. /**
  49207. * Enable the FOV adjustment feature controlled by fovMultiplier.
  49208. */
  49209. useEquirectangularFOV: boolean;
  49210. private _maxSimultaneousLights;
  49211. /**
  49212. * Number of Simultaneous lights allowed on the material.
  49213. */
  49214. maxSimultaneousLights: int;
  49215. /**
  49216. * Default configuration related to image processing available in the Background Material.
  49217. */
  49218. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49219. /**
  49220. * Keep track of the image processing observer to allow dispose and replace.
  49221. */
  49222. private _imageProcessingObserver;
  49223. /**
  49224. * Attaches a new image processing configuration to the PBR Material.
  49225. * @param configuration (if null the scene configuration will be use)
  49226. */
  49227. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49228. /**
  49229. * Gets the image processing configuration used either in this material.
  49230. */
  49231. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  49232. /**
  49233. * Sets the Default image processing configuration used either in the this material.
  49234. *
  49235. * If sets to null, the scene one is in use.
  49236. */
  49237. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  49238. /**
  49239. * Gets wether the color curves effect is enabled.
  49240. */
  49241. get cameraColorCurvesEnabled(): boolean;
  49242. /**
  49243. * Sets wether the color curves effect is enabled.
  49244. */
  49245. set cameraColorCurvesEnabled(value: boolean);
  49246. /**
  49247. * Gets wether the color grading effect is enabled.
  49248. */
  49249. get cameraColorGradingEnabled(): boolean;
  49250. /**
  49251. * Gets wether the color grading effect is enabled.
  49252. */
  49253. set cameraColorGradingEnabled(value: boolean);
  49254. /**
  49255. * Gets wether tonemapping is enabled or not.
  49256. */
  49257. get cameraToneMappingEnabled(): boolean;
  49258. /**
  49259. * Sets wether tonemapping is enabled or not
  49260. */
  49261. set cameraToneMappingEnabled(value: boolean);
  49262. /**
  49263. * The camera exposure used on this material.
  49264. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49265. * This corresponds to a photographic exposure.
  49266. */
  49267. get cameraExposure(): float;
  49268. /**
  49269. * The camera exposure used on this material.
  49270. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49271. * This corresponds to a photographic exposure.
  49272. */
  49273. set cameraExposure(value: float);
  49274. /**
  49275. * Gets The camera contrast used on this material.
  49276. */
  49277. get cameraContrast(): float;
  49278. /**
  49279. * Sets The camera contrast used on this material.
  49280. */
  49281. set cameraContrast(value: float);
  49282. /**
  49283. * Gets the Color Grading 2D Lookup Texture.
  49284. */
  49285. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  49286. /**
  49287. * Sets the Color Grading 2D Lookup Texture.
  49288. */
  49289. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  49290. /**
  49291. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49292. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49293. * 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;
  49294. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49295. */
  49296. get cameraColorCurves(): Nullable<ColorCurves>;
  49297. /**
  49298. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49299. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49300. * 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;
  49301. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49302. */
  49303. set cameraColorCurves(value: Nullable<ColorCurves>);
  49304. /**
  49305. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  49306. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  49307. */
  49308. switchToBGR: boolean;
  49309. private _renderTargets;
  49310. private _reflectionControls;
  49311. private _white;
  49312. private _primaryShadowColor;
  49313. private _primaryHighlightColor;
  49314. /**
  49315. * Instantiates a Background Material in the given scene
  49316. * @param name The friendly name of the material
  49317. * @param scene The scene to add the material to
  49318. */
  49319. constructor(name: string, scene: Scene);
  49320. /**
  49321. * Gets a boolean indicating that current material needs to register RTT
  49322. */
  49323. get hasRenderTargetTextures(): boolean;
  49324. /**
  49325. * The entire material has been created in order to prevent overdraw.
  49326. * @returns false
  49327. */
  49328. needAlphaTesting(): boolean;
  49329. /**
  49330. * The entire material has been created in order to prevent overdraw.
  49331. * @returns true if blending is enable
  49332. */
  49333. needAlphaBlending(): boolean;
  49334. /**
  49335. * Checks wether the material is ready to be rendered for a given mesh.
  49336. * @param mesh The mesh to render
  49337. * @param subMesh The submesh to check against
  49338. * @param useInstances Specify wether or not the material is used with instances
  49339. * @returns true if all the dependencies are ready (Textures, Effects...)
  49340. */
  49341. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  49342. /**
  49343. * Compute the primary color according to the chosen perceptual color.
  49344. */
  49345. private _computePrimaryColorFromPerceptualColor;
  49346. /**
  49347. * Compute the highlights and shadow colors according to their chosen levels.
  49348. */
  49349. private _computePrimaryColors;
  49350. /**
  49351. * Build the uniform buffer used in the material.
  49352. */
  49353. buildUniformLayout(): void;
  49354. /**
  49355. * Unbind the material.
  49356. */
  49357. unbind(): void;
  49358. /**
  49359. * Bind only the world matrix to the material.
  49360. * @param world The world matrix to bind.
  49361. */
  49362. bindOnlyWorldMatrix(world: Matrix): void;
  49363. /**
  49364. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  49365. * @param world The world matrix to bind.
  49366. * @param subMesh The submesh to bind for.
  49367. */
  49368. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49369. /**
  49370. * Checks to see if a texture is used in the material.
  49371. * @param texture - Base texture to use.
  49372. * @returns - Boolean specifying if a texture is used in the material.
  49373. */
  49374. hasTexture(texture: BaseTexture): boolean;
  49375. /**
  49376. * Dispose the material.
  49377. * @param forceDisposeEffect Force disposal of the associated effect.
  49378. * @param forceDisposeTextures Force disposal of the associated textures.
  49379. */
  49380. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  49381. /**
  49382. * Clones the material.
  49383. * @param name The cloned name.
  49384. * @returns The cloned material.
  49385. */
  49386. clone(name: string): BackgroundMaterial;
  49387. /**
  49388. * Serializes the current material to its JSON representation.
  49389. * @returns The JSON representation.
  49390. */
  49391. serialize(): any;
  49392. /**
  49393. * Gets the class name of the material
  49394. * @returns "BackgroundMaterial"
  49395. */
  49396. getClassName(): string;
  49397. /**
  49398. * Parse a JSON input to create back a background material.
  49399. * @param source The JSON data to parse
  49400. * @param scene The scene to create the parsed material in
  49401. * @param rootUrl The root url of the assets the material depends upon
  49402. * @returns the instantiated BackgroundMaterial.
  49403. */
  49404. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  49405. }
  49406. }
  49407. declare module BABYLON {
  49408. /**
  49409. * Represents the different options available during the creation of
  49410. * a Environment helper.
  49411. *
  49412. * This can control the default ground, skybox and image processing setup of your scene.
  49413. */
  49414. export interface IEnvironmentHelperOptions {
  49415. /**
  49416. * Specifies whether or not to create a ground.
  49417. * True by default.
  49418. */
  49419. createGround: boolean;
  49420. /**
  49421. * Specifies the ground size.
  49422. * 15 by default.
  49423. */
  49424. groundSize: number;
  49425. /**
  49426. * The texture used on the ground for the main color.
  49427. * Comes from the BabylonJS CDN by default.
  49428. *
  49429. * Remarks: Can be either a texture or a url.
  49430. */
  49431. groundTexture: string | BaseTexture;
  49432. /**
  49433. * The color mixed in the ground texture by default.
  49434. * BabylonJS clearColor by default.
  49435. */
  49436. groundColor: Color3;
  49437. /**
  49438. * Specifies the ground opacity.
  49439. * 1 by default.
  49440. */
  49441. groundOpacity: number;
  49442. /**
  49443. * Enables the ground to receive shadows.
  49444. * True by default.
  49445. */
  49446. enableGroundShadow: boolean;
  49447. /**
  49448. * Helps preventing the shadow to be fully black on the ground.
  49449. * 0.5 by default.
  49450. */
  49451. groundShadowLevel: number;
  49452. /**
  49453. * Creates a mirror texture attach to the ground.
  49454. * false by default.
  49455. */
  49456. enableGroundMirror: boolean;
  49457. /**
  49458. * Specifies the ground mirror size ratio.
  49459. * 0.3 by default as the default kernel is 64.
  49460. */
  49461. groundMirrorSizeRatio: number;
  49462. /**
  49463. * Specifies the ground mirror blur kernel size.
  49464. * 64 by default.
  49465. */
  49466. groundMirrorBlurKernel: number;
  49467. /**
  49468. * Specifies the ground mirror visibility amount.
  49469. * 1 by default
  49470. */
  49471. groundMirrorAmount: number;
  49472. /**
  49473. * Specifies the ground mirror reflectance weight.
  49474. * This uses the standard weight of the background material to setup the fresnel effect
  49475. * of the mirror.
  49476. * 1 by default.
  49477. */
  49478. groundMirrorFresnelWeight: number;
  49479. /**
  49480. * Specifies the ground mirror Falloff distance.
  49481. * This can helps reducing the size of the reflection.
  49482. * 0 by Default.
  49483. */
  49484. groundMirrorFallOffDistance: number;
  49485. /**
  49486. * Specifies the ground mirror texture type.
  49487. * Unsigned Int by Default.
  49488. */
  49489. groundMirrorTextureType: number;
  49490. /**
  49491. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  49492. * the shown objects.
  49493. */
  49494. groundYBias: number;
  49495. /**
  49496. * Specifies whether or not to create a skybox.
  49497. * True by default.
  49498. */
  49499. createSkybox: boolean;
  49500. /**
  49501. * Specifies the skybox size.
  49502. * 20 by default.
  49503. */
  49504. skyboxSize: number;
  49505. /**
  49506. * The texture used on the skybox for the main color.
  49507. * Comes from the BabylonJS CDN by default.
  49508. *
  49509. * Remarks: Can be either a texture or a url.
  49510. */
  49511. skyboxTexture: string | BaseTexture;
  49512. /**
  49513. * The color mixed in the skybox texture by default.
  49514. * BabylonJS clearColor by default.
  49515. */
  49516. skyboxColor: Color3;
  49517. /**
  49518. * The background rotation around the Y axis of the scene.
  49519. * This helps aligning the key lights of your scene with the background.
  49520. * 0 by default.
  49521. */
  49522. backgroundYRotation: number;
  49523. /**
  49524. * Compute automatically the size of the elements to best fit with the scene.
  49525. */
  49526. sizeAuto: boolean;
  49527. /**
  49528. * Default position of the rootMesh if autoSize is not true.
  49529. */
  49530. rootPosition: Vector3;
  49531. /**
  49532. * Sets up the image processing in the scene.
  49533. * true by default.
  49534. */
  49535. setupImageProcessing: boolean;
  49536. /**
  49537. * The texture used as your environment texture in the scene.
  49538. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  49539. *
  49540. * Remarks: Can be either a texture or a url.
  49541. */
  49542. environmentTexture: string | BaseTexture;
  49543. /**
  49544. * The value of the exposure to apply to the scene.
  49545. * 0.6 by default if setupImageProcessing is true.
  49546. */
  49547. cameraExposure: number;
  49548. /**
  49549. * The value of the contrast to apply to the scene.
  49550. * 1.6 by default if setupImageProcessing is true.
  49551. */
  49552. cameraContrast: number;
  49553. /**
  49554. * Specifies whether or not tonemapping should be enabled in the scene.
  49555. * true by default if setupImageProcessing is true.
  49556. */
  49557. toneMappingEnabled: boolean;
  49558. }
  49559. /**
  49560. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  49561. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  49562. * It also helps with the default setup of your imageProcessing configuration.
  49563. */
  49564. export class EnvironmentHelper {
  49565. /**
  49566. * Default ground texture URL.
  49567. */
  49568. private static _groundTextureCDNUrl;
  49569. /**
  49570. * Default skybox texture URL.
  49571. */
  49572. private static _skyboxTextureCDNUrl;
  49573. /**
  49574. * Default environment texture URL.
  49575. */
  49576. private static _environmentTextureCDNUrl;
  49577. /**
  49578. * Creates the default options for the helper.
  49579. */
  49580. private static _getDefaultOptions;
  49581. private _rootMesh;
  49582. /**
  49583. * Gets the root mesh created by the helper.
  49584. */
  49585. get rootMesh(): Mesh;
  49586. private _skybox;
  49587. /**
  49588. * Gets the skybox created by the helper.
  49589. */
  49590. get skybox(): Nullable<Mesh>;
  49591. private _skyboxTexture;
  49592. /**
  49593. * Gets the skybox texture created by the helper.
  49594. */
  49595. get skyboxTexture(): Nullable<BaseTexture>;
  49596. private _skyboxMaterial;
  49597. /**
  49598. * Gets the skybox material created by the helper.
  49599. */
  49600. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  49601. private _ground;
  49602. /**
  49603. * Gets the ground mesh created by the helper.
  49604. */
  49605. get ground(): Nullable<Mesh>;
  49606. private _groundTexture;
  49607. /**
  49608. * Gets the ground texture created by the helper.
  49609. */
  49610. get groundTexture(): Nullable<BaseTexture>;
  49611. private _groundMirror;
  49612. /**
  49613. * Gets the ground mirror created by the helper.
  49614. */
  49615. get groundMirror(): Nullable<MirrorTexture>;
  49616. /**
  49617. * Gets the ground mirror render list to helps pushing the meshes
  49618. * you wish in the ground reflection.
  49619. */
  49620. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  49621. private _groundMaterial;
  49622. /**
  49623. * Gets the ground material created by the helper.
  49624. */
  49625. get groundMaterial(): Nullable<BackgroundMaterial>;
  49626. /**
  49627. * Stores the creation options.
  49628. */
  49629. private readonly _scene;
  49630. private _options;
  49631. /**
  49632. * This observable will be notified with any error during the creation of the environment,
  49633. * mainly texture creation errors.
  49634. */
  49635. onErrorObservable: Observable<{
  49636. message?: string;
  49637. exception?: any;
  49638. }>;
  49639. /**
  49640. * constructor
  49641. * @param options Defines the options we want to customize the helper
  49642. * @param scene The scene to add the material to
  49643. */
  49644. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  49645. /**
  49646. * Updates the background according to the new options
  49647. * @param options
  49648. */
  49649. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  49650. /**
  49651. * Sets the primary color of all the available elements.
  49652. * @param color the main color to affect to the ground and the background
  49653. */
  49654. setMainColor(color: Color3): void;
  49655. /**
  49656. * Setup the image processing according to the specified options.
  49657. */
  49658. private _setupImageProcessing;
  49659. /**
  49660. * Setup the environment texture according to the specified options.
  49661. */
  49662. private _setupEnvironmentTexture;
  49663. /**
  49664. * Setup the background according to the specified options.
  49665. */
  49666. private _setupBackground;
  49667. /**
  49668. * Get the scene sizes according to the setup.
  49669. */
  49670. private _getSceneSize;
  49671. /**
  49672. * Setup the ground according to the specified options.
  49673. */
  49674. private _setupGround;
  49675. /**
  49676. * Setup the ground material according to the specified options.
  49677. */
  49678. private _setupGroundMaterial;
  49679. /**
  49680. * Setup the ground diffuse texture according to the specified options.
  49681. */
  49682. private _setupGroundDiffuseTexture;
  49683. /**
  49684. * Setup the ground mirror texture according to the specified options.
  49685. */
  49686. private _setupGroundMirrorTexture;
  49687. /**
  49688. * Setup the ground to receive the mirror texture.
  49689. */
  49690. private _setupMirrorInGroundMaterial;
  49691. /**
  49692. * Setup the skybox according to the specified options.
  49693. */
  49694. private _setupSkybox;
  49695. /**
  49696. * Setup the skybox material according to the specified options.
  49697. */
  49698. private _setupSkyboxMaterial;
  49699. /**
  49700. * Setup the skybox reflection texture according to the specified options.
  49701. */
  49702. private _setupSkyboxReflectionTexture;
  49703. private _errorHandler;
  49704. /**
  49705. * Dispose all the elements created by the Helper.
  49706. */
  49707. dispose(): void;
  49708. }
  49709. }
  49710. declare module BABYLON {
  49711. /**
  49712. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  49713. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  49714. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  49715. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  49716. */
  49717. export class PhotoDome extends TransformNode {
  49718. /**
  49719. * Define the image as a Monoscopic panoramic 360 image.
  49720. */
  49721. static readonly MODE_MONOSCOPIC: number;
  49722. /**
  49723. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  49724. */
  49725. static readonly MODE_TOPBOTTOM: number;
  49726. /**
  49727. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  49728. */
  49729. static readonly MODE_SIDEBYSIDE: number;
  49730. private _useDirectMapping;
  49731. /**
  49732. * The texture being displayed on the sphere
  49733. */
  49734. protected _photoTexture: Texture;
  49735. /**
  49736. * Gets or sets the texture being displayed on the sphere
  49737. */
  49738. get photoTexture(): Texture;
  49739. set photoTexture(value: Texture);
  49740. /**
  49741. * Observable raised when an error occured while loading the 360 image
  49742. */
  49743. onLoadErrorObservable: Observable<string>;
  49744. /**
  49745. * The skybox material
  49746. */
  49747. protected _material: BackgroundMaterial;
  49748. /**
  49749. * The surface used for the skybox
  49750. */
  49751. protected _mesh: Mesh;
  49752. /**
  49753. * Gets the mesh used for the skybox.
  49754. */
  49755. get mesh(): Mesh;
  49756. /**
  49757. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49758. * Also see the options.resolution property.
  49759. */
  49760. get fovMultiplier(): number;
  49761. set fovMultiplier(value: number);
  49762. private _imageMode;
  49763. /**
  49764. * Gets or set the current video mode for the video. It can be:
  49765. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  49766. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  49767. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  49768. */
  49769. get imageMode(): number;
  49770. set imageMode(value: number);
  49771. /**
  49772. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  49773. * @param name Element's name, child elements will append suffixes for their own names.
  49774. * @param urlsOfPhoto defines the url of the photo to display
  49775. * @param options defines an object containing optional or exposed sub element properties
  49776. * @param onError defines a callback called when an error occured while loading the texture
  49777. */
  49778. constructor(name: string, urlOfPhoto: string, options: {
  49779. resolution?: number;
  49780. size?: number;
  49781. useDirectMapping?: boolean;
  49782. faceForward?: boolean;
  49783. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  49784. private _onBeforeCameraRenderObserver;
  49785. private _changeImageMode;
  49786. /**
  49787. * Releases resources associated with this node.
  49788. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  49789. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  49790. */
  49791. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  49792. }
  49793. }
  49794. declare module BABYLON {
  49795. /**
  49796. * Class used to host RGBD texture specific utilities
  49797. */
  49798. export class RGBDTextureTools {
  49799. /**
  49800. * Expand the RGBD Texture from RGBD to Half Float if possible.
  49801. * @param texture the texture to expand.
  49802. */
  49803. static ExpandRGBDTexture(texture: Texture): void;
  49804. }
  49805. }
  49806. declare module BABYLON {
  49807. /**
  49808. * Class used to host texture specific utilities
  49809. */
  49810. export class BRDFTextureTools {
  49811. /**
  49812. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  49813. * @param scene defines the hosting scene
  49814. * @returns the environment BRDF texture
  49815. */
  49816. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  49817. private static _environmentBRDFBase64Texture;
  49818. }
  49819. }
  49820. declare module BABYLON {
  49821. /**
  49822. * @hidden
  49823. */
  49824. export interface IMaterialClearCoatDefines {
  49825. CLEARCOAT: boolean;
  49826. CLEARCOAT_DEFAULTIOR: boolean;
  49827. CLEARCOAT_TEXTURE: boolean;
  49828. CLEARCOAT_TEXTUREDIRECTUV: number;
  49829. CLEARCOAT_BUMP: boolean;
  49830. CLEARCOAT_BUMPDIRECTUV: number;
  49831. CLEARCOAT_TINT: boolean;
  49832. CLEARCOAT_TINT_TEXTURE: boolean;
  49833. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49834. /** @hidden */
  49835. _areTexturesDirty: boolean;
  49836. }
  49837. /**
  49838. * Define the code related to the clear coat parameters of the pbr material.
  49839. */
  49840. export class PBRClearCoatConfiguration {
  49841. /**
  49842. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  49843. * The default fits with a polyurethane material.
  49844. */
  49845. private static readonly _DefaultIndexOfRefraction;
  49846. private _isEnabled;
  49847. /**
  49848. * Defines if the clear coat is enabled in the material.
  49849. */
  49850. isEnabled: boolean;
  49851. /**
  49852. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  49853. */
  49854. intensity: number;
  49855. /**
  49856. * Defines the clear coat layer roughness.
  49857. */
  49858. roughness: number;
  49859. private _indexOfRefraction;
  49860. /**
  49861. * Defines the index of refraction of the clear coat.
  49862. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  49863. * The default fits with a polyurethane material.
  49864. * Changing the default value is more performance intensive.
  49865. */
  49866. indexOfRefraction: number;
  49867. private _texture;
  49868. /**
  49869. * Stores the clear coat values in a texture.
  49870. */
  49871. texture: Nullable<BaseTexture>;
  49872. private _bumpTexture;
  49873. /**
  49874. * Define the clear coat specific bump texture.
  49875. */
  49876. bumpTexture: Nullable<BaseTexture>;
  49877. private _isTintEnabled;
  49878. /**
  49879. * Defines if the clear coat tint is enabled in the material.
  49880. */
  49881. isTintEnabled: boolean;
  49882. /**
  49883. * Defines the clear coat tint of the material.
  49884. * This is only use if tint is enabled
  49885. */
  49886. tintColor: Color3;
  49887. /**
  49888. * Defines the distance at which the tint color should be found in the
  49889. * clear coat media.
  49890. * This is only use if tint is enabled
  49891. */
  49892. tintColorAtDistance: number;
  49893. /**
  49894. * Defines the clear coat layer thickness.
  49895. * This is only use if tint is enabled
  49896. */
  49897. tintThickness: number;
  49898. private _tintTexture;
  49899. /**
  49900. * Stores the clear tint values in a texture.
  49901. * rgb is tint
  49902. * a is a thickness factor
  49903. */
  49904. tintTexture: Nullable<BaseTexture>;
  49905. /** @hidden */
  49906. private _internalMarkAllSubMeshesAsTexturesDirty;
  49907. /** @hidden */
  49908. _markAllSubMeshesAsTexturesDirty(): void;
  49909. /**
  49910. * Instantiate a new istance of clear coat configuration.
  49911. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49912. */
  49913. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49914. /**
  49915. * Gets wehter the submesh is ready to be used or not.
  49916. * @param defines the list of "defines" to update.
  49917. * @param scene defines the scene the material belongs to.
  49918. * @param engine defines the engine the material belongs to.
  49919. * @param disableBumpMap defines wether the material disables bump or not.
  49920. * @returns - boolean indicating that the submesh is ready or not.
  49921. */
  49922. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  49923. /**
  49924. * Checks to see if a texture is used in the material.
  49925. * @param defines the list of "defines" to update.
  49926. * @param scene defines the scene to the material belongs to.
  49927. */
  49928. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  49929. /**
  49930. * Binds the material data.
  49931. * @param uniformBuffer defines the Uniform buffer to fill in.
  49932. * @param scene defines the scene the material belongs to.
  49933. * @param engine defines the engine the material belongs to.
  49934. * @param disableBumpMap defines wether the material disables bump or not.
  49935. * @param isFrozen defines wether the material is frozen or not.
  49936. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  49937. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  49938. */
  49939. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  49940. /**
  49941. * Checks to see if a texture is used in the material.
  49942. * @param texture - Base texture to use.
  49943. * @returns - Boolean specifying if a texture is used in the material.
  49944. */
  49945. hasTexture(texture: BaseTexture): boolean;
  49946. /**
  49947. * Returns an array of the actively used textures.
  49948. * @param activeTextures Array of BaseTextures
  49949. */
  49950. getActiveTextures(activeTextures: BaseTexture[]): void;
  49951. /**
  49952. * Returns the animatable textures.
  49953. * @param animatables Array of animatable textures.
  49954. */
  49955. getAnimatables(animatables: IAnimatable[]): void;
  49956. /**
  49957. * Disposes the resources of the material.
  49958. * @param forceDisposeTextures - Forces the disposal of all textures.
  49959. */
  49960. dispose(forceDisposeTextures?: boolean): void;
  49961. /**
  49962. * Get the current class name of the texture useful for serialization or dynamic coding.
  49963. * @returns "PBRClearCoatConfiguration"
  49964. */
  49965. getClassName(): string;
  49966. /**
  49967. * Add fallbacks to the effect fallbacks list.
  49968. * @param defines defines the Base texture to use.
  49969. * @param fallbacks defines the current fallback list.
  49970. * @param currentRank defines the current fallback rank.
  49971. * @returns the new fallback rank.
  49972. */
  49973. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49974. /**
  49975. * Add the required uniforms to the current list.
  49976. * @param uniforms defines the current uniform list.
  49977. */
  49978. static AddUniforms(uniforms: string[]): void;
  49979. /**
  49980. * Add the required samplers to the current list.
  49981. * @param samplers defines the current sampler list.
  49982. */
  49983. static AddSamplers(samplers: string[]): void;
  49984. /**
  49985. * Add the required uniforms to the current buffer.
  49986. * @param uniformBuffer defines the current uniform buffer.
  49987. */
  49988. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49989. /**
  49990. * Makes a duplicate of the current configuration into another one.
  49991. * @param clearCoatConfiguration define the config where to copy the info
  49992. */
  49993. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  49994. /**
  49995. * Serializes this clear coat configuration.
  49996. * @returns - An object with the serialized config.
  49997. */
  49998. serialize(): any;
  49999. /**
  50000. * Parses a anisotropy Configuration from a serialized object.
  50001. * @param source - Serialized object.
  50002. * @param scene Defines the scene we are parsing for
  50003. * @param rootUrl Defines the rootUrl to load from
  50004. */
  50005. parse(source: any, scene: Scene, rootUrl: string): void;
  50006. }
  50007. }
  50008. declare module BABYLON {
  50009. /**
  50010. * @hidden
  50011. */
  50012. export interface IMaterialAnisotropicDefines {
  50013. ANISOTROPIC: boolean;
  50014. ANISOTROPIC_TEXTURE: boolean;
  50015. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50016. MAINUV1: boolean;
  50017. _areTexturesDirty: boolean;
  50018. _needUVs: boolean;
  50019. }
  50020. /**
  50021. * Define the code related to the anisotropic parameters of the pbr material.
  50022. */
  50023. export class PBRAnisotropicConfiguration {
  50024. private _isEnabled;
  50025. /**
  50026. * Defines if the anisotropy is enabled in the material.
  50027. */
  50028. isEnabled: boolean;
  50029. /**
  50030. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  50031. */
  50032. intensity: number;
  50033. /**
  50034. * Defines if the effect is along the tangents, bitangents or in between.
  50035. * By default, the effect is "strectching" the highlights along the tangents.
  50036. */
  50037. direction: Vector2;
  50038. private _texture;
  50039. /**
  50040. * Stores the anisotropy values in a texture.
  50041. * rg is direction (like normal from -1 to 1)
  50042. * b is a intensity
  50043. */
  50044. texture: Nullable<BaseTexture>;
  50045. /** @hidden */
  50046. private _internalMarkAllSubMeshesAsTexturesDirty;
  50047. /** @hidden */
  50048. _markAllSubMeshesAsTexturesDirty(): void;
  50049. /**
  50050. * Instantiate a new istance of anisotropy configuration.
  50051. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50052. */
  50053. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50054. /**
  50055. * Specifies that the submesh is ready to be used.
  50056. * @param defines the list of "defines" to update.
  50057. * @param scene defines the scene the material belongs to.
  50058. * @returns - boolean indicating that the submesh is ready or not.
  50059. */
  50060. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  50061. /**
  50062. * Checks to see if a texture is used in the material.
  50063. * @param defines the list of "defines" to update.
  50064. * @param mesh the mesh we are preparing the defines for.
  50065. * @param scene defines the scene the material belongs to.
  50066. */
  50067. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  50068. /**
  50069. * Binds the material data.
  50070. * @param uniformBuffer defines the Uniform buffer to fill in.
  50071. * @param scene defines the scene the material belongs to.
  50072. * @param isFrozen defines wether the material is frozen or not.
  50073. */
  50074. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50075. /**
  50076. * Checks to see if a texture is used in the material.
  50077. * @param texture - Base texture to use.
  50078. * @returns - Boolean specifying if a texture is used in the material.
  50079. */
  50080. hasTexture(texture: BaseTexture): boolean;
  50081. /**
  50082. * Returns an array of the actively used textures.
  50083. * @param activeTextures Array of BaseTextures
  50084. */
  50085. getActiveTextures(activeTextures: BaseTexture[]): void;
  50086. /**
  50087. * Returns the animatable textures.
  50088. * @param animatables Array of animatable textures.
  50089. */
  50090. getAnimatables(animatables: IAnimatable[]): void;
  50091. /**
  50092. * Disposes the resources of the material.
  50093. * @param forceDisposeTextures - Forces the disposal of all textures.
  50094. */
  50095. dispose(forceDisposeTextures?: boolean): void;
  50096. /**
  50097. * Get the current class name of the texture useful for serialization or dynamic coding.
  50098. * @returns "PBRAnisotropicConfiguration"
  50099. */
  50100. getClassName(): string;
  50101. /**
  50102. * Add fallbacks to the effect fallbacks list.
  50103. * @param defines defines the Base texture to use.
  50104. * @param fallbacks defines the current fallback list.
  50105. * @param currentRank defines the current fallback rank.
  50106. * @returns the new fallback rank.
  50107. */
  50108. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50109. /**
  50110. * Add the required uniforms to the current list.
  50111. * @param uniforms defines the current uniform list.
  50112. */
  50113. static AddUniforms(uniforms: string[]): void;
  50114. /**
  50115. * Add the required uniforms to the current buffer.
  50116. * @param uniformBuffer defines the current uniform buffer.
  50117. */
  50118. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50119. /**
  50120. * Add the required samplers to the current list.
  50121. * @param samplers defines the current sampler list.
  50122. */
  50123. static AddSamplers(samplers: string[]): void;
  50124. /**
  50125. * Makes a duplicate of the current configuration into another one.
  50126. * @param anisotropicConfiguration define the config where to copy the info
  50127. */
  50128. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  50129. /**
  50130. * Serializes this anisotropy configuration.
  50131. * @returns - An object with the serialized config.
  50132. */
  50133. serialize(): any;
  50134. /**
  50135. * Parses a anisotropy Configuration from a serialized object.
  50136. * @param source - Serialized object.
  50137. * @param scene Defines the scene we are parsing for
  50138. * @param rootUrl Defines the rootUrl to load from
  50139. */
  50140. parse(source: any, scene: Scene, rootUrl: string): void;
  50141. }
  50142. }
  50143. declare module BABYLON {
  50144. /**
  50145. * @hidden
  50146. */
  50147. export interface IMaterialBRDFDefines {
  50148. BRDF_V_HEIGHT_CORRELATED: boolean;
  50149. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50150. SPHERICAL_HARMONICS: boolean;
  50151. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50152. /** @hidden */
  50153. _areMiscDirty: boolean;
  50154. }
  50155. /**
  50156. * Define the code related to the BRDF parameters of the pbr material.
  50157. */
  50158. export class PBRBRDFConfiguration {
  50159. /**
  50160. * Default value used for the energy conservation.
  50161. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50162. */
  50163. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  50164. /**
  50165. * Default value used for the Smith Visibility Height Correlated mode.
  50166. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  50167. */
  50168. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  50169. /**
  50170. * Default value used for the IBL diffuse part.
  50171. * This can help switching back to the polynomials mode globally which is a tiny bit
  50172. * less GPU intensive at the drawback of a lower quality.
  50173. */
  50174. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  50175. /**
  50176. * Default value used for activating energy conservation for the specular workflow.
  50177. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50178. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50179. */
  50180. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  50181. private _useEnergyConservation;
  50182. /**
  50183. * Defines if the material uses energy conservation.
  50184. */
  50185. useEnergyConservation: boolean;
  50186. private _useSmithVisibilityHeightCorrelated;
  50187. /**
  50188. * LEGACY Mode set to false
  50189. * Defines if the material uses height smith correlated visibility term.
  50190. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  50191. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  50192. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  50193. * Not relying on height correlated will also disable energy conservation.
  50194. */
  50195. useSmithVisibilityHeightCorrelated: boolean;
  50196. private _useSphericalHarmonics;
  50197. /**
  50198. * LEGACY Mode set to false
  50199. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  50200. * diffuse part of the IBL.
  50201. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  50202. * to the ground truth.
  50203. */
  50204. useSphericalHarmonics: boolean;
  50205. private _useSpecularGlossinessInputEnergyConservation;
  50206. /**
  50207. * Defines if the material uses energy conservation, when the specular workflow is active.
  50208. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  50209. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  50210. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  50211. */
  50212. useSpecularGlossinessInputEnergyConservation: boolean;
  50213. /** @hidden */
  50214. private _internalMarkAllSubMeshesAsMiscDirty;
  50215. /** @hidden */
  50216. _markAllSubMeshesAsMiscDirty(): void;
  50217. /**
  50218. * Instantiate a new istance of clear coat configuration.
  50219. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  50220. */
  50221. constructor(markAllSubMeshesAsMiscDirty: () => void);
  50222. /**
  50223. * Checks to see if a texture is used in the material.
  50224. * @param defines the list of "defines" to update.
  50225. */
  50226. prepareDefines(defines: IMaterialBRDFDefines): void;
  50227. /**
  50228. * Get the current class name of the texture useful for serialization or dynamic coding.
  50229. * @returns "PBRClearCoatConfiguration"
  50230. */
  50231. getClassName(): string;
  50232. /**
  50233. * Makes a duplicate of the current configuration into another one.
  50234. * @param brdfConfiguration define the config where to copy the info
  50235. */
  50236. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  50237. /**
  50238. * Serializes this BRDF configuration.
  50239. * @returns - An object with the serialized config.
  50240. */
  50241. serialize(): any;
  50242. /**
  50243. * Parses a anisotropy Configuration from a serialized object.
  50244. * @param source - Serialized object.
  50245. * @param scene Defines the scene we are parsing for
  50246. * @param rootUrl Defines the rootUrl to load from
  50247. */
  50248. parse(source: any, scene: Scene, rootUrl: string): void;
  50249. }
  50250. }
  50251. declare module BABYLON {
  50252. /**
  50253. * @hidden
  50254. */
  50255. export interface IMaterialSheenDefines {
  50256. SHEEN: boolean;
  50257. SHEEN_TEXTURE: boolean;
  50258. SHEEN_TEXTUREDIRECTUV: number;
  50259. SHEEN_LINKWITHALBEDO: boolean;
  50260. /** @hidden */
  50261. _areTexturesDirty: boolean;
  50262. }
  50263. /**
  50264. * Define the code related to the Sheen parameters of the pbr material.
  50265. */
  50266. export class PBRSheenConfiguration {
  50267. private _isEnabled;
  50268. /**
  50269. * Defines if the material uses sheen.
  50270. */
  50271. isEnabled: boolean;
  50272. private _linkSheenWithAlbedo;
  50273. /**
  50274. * Defines if the sheen is linked to the sheen color.
  50275. */
  50276. linkSheenWithAlbedo: boolean;
  50277. /**
  50278. * Defines the sheen intensity.
  50279. */
  50280. intensity: number;
  50281. /**
  50282. * Defines the sheen color.
  50283. */
  50284. color: Color3;
  50285. private _texture;
  50286. /**
  50287. * Stores the sheen tint values in a texture.
  50288. * rgb is tint
  50289. * a is a intensity
  50290. */
  50291. texture: Nullable<BaseTexture>;
  50292. /** @hidden */
  50293. private _internalMarkAllSubMeshesAsTexturesDirty;
  50294. /** @hidden */
  50295. _markAllSubMeshesAsTexturesDirty(): void;
  50296. /**
  50297. * Instantiate a new istance of clear coat configuration.
  50298. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50299. */
  50300. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50301. /**
  50302. * Specifies that the submesh is ready to be used.
  50303. * @param defines the list of "defines" to update.
  50304. * @param scene defines the scene the material belongs to.
  50305. * @returns - boolean indicating that the submesh is ready or not.
  50306. */
  50307. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  50308. /**
  50309. * Checks to see if a texture is used in the material.
  50310. * @param defines the list of "defines" to update.
  50311. * @param scene defines the scene the material belongs to.
  50312. */
  50313. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  50314. /**
  50315. * Binds the material data.
  50316. * @param uniformBuffer defines the Uniform buffer to fill in.
  50317. * @param scene defines the scene the material belongs to.
  50318. * @param isFrozen defines wether the material is frozen or not.
  50319. */
  50320. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  50321. /**
  50322. * Checks to see if a texture is used in the material.
  50323. * @param texture - Base texture to use.
  50324. * @returns - Boolean specifying if a texture is used in the material.
  50325. */
  50326. hasTexture(texture: BaseTexture): boolean;
  50327. /**
  50328. * Returns an array of the actively used textures.
  50329. * @param activeTextures Array of BaseTextures
  50330. */
  50331. getActiveTextures(activeTextures: BaseTexture[]): void;
  50332. /**
  50333. * Returns the animatable textures.
  50334. * @param animatables Array of animatable textures.
  50335. */
  50336. getAnimatables(animatables: IAnimatable[]): void;
  50337. /**
  50338. * Disposes the resources of the material.
  50339. * @param forceDisposeTextures - Forces the disposal of all textures.
  50340. */
  50341. dispose(forceDisposeTextures?: boolean): void;
  50342. /**
  50343. * Get the current class name of the texture useful for serialization or dynamic coding.
  50344. * @returns "PBRSheenConfiguration"
  50345. */
  50346. getClassName(): string;
  50347. /**
  50348. * Add fallbacks to the effect fallbacks list.
  50349. * @param defines defines the Base texture to use.
  50350. * @param fallbacks defines the current fallback list.
  50351. * @param currentRank defines the current fallback rank.
  50352. * @returns the new fallback rank.
  50353. */
  50354. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50355. /**
  50356. * Add the required uniforms to the current list.
  50357. * @param uniforms defines the current uniform list.
  50358. */
  50359. static AddUniforms(uniforms: string[]): void;
  50360. /**
  50361. * Add the required uniforms to the current buffer.
  50362. * @param uniformBuffer defines the current uniform buffer.
  50363. */
  50364. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50365. /**
  50366. * Add the required samplers to the current list.
  50367. * @param samplers defines the current sampler list.
  50368. */
  50369. static AddSamplers(samplers: string[]): void;
  50370. /**
  50371. * Makes a duplicate of the current configuration into another one.
  50372. * @param sheenConfiguration define the config where to copy the info
  50373. */
  50374. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  50375. /**
  50376. * Serializes this BRDF configuration.
  50377. * @returns - An object with the serialized config.
  50378. */
  50379. serialize(): any;
  50380. /**
  50381. * Parses a anisotropy Configuration from a serialized object.
  50382. * @param source - Serialized object.
  50383. * @param scene Defines the scene we are parsing for
  50384. * @param rootUrl Defines the rootUrl to load from
  50385. */
  50386. parse(source: any, scene: Scene, rootUrl: string): void;
  50387. }
  50388. }
  50389. declare module BABYLON {
  50390. /**
  50391. * @hidden
  50392. */
  50393. export interface IMaterialSubSurfaceDefines {
  50394. SUBSURFACE: boolean;
  50395. SS_REFRACTION: boolean;
  50396. SS_TRANSLUCENCY: boolean;
  50397. SS_SCATERRING: boolean;
  50398. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50399. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50400. SS_REFRACTIONMAP_3D: boolean;
  50401. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50402. SS_LODINREFRACTIONALPHA: boolean;
  50403. SS_GAMMAREFRACTION: boolean;
  50404. SS_RGBDREFRACTION: boolean;
  50405. SS_LINEARSPECULARREFRACTION: boolean;
  50406. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50407. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50408. /** @hidden */
  50409. _areTexturesDirty: boolean;
  50410. }
  50411. /**
  50412. * Define the code related to the sub surface parameters of the pbr material.
  50413. */
  50414. export class PBRSubSurfaceConfiguration {
  50415. private _isRefractionEnabled;
  50416. /**
  50417. * Defines if the refraction is enabled in the material.
  50418. */
  50419. isRefractionEnabled: boolean;
  50420. private _isTranslucencyEnabled;
  50421. /**
  50422. * Defines if the translucency is enabled in the material.
  50423. */
  50424. isTranslucencyEnabled: boolean;
  50425. private _isScatteringEnabled;
  50426. /**
  50427. * Defines the refraction intensity of the material.
  50428. * The refraction when enabled replaces the Diffuse part of the material.
  50429. * The intensity helps transitionning between diffuse and refraction.
  50430. */
  50431. refractionIntensity: number;
  50432. /**
  50433. * Defines the translucency intensity of the material.
  50434. * When translucency has been enabled, this defines how much of the "translucency"
  50435. * is addded to the diffuse part of the material.
  50436. */
  50437. translucencyIntensity: number;
  50438. /**
  50439. * Defines the scattering intensity of the material.
  50440. * When scattering has been enabled, this defines how much of the "scattered light"
  50441. * is addded to the diffuse part of the material.
  50442. */
  50443. scatteringIntensity: number;
  50444. private _thicknessTexture;
  50445. /**
  50446. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  50447. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  50448. * 0 would mean minimumThickness
  50449. * 1 would mean maximumThickness
  50450. * The other channels might be use as a mask to vary the different effects intensity.
  50451. */
  50452. thicknessTexture: Nullable<BaseTexture>;
  50453. private _refractionTexture;
  50454. /**
  50455. * Defines the texture to use for refraction.
  50456. */
  50457. refractionTexture: Nullable<BaseTexture>;
  50458. private _indexOfRefraction;
  50459. /**
  50460. * Defines the index of refraction used in the material.
  50461. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  50462. */
  50463. indexOfRefraction: number;
  50464. private _invertRefractionY;
  50465. /**
  50466. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50467. */
  50468. invertRefractionY: boolean;
  50469. private _linkRefractionWithTransparency;
  50470. /**
  50471. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50472. * Materials half opaque for instance using refraction could benefit from this control.
  50473. */
  50474. linkRefractionWithTransparency: boolean;
  50475. /**
  50476. * Defines the minimum thickness stored in the thickness map.
  50477. * If no thickness map is defined, this value will be used to simulate thickness.
  50478. */
  50479. minimumThickness: number;
  50480. /**
  50481. * Defines the maximum thickness stored in the thickness map.
  50482. */
  50483. maximumThickness: number;
  50484. /**
  50485. * Defines the volume tint of the material.
  50486. * This is used for both translucency and scattering.
  50487. */
  50488. tintColor: Color3;
  50489. /**
  50490. * Defines the distance at which the tint color should be found in the media.
  50491. * This is used for refraction only.
  50492. */
  50493. tintColorAtDistance: number;
  50494. /**
  50495. * Defines how far each channel transmit through the media.
  50496. * It is defined as a color to simplify it selection.
  50497. */
  50498. diffusionDistance: Color3;
  50499. private _useMaskFromThicknessTexture;
  50500. /**
  50501. * Stores the intensity of the different subsurface effects in the thickness texture.
  50502. * * the green channel is the translucency intensity.
  50503. * * the blue channel is the scattering intensity.
  50504. * * the alpha channel is the refraction intensity.
  50505. */
  50506. useMaskFromThicknessTexture: boolean;
  50507. /** @hidden */
  50508. private _internalMarkAllSubMeshesAsTexturesDirty;
  50509. /** @hidden */
  50510. _markAllSubMeshesAsTexturesDirty(): void;
  50511. /**
  50512. * Instantiate a new istance of sub surface configuration.
  50513. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  50514. */
  50515. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  50516. /**
  50517. * Gets wehter the submesh is ready to be used or not.
  50518. * @param defines the list of "defines" to update.
  50519. * @param scene defines the scene the material belongs to.
  50520. * @returns - boolean indicating that the submesh is ready or not.
  50521. */
  50522. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  50523. /**
  50524. * Checks to see if a texture is used in the material.
  50525. * @param defines the list of "defines" to update.
  50526. * @param scene defines the scene to the material belongs to.
  50527. */
  50528. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  50529. /**
  50530. * Binds the material data.
  50531. * @param uniformBuffer defines the Uniform buffer to fill in.
  50532. * @param scene defines the scene the material belongs to.
  50533. * @param engine defines the engine the material belongs to.
  50534. * @param isFrozen defines wether the material is frozen or not.
  50535. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  50536. */
  50537. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  50538. /**
  50539. * Unbinds the material from the mesh.
  50540. * @param activeEffect defines the effect that should be unbound from.
  50541. * @returns true if unbound, otherwise false
  50542. */
  50543. unbind(activeEffect: Effect): boolean;
  50544. /**
  50545. * Returns the texture used for refraction or null if none is used.
  50546. * @param scene defines the scene the material belongs to.
  50547. * @returns - Refraction texture if present. If no refraction texture and refraction
  50548. * is linked with transparency, returns environment texture. Otherwise, returns null.
  50549. */
  50550. private _getRefractionTexture;
  50551. /**
  50552. * Returns true if alpha blending should be disabled.
  50553. */
  50554. get disableAlphaBlending(): boolean;
  50555. /**
  50556. * Fills the list of render target textures.
  50557. * @param renderTargets the list of render targets to update
  50558. */
  50559. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  50560. /**
  50561. * Checks to see if a texture is used in the material.
  50562. * @param texture - Base texture to use.
  50563. * @returns - Boolean specifying if a texture is used in the material.
  50564. */
  50565. hasTexture(texture: BaseTexture): boolean;
  50566. /**
  50567. * Gets a boolean indicating that current material needs to register RTT
  50568. * @returns true if this uses a render target otherwise false.
  50569. */
  50570. hasRenderTargetTextures(): boolean;
  50571. /**
  50572. * Returns an array of the actively used textures.
  50573. * @param activeTextures Array of BaseTextures
  50574. */
  50575. getActiveTextures(activeTextures: BaseTexture[]): void;
  50576. /**
  50577. * Returns the animatable textures.
  50578. * @param animatables Array of animatable textures.
  50579. */
  50580. getAnimatables(animatables: IAnimatable[]): void;
  50581. /**
  50582. * Disposes the resources of the material.
  50583. * @param forceDisposeTextures - Forces the disposal of all textures.
  50584. */
  50585. dispose(forceDisposeTextures?: boolean): void;
  50586. /**
  50587. * Get the current class name of the texture useful for serialization or dynamic coding.
  50588. * @returns "PBRSubSurfaceConfiguration"
  50589. */
  50590. getClassName(): string;
  50591. /**
  50592. * Add fallbacks to the effect fallbacks list.
  50593. * @param defines defines the Base texture to use.
  50594. * @param fallbacks defines the current fallback list.
  50595. * @param currentRank defines the current fallback rank.
  50596. * @returns the new fallback rank.
  50597. */
  50598. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  50599. /**
  50600. * Add the required uniforms to the current list.
  50601. * @param uniforms defines the current uniform list.
  50602. */
  50603. static AddUniforms(uniforms: string[]): void;
  50604. /**
  50605. * Add the required samplers to the current list.
  50606. * @param samplers defines the current sampler list.
  50607. */
  50608. static AddSamplers(samplers: string[]): void;
  50609. /**
  50610. * Add the required uniforms to the current buffer.
  50611. * @param uniformBuffer defines the current uniform buffer.
  50612. */
  50613. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  50614. /**
  50615. * Makes a duplicate of the current configuration into another one.
  50616. * @param configuration define the config where to copy the info
  50617. */
  50618. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  50619. /**
  50620. * Serializes this Sub Surface configuration.
  50621. * @returns - An object with the serialized config.
  50622. */
  50623. serialize(): any;
  50624. /**
  50625. * Parses a anisotropy Configuration from a serialized object.
  50626. * @param source - Serialized object.
  50627. * @param scene Defines the scene we are parsing for
  50628. * @param rootUrl Defines the rootUrl to load from
  50629. */
  50630. parse(source: any, scene: Scene, rootUrl: string): void;
  50631. }
  50632. }
  50633. declare module BABYLON {
  50634. /** @hidden */
  50635. export var pbrFragmentDeclaration: {
  50636. name: string;
  50637. shader: string;
  50638. };
  50639. }
  50640. declare module BABYLON {
  50641. /** @hidden */
  50642. export var pbrUboDeclaration: {
  50643. name: string;
  50644. shader: string;
  50645. };
  50646. }
  50647. declare module BABYLON {
  50648. /** @hidden */
  50649. export var pbrFragmentExtraDeclaration: {
  50650. name: string;
  50651. shader: string;
  50652. };
  50653. }
  50654. declare module BABYLON {
  50655. /** @hidden */
  50656. export var pbrFragmentSamplersDeclaration: {
  50657. name: string;
  50658. shader: string;
  50659. };
  50660. }
  50661. declare module BABYLON {
  50662. /** @hidden */
  50663. export var pbrHelperFunctions: {
  50664. name: string;
  50665. shader: string;
  50666. };
  50667. }
  50668. declare module BABYLON {
  50669. /** @hidden */
  50670. export var harmonicsFunctions: {
  50671. name: string;
  50672. shader: string;
  50673. };
  50674. }
  50675. declare module BABYLON {
  50676. /** @hidden */
  50677. export var pbrDirectLightingSetupFunctions: {
  50678. name: string;
  50679. shader: string;
  50680. };
  50681. }
  50682. declare module BABYLON {
  50683. /** @hidden */
  50684. export var pbrDirectLightingFalloffFunctions: {
  50685. name: string;
  50686. shader: string;
  50687. };
  50688. }
  50689. declare module BABYLON {
  50690. /** @hidden */
  50691. export var pbrBRDFFunctions: {
  50692. name: string;
  50693. shader: string;
  50694. };
  50695. }
  50696. declare module BABYLON {
  50697. /** @hidden */
  50698. export var pbrDirectLightingFunctions: {
  50699. name: string;
  50700. shader: string;
  50701. };
  50702. }
  50703. declare module BABYLON {
  50704. /** @hidden */
  50705. export var pbrIBLFunctions: {
  50706. name: string;
  50707. shader: string;
  50708. };
  50709. }
  50710. declare module BABYLON {
  50711. /** @hidden */
  50712. export var pbrDebug: {
  50713. name: string;
  50714. shader: string;
  50715. };
  50716. }
  50717. declare module BABYLON {
  50718. /** @hidden */
  50719. export var pbrPixelShader: {
  50720. name: string;
  50721. shader: string;
  50722. };
  50723. }
  50724. declare module BABYLON {
  50725. /** @hidden */
  50726. export var pbrVertexDeclaration: {
  50727. name: string;
  50728. shader: string;
  50729. };
  50730. }
  50731. declare module BABYLON {
  50732. /** @hidden */
  50733. export var pbrVertexShader: {
  50734. name: string;
  50735. shader: string;
  50736. };
  50737. }
  50738. declare module BABYLON {
  50739. /**
  50740. * Manages the defines for the PBR Material.
  50741. * @hidden
  50742. */
  50743. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  50744. PBR: boolean;
  50745. MAINUV1: boolean;
  50746. MAINUV2: boolean;
  50747. UV1: boolean;
  50748. UV2: boolean;
  50749. ALBEDO: boolean;
  50750. ALBEDODIRECTUV: number;
  50751. VERTEXCOLOR: boolean;
  50752. AMBIENT: boolean;
  50753. AMBIENTDIRECTUV: number;
  50754. AMBIENTINGRAYSCALE: boolean;
  50755. OPACITY: boolean;
  50756. VERTEXALPHA: boolean;
  50757. OPACITYDIRECTUV: number;
  50758. OPACITYRGB: boolean;
  50759. ALPHATEST: boolean;
  50760. DEPTHPREPASS: boolean;
  50761. ALPHABLEND: boolean;
  50762. ALPHAFROMALBEDO: boolean;
  50763. ALPHATESTVALUE: string;
  50764. SPECULAROVERALPHA: boolean;
  50765. RADIANCEOVERALPHA: boolean;
  50766. ALPHAFRESNEL: boolean;
  50767. LINEARALPHAFRESNEL: boolean;
  50768. PREMULTIPLYALPHA: boolean;
  50769. EMISSIVE: boolean;
  50770. EMISSIVEDIRECTUV: number;
  50771. REFLECTIVITY: boolean;
  50772. REFLECTIVITYDIRECTUV: number;
  50773. SPECULARTERM: boolean;
  50774. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  50775. MICROSURFACEAUTOMATIC: boolean;
  50776. LODBASEDMICROSFURACE: boolean;
  50777. MICROSURFACEMAP: boolean;
  50778. MICROSURFACEMAPDIRECTUV: number;
  50779. METALLICWORKFLOW: boolean;
  50780. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  50781. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  50782. METALLNESSSTOREINMETALMAPBLUE: boolean;
  50783. AOSTOREINMETALMAPRED: boolean;
  50784. METALLICF0FACTORFROMMETALLICMAP: boolean;
  50785. ENVIRONMENTBRDF: boolean;
  50786. ENVIRONMENTBRDF_RGBD: boolean;
  50787. NORMAL: boolean;
  50788. TANGENT: boolean;
  50789. BUMP: boolean;
  50790. BUMPDIRECTUV: number;
  50791. OBJECTSPACE_NORMALMAP: boolean;
  50792. PARALLAX: boolean;
  50793. PARALLAXOCCLUSION: boolean;
  50794. NORMALXYSCALE: boolean;
  50795. LIGHTMAP: boolean;
  50796. LIGHTMAPDIRECTUV: number;
  50797. USELIGHTMAPASSHADOWMAP: boolean;
  50798. GAMMALIGHTMAP: boolean;
  50799. RGBDLIGHTMAP: boolean;
  50800. REFLECTION: boolean;
  50801. REFLECTIONMAP_3D: boolean;
  50802. REFLECTIONMAP_SPHERICAL: boolean;
  50803. REFLECTIONMAP_PLANAR: boolean;
  50804. REFLECTIONMAP_CUBIC: boolean;
  50805. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  50806. REFLECTIONMAP_PROJECTION: boolean;
  50807. REFLECTIONMAP_SKYBOX: boolean;
  50808. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  50809. REFLECTIONMAP_EXPLICIT: boolean;
  50810. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  50811. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  50812. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  50813. INVERTCUBICMAP: boolean;
  50814. USESPHERICALFROMREFLECTIONMAP: boolean;
  50815. USEIRRADIANCEMAP: boolean;
  50816. SPHERICAL_HARMONICS: boolean;
  50817. USESPHERICALINVERTEX: boolean;
  50818. REFLECTIONMAP_OPPOSITEZ: boolean;
  50819. LODINREFLECTIONALPHA: boolean;
  50820. GAMMAREFLECTION: boolean;
  50821. RGBDREFLECTION: boolean;
  50822. LINEARSPECULARREFLECTION: boolean;
  50823. RADIANCEOCCLUSION: boolean;
  50824. HORIZONOCCLUSION: boolean;
  50825. INSTANCES: boolean;
  50826. NUM_BONE_INFLUENCERS: number;
  50827. BonesPerMesh: number;
  50828. BONETEXTURE: boolean;
  50829. NONUNIFORMSCALING: boolean;
  50830. MORPHTARGETS: boolean;
  50831. MORPHTARGETS_NORMAL: boolean;
  50832. MORPHTARGETS_TANGENT: boolean;
  50833. MORPHTARGETS_UV: boolean;
  50834. NUM_MORPH_INFLUENCERS: number;
  50835. IMAGEPROCESSING: boolean;
  50836. VIGNETTE: boolean;
  50837. VIGNETTEBLENDMODEMULTIPLY: boolean;
  50838. VIGNETTEBLENDMODEOPAQUE: boolean;
  50839. TONEMAPPING: boolean;
  50840. TONEMAPPING_ACES: boolean;
  50841. CONTRAST: boolean;
  50842. COLORCURVES: boolean;
  50843. COLORGRADING: boolean;
  50844. COLORGRADING3D: boolean;
  50845. SAMPLER3DGREENDEPTH: boolean;
  50846. SAMPLER3DBGRMAP: boolean;
  50847. IMAGEPROCESSINGPOSTPROCESS: boolean;
  50848. EXPOSURE: boolean;
  50849. MULTIVIEW: boolean;
  50850. USEPHYSICALLIGHTFALLOFF: boolean;
  50851. USEGLTFLIGHTFALLOFF: boolean;
  50852. TWOSIDEDLIGHTING: boolean;
  50853. SHADOWFLOAT: boolean;
  50854. CLIPPLANE: boolean;
  50855. CLIPPLANE2: boolean;
  50856. CLIPPLANE3: boolean;
  50857. CLIPPLANE4: boolean;
  50858. CLIPPLANE5: boolean;
  50859. CLIPPLANE6: boolean;
  50860. POINTSIZE: boolean;
  50861. FOG: boolean;
  50862. LOGARITHMICDEPTH: boolean;
  50863. FORCENORMALFORWARD: boolean;
  50864. SPECULARAA: boolean;
  50865. CLEARCOAT: boolean;
  50866. CLEARCOAT_DEFAULTIOR: boolean;
  50867. CLEARCOAT_TEXTURE: boolean;
  50868. CLEARCOAT_TEXTUREDIRECTUV: number;
  50869. CLEARCOAT_BUMP: boolean;
  50870. CLEARCOAT_BUMPDIRECTUV: number;
  50871. CLEARCOAT_TINT: boolean;
  50872. CLEARCOAT_TINT_TEXTURE: boolean;
  50873. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  50874. ANISOTROPIC: boolean;
  50875. ANISOTROPIC_TEXTURE: boolean;
  50876. ANISOTROPIC_TEXTUREDIRECTUV: number;
  50877. BRDF_V_HEIGHT_CORRELATED: boolean;
  50878. MS_BRDF_ENERGY_CONSERVATION: boolean;
  50879. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  50880. SHEEN: boolean;
  50881. SHEEN_TEXTURE: boolean;
  50882. SHEEN_TEXTUREDIRECTUV: number;
  50883. SHEEN_LINKWITHALBEDO: boolean;
  50884. SUBSURFACE: boolean;
  50885. SS_REFRACTION: boolean;
  50886. SS_TRANSLUCENCY: boolean;
  50887. SS_SCATERRING: boolean;
  50888. SS_THICKNESSANDMASK_TEXTURE: boolean;
  50889. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  50890. SS_REFRACTIONMAP_3D: boolean;
  50891. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  50892. SS_LODINREFRACTIONALPHA: boolean;
  50893. SS_GAMMAREFRACTION: boolean;
  50894. SS_RGBDREFRACTION: boolean;
  50895. SS_LINEARSPECULARREFRACTION: boolean;
  50896. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  50897. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  50898. UNLIT: boolean;
  50899. DEBUGMODE: number;
  50900. /**
  50901. * Initializes the PBR Material defines.
  50902. */
  50903. constructor();
  50904. /**
  50905. * Resets the PBR Material defines.
  50906. */
  50907. reset(): void;
  50908. }
  50909. /**
  50910. * The Physically based material base class of BJS.
  50911. *
  50912. * This offers the main features of a standard PBR material.
  50913. * For more information, please refer to the documentation :
  50914. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50915. */
  50916. export abstract class PBRBaseMaterial extends PushMaterial {
  50917. /**
  50918. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50919. */
  50920. static readonly PBRMATERIAL_OPAQUE: number;
  50921. /**
  50922. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50923. */
  50924. static readonly PBRMATERIAL_ALPHATEST: number;
  50925. /**
  50926. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50927. */
  50928. static readonly PBRMATERIAL_ALPHABLEND: number;
  50929. /**
  50930. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50931. * They are also discarded below the alpha cutoff threshold to improve performances.
  50932. */
  50933. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50934. /**
  50935. * Defines the default value of how much AO map is occluding the analytical lights
  50936. * (point spot...).
  50937. */
  50938. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50939. /**
  50940. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  50941. */
  50942. static readonly LIGHTFALLOFF_PHYSICAL: number;
  50943. /**
  50944. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  50945. * to enhance interoperability with other engines.
  50946. */
  50947. static readonly LIGHTFALLOFF_GLTF: number;
  50948. /**
  50949. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  50950. * to enhance interoperability with other materials.
  50951. */
  50952. static readonly LIGHTFALLOFF_STANDARD: number;
  50953. /**
  50954. * Intensity of the direct lights e.g. the four lights available in your scene.
  50955. * This impacts both the direct diffuse and specular highlights.
  50956. */
  50957. protected _directIntensity: number;
  50958. /**
  50959. * Intensity of the emissive part of the material.
  50960. * This helps controlling the emissive effect without modifying the emissive color.
  50961. */
  50962. protected _emissiveIntensity: number;
  50963. /**
  50964. * Intensity of the environment e.g. how much the environment will light the object
  50965. * either through harmonics for rough material or through the refelction for shiny ones.
  50966. */
  50967. protected _environmentIntensity: number;
  50968. /**
  50969. * This is a special control allowing the reduction of the specular highlights coming from the
  50970. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50971. */
  50972. protected _specularIntensity: number;
  50973. /**
  50974. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  50975. */
  50976. private _lightingInfos;
  50977. /**
  50978. * Debug Control allowing disabling the bump map on this material.
  50979. */
  50980. protected _disableBumpMap: boolean;
  50981. /**
  50982. * AKA Diffuse Texture in standard nomenclature.
  50983. */
  50984. protected _albedoTexture: Nullable<BaseTexture>;
  50985. /**
  50986. * AKA Occlusion Texture in other nomenclature.
  50987. */
  50988. protected _ambientTexture: Nullable<BaseTexture>;
  50989. /**
  50990. * AKA Occlusion Texture Intensity in other nomenclature.
  50991. */
  50992. protected _ambientTextureStrength: number;
  50993. /**
  50994. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50995. * 1 means it completely occludes it
  50996. * 0 mean it has no impact
  50997. */
  50998. protected _ambientTextureImpactOnAnalyticalLights: number;
  50999. /**
  51000. * Stores the alpha values in a texture.
  51001. */
  51002. protected _opacityTexture: Nullable<BaseTexture>;
  51003. /**
  51004. * Stores the reflection values in a texture.
  51005. */
  51006. protected _reflectionTexture: Nullable<BaseTexture>;
  51007. /**
  51008. * Stores the emissive values in a texture.
  51009. */
  51010. protected _emissiveTexture: Nullable<BaseTexture>;
  51011. /**
  51012. * AKA Specular texture in other nomenclature.
  51013. */
  51014. protected _reflectivityTexture: Nullable<BaseTexture>;
  51015. /**
  51016. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51017. */
  51018. protected _metallicTexture: Nullable<BaseTexture>;
  51019. /**
  51020. * Specifies the metallic scalar of the metallic/roughness workflow.
  51021. * Can also be used to scale the metalness values of the metallic texture.
  51022. */
  51023. protected _metallic: Nullable<number>;
  51024. /**
  51025. * Specifies the roughness scalar of the metallic/roughness workflow.
  51026. * Can also be used to scale the roughness values of the metallic texture.
  51027. */
  51028. protected _roughness: Nullable<number>;
  51029. /**
  51030. * Specifies the an F0 factor to help configuring the material F0.
  51031. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51032. * to 0.5 the previously hard coded value stays the same.
  51033. * Can also be used to scale the F0 values of the metallic texture.
  51034. */
  51035. protected _metallicF0Factor: number;
  51036. /**
  51037. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51038. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51039. * your expectation as it multiplies with the texture data.
  51040. */
  51041. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  51042. /**
  51043. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51044. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51045. */
  51046. protected _microSurfaceTexture: Nullable<BaseTexture>;
  51047. /**
  51048. * Stores surface normal data used to displace a mesh in a texture.
  51049. */
  51050. protected _bumpTexture: Nullable<BaseTexture>;
  51051. /**
  51052. * Stores the pre-calculated light information of a mesh in a texture.
  51053. */
  51054. protected _lightmapTexture: Nullable<BaseTexture>;
  51055. /**
  51056. * The color of a material in ambient lighting.
  51057. */
  51058. protected _ambientColor: Color3;
  51059. /**
  51060. * AKA Diffuse Color in other nomenclature.
  51061. */
  51062. protected _albedoColor: Color3;
  51063. /**
  51064. * AKA Specular Color in other nomenclature.
  51065. */
  51066. protected _reflectivityColor: Color3;
  51067. /**
  51068. * The color applied when light is reflected from a material.
  51069. */
  51070. protected _reflectionColor: Color3;
  51071. /**
  51072. * The color applied when light is emitted from a material.
  51073. */
  51074. protected _emissiveColor: Color3;
  51075. /**
  51076. * AKA Glossiness in other nomenclature.
  51077. */
  51078. protected _microSurface: number;
  51079. /**
  51080. * Specifies that the material will use the light map as a show map.
  51081. */
  51082. protected _useLightmapAsShadowmap: boolean;
  51083. /**
  51084. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51085. * makes the reflect vector face the model (under horizon).
  51086. */
  51087. protected _useHorizonOcclusion: boolean;
  51088. /**
  51089. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51090. * too much the area relying on ambient texture to define their ambient occlusion.
  51091. */
  51092. protected _useRadianceOcclusion: boolean;
  51093. /**
  51094. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51095. */
  51096. protected _useAlphaFromAlbedoTexture: boolean;
  51097. /**
  51098. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  51099. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51100. */
  51101. protected _useSpecularOverAlpha: boolean;
  51102. /**
  51103. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51104. */
  51105. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51106. /**
  51107. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51108. */
  51109. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  51110. /**
  51111. * Specifies if the metallic texture contains the roughness information in its green channel.
  51112. */
  51113. protected _useRoughnessFromMetallicTextureGreen: boolean;
  51114. /**
  51115. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51116. */
  51117. protected _useMetallnessFromMetallicTextureBlue: boolean;
  51118. /**
  51119. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51120. */
  51121. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  51122. /**
  51123. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51124. */
  51125. protected _useAmbientInGrayScale: boolean;
  51126. /**
  51127. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51128. * The material will try to infer what glossiness each pixel should be.
  51129. */
  51130. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  51131. /**
  51132. * Defines the falloff type used in this material.
  51133. * It by default is Physical.
  51134. */
  51135. protected _lightFalloff: number;
  51136. /**
  51137. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51138. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51139. */
  51140. protected _useRadianceOverAlpha: boolean;
  51141. /**
  51142. * Allows using an object space normal map (instead of tangent space).
  51143. */
  51144. protected _useObjectSpaceNormalMap: boolean;
  51145. /**
  51146. * Allows using the bump map in parallax mode.
  51147. */
  51148. protected _useParallax: boolean;
  51149. /**
  51150. * Allows using the bump map in parallax occlusion mode.
  51151. */
  51152. protected _useParallaxOcclusion: boolean;
  51153. /**
  51154. * Controls the scale bias of the parallax mode.
  51155. */
  51156. protected _parallaxScaleBias: number;
  51157. /**
  51158. * If sets to true, disables all the lights affecting the material.
  51159. */
  51160. protected _disableLighting: boolean;
  51161. /**
  51162. * Number of Simultaneous lights allowed on the material.
  51163. */
  51164. protected _maxSimultaneousLights: number;
  51165. /**
  51166. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  51167. */
  51168. protected _invertNormalMapX: boolean;
  51169. /**
  51170. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  51171. */
  51172. protected _invertNormalMapY: boolean;
  51173. /**
  51174. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51175. */
  51176. protected _twoSidedLighting: boolean;
  51177. /**
  51178. * Defines the alpha limits in alpha test mode.
  51179. */
  51180. protected _alphaCutOff: number;
  51181. /**
  51182. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51183. */
  51184. protected _forceAlphaTest: boolean;
  51185. /**
  51186. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51187. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51188. */
  51189. protected _useAlphaFresnel: boolean;
  51190. /**
  51191. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51192. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51193. */
  51194. protected _useLinearAlphaFresnel: boolean;
  51195. /**
  51196. * The transparency mode of the material.
  51197. */
  51198. protected _transparencyMode: Nullable<number>;
  51199. /**
  51200. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  51201. * from cos thetav and roughness:
  51202. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  51203. */
  51204. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  51205. /**
  51206. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51207. */
  51208. protected _forceIrradianceInFragment: boolean;
  51209. /**
  51210. * Force normal to face away from face.
  51211. */
  51212. protected _forceNormalForward: boolean;
  51213. /**
  51214. * Enables specular anti aliasing in the PBR shader.
  51215. * It will both interacts on the Geometry for analytical and IBL lighting.
  51216. * It also prefilter the roughness map based on the bump values.
  51217. */
  51218. protected _enableSpecularAntiAliasing: boolean;
  51219. /**
  51220. * Default configuration related to image processing available in the PBR Material.
  51221. */
  51222. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51223. /**
  51224. * Keep track of the image processing observer to allow dispose and replace.
  51225. */
  51226. private _imageProcessingObserver;
  51227. /**
  51228. * Attaches a new image processing configuration to the PBR Material.
  51229. * @param configuration
  51230. */
  51231. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51232. /**
  51233. * Stores the available render targets.
  51234. */
  51235. private _renderTargets;
  51236. /**
  51237. * Sets the global ambient color for the material used in lighting calculations.
  51238. */
  51239. private _globalAmbientColor;
  51240. /**
  51241. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  51242. */
  51243. private _useLogarithmicDepth;
  51244. /**
  51245. * If set to true, no lighting calculations will be applied.
  51246. */
  51247. private _unlit;
  51248. private _debugMode;
  51249. /**
  51250. * @hidden
  51251. * This is reserved for the inspector.
  51252. * Defines the material debug mode.
  51253. * It helps seeing only some components of the material while troubleshooting.
  51254. */
  51255. debugMode: number;
  51256. /**
  51257. * @hidden
  51258. * This is reserved for the inspector.
  51259. * Specify from where on screen the debug mode should start.
  51260. * The value goes from -1 (full screen) to 1 (not visible)
  51261. * It helps with side by side comparison against the final render
  51262. * This defaults to -1
  51263. */
  51264. private debugLimit;
  51265. /**
  51266. * @hidden
  51267. * This is reserved for the inspector.
  51268. * As the default viewing range might not be enough (if the ambient is really small for instance)
  51269. * You can use the factor to better multiply the final value.
  51270. */
  51271. private debugFactor;
  51272. /**
  51273. * Defines the clear coat layer parameters for the material.
  51274. */
  51275. readonly clearCoat: PBRClearCoatConfiguration;
  51276. /**
  51277. * Defines the anisotropic parameters for the material.
  51278. */
  51279. readonly anisotropy: PBRAnisotropicConfiguration;
  51280. /**
  51281. * Defines the BRDF parameters for the material.
  51282. */
  51283. readonly brdf: PBRBRDFConfiguration;
  51284. /**
  51285. * Defines the Sheen parameters for the material.
  51286. */
  51287. readonly sheen: PBRSheenConfiguration;
  51288. /**
  51289. * Defines the SubSurface parameters for the material.
  51290. */
  51291. readonly subSurface: PBRSubSurfaceConfiguration;
  51292. /**
  51293. * Custom callback helping to override the default shader used in the material.
  51294. */
  51295. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  51296. protected _rebuildInParallel: boolean;
  51297. /**
  51298. * Instantiates a new PBRMaterial instance.
  51299. *
  51300. * @param name The material name
  51301. * @param scene The scene the material will be use in.
  51302. */
  51303. constructor(name: string, scene: Scene);
  51304. /**
  51305. * Gets a boolean indicating that current material needs to register RTT
  51306. */
  51307. get hasRenderTargetTextures(): boolean;
  51308. /**
  51309. * Gets the name of the material class.
  51310. */
  51311. getClassName(): string;
  51312. /**
  51313. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51314. */
  51315. get useLogarithmicDepth(): boolean;
  51316. /**
  51317. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51318. */
  51319. set useLogarithmicDepth(value: boolean);
  51320. /**
  51321. * Gets the current transparency mode.
  51322. */
  51323. get transparencyMode(): Nullable<number>;
  51324. /**
  51325. * Sets the transparency mode of the material.
  51326. *
  51327. * | Value | Type | Description |
  51328. * | ----- | ----------------------------------- | ----------- |
  51329. * | 0 | OPAQUE | |
  51330. * | 1 | ALPHATEST | |
  51331. * | 2 | ALPHABLEND | |
  51332. * | 3 | ALPHATESTANDBLEND | |
  51333. *
  51334. */
  51335. set transparencyMode(value: Nullable<number>);
  51336. /**
  51337. * Returns true if alpha blending should be disabled.
  51338. */
  51339. private get _disableAlphaBlending();
  51340. /**
  51341. * Specifies whether or not this material should be rendered in alpha blend mode.
  51342. */
  51343. needAlphaBlending(): boolean;
  51344. /**
  51345. * Specifies if the mesh will require alpha blending.
  51346. * @param mesh - BJS mesh.
  51347. */
  51348. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  51349. /**
  51350. * Specifies whether or not this material should be rendered in alpha test mode.
  51351. */
  51352. needAlphaTesting(): boolean;
  51353. /**
  51354. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  51355. */
  51356. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  51357. /**
  51358. * Gets the texture used for the alpha test.
  51359. */
  51360. getAlphaTestTexture(): Nullable<BaseTexture>;
  51361. /**
  51362. * Specifies that the submesh is ready to be used.
  51363. * @param mesh - BJS mesh.
  51364. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  51365. * @param useInstances - Specifies that instances should be used.
  51366. * @returns - boolean indicating that the submesh is ready or not.
  51367. */
  51368. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51369. /**
  51370. * Specifies if the material uses metallic roughness workflow.
  51371. * @returns boolean specifiying if the material uses metallic roughness workflow.
  51372. */
  51373. isMetallicWorkflow(): boolean;
  51374. private _prepareEffect;
  51375. private _prepareDefines;
  51376. /**
  51377. * Force shader compilation
  51378. */
  51379. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  51380. /**
  51381. * Initializes the uniform buffer layout for the shader.
  51382. */
  51383. buildUniformLayout(): void;
  51384. /**
  51385. * Unbinds the material from the mesh
  51386. */
  51387. unbind(): void;
  51388. /**
  51389. * Binds the submesh data.
  51390. * @param world - The world matrix.
  51391. * @param mesh - The BJS mesh.
  51392. * @param subMesh - A submesh of the BJS mesh.
  51393. */
  51394. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51395. /**
  51396. * Returns the animatable textures.
  51397. * @returns - Array of animatable textures.
  51398. */
  51399. getAnimatables(): IAnimatable[];
  51400. /**
  51401. * Returns the texture used for reflections.
  51402. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  51403. */
  51404. private _getReflectionTexture;
  51405. /**
  51406. * Returns an array of the actively used textures.
  51407. * @returns - Array of BaseTextures
  51408. */
  51409. getActiveTextures(): BaseTexture[];
  51410. /**
  51411. * Checks to see if a texture is used in the material.
  51412. * @param texture - Base texture to use.
  51413. * @returns - Boolean specifying if a texture is used in the material.
  51414. */
  51415. hasTexture(texture: BaseTexture): boolean;
  51416. /**
  51417. * Disposes the resources of the material.
  51418. * @param forceDisposeEffect - Forces the disposal of effects.
  51419. * @param forceDisposeTextures - Forces the disposal of all textures.
  51420. */
  51421. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51422. }
  51423. }
  51424. declare module BABYLON {
  51425. /**
  51426. * The Physically based material of BJS.
  51427. *
  51428. * This offers the main features of a standard PBR material.
  51429. * For more information, please refer to the documentation :
  51430. * https://doc.babylonjs.com/how_to/physically_based_rendering
  51431. */
  51432. export class PBRMaterial extends PBRBaseMaterial {
  51433. /**
  51434. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  51435. */
  51436. static readonly PBRMATERIAL_OPAQUE: number;
  51437. /**
  51438. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  51439. */
  51440. static readonly PBRMATERIAL_ALPHATEST: number;
  51441. /**
  51442. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51443. */
  51444. static readonly PBRMATERIAL_ALPHABLEND: number;
  51445. /**
  51446. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  51447. * They are also discarded below the alpha cutoff threshold to improve performances.
  51448. */
  51449. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  51450. /**
  51451. * Defines the default value of how much AO map is occluding the analytical lights
  51452. * (point spot...).
  51453. */
  51454. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  51455. /**
  51456. * Intensity of the direct lights e.g. the four lights available in your scene.
  51457. * This impacts both the direct diffuse and specular highlights.
  51458. */
  51459. directIntensity: number;
  51460. /**
  51461. * Intensity of the emissive part of the material.
  51462. * This helps controlling the emissive effect without modifying the emissive color.
  51463. */
  51464. emissiveIntensity: number;
  51465. /**
  51466. * Intensity of the environment e.g. how much the environment will light the object
  51467. * either through harmonics for rough material or through the refelction for shiny ones.
  51468. */
  51469. environmentIntensity: number;
  51470. /**
  51471. * This is a special control allowing the reduction of the specular highlights coming from the
  51472. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  51473. */
  51474. specularIntensity: number;
  51475. /**
  51476. * Debug Control allowing disabling the bump map on this material.
  51477. */
  51478. disableBumpMap: boolean;
  51479. /**
  51480. * AKA Diffuse Texture in standard nomenclature.
  51481. */
  51482. albedoTexture: BaseTexture;
  51483. /**
  51484. * AKA Occlusion Texture in other nomenclature.
  51485. */
  51486. ambientTexture: BaseTexture;
  51487. /**
  51488. * AKA Occlusion Texture Intensity in other nomenclature.
  51489. */
  51490. ambientTextureStrength: number;
  51491. /**
  51492. * Defines how much the AO map is occluding the analytical lights (point spot...).
  51493. * 1 means it completely occludes it
  51494. * 0 mean it has no impact
  51495. */
  51496. ambientTextureImpactOnAnalyticalLights: number;
  51497. /**
  51498. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  51499. */
  51500. opacityTexture: BaseTexture;
  51501. /**
  51502. * Stores the reflection values in a texture.
  51503. */
  51504. reflectionTexture: Nullable<BaseTexture>;
  51505. /**
  51506. * Stores the emissive values in a texture.
  51507. */
  51508. emissiveTexture: BaseTexture;
  51509. /**
  51510. * AKA Specular texture in other nomenclature.
  51511. */
  51512. reflectivityTexture: BaseTexture;
  51513. /**
  51514. * Used to switch from specular/glossiness to metallic/roughness workflow.
  51515. */
  51516. metallicTexture: BaseTexture;
  51517. /**
  51518. * Specifies the metallic scalar of the metallic/roughness workflow.
  51519. * Can also be used to scale the metalness values of the metallic texture.
  51520. */
  51521. metallic: Nullable<number>;
  51522. /**
  51523. * Specifies the roughness scalar of the metallic/roughness workflow.
  51524. * Can also be used to scale the roughness values of the metallic texture.
  51525. */
  51526. roughness: Nullable<number>;
  51527. /**
  51528. * Specifies the an F0 factor to help configuring the material F0.
  51529. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  51530. * to 0.5 the previously hard coded value stays the same.
  51531. * Can also be used to scale the F0 values of the metallic texture.
  51532. */
  51533. metallicF0Factor: number;
  51534. /**
  51535. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  51536. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  51537. * your expectation as it multiplies with the texture data.
  51538. */
  51539. useMetallicF0FactorFromMetallicTexture: boolean;
  51540. /**
  51541. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  51542. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  51543. */
  51544. microSurfaceTexture: BaseTexture;
  51545. /**
  51546. * Stores surface normal data used to displace a mesh in a texture.
  51547. */
  51548. bumpTexture: BaseTexture;
  51549. /**
  51550. * Stores the pre-calculated light information of a mesh in a texture.
  51551. */
  51552. lightmapTexture: BaseTexture;
  51553. /**
  51554. * Stores the refracted light information in a texture.
  51555. */
  51556. get refractionTexture(): Nullable<BaseTexture>;
  51557. set refractionTexture(value: Nullable<BaseTexture>);
  51558. /**
  51559. * The color of a material in ambient lighting.
  51560. */
  51561. ambientColor: Color3;
  51562. /**
  51563. * AKA Diffuse Color in other nomenclature.
  51564. */
  51565. albedoColor: Color3;
  51566. /**
  51567. * AKA Specular Color in other nomenclature.
  51568. */
  51569. reflectivityColor: Color3;
  51570. /**
  51571. * The color reflected from the material.
  51572. */
  51573. reflectionColor: Color3;
  51574. /**
  51575. * The color emitted from the material.
  51576. */
  51577. emissiveColor: Color3;
  51578. /**
  51579. * AKA Glossiness in other nomenclature.
  51580. */
  51581. microSurface: number;
  51582. /**
  51583. * source material index of refraction (IOR)' / 'destination material IOR.
  51584. */
  51585. get indexOfRefraction(): number;
  51586. set indexOfRefraction(value: number);
  51587. /**
  51588. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  51589. */
  51590. get invertRefractionY(): boolean;
  51591. set invertRefractionY(value: boolean);
  51592. /**
  51593. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  51594. * Materials half opaque for instance using refraction could benefit from this control.
  51595. */
  51596. get linkRefractionWithTransparency(): boolean;
  51597. set linkRefractionWithTransparency(value: boolean);
  51598. /**
  51599. * If true, the light map contains occlusion information instead of lighting info.
  51600. */
  51601. useLightmapAsShadowmap: boolean;
  51602. /**
  51603. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  51604. */
  51605. useAlphaFromAlbedoTexture: boolean;
  51606. /**
  51607. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  51608. */
  51609. forceAlphaTest: boolean;
  51610. /**
  51611. * Defines the alpha limits in alpha test mode.
  51612. */
  51613. alphaCutOff: number;
  51614. /**
  51615. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  51616. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  51617. */
  51618. useSpecularOverAlpha: boolean;
  51619. /**
  51620. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  51621. */
  51622. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  51623. /**
  51624. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  51625. */
  51626. useRoughnessFromMetallicTextureAlpha: boolean;
  51627. /**
  51628. * Specifies if the metallic texture contains the roughness information in its green channel.
  51629. */
  51630. useRoughnessFromMetallicTextureGreen: boolean;
  51631. /**
  51632. * Specifies if the metallic texture contains the metallness information in its blue channel.
  51633. */
  51634. useMetallnessFromMetallicTextureBlue: boolean;
  51635. /**
  51636. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  51637. */
  51638. useAmbientOcclusionFromMetallicTextureRed: boolean;
  51639. /**
  51640. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  51641. */
  51642. useAmbientInGrayScale: boolean;
  51643. /**
  51644. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  51645. * The material will try to infer what glossiness each pixel should be.
  51646. */
  51647. useAutoMicroSurfaceFromReflectivityMap: boolean;
  51648. /**
  51649. * BJS is using an harcoded light falloff based on a manually sets up range.
  51650. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51651. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51652. */
  51653. get usePhysicalLightFalloff(): boolean;
  51654. /**
  51655. * BJS is using an harcoded light falloff based on a manually sets up range.
  51656. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  51657. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  51658. */
  51659. set usePhysicalLightFalloff(value: boolean);
  51660. /**
  51661. * In order to support the falloff compatibility with gltf, a special mode has been added
  51662. * to reproduce the gltf light falloff.
  51663. */
  51664. get useGLTFLightFalloff(): boolean;
  51665. /**
  51666. * In order to support the falloff compatibility with gltf, a special mode has been added
  51667. * to reproduce the gltf light falloff.
  51668. */
  51669. set useGLTFLightFalloff(value: boolean);
  51670. /**
  51671. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  51672. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  51673. */
  51674. useRadianceOverAlpha: boolean;
  51675. /**
  51676. * Allows using an object space normal map (instead of tangent space).
  51677. */
  51678. useObjectSpaceNormalMap: boolean;
  51679. /**
  51680. * Allows using the bump map in parallax mode.
  51681. */
  51682. useParallax: boolean;
  51683. /**
  51684. * Allows using the bump map in parallax occlusion mode.
  51685. */
  51686. useParallaxOcclusion: boolean;
  51687. /**
  51688. * Controls the scale bias of the parallax mode.
  51689. */
  51690. parallaxScaleBias: number;
  51691. /**
  51692. * If sets to true, disables all the lights affecting the material.
  51693. */
  51694. disableLighting: boolean;
  51695. /**
  51696. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51697. */
  51698. forceIrradianceInFragment: boolean;
  51699. /**
  51700. * Number of Simultaneous lights allowed on the material.
  51701. */
  51702. maxSimultaneousLights: number;
  51703. /**
  51704. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51705. */
  51706. invertNormalMapX: boolean;
  51707. /**
  51708. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51709. */
  51710. invertNormalMapY: boolean;
  51711. /**
  51712. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51713. */
  51714. twoSidedLighting: boolean;
  51715. /**
  51716. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51717. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  51718. */
  51719. useAlphaFresnel: boolean;
  51720. /**
  51721. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  51722. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  51723. */
  51724. useLinearAlphaFresnel: boolean;
  51725. /**
  51726. * Let user defines the brdf lookup texture used for IBL.
  51727. * A default 8bit version is embedded but you could point at :
  51728. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  51729. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  51730. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  51731. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  51732. */
  51733. environmentBRDFTexture: Nullable<BaseTexture>;
  51734. /**
  51735. * Force normal to face away from face.
  51736. */
  51737. forceNormalForward: boolean;
  51738. /**
  51739. * Enables specular anti aliasing in the PBR shader.
  51740. * It will both interacts on the Geometry for analytical and IBL lighting.
  51741. * It also prefilter the roughness map based on the bump values.
  51742. */
  51743. enableSpecularAntiAliasing: boolean;
  51744. /**
  51745. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  51746. * makes the reflect vector face the model (under horizon).
  51747. */
  51748. useHorizonOcclusion: boolean;
  51749. /**
  51750. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  51751. * too much the area relying on ambient texture to define their ambient occlusion.
  51752. */
  51753. useRadianceOcclusion: boolean;
  51754. /**
  51755. * If set to true, no lighting calculations will be applied.
  51756. */
  51757. unlit: boolean;
  51758. /**
  51759. * Gets the image processing configuration used either in this material.
  51760. */
  51761. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  51762. /**
  51763. * Sets the Default image processing configuration used either in the this material.
  51764. *
  51765. * If sets to null, the scene one is in use.
  51766. */
  51767. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  51768. /**
  51769. * Gets wether the color curves effect is enabled.
  51770. */
  51771. get cameraColorCurvesEnabled(): boolean;
  51772. /**
  51773. * Sets wether the color curves effect is enabled.
  51774. */
  51775. set cameraColorCurvesEnabled(value: boolean);
  51776. /**
  51777. * Gets wether the color grading effect is enabled.
  51778. */
  51779. get cameraColorGradingEnabled(): boolean;
  51780. /**
  51781. * Gets wether the color grading effect is enabled.
  51782. */
  51783. set cameraColorGradingEnabled(value: boolean);
  51784. /**
  51785. * Gets wether tonemapping is enabled or not.
  51786. */
  51787. get cameraToneMappingEnabled(): boolean;
  51788. /**
  51789. * Sets wether tonemapping is enabled or not
  51790. */
  51791. set cameraToneMappingEnabled(value: boolean);
  51792. /**
  51793. * The camera exposure used on this material.
  51794. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51795. * This corresponds to a photographic exposure.
  51796. */
  51797. get cameraExposure(): number;
  51798. /**
  51799. * The camera exposure used on this material.
  51800. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51801. * This corresponds to a photographic exposure.
  51802. */
  51803. set cameraExposure(value: number);
  51804. /**
  51805. * Gets The camera contrast used on this material.
  51806. */
  51807. get cameraContrast(): number;
  51808. /**
  51809. * Sets The camera contrast used on this material.
  51810. */
  51811. set cameraContrast(value: number);
  51812. /**
  51813. * Gets the Color Grading 2D Lookup Texture.
  51814. */
  51815. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  51816. /**
  51817. * Sets the Color Grading 2D Lookup Texture.
  51818. */
  51819. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  51820. /**
  51821. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51822. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51823. * 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;
  51824. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51825. */
  51826. get cameraColorCurves(): Nullable<ColorCurves>;
  51827. /**
  51828. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51829. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51830. * 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;
  51831. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51832. */
  51833. set cameraColorCurves(value: Nullable<ColorCurves>);
  51834. /**
  51835. * Instantiates a new PBRMaterial instance.
  51836. *
  51837. * @param name The material name
  51838. * @param scene The scene the material will be use in.
  51839. */
  51840. constructor(name: string, scene: Scene);
  51841. /**
  51842. * Returns the name of this material class.
  51843. */
  51844. getClassName(): string;
  51845. /**
  51846. * Makes a duplicate of the current material.
  51847. * @param name - name to use for the new material.
  51848. */
  51849. clone(name: string): PBRMaterial;
  51850. /**
  51851. * Serializes this PBR Material.
  51852. * @returns - An object with the serialized material.
  51853. */
  51854. serialize(): any;
  51855. /**
  51856. * Parses a PBR Material from a serialized object.
  51857. * @param source - Serialized object.
  51858. * @param scene - BJS scene instance.
  51859. * @param rootUrl - url for the scene object
  51860. * @returns - PBRMaterial
  51861. */
  51862. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  51863. }
  51864. }
  51865. declare module BABYLON {
  51866. /**
  51867. * Direct draw surface info
  51868. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  51869. */
  51870. export interface DDSInfo {
  51871. /**
  51872. * Width of the texture
  51873. */
  51874. width: number;
  51875. /**
  51876. * Width of the texture
  51877. */
  51878. height: number;
  51879. /**
  51880. * Number of Mipmaps for the texture
  51881. * @see https://en.wikipedia.org/wiki/Mipmap
  51882. */
  51883. mipmapCount: number;
  51884. /**
  51885. * If the textures format is a known fourCC format
  51886. * @see https://www.fourcc.org/
  51887. */
  51888. isFourCC: boolean;
  51889. /**
  51890. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  51891. */
  51892. isRGB: boolean;
  51893. /**
  51894. * If the texture is a lumincance format
  51895. */
  51896. isLuminance: boolean;
  51897. /**
  51898. * If this is a cube texture
  51899. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  51900. */
  51901. isCube: boolean;
  51902. /**
  51903. * If the texture is a compressed format eg. FOURCC_DXT1
  51904. */
  51905. isCompressed: boolean;
  51906. /**
  51907. * The dxgiFormat of the texture
  51908. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  51909. */
  51910. dxgiFormat: number;
  51911. /**
  51912. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  51913. */
  51914. textureType: number;
  51915. /**
  51916. * Sphericle polynomial created for the dds texture
  51917. */
  51918. sphericalPolynomial?: SphericalPolynomial;
  51919. }
  51920. /**
  51921. * Class used to provide DDS decompression tools
  51922. */
  51923. export class DDSTools {
  51924. /**
  51925. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  51926. */
  51927. static StoreLODInAlphaChannel: boolean;
  51928. /**
  51929. * Gets DDS information from an array buffer
  51930. * @param data defines the array buffer view to read data from
  51931. * @returns the DDS information
  51932. */
  51933. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  51934. private static _FloatView;
  51935. private static _Int32View;
  51936. private static _ToHalfFloat;
  51937. private static _FromHalfFloat;
  51938. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  51939. private static _GetHalfFloatRGBAArrayBuffer;
  51940. private static _GetFloatRGBAArrayBuffer;
  51941. private static _GetFloatAsUIntRGBAArrayBuffer;
  51942. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  51943. private static _GetRGBAArrayBuffer;
  51944. private static _ExtractLongWordOrder;
  51945. private static _GetRGBArrayBuffer;
  51946. private static _GetLuminanceArrayBuffer;
  51947. /**
  51948. * Uploads DDS Levels to a Babylon Texture
  51949. * @hidden
  51950. */
  51951. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  51952. }
  51953. interface ThinEngine {
  51954. /**
  51955. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  51956. * @param rootUrl defines the url where the file to load is located
  51957. * @param scene defines the current scene
  51958. * @param lodScale defines scale to apply to the mip map selection
  51959. * @param lodOffset defines offset to apply to the mip map selection
  51960. * @param onLoad defines an optional callback raised when the texture is loaded
  51961. * @param onError defines an optional callback raised if there is an issue to load the texture
  51962. * @param format defines the format of the data
  51963. * @param forcedExtension defines the extension to use to pick the right loader
  51964. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  51965. * @returns the cube texture as an InternalTexture
  51966. */
  51967. 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;
  51968. }
  51969. }
  51970. declare module BABYLON {
  51971. /**
  51972. * Implementation of the DDS Texture Loader.
  51973. * @hidden
  51974. */
  51975. export class _DDSTextureLoader implements IInternalTextureLoader {
  51976. /**
  51977. * Defines wether the loader supports cascade loading the different faces.
  51978. */
  51979. readonly supportCascades: boolean;
  51980. /**
  51981. * This returns if the loader support the current file information.
  51982. * @param extension defines the file extension of the file being loaded
  51983. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51984. * @param fallback defines the fallback internal texture if any
  51985. * @param isBase64 defines whether the texture is encoded as a base64
  51986. * @param isBuffer defines whether the texture data are stored as a buffer
  51987. * @returns true if the loader can load the specified file
  51988. */
  51989. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51990. /**
  51991. * Transform the url before loading if required.
  51992. * @param rootUrl the url of the texture
  51993. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51994. * @returns the transformed texture
  51995. */
  51996. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51997. /**
  51998. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51999. * @param rootUrl the url of the texture
  52000. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52001. * @returns the fallback texture
  52002. */
  52003. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52004. /**
  52005. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52006. * @param data contains the texture data
  52007. * @param texture defines the BabylonJS internal texture
  52008. * @param createPolynomials will be true if polynomials have been requested
  52009. * @param onLoad defines the callback to trigger once the texture is ready
  52010. * @param onError defines the callback to trigger in case of error
  52011. */
  52012. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52013. /**
  52014. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52015. * @param data contains the texture data
  52016. * @param texture defines the BabylonJS internal texture
  52017. * @param callback defines the method to call once ready to upload
  52018. */
  52019. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52020. }
  52021. }
  52022. declare module BABYLON {
  52023. /**
  52024. * Implementation of the ENV Texture Loader.
  52025. * @hidden
  52026. */
  52027. export class _ENVTextureLoader implements IInternalTextureLoader {
  52028. /**
  52029. * Defines wether the loader supports cascade loading the different faces.
  52030. */
  52031. readonly supportCascades: boolean;
  52032. /**
  52033. * This returns if the loader support the current file information.
  52034. * @param extension defines the file extension of the file being loaded
  52035. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52036. * @param fallback defines the fallback internal texture if any
  52037. * @param isBase64 defines whether the texture is encoded as a base64
  52038. * @param isBuffer defines whether the texture data are stored as a buffer
  52039. * @returns true if the loader can load the specified file
  52040. */
  52041. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52042. /**
  52043. * Transform the url before loading if required.
  52044. * @param rootUrl the url of the texture
  52045. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52046. * @returns the transformed texture
  52047. */
  52048. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52049. /**
  52050. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52051. * @param rootUrl the url of the texture
  52052. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52053. * @returns the fallback texture
  52054. */
  52055. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52056. /**
  52057. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52058. * @param data contains the texture data
  52059. * @param texture defines the BabylonJS internal texture
  52060. * @param createPolynomials will be true if polynomials have been requested
  52061. * @param onLoad defines the callback to trigger once the texture is ready
  52062. * @param onError defines the callback to trigger in case of error
  52063. */
  52064. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52065. /**
  52066. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52067. * @param data contains the texture data
  52068. * @param texture defines the BabylonJS internal texture
  52069. * @param callback defines the method to call once ready to upload
  52070. */
  52071. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  52072. }
  52073. }
  52074. declare module BABYLON {
  52075. /**
  52076. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52077. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52078. */
  52079. export class KhronosTextureContainer {
  52080. /** contents of the KTX container file */
  52081. data: ArrayBufferView;
  52082. private static HEADER_LEN;
  52083. private static COMPRESSED_2D;
  52084. private static COMPRESSED_3D;
  52085. private static TEX_2D;
  52086. private static TEX_3D;
  52087. /**
  52088. * Gets the openGL type
  52089. */
  52090. glType: number;
  52091. /**
  52092. * Gets the openGL type size
  52093. */
  52094. glTypeSize: number;
  52095. /**
  52096. * Gets the openGL format
  52097. */
  52098. glFormat: number;
  52099. /**
  52100. * Gets the openGL internal format
  52101. */
  52102. glInternalFormat: number;
  52103. /**
  52104. * Gets the base internal format
  52105. */
  52106. glBaseInternalFormat: number;
  52107. /**
  52108. * Gets image width in pixel
  52109. */
  52110. pixelWidth: number;
  52111. /**
  52112. * Gets image height in pixel
  52113. */
  52114. pixelHeight: number;
  52115. /**
  52116. * Gets image depth in pixels
  52117. */
  52118. pixelDepth: number;
  52119. /**
  52120. * Gets the number of array elements
  52121. */
  52122. numberOfArrayElements: number;
  52123. /**
  52124. * Gets the number of faces
  52125. */
  52126. numberOfFaces: number;
  52127. /**
  52128. * Gets the number of mipmap levels
  52129. */
  52130. numberOfMipmapLevels: number;
  52131. /**
  52132. * Gets the bytes of key value data
  52133. */
  52134. bytesOfKeyValueData: number;
  52135. /**
  52136. * Gets the load type
  52137. */
  52138. loadType: number;
  52139. /**
  52140. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  52141. */
  52142. isInvalid: boolean;
  52143. /**
  52144. * Creates a new KhronosTextureContainer
  52145. * @param data contents of the KTX container file
  52146. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  52147. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  52148. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  52149. */
  52150. constructor(
  52151. /** contents of the KTX container file */
  52152. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  52153. /**
  52154. * Uploads KTX content to a Babylon Texture.
  52155. * It is assumed that the texture has already been created & is currently bound
  52156. * @hidden
  52157. */
  52158. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  52159. private _upload2DCompressedLevels;
  52160. }
  52161. }
  52162. declare module BABYLON {
  52163. /**
  52164. * Implementation of the KTX Texture Loader.
  52165. * @hidden
  52166. */
  52167. export class _KTXTextureLoader implements IInternalTextureLoader {
  52168. /**
  52169. * Defines wether the loader supports cascade loading the different faces.
  52170. */
  52171. readonly supportCascades: boolean;
  52172. /**
  52173. * This returns if the loader support the current file information.
  52174. * @param extension defines the file extension of the file being loaded
  52175. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52176. * @param fallback defines the fallback internal texture if any
  52177. * @param isBase64 defines whether the texture is encoded as a base64
  52178. * @param isBuffer defines whether the texture data are stored as a buffer
  52179. * @returns true if the loader can load the specified file
  52180. */
  52181. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  52182. /**
  52183. * Transform the url before loading if required.
  52184. * @param rootUrl the url of the texture
  52185. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52186. * @returns the transformed texture
  52187. */
  52188. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  52189. /**
  52190. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  52191. * @param rootUrl the url of the texture
  52192. * @param textureFormatInUse defines the current compressed format in use iun the engine
  52193. * @returns the fallback texture
  52194. */
  52195. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  52196. /**
  52197. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  52198. * @param data contains the texture data
  52199. * @param texture defines the BabylonJS internal texture
  52200. * @param createPolynomials will be true if polynomials have been requested
  52201. * @param onLoad defines the callback to trigger once the texture is ready
  52202. * @param onError defines the callback to trigger in case of error
  52203. */
  52204. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  52205. /**
  52206. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  52207. * @param data contains the texture data
  52208. * @param texture defines the BabylonJS internal texture
  52209. * @param callback defines the method to call once ready to upload
  52210. */
  52211. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  52212. }
  52213. }
  52214. declare module BABYLON {
  52215. /** @hidden */
  52216. export var _forceSceneHelpersToBundle: boolean;
  52217. interface Scene {
  52218. /**
  52219. * Creates a default light for the scene.
  52220. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  52221. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  52222. */
  52223. createDefaultLight(replace?: boolean): void;
  52224. /**
  52225. * Creates a default camera for the scene.
  52226. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  52227. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52228. * @param replace has default false, when true replaces the active camera in the scene
  52229. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  52230. */
  52231. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52232. /**
  52233. * Creates a default camera and a default light.
  52234. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  52235. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  52236. * @param replace has the default false, when true replaces the active camera/light in the scene
  52237. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  52238. */
  52239. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  52240. /**
  52241. * Creates a new sky box
  52242. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  52243. * @param environmentTexture defines the texture to use as environment texture
  52244. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  52245. * @param scale defines the overall scale of the skybox
  52246. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  52247. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  52248. * @returns a new mesh holding the sky box
  52249. */
  52250. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  52251. /**
  52252. * Creates a new environment
  52253. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  52254. * @param options defines the options you can use to configure the environment
  52255. * @returns the new EnvironmentHelper
  52256. */
  52257. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  52258. /**
  52259. * Creates a new VREXperienceHelper
  52260. * @see http://doc.babylonjs.com/how_to/webvr_helper
  52261. * @param webVROptions defines the options used to create the new VREXperienceHelper
  52262. * @returns a new VREXperienceHelper
  52263. */
  52264. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  52265. /**
  52266. * Creates a new WebXRDefaultExperience
  52267. * @see http://doc.babylonjs.com/how_to/webxr
  52268. * @param options experience options
  52269. * @returns a promise for a new WebXRDefaultExperience
  52270. */
  52271. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  52272. }
  52273. }
  52274. declare module BABYLON {
  52275. /**
  52276. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  52277. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  52278. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  52279. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  52280. */
  52281. export class VideoDome extends TransformNode {
  52282. /**
  52283. * Define the video source as a Monoscopic panoramic 360 video.
  52284. */
  52285. static readonly MODE_MONOSCOPIC: number;
  52286. /**
  52287. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52288. */
  52289. static readonly MODE_TOPBOTTOM: number;
  52290. /**
  52291. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52292. */
  52293. static readonly MODE_SIDEBYSIDE: number;
  52294. private _halfDome;
  52295. private _useDirectMapping;
  52296. /**
  52297. * The video texture being displayed on the sphere
  52298. */
  52299. protected _videoTexture: VideoTexture;
  52300. /**
  52301. * Gets the video texture being displayed on the sphere
  52302. */
  52303. get videoTexture(): VideoTexture;
  52304. /**
  52305. * The skybox material
  52306. */
  52307. protected _material: BackgroundMaterial;
  52308. /**
  52309. * The surface used for the skybox
  52310. */
  52311. protected _mesh: Mesh;
  52312. /**
  52313. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  52314. */
  52315. private _halfDomeMask;
  52316. /**
  52317. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52318. * Also see the options.resolution property.
  52319. */
  52320. get fovMultiplier(): number;
  52321. set fovMultiplier(value: number);
  52322. private _videoMode;
  52323. /**
  52324. * Gets or set the current video mode for the video. It can be:
  52325. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  52326. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  52327. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  52328. */
  52329. get videoMode(): number;
  52330. set videoMode(value: number);
  52331. /**
  52332. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  52333. *
  52334. */
  52335. get halfDome(): boolean;
  52336. /**
  52337. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  52338. */
  52339. set halfDome(enabled: boolean);
  52340. /**
  52341. * Oberserver used in Stereoscopic VR Mode.
  52342. */
  52343. private _onBeforeCameraRenderObserver;
  52344. /**
  52345. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  52346. * @param name Element's name, child elements will append suffixes for their own names.
  52347. * @param urlsOrVideo defines the url(s) or the video element to use
  52348. * @param options An object containing optional or exposed sub element properties
  52349. */
  52350. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  52351. resolution?: number;
  52352. clickToPlay?: boolean;
  52353. autoPlay?: boolean;
  52354. loop?: boolean;
  52355. size?: number;
  52356. poster?: string;
  52357. faceForward?: boolean;
  52358. useDirectMapping?: boolean;
  52359. halfDomeMode?: boolean;
  52360. }, scene: Scene);
  52361. private _changeVideoMode;
  52362. /**
  52363. * Releases resources associated with this node.
  52364. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  52365. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  52366. */
  52367. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  52368. }
  52369. }
  52370. declare module BABYLON {
  52371. /**
  52372. * This class can be used to get instrumentation data from a Babylon engine
  52373. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52374. */
  52375. export class EngineInstrumentation implements IDisposable {
  52376. /**
  52377. * Define the instrumented engine.
  52378. */
  52379. engine: Engine;
  52380. private _captureGPUFrameTime;
  52381. private _gpuFrameTimeToken;
  52382. private _gpuFrameTime;
  52383. private _captureShaderCompilationTime;
  52384. private _shaderCompilationTime;
  52385. private _onBeginFrameObserver;
  52386. private _onEndFrameObserver;
  52387. private _onBeforeShaderCompilationObserver;
  52388. private _onAfterShaderCompilationObserver;
  52389. /**
  52390. * Gets the perf counter used for GPU frame time
  52391. */
  52392. get gpuFrameTimeCounter(): PerfCounter;
  52393. /**
  52394. * Gets the GPU frame time capture status
  52395. */
  52396. get captureGPUFrameTime(): boolean;
  52397. /**
  52398. * Enable or disable the GPU frame time capture
  52399. */
  52400. set captureGPUFrameTime(value: boolean);
  52401. /**
  52402. * Gets the perf counter used for shader compilation time
  52403. */
  52404. get shaderCompilationTimeCounter(): PerfCounter;
  52405. /**
  52406. * Gets the shader compilation time capture status
  52407. */
  52408. get captureShaderCompilationTime(): boolean;
  52409. /**
  52410. * Enable or disable the shader compilation time capture
  52411. */
  52412. set captureShaderCompilationTime(value: boolean);
  52413. /**
  52414. * Instantiates a new engine instrumentation.
  52415. * This class can be used to get instrumentation data from a Babylon engine
  52416. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  52417. * @param engine Defines the engine to instrument
  52418. */
  52419. constructor(
  52420. /**
  52421. * Define the instrumented engine.
  52422. */
  52423. engine: Engine);
  52424. /**
  52425. * Dispose and release associated resources.
  52426. */
  52427. dispose(): void;
  52428. }
  52429. }
  52430. declare module BABYLON {
  52431. /**
  52432. * This class can be used to get instrumentation data from a Babylon engine
  52433. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52434. */
  52435. export class SceneInstrumentation implements IDisposable {
  52436. /**
  52437. * Defines the scene to instrument
  52438. */
  52439. scene: Scene;
  52440. private _captureActiveMeshesEvaluationTime;
  52441. private _activeMeshesEvaluationTime;
  52442. private _captureRenderTargetsRenderTime;
  52443. private _renderTargetsRenderTime;
  52444. private _captureFrameTime;
  52445. private _frameTime;
  52446. private _captureRenderTime;
  52447. private _renderTime;
  52448. private _captureInterFrameTime;
  52449. private _interFrameTime;
  52450. private _captureParticlesRenderTime;
  52451. private _particlesRenderTime;
  52452. private _captureSpritesRenderTime;
  52453. private _spritesRenderTime;
  52454. private _capturePhysicsTime;
  52455. private _physicsTime;
  52456. private _captureAnimationsTime;
  52457. private _animationsTime;
  52458. private _captureCameraRenderTime;
  52459. private _cameraRenderTime;
  52460. private _onBeforeActiveMeshesEvaluationObserver;
  52461. private _onAfterActiveMeshesEvaluationObserver;
  52462. private _onBeforeRenderTargetsRenderObserver;
  52463. private _onAfterRenderTargetsRenderObserver;
  52464. private _onAfterRenderObserver;
  52465. private _onBeforeDrawPhaseObserver;
  52466. private _onAfterDrawPhaseObserver;
  52467. private _onBeforeAnimationsObserver;
  52468. private _onBeforeParticlesRenderingObserver;
  52469. private _onAfterParticlesRenderingObserver;
  52470. private _onBeforeSpritesRenderingObserver;
  52471. private _onAfterSpritesRenderingObserver;
  52472. private _onBeforePhysicsObserver;
  52473. private _onAfterPhysicsObserver;
  52474. private _onAfterAnimationsObserver;
  52475. private _onBeforeCameraRenderObserver;
  52476. private _onAfterCameraRenderObserver;
  52477. /**
  52478. * Gets the perf counter used for active meshes evaluation time
  52479. */
  52480. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  52481. /**
  52482. * Gets the active meshes evaluation time capture status
  52483. */
  52484. get captureActiveMeshesEvaluationTime(): boolean;
  52485. /**
  52486. * Enable or disable the active meshes evaluation time capture
  52487. */
  52488. set captureActiveMeshesEvaluationTime(value: boolean);
  52489. /**
  52490. * Gets the perf counter used for render targets render time
  52491. */
  52492. get renderTargetsRenderTimeCounter(): PerfCounter;
  52493. /**
  52494. * Gets the render targets render time capture status
  52495. */
  52496. get captureRenderTargetsRenderTime(): boolean;
  52497. /**
  52498. * Enable or disable the render targets render time capture
  52499. */
  52500. set captureRenderTargetsRenderTime(value: boolean);
  52501. /**
  52502. * Gets the perf counter used for particles render time
  52503. */
  52504. get particlesRenderTimeCounter(): PerfCounter;
  52505. /**
  52506. * Gets the particles render time capture status
  52507. */
  52508. get captureParticlesRenderTime(): boolean;
  52509. /**
  52510. * Enable or disable the particles render time capture
  52511. */
  52512. set captureParticlesRenderTime(value: boolean);
  52513. /**
  52514. * Gets the perf counter used for sprites render time
  52515. */
  52516. get spritesRenderTimeCounter(): PerfCounter;
  52517. /**
  52518. * Gets the sprites render time capture status
  52519. */
  52520. get captureSpritesRenderTime(): boolean;
  52521. /**
  52522. * Enable or disable the sprites render time capture
  52523. */
  52524. set captureSpritesRenderTime(value: boolean);
  52525. /**
  52526. * Gets the perf counter used for physics time
  52527. */
  52528. get physicsTimeCounter(): PerfCounter;
  52529. /**
  52530. * Gets the physics time capture status
  52531. */
  52532. get capturePhysicsTime(): boolean;
  52533. /**
  52534. * Enable or disable the physics time capture
  52535. */
  52536. set capturePhysicsTime(value: boolean);
  52537. /**
  52538. * Gets the perf counter used for animations time
  52539. */
  52540. get animationsTimeCounter(): PerfCounter;
  52541. /**
  52542. * Gets the animations time capture status
  52543. */
  52544. get captureAnimationsTime(): boolean;
  52545. /**
  52546. * Enable or disable the animations time capture
  52547. */
  52548. set captureAnimationsTime(value: boolean);
  52549. /**
  52550. * Gets the perf counter used for frame time capture
  52551. */
  52552. get frameTimeCounter(): PerfCounter;
  52553. /**
  52554. * Gets the frame time capture status
  52555. */
  52556. get captureFrameTime(): boolean;
  52557. /**
  52558. * Enable or disable the frame time capture
  52559. */
  52560. set captureFrameTime(value: boolean);
  52561. /**
  52562. * Gets the perf counter used for inter-frames time capture
  52563. */
  52564. get interFrameTimeCounter(): PerfCounter;
  52565. /**
  52566. * Gets the inter-frames time capture status
  52567. */
  52568. get captureInterFrameTime(): boolean;
  52569. /**
  52570. * Enable or disable the inter-frames time capture
  52571. */
  52572. set captureInterFrameTime(value: boolean);
  52573. /**
  52574. * Gets the perf counter used for render time capture
  52575. */
  52576. get renderTimeCounter(): PerfCounter;
  52577. /**
  52578. * Gets the render time capture status
  52579. */
  52580. get captureRenderTime(): boolean;
  52581. /**
  52582. * Enable or disable the render time capture
  52583. */
  52584. set captureRenderTime(value: boolean);
  52585. /**
  52586. * Gets the perf counter used for camera render time capture
  52587. */
  52588. get cameraRenderTimeCounter(): PerfCounter;
  52589. /**
  52590. * Gets the camera render time capture status
  52591. */
  52592. get captureCameraRenderTime(): boolean;
  52593. /**
  52594. * Enable or disable the camera render time capture
  52595. */
  52596. set captureCameraRenderTime(value: boolean);
  52597. /**
  52598. * Gets the perf counter used for draw calls
  52599. */
  52600. get drawCallsCounter(): PerfCounter;
  52601. /**
  52602. * Instantiates a new scene instrumentation.
  52603. * This class can be used to get instrumentation data from a Babylon engine
  52604. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  52605. * @param scene Defines the scene to instrument
  52606. */
  52607. constructor(
  52608. /**
  52609. * Defines the scene to instrument
  52610. */
  52611. scene: Scene);
  52612. /**
  52613. * Dispose and release associated resources.
  52614. */
  52615. dispose(): void;
  52616. }
  52617. }
  52618. declare module BABYLON {
  52619. /** @hidden */
  52620. export var glowMapGenerationPixelShader: {
  52621. name: string;
  52622. shader: string;
  52623. };
  52624. }
  52625. declare module BABYLON {
  52626. /** @hidden */
  52627. export var glowMapGenerationVertexShader: {
  52628. name: string;
  52629. shader: string;
  52630. };
  52631. }
  52632. declare module BABYLON {
  52633. /**
  52634. * Effect layer options. This helps customizing the behaviour
  52635. * of the effect layer.
  52636. */
  52637. export interface IEffectLayerOptions {
  52638. /**
  52639. * Multiplication factor apply to the canvas size to compute the render target size
  52640. * used to generated the objects (the smaller the faster).
  52641. */
  52642. mainTextureRatio: number;
  52643. /**
  52644. * Enforces a fixed size texture to ensure effect stability across devices.
  52645. */
  52646. mainTextureFixedSize?: number;
  52647. /**
  52648. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  52649. */
  52650. alphaBlendingMode: number;
  52651. /**
  52652. * The camera attached to the layer.
  52653. */
  52654. camera: Nullable<Camera>;
  52655. /**
  52656. * The rendering group to draw the layer in.
  52657. */
  52658. renderingGroupId: number;
  52659. }
  52660. /**
  52661. * The effect layer Helps adding post process effect blended with the main pass.
  52662. *
  52663. * This can be for instance use to generate glow or higlight effects on the scene.
  52664. *
  52665. * The effect layer class can not be used directly and is intented to inherited from to be
  52666. * customized per effects.
  52667. */
  52668. export abstract class EffectLayer {
  52669. private _vertexBuffers;
  52670. private _indexBuffer;
  52671. private _cachedDefines;
  52672. private _effectLayerMapGenerationEffect;
  52673. private _effectLayerOptions;
  52674. private _mergeEffect;
  52675. protected _scene: Scene;
  52676. protected _engine: Engine;
  52677. protected _maxSize: number;
  52678. protected _mainTextureDesiredSize: ISize;
  52679. protected _mainTexture: RenderTargetTexture;
  52680. protected _shouldRender: boolean;
  52681. protected _postProcesses: PostProcess[];
  52682. protected _textures: BaseTexture[];
  52683. protected _emissiveTextureAndColor: {
  52684. texture: Nullable<BaseTexture>;
  52685. color: Color4;
  52686. };
  52687. /**
  52688. * The name of the layer
  52689. */
  52690. name: string;
  52691. /**
  52692. * The clear color of the texture used to generate the glow map.
  52693. */
  52694. neutralColor: Color4;
  52695. /**
  52696. * Specifies whether the highlight layer is enabled or not.
  52697. */
  52698. isEnabled: boolean;
  52699. /**
  52700. * Gets the camera attached to the layer.
  52701. */
  52702. get camera(): Nullable<Camera>;
  52703. /**
  52704. * Gets the rendering group id the layer should render in.
  52705. */
  52706. get renderingGroupId(): number;
  52707. set renderingGroupId(renderingGroupId: number);
  52708. /**
  52709. * An event triggered when the effect layer has been disposed.
  52710. */
  52711. onDisposeObservable: Observable<EffectLayer>;
  52712. /**
  52713. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  52714. */
  52715. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  52716. /**
  52717. * An event triggered when the generated texture is being merged in the scene.
  52718. */
  52719. onBeforeComposeObservable: Observable<EffectLayer>;
  52720. /**
  52721. * An event triggered when the mesh is rendered into the effect render target.
  52722. */
  52723. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  52724. /**
  52725. * An event triggered after the mesh has been rendered into the effect render target.
  52726. */
  52727. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  52728. /**
  52729. * An event triggered when the generated texture has been merged in the scene.
  52730. */
  52731. onAfterComposeObservable: Observable<EffectLayer>;
  52732. /**
  52733. * An event triggered when the efffect layer changes its size.
  52734. */
  52735. onSizeChangedObservable: Observable<EffectLayer>;
  52736. /** @hidden */
  52737. static _SceneComponentInitialization: (scene: Scene) => void;
  52738. /**
  52739. * Instantiates a new effect Layer and references it in the scene.
  52740. * @param name The name of the layer
  52741. * @param scene The scene to use the layer in
  52742. */
  52743. constructor(
  52744. /** The Friendly of the effect in the scene */
  52745. name: string, scene: Scene);
  52746. /**
  52747. * Get the effect name of the layer.
  52748. * @return The effect name
  52749. */
  52750. abstract getEffectName(): string;
  52751. /**
  52752. * Checks for the readiness of the element composing the layer.
  52753. * @param subMesh the mesh to check for
  52754. * @param useInstances specify whether or not to use instances to render the mesh
  52755. * @return true if ready otherwise, false
  52756. */
  52757. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52758. /**
  52759. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  52760. * @returns true if the effect requires stencil during the main canvas render pass.
  52761. */
  52762. abstract needStencil(): boolean;
  52763. /**
  52764. * Create the merge effect. This is the shader use to blit the information back
  52765. * to the main canvas at the end of the scene rendering.
  52766. * @returns The effect containing the shader used to merge the effect on the main canvas
  52767. */
  52768. protected abstract _createMergeEffect(): Effect;
  52769. /**
  52770. * Creates the render target textures and post processes used in the effect layer.
  52771. */
  52772. protected abstract _createTextureAndPostProcesses(): void;
  52773. /**
  52774. * Implementation specific of rendering the generating effect on the main canvas.
  52775. * @param effect The effect used to render through
  52776. */
  52777. protected abstract _internalRender(effect: Effect): void;
  52778. /**
  52779. * Sets the required values for both the emissive texture and and the main color.
  52780. */
  52781. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52782. /**
  52783. * Free any resources and references associated to a mesh.
  52784. * Internal use
  52785. * @param mesh The mesh to free.
  52786. */
  52787. abstract _disposeMesh(mesh: Mesh): void;
  52788. /**
  52789. * Serializes this layer (Glow or Highlight for example)
  52790. * @returns a serialized layer object
  52791. */
  52792. abstract serialize?(): any;
  52793. /**
  52794. * Initializes the effect layer with the required options.
  52795. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  52796. */
  52797. protected _init(options: Partial<IEffectLayerOptions>): void;
  52798. /**
  52799. * Generates the index buffer of the full screen quad blending to the main canvas.
  52800. */
  52801. private _generateIndexBuffer;
  52802. /**
  52803. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  52804. */
  52805. private _generateVertexBuffer;
  52806. /**
  52807. * Sets the main texture desired size which is the closest power of two
  52808. * of the engine canvas size.
  52809. */
  52810. private _setMainTextureSize;
  52811. /**
  52812. * Creates the main texture for the effect layer.
  52813. */
  52814. protected _createMainTexture(): void;
  52815. /**
  52816. * Adds specific effects defines.
  52817. * @param defines The defines to add specifics to.
  52818. */
  52819. protected _addCustomEffectDefines(defines: string[]): void;
  52820. /**
  52821. * Checks for the readiness of the element composing the layer.
  52822. * @param subMesh the mesh to check for
  52823. * @param useInstances specify whether or not to use instances to render the mesh
  52824. * @param emissiveTexture the associated emissive texture used to generate the glow
  52825. * @return true if ready otherwise, false
  52826. */
  52827. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  52828. /**
  52829. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  52830. */
  52831. render(): void;
  52832. /**
  52833. * Determine if a given mesh will be used in the current effect.
  52834. * @param mesh mesh to test
  52835. * @returns true if the mesh will be used
  52836. */
  52837. hasMesh(mesh: AbstractMesh): boolean;
  52838. /**
  52839. * Returns true if the layer contains information to display, otherwise false.
  52840. * @returns true if the glow layer should be rendered
  52841. */
  52842. shouldRender(): boolean;
  52843. /**
  52844. * Returns true if the mesh should render, otherwise false.
  52845. * @param mesh The mesh to render
  52846. * @returns true if it should render otherwise false
  52847. */
  52848. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  52849. /**
  52850. * Returns true if the mesh can be rendered, otherwise false.
  52851. * @param mesh The mesh to render
  52852. * @param material The material used on the mesh
  52853. * @returns true if it can be rendered otherwise false
  52854. */
  52855. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  52856. /**
  52857. * Returns true if the mesh should render, otherwise false.
  52858. * @param mesh The mesh to render
  52859. * @returns true if it should render otherwise false
  52860. */
  52861. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  52862. /**
  52863. * Renders the submesh passed in parameter to the generation map.
  52864. */
  52865. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  52866. /**
  52867. * Defines whether the current material of the mesh should be use to render the effect.
  52868. * @param mesh defines the current mesh to render
  52869. */
  52870. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  52871. /**
  52872. * Rebuild the required buffers.
  52873. * @hidden Internal use only.
  52874. */
  52875. _rebuild(): void;
  52876. /**
  52877. * Dispose only the render target textures and post process.
  52878. */
  52879. private _disposeTextureAndPostProcesses;
  52880. /**
  52881. * Dispose the highlight layer and free resources.
  52882. */
  52883. dispose(): void;
  52884. /**
  52885. * Gets the class name of the effect layer
  52886. * @returns the string with the class name of the effect layer
  52887. */
  52888. getClassName(): string;
  52889. /**
  52890. * Creates an effect layer from parsed effect layer data
  52891. * @param parsedEffectLayer defines effect layer data
  52892. * @param scene defines the current scene
  52893. * @param rootUrl defines the root URL containing the effect layer information
  52894. * @returns a parsed effect Layer
  52895. */
  52896. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  52897. }
  52898. }
  52899. declare module BABYLON {
  52900. interface AbstractScene {
  52901. /**
  52902. * The list of effect layers (highlights/glow) added to the scene
  52903. * @see http://doc.babylonjs.com/how_to/highlight_layer
  52904. * @see http://doc.babylonjs.com/how_to/glow_layer
  52905. */
  52906. effectLayers: Array<EffectLayer>;
  52907. /**
  52908. * Removes the given effect layer from this scene.
  52909. * @param toRemove defines the effect layer to remove
  52910. * @returns the index of the removed effect layer
  52911. */
  52912. removeEffectLayer(toRemove: EffectLayer): number;
  52913. /**
  52914. * Adds the given effect layer to this scene
  52915. * @param newEffectLayer defines the effect layer to add
  52916. */
  52917. addEffectLayer(newEffectLayer: EffectLayer): void;
  52918. }
  52919. /**
  52920. * Defines the layer scene component responsible to manage any effect layers
  52921. * in a given scene.
  52922. */
  52923. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  52924. /**
  52925. * The component name helpfull to identify the component in the list of scene components.
  52926. */
  52927. readonly name: string;
  52928. /**
  52929. * The scene the component belongs to.
  52930. */
  52931. scene: Scene;
  52932. private _engine;
  52933. private _renderEffects;
  52934. private _needStencil;
  52935. private _previousStencilState;
  52936. /**
  52937. * Creates a new instance of the component for the given scene
  52938. * @param scene Defines the scene to register the component in
  52939. */
  52940. constructor(scene: Scene);
  52941. /**
  52942. * Registers the component in a given scene
  52943. */
  52944. register(): void;
  52945. /**
  52946. * Rebuilds the elements related to this component in case of
  52947. * context lost for instance.
  52948. */
  52949. rebuild(): void;
  52950. /**
  52951. * Serializes the component data to the specified json object
  52952. * @param serializationObject The object to serialize to
  52953. */
  52954. serialize(serializationObject: any): void;
  52955. /**
  52956. * Adds all the elements from the container to the scene
  52957. * @param container the container holding the elements
  52958. */
  52959. addFromContainer(container: AbstractScene): void;
  52960. /**
  52961. * Removes all the elements in the container from the scene
  52962. * @param container contains the elements to remove
  52963. * @param dispose if the removed element should be disposed (default: false)
  52964. */
  52965. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52966. /**
  52967. * Disposes the component and the associated ressources.
  52968. */
  52969. dispose(): void;
  52970. private _isReadyForMesh;
  52971. private _renderMainTexture;
  52972. private _setStencil;
  52973. private _setStencilBack;
  52974. private _draw;
  52975. private _drawCamera;
  52976. private _drawRenderingGroup;
  52977. }
  52978. }
  52979. declare module BABYLON {
  52980. /** @hidden */
  52981. export var glowMapMergePixelShader: {
  52982. name: string;
  52983. shader: string;
  52984. };
  52985. }
  52986. declare module BABYLON {
  52987. /** @hidden */
  52988. export var glowMapMergeVertexShader: {
  52989. name: string;
  52990. shader: string;
  52991. };
  52992. }
  52993. declare module BABYLON {
  52994. interface AbstractScene {
  52995. /**
  52996. * Return a the first highlight layer of the scene with a given name.
  52997. * @param name The name of the highlight layer to look for.
  52998. * @return The highlight layer if found otherwise null.
  52999. */
  53000. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  53001. }
  53002. /**
  53003. * Glow layer options. This helps customizing the behaviour
  53004. * of the glow layer.
  53005. */
  53006. export interface IGlowLayerOptions {
  53007. /**
  53008. * Multiplication factor apply to the canvas size to compute the render target size
  53009. * used to generated the glowing objects (the smaller the faster).
  53010. */
  53011. mainTextureRatio: number;
  53012. /**
  53013. * Enforces a fixed size texture to ensure resize independant blur.
  53014. */
  53015. mainTextureFixedSize?: number;
  53016. /**
  53017. * How big is the kernel of the blur texture.
  53018. */
  53019. blurKernelSize: number;
  53020. /**
  53021. * The camera attached to the layer.
  53022. */
  53023. camera: Nullable<Camera>;
  53024. /**
  53025. * Enable MSAA by chosing the number of samples.
  53026. */
  53027. mainTextureSamples?: number;
  53028. /**
  53029. * The rendering group to draw the layer in.
  53030. */
  53031. renderingGroupId: number;
  53032. }
  53033. /**
  53034. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  53035. *
  53036. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  53037. *
  53038. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  53039. */
  53040. export class GlowLayer extends EffectLayer {
  53041. /**
  53042. * Effect Name of the layer.
  53043. */
  53044. static readonly EffectName: string;
  53045. /**
  53046. * The default blur kernel size used for the glow.
  53047. */
  53048. static DefaultBlurKernelSize: number;
  53049. /**
  53050. * The default texture size ratio used for the glow.
  53051. */
  53052. static DefaultTextureRatio: number;
  53053. /**
  53054. * Sets the kernel size of the blur.
  53055. */
  53056. set blurKernelSize(value: number);
  53057. /**
  53058. * Gets the kernel size of the blur.
  53059. */
  53060. get blurKernelSize(): number;
  53061. /**
  53062. * Sets the glow intensity.
  53063. */
  53064. set intensity(value: number);
  53065. /**
  53066. * Gets the glow intensity.
  53067. */
  53068. get intensity(): number;
  53069. private _options;
  53070. private _intensity;
  53071. private _horizontalBlurPostprocess1;
  53072. private _verticalBlurPostprocess1;
  53073. private _horizontalBlurPostprocess2;
  53074. private _verticalBlurPostprocess2;
  53075. private _blurTexture1;
  53076. private _blurTexture2;
  53077. private _postProcesses1;
  53078. private _postProcesses2;
  53079. private _includedOnlyMeshes;
  53080. private _excludedMeshes;
  53081. private _meshesUsingTheirOwnMaterials;
  53082. /**
  53083. * Callback used to let the user override the color selection on a per mesh basis
  53084. */
  53085. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  53086. /**
  53087. * Callback used to let the user override the texture selection on a per mesh basis
  53088. */
  53089. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  53090. /**
  53091. * Instantiates a new glow Layer and references it to the scene.
  53092. * @param name The name of the layer
  53093. * @param scene The scene to use the layer in
  53094. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  53095. */
  53096. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  53097. /**
  53098. * Get the effect name of the layer.
  53099. * @return The effect name
  53100. */
  53101. getEffectName(): string;
  53102. /**
  53103. * Create the merge effect. This is the shader use to blit the information back
  53104. * to the main canvas at the end of the scene rendering.
  53105. */
  53106. protected _createMergeEffect(): Effect;
  53107. /**
  53108. * Creates the render target textures and post processes used in the glow layer.
  53109. */
  53110. protected _createTextureAndPostProcesses(): void;
  53111. /**
  53112. * Checks for the readiness of the element composing the layer.
  53113. * @param subMesh the mesh to check for
  53114. * @param useInstances specify wether or not to use instances to render the mesh
  53115. * @param emissiveTexture the associated emissive texture used to generate the glow
  53116. * @return true if ready otherwise, false
  53117. */
  53118. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53119. /**
  53120. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  53121. */
  53122. needStencil(): boolean;
  53123. /**
  53124. * Returns true if the mesh can be rendered, otherwise false.
  53125. * @param mesh The mesh to render
  53126. * @param material The material used on the mesh
  53127. * @returns true if it can be rendered otherwise false
  53128. */
  53129. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  53130. /**
  53131. * Implementation specific of rendering the generating effect on the main canvas.
  53132. * @param effect The effect used to render through
  53133. */
  53134. protected _internalRender(effect: Effect): void;
  53135. /**
  53136. * Sets the required values for both the emissive texture and and the main color.
  53137. */
  53138. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53139. /**
  53140. * Returns true if the mesh should render, otherwise false.
  53141. * @param mesh The mesh to render
  53142. * @returns true if it should render otherwise false
  53143. */
  53144. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53145. /**
  53146. * Adds specific effects defines.
  53147. * @param defines The defines to add specifics to.
  53148. */
  53149. protected _addCustomEffectDefines(defines: string[]): void;
  53150. /**
  53151. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  53152. * @param mesh The mesh to exclude from the glow layer
  53153. */
  53154. addExcludedMesh(mesh: Mesh): void;
  53155. /**
  53156. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  53157. * @param mesh The mesh to remove
  53158. */
  53159. removeExcludedMesh(mesh: Mesh): void;
  53160. /**
  53161. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  53162. * @param mesh The mesh to include in the glow layer
  53163. */
  53164. addIncludedOnlyMesh(mesh: Mesh): void;
  53165. /**
  53166. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  53167. * @param mesh The mesh to remove
  53168. */
  53169. removeIncludedOnlyMesh(mesh: Mesh): void;
  53170. /**
  53171. * Determine if a given mesh will be used in the glow layer
  53172. * @param mesh The mesh to test
  53173. * @returns true if the mesh will be highlighted by the current glow layer
  53174. */
  53175. hasMesh(mesh: AbstractMesh): boolean;
  53176. /**
  53177. * Defines whether the current material of the mesh should be use to render the effect.
  53178. * @param mesh defines the current mesh to render
  53179. */
  53180. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  53181. /**
  53182. * Add a mesh to be rendered through its own material and not with emissive only.
  53183. * @param mesh The mesh for which we need to use its material
  53184. */
  53185. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  53186. /**
  53187. * Remove a mesh from being rendered through its own material and not with emissive only.
  53188. * @param mesh The mesh for which we need to not use its material
  53189. */
  53190. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  53191. /**
  53192. * Free any resources and references associated to a mesh.
  53193. * Internal use
  53194. * @param mesh The mesh to free.
  53195. * @hidden
  53196. */
  53197. _disposeMesh(mesh: Mesh): void;
  53198. /**
  53199. * Gets the class name of the effect layer
  53200. * @returns the string with the class name of the effect layer
  53201. */
  53202. getClassName(): string;
  53203. /**
  53204. * Serializes this glow layer
  53205. * @returns a serialized glow layer object
  53206. */
  53207. serialize(): any;
  53208. /**
  53209. * Creates a Glow Layer from parsed glow layer data
  53210. * @param parsedGlowLayer defines glow layer data
  53211. * @param scene defines the current scene
  53212. * @param rootUrl defines the root URL containing the glow layer information
  53213. * @returns a parsed Glow Layer
  53214. */
  53215. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  53216. }
  53217. }
  53218. declare module BABYLON {
  53219. /** @hidden */
  53220. export var glowBlurPostProcessPixelShader: {
  53221. name: string;
  53222. shader: string;
  53223. };
  53224. }
  53225. declare module BABYLON {
  53226. interface AbstractScene {
  53227. /**
  53228. * Return a the first highlight layer of the scene with a given name.
  53229. * @param name The name of the highlight layer to look for.
  53230. * @return The highlight layer if found otherwise null.
  53231. */
  53232. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  53233. }
  53234. /**
  53235. * Highlight layer options. This helps customizing the behaviour
  53236. * of the highlight layer.
  53237. */
  53238. export interface IHighlightLayerOptions {
  53239. /**
  53240. * Multiplication factor apply to the canvas size to compute the render target size
  53241. * used to generated the glowing objects (the smaller the faster).
  53242. */
  53243. mainTextureRatio: number;
  53244. /**
  53245. * Enforces a fixed size texture to ensure resize independant blur.
  53246. */
  53247. mainTextureFixedSize?: number;
  53248. /**
  53249. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  53250. * of the picture to blur (the smaller the faster).
  53251. */
  53252. blurTextureSizeRatio: number;
  53253. /**
  53254. * How big in texel of the blur texture is the vertical blur.
  53255. */
  53256. blurVerticalSize: number;
  53257. /**
  53258. * How big in texel of the blur texture is the horizontal blur.
  53259. */
  53260. blurHorizontalSize: number;
  53261. /**
  53262. * Alpha blending mode used to apply the blur. Default is combine.
  53263. */
  53264. alphaBlendingMode: number;
  53265. /**
  53266. * The camera attached to the layer.
  53267. */
  53268. camera: Nullable<Camera>;
  53269. /**
  53270. * Should we display highlight as a solid stroke?
  53271. */
  53272. isStroke?: boolean;
  53273. /**
  53274. * The rendering group to draw the layer in.
  53275. */
  53276. renderingGroupId: number;
  53277. }
  53278. /**
  53279. * The highlight layer Helps adding a glow effect around a mesh.
  53280. *
  53281. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  53282. * glowy meshes to your scene.
  53283. *
  53284. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  53285. */
  53286. export class HighlightLayer extends EffectLayer {
  53287. name: string;
  53288. /**
  53289. * Effect Name of the highlight layer.
  53290. */
  53291. static readonly EffectName: string;
  53292. /**
  53293. * The neutral color used during the preparation of the glow effect.
  53294. * This is black by default as the blend operation is a blend operation.
  53295. */
  53296. static NeutralColor: Color4;
  53297. /**
  53298. * Stencil value used for glowing meshes.
  53299. */
  53300. static GlowingMeshStencilReference: number;
  53301. /**
  53302. * Stencil value used for the other meshes in the scene.
  53303. */
  53304. static NormalMeshStencilReference: number;
  53305. /**
  53306. * Specifies whether or not the inner glow is ACTIVE in the layer.
  53307. */
  53308. innerGlow: boolean;
  53309. /**
  53310. * Specifies whether or not the outer glow is ACTIVE in the layer.
  53311. */
  53312. outerGlow: boolean;
  53313. /**
  53314. * Specifies the horizontal size of the blur.
  53315. */
  53316. set blurHorizontalSize(value: number);
  53317. /**
  53318. * Specifies the vertical size of the blur.
  53319. */
  53320. set blurVerticalSize(value: number);
  53321. /**
  53322. * Gets the horizontal size of the blur.
  53323. */
  53324. get blurHorizontalSize(): number;
  53325. /**
  53326. * Gets the vertical size of the blur.
  53327. */
  53328. get blurVerticalSize(): number;
  53329. /**
  53330. * An event triggered when the highlight layer is being blurred.
  53331. */
  53332. onBeforeBlurObservable: Observable<HighlightLayer>;
  53333. /**
  53334. * An event triggered when the highlight layer has been blurred.
  53335. */
  53336. onAfterBlurObservable: Observable<HighlightLayer>;
  53337. private _instanceGlowingMeshStencilReference;
  53338. private _options;
  53339. private _downSamplePostprocess;
  53340. private _horizontalBlurPostprocess;
  53341. private _verticalBlurPostprocess;
  53342. private _blurTexture;
  53343. private _meshes;
  53344. private _excludedMeshes;
  53345. /**
  53346. * Instantiates a new highlight Layer and references it to the scene..
  53347. * @param name The name of the layer
  53348. * @param scene The scene to use the layer in
  53349. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  53350. */
  53351. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  53352. /**
  53353. * Get the effect name of the layer.
  53354. * @return The effect name
  53355. */
  53356. getEffectName(): string;
  53357. /**
  53358. * Create the merge effect. This is the shader use to blit the information back
  53359. * to the main canvas at the end of the scene rendering.
  53360. */
  53361. protected _createMergeEffect(): Effect;
  53362. /**
  53363. * Creates the render target textures and post processes used in the highlight layer.
  53364. */
  53365. protected _createTextureAndPostProcesses(): void;
  53366. /**
  53367. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  53368. */
  53369. needStencil(): boolean;
  53370. /**
  53371. * Checks for the readiness of the element composing the layer.
  53372. * @param subMesh the mesh to check for
  53373. * @param useInstances specify wether or not to use instances to render the mesh
  53374. * @param emissiveTexture the associated emissive texture used to generate the glow
  53375. * @return true if ready otherwise, false
  53376. */
  53377. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53378. /**
  53379. * Implementation specific of rendering the generating effect on the main canvas.
  53380. * @param effect The effect used to render through
  53381. */
  53382. protected _internalRender(effect: Effect): void;
  53383. /**
  53384. * Returns true if the layer contains information to display, otherwise false.
  53385. */
  53386. shouldRender(): boolean;
  53387. /**
  53388. * Returns true if the mesh should render, otherwise false.
  53389. * @param mesh The mesh to render
  53390. * @returns true if it should render otherwise false
  53391. */
  53392. protected _shouldRenderMesh(mesh: Mesh): boolean;
  53393. /**
  53394. * Sets the required values for both the emissive texture and and the main color.
  53395. */
  53396. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  53397. /**
  53398. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  53399. * @param mesh The mesh to exclude from the highlight layer
  53400. */
  53401. addExcludedMesh(mesh: Mesh): void;
  53402. /**
  53403. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  53404. * @param mesh The mesh to highlight
  53405. */
  53406. removeExcludedMesh(mesh: Mesh): void;
  53407. /**
  53408. * Determine if a given mesh will be highlighted by the current HighlightLayer
  53409. * @param mesh mesh to test
  53410. * @returns true if the mesh will be highlighted by the current HighlightLayer
  53411. */
  53412. hasMesh(mesh: AbstractMesh): boolean;
  53413. /**
  53414. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  53415. * @param mesh The mesh to highlight
  53416. * @param color The color of the highlight
  53417. * @param glowEmissiveOnly Extract the glow from the emissive texture
  53418. */
  53419. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  53420. /**
  53421. * Remove a mesh from the highlight layer in order to make it stop glowing.
  53422. * @param mesh The mesh to highlight
  53423. */
  53424. removeMesh(mesh: Mesh): void;
  53425. /**
  53426. * Force the stencil to the normal expected value for none glowing parts
  53427. */
  53428. private _defaultStencilReference;
  53429. /**
  53430. * Free any resources and references associated to a mesh.
  53431. * Internal use
  53432. * @param mesh The mesh to free.
  53433. * @hidden
  53434. */
  53435. _disposeMesh(mesh: Mesh): void;
  53436. /**
  53437. * Dispose the highlight layer and free resources.
  53438. */
  53439. dispose(): void;
  53440. /**
  53441. * Gets the class name of the effect layer
  53442. * @returns the string with the class name of the effect layer
  53443. */
  53444. getClassName(): string;
  53445. /**
  53446. * Serializes this Highlight layer
  53447. * @returns a serialized Highlight layer object
  53448. */
  53449. serialize(): any;
  53450. /**
  53451. * Creates a Highlight layer from parsed Highlight layer data
  53452. * @param parsedHightlightLayer defines the Highlight layer data
  53453. * @param scene defines the current scene
  53454. * @param rootUrl defines the root URL containing the Highlight layer information
  53455. * @returns a parsed Highlight layer
  53456. */
  53457. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  53458. }
  53459. }
  53460. declare module BABYLON {
  53461. interface AbstractScene {
  53462. /**
  53463. * The list of layers (background and foreground) of the scene
  53464. */
  53465. layers: Array<Layer>;
  53466. }
  53467. /**
  53468. * Defines the layer scene component responsible to manage any layers
  53469. * in a given scene.
  53470. */
  53471. export class LayerSceneComponent implements ISceneComponent {
  53472. /**
  53473. * The component name helpfull to identify the component in the list of scene components.
  53474. */
  53475. readonly name: string;
  53476. /**
  53477. * The scene the component belongs to.
  53478. */
  53479. scene: Scene;
  53480. private _engine;
  53481. /**
  53482. * Creates a new instance of the component for the given scene
  53483. * @param scene Defines the scene to register the component in
  53484. */
  53485. constructor(scene: Scene);
  53486. /**
  53487. * Registers the component in a given scene
  53488. */
  53489. register(): void;
  53490. /**
  53491. * Rebuilds the elements related to this component in case of
  53492. * context lost for instance.
  53493. */
  53494. rebuild(): void;
  53495. /**
  53496. * Disposes the component and the associated ressources.
  53497. */
  53498. dispose(): void;
  53499. private _draw;
  53500. private _drawCameraPredicate;
  53501. private _drawCameraBackground;
  53502. private _drawCameraForeground;
  53503. private _drawRenderTargetPredicate;
  53504. private _drawRenderTargetBackground;
  53505. private _drawRenderTargetForeground;
  53506. /**
  53507. * Adds all the elements from the container to the scene
  53508. * @param container the container holding the elements
  53509. */
  53510. addFromContainer(container: AbstractScene): void;
  53511. /**
  53512. * Removes all the elements in the container from the scene
  53513. * @param container contains the elements to remove
  53514. * @param dispose if the removed element should be disposed (default: false)
  53515. */
  53516. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53517. }
  53518. }
  53519. declare module BABYLON {
  53520. /** @hidden */
  53521. export var layerPixelShader: {
  53522. name: string;
  53523. shader: string;
  53524. };
  53525. }
  53526. declare module BABYLON {
  53527. /** @hidden */
  53528. export var layerVertexShader: {
  53529. name: string;
  53530. shader: string;
  53531. };
  53532. }
  53533. declare module BABYLON {
  53534. /**
  53535. * This represents a full screen 2d layer.
  53536. * This can be useful to display a picture in the background of your scene for instance.
  53537. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53538. */
  53539. export class Layer {
  53540. /**
  53541. * Define the name of the layer.
  53542. */
  53543. name: string;
  53544. /**
  53545. * Define the texture the layer should display.
  53546. */
  53547. texture: Nullable<Texture>;
  53548. /**
  53549. * Is the layer in background or foreground.
  53550. */
  53551. isBackground: boolean;
  53552. /**
  53553. * Define the color of the layer (instead of texture).
  53554. */
  53555. color: Color4;
  53556. /**
  53557. * Define the scale of the layer in order to zoom in out of the texture.
  53558. */
  53559. scale: Vector2;
  53560. /**
  53561. * Define an offset for the layer in order to shift the texture.
  53562. */
  53563. offset: Vector2;
  53564. /**
  53565. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  53566. */
  53567. alphaBlendingMode: number;
  53568. /**
  53569. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  53570. * Alpha test will not mix with the background color in case of transparency.
  53571. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  53572. */
  53573. alphaTest: boolean;
  53574. /**
  53575. * Define a mask to restrict the layer to only some of the scene cameras.
  53576. */
  53577. layerMask: number;
  53578. /**
  53579. * Define the list of render target the layer is visible into.
  53580. */
  53581. renderTargetTextures: RenderTargetTexture[];
  53582. /**
  53583. * Define if the layer is only used in renderTarget or if it also
  53584. * renders in the main frame buffer of the canvas.
  53585. */
  53586. renderOnlyInRenderTargetTextures: boolean;
  53587. private _scene;
  53588. private _vertexBuffers;
  53589. private _indexBuffer;
  53590. private _effect;
  53591. private _previousDefines;
  53592. /**
  53593. * An event triggered when the layer is disposed.
  53594. */
  53595. onDisposeObservable: Observable<Layer>;
  53596. private _onDisposeObserver;
  53597. /**
  53598. * Back compatibility with callback before the onDisposeObservable existed.
  53599. * The set callback will be triggered when the layer has been disposed.
  53600. */
  53601. set onDispose(callback: () => void);
  53602. /**
  53603. * An event triggered before rendering the scene
  53604. */
  53605. onBeforeRenderObservable: Observable<Layer>;
  53606. private _onBeforeRenderObserver;
  53607. /**
  53608. * Back compatibility with callback before the onBeforeRenderObservable existed.
  53609. * The set callback will be triggered just before rendering the layer.
  53610. */
  53611. set onBeforeRender(callback: () => void);
  53612. /**
  53613. * An event triggered after rendering the scene
  53614. */
  53615. onAfterRenderObservable: Observable<Layer>;
  53616. private _onAfterRenderObserver;
  53617. /**
  53618. * Back compatibility with callback before the onAfterRenderObservable existed.
  53619. * The set callback will be triggered just after rendering the layer.
  53620. */
  53621. set onAfterRender(callback: () => void);
  53622. /**
  53623. * Instantiates a new layer.
  53624. * This represents a full screen 2d layer.
  53625. * This can be useful to display a picture in the background of your scene for instance.
  53626. * @see https://www.babylonjs-playground.com/#08A2BS#1
  53627. * @param name Define the name of the layer in the scene
  53628. * @param imgUrl Define the url of the texture to display in the layer
  53629. * @param scene Define the scene the layer belongs to
  53630. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  53631. * @param color Defines a color for the layer
  53632. */
  53633. constructor(
  53634. /**
  53635. * Define the name of the layer.
  53636. */
  53637. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  53638. private _createIndexBuffer;
  53639. /** @hidden */
  53640. _rebuild(): void;
  53641. /**
  53642. * Renders the layer in the scene.
  53643. */
  53644. render(): void;
  53645. /**
  53646. * Disposes and releases the associated ressources.
  53647. */
  53648. dispose(): void;
  53649. }
  53650. }
  53651. declare module BABYLON {
  53652. /** @hidden */
  53653. export var lensFlarePixelShader: {
  53654. name: string;
  53655. shader: string;
  53656. };
  53657. }
  53658. declare module BABYLON {
  53659. /** @hidden */
  53660. export var lensFlareVertexShader: {
  53661. name: string;
  53662. shader: string;
  53663. };
  53664. }
  53665. declare module BABYLON {
  53666. /**
  53667. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53668. * It is usually composed of several `lensFlare`.
  53669. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53670. */
  53671. export class LensFlareSystem {
  53672. /**
  53673. * Define the name of the lens flare system
  53674. */
  53675. name: string;
  53676. /**
  53677. * List of lens flares used in this system.
  53678. */
  53679. lensFlares: LensFlare[];
  53680. /**
  53681. * Define a limit from the border the lens flare can be visible.
  53682. */
  53683. borderLimit: number;
  53684. /**
  53685. * Define a viewport border we do not want to see the lens flare in.
  53686. */
  53687. viewportBorder: number;
  53688. /**
  53689. * Define a predicate which could limit the list of meshes able to occlude the effect.
  53690. */
  53691. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  53692. /**
  53693. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  53694. */
  53695. layerMask: number;
  53696. /**
  53697. * Define the id of the lens flare system in the scene.
  53698. * (equal to name by default)
  53699. */
  53700. id: string;
  53701. private _scene;
  53702. private _emitter;
  53703. private _vertexBuffers;
  53704. private _indexBuffer;
  53705. private _effect;
  53706. private _positionX;
  53707. private _positionY;
  53708. private _isEnabled;
  53709. /** @hidden */
  53710. static _SceneComponentInitialization: (scene: Scene) => void;
  53711. /**
  53712. * Instantiates a lens flare system.
  53713. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  53714. * It is usually composed of several `lensFlare`.
  53715. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53716. * @param name Define the name of the lens flare system in the scene
  53717. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  53718. * @param scene Define the scene the lens flare system belongs to
  53719. */
  53720. constructor(
  53721. /**
  53722. * Define the name of the lens flare system
  53723. */
  53724. name: string, emitter: any, scene: Scene);
  53725. /**
  53726. * Define if the lens flare system is enabled.
  53727. */
  53728. get isEnabled(): boolean;
  53729. set isEnabled(value: boolean);
  53730. /**
  53731. * Get the scene the effects belongs to.
  53732. * @returns the scene holding the lens flare system
  53733. */
  53734. getScene(): Scene;
  53735. /**
  53736. * Get the emitter of the lens flare system.
  53737. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53738. * @returns the emitter of the lens flare system
  53739. */
  53740. getEmitter(): any;
  53741. /**
  53742. * Set the emitter of the lens flare system.
  53743. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  53744. * @param newEmitter Define the new emitter of the system
  53745. */
  53746. setEmitter(newEmitter: any): void;
  53747. /**
  53748. * Get the lens flare system emitter position.
  53749. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  53750. * @returns the position
  53751. */
  53752. getEmitterPosition(): Vector3;
  53753. /**
  53754. * @hidden
  53755. */
  53756. computeEffectivePosition(globalViewport: Viewport): boolean;
  53757. /** @hidden */
  53758. _isVisible(): boolean;
  53759. /**
  53760. * @hidden
  53761. */
  53762. render(): boolean;
  53763. /**
  53764. * Dispose and release the lens flare with its associated resources.
  53765. */
  53766. dispose(): void;
  53767. /**
  53768. * Parse a lens flare system from a JSON repressentation
  53769. * @param parsedLensFlareSystem Define the JSON to parse
  53770. * @param scene Define the scene the parsed system should be instantiated in
  53771. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  53772. * @returns the parsed system
  53773. */
  53774. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  53775. /**
  53776. * Serialize the current Lens Flare System into a JSON representation.
  53777. * @returns the serialized JSON
  53778. */
  53779. serialize(): any;
  53780. }
  53781. }
  53782. declare module BABYLON {
  53783. /**
  53784. * This represents one of the lens effect in a `lensFlareSystem`.
  53785. * It controls one of the indiviual texture used in the effect.
  53786. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53787. */
  53788. export class LensFlare {
  53789. /**
  53790. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53791. */
  53792. size: number;
  53793. /**
  53794. * 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.
  53795. */
  53796. position: number;
  53797. /**
  53798. * Define the lens color.
  53799. */
  53800. color: Color3;
  53801. /**
  53802. * Define the lens texture.
  53803. */
  53804. texture: Nullable<Texture>;
  53805. /**
  53806. * Define the alpha mode to render this particular lens.
  53807. */
  53808. alphaMode: number;
  53809. private _system;
  53810. /**
  53811. * Creates a new Lens Flare.
  53812. * This represents one of the lens effect in a `lensFlareSystem`.
  53813. * It controls one of the indiviual texture used in the effect.
  53814. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53815. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  53816. * @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.
  53817. * @param color Define the lens color
  53818. * @param imgUrl Define the lens texture url
  53819. * @param system Define the `lensFlareSystem` this flare is part of
  53820. * @returns The newly created Lens Flare
  53821. */
  53822. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  53823. /**
  53824. * Instantiates a new Lens Flare.
  53825. * This represents one of the lens effect in a `lensFlareSystem`.
  53826. * It controls one of the indiviual texture used in the effect.
  53827. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53828. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  53829. * @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.
  53830. * @param color Define the lens color
  53831. * @param imgUrl Define the lens texture url
  53832. * @param system Define the `lensFlareSystem` this flare is part of
  53833. */
  53834. constructor(
  53835. /**
  53836. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  53837. */
  53838. size: number,
  53839. /**
  53840. * 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.
  53841. */
  53842. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  53843. /**
  53844. * Dispose and release the lens flare with its associated resources.
  53845. */
  53846. dispose(): void;
  53847. }
  53848. }
  53849. declare module BABYLON {
  53850. interface AbstractScene {
  53851. /**
  53852. * The list of lens flare system added to the scene
  53853. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  53854. */
  53855. lensFlareSystems: Array<LensFlareSystem>;
  53856. /**
  53857. * Removes the given lens flare system from this scene.
  53858. * @param toRemove The lens flare system to remove
  53859. * @returns The index of the removed lens flare system
  53860. */
  53861. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  53862. /**
  53863. * Adds the given lens flare system to this scene
  53864. * @param newLensFlareSystem The lens flare system to add
  53865. */
  53866. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  53867. /**
  53868. * Gets a lens flare system using its name
  53869. * @param name defines the name to look for
  53870. * @returns the lens flare system or null if not found
  53871. */
  53872. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  53873. /**
  53874. * Gets a lens flare system using its id
  53875. * @param id defines the id to look for
  53876. * @returns the lens flare system or null if not found
  53877. */
  53878. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  53879. }
  53880. /**
  53881. * Defines the lens flare scene component responsible to manage any lens flares
  53882. * in a given scene.
  53883. */
  53884. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  53885. /**
  53886. * The component name helpfull to identify the component in the list of scene components.
  53887. */
  53888. readonly name: string;
  53889. /**
  53890. * The scene the component belongs to.
  53891. */
  53892. scene: Scene;
  53893. /**
  53894. * Creates a new instance of the component for the given scene
  53895. * @param scene Defines the scene to register the component in
  53896. */
  53897. constructor(scene: Scene);
  53898. /**
  53899. * Registers the component in a given scene
  53900. */
  53901. register(): void;
  53902. /**
  53903. * Rebuilds the elements related to this component in case of
  53904. * context lost for instance.
  53905. */
  53906. rebuild(): void;
  53907. /**
  53908. * Adds all the elements from the container to the scene
  53909. * @param container the container holding the elements
  53910. */
  53911. addFromContainer(container: AbstractScene): void;
  53912. /**
  53913. * Removes all the elements in the container from the scene
  53914. * @param container contains the elements to remove
  53915. * @param dispose if the removed element should be disposed (default: false)
  53916. */
  53917. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  53918. /**
  53919. * Serializes the component data to the specified json object
  53920. * @param serializationObject The object to serialize to
  53921. */
  53922. serialize(serializationObject: any): void;
  53923. /**
  53924. * Disposes the component and the associated ressources.
  53925. */
  53926. dispose(): void;
  53927. private _draw;
  53928. }
  53929. }
  53930. declare module BABYLON {
  53931. /** @hidden */
  53932. export var depthPixelShader: {
  53933. name: string;
  53934. shader: string;
  53935. };
  53936. }
  53937. declare module BABYLON {
  53938. /** @hidden */
  53939. export var depthVertexShader: {
  53940. name: string;
  53941. shader: string;
  53942. };
  53943. }
  53944. declare module BABYLON {
  53945. /**
  53946. * This represents a depth renderer in Babylon.
  53947. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  53948. */
  53949. export class DepthRenderer {
  53950. private _scene;
  53951. private _depthMap;
  53952. private _effect;
  53953. private readonly _storeNonLinearDepth;
  53954. private readonly _clearColor;
  53955. /** Get if the depth renderer is using packed depth or not */
  53956. readonly isPacked: boolean;
  53957. private _cachedDefines;
  53958. private _camera;
  53959. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  53960. enabled: boolean;
  53961. /**
  53962. * Specifiess that the depth renderer will only be used within
  53963. * the camera it is created for.
  53964. * This can help forcing its rendering during the camera processing.
  53965. */
  53966. useOnlyInActiveCamera: boolean;
  53967. /** @hidden */
  53968. static _SceneComponentInitialization: (scene: Scene) => void;
  53969. /**
  53970. * Instantiates a depth renderer
  53971. * @param scene The scene the renderer belongs to
  53972. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  53973. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  53974. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  53975. */
  53976. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  53977. /**
  53978. * Creates the depth rendering effect and checks if the effect is ready.
  53979. * @param subMesh The submesh to be used to render the depth map of
  53980. * @param useInstances If multiple world instances should be used
  53981. * @returns if the depth renderer is ready to render the depth map
  53982. */
  53983. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  53984. /**
  53985. * Gets the texture which the depth map will be written to.
  53986. * @returns The depth map texture
  53987. */
  53988. getDepthMap(): RenderTargetTexture;
  53989. /**
  53990. * Disposes of the depth renderer.
  53991. */
  53992. dispose(): void;
  53993. }
  53994. }
  53995. declare module BABYLON {
  53996. /** @hidden */
  53997. export var minmaxReduxPixelShader: {
  53998. name: string;
  53999. shader: string;
  54000. };
  54001. }
  54002. declare module BABYLON {
  54003. /**
  54004. * This class computes a min/max reduction from a texture: it means it computes the minimum
  54005. * and maximum values from all values of the texture.
  54006. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  54007. * The source values are read from the red channel of the texture.
  54008. */
  54009. export class MinMaxReducer {
  54010. /**
  54011. * Observable triggered when the computation has been performed
  54012. */
  54013. onAfterReductionPerformed: Observable<{
  54014. min: number;
  54015. max: number;
  54016. }>;
  54017. protected _camera: Camera;
  54018. protected _sourceTexture: Nullable<RenderTargetTexture>;
  54019. protected _reductionSteps: Nullable<Array<PostProcess>>;
  54020. protected _postProcessManager: PostProcessManager;
  54021. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  54022. protected _forceFullscreenViewport: boolean;
  54023. /**
  54024. * Creates a min/max reducer
  54025. * @param camera The camera to use for the post processes
  54026. */
  54027. constructor(camera: Camera);
  54028. /**
  54029. * Gets the texture used to read the values from.
  54030. */
  54031. get sourceTexture(): Nullable<RenderTargetTexture>;
  54032. /**
  54033. * Sets the source texture to read the values from.
  54034. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  54035. * because in such textures '1' value must not be taken into account to compute the maximum
  54036. * as this value is used to clear the texture.
  54037. * Note that the computation is not activated by calling this function, you must call activate() for that!
  54038. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  54039. * @param depthRedux Indicates if the texture is a depth texture or not
  54040. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  54041. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54042. */
  54043. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54044. /**
  54045. * Defines the refresh rate of the computation.
  54046. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54047. */
  54048. get refreshRate(): number;
  54049. set refreshRate(value: number);
  54050. protected _activated: boolean;
  54051. /**
  54052. * Gets the activation status of the reducer
  54053. */
  54054. get activated(): boolean;
  54055. /**
  54056. * Activates the reduction computation.
  54057. * When activated, the observers registered in onAfterReductionPerformed are
  54058. * called after the compuation is performed
  54059. */
  54060. activate(): void;
  54061. /**
  54062. * Deactivates the reduction computation.
  54063. */
  54064. deactivate(): void;
  54065. /**
  54066. * Disposes the min/max reducer
  54067. * @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.
  54068. */
  54069. dispose(disposeAll?: boolean): void;
  54070. }
  54071. }
  54072. declare module BABYLON {
  54073. /**
  54074. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  54075. */
  54076. export class DepthReducer extends MinMaxReducer {
  54077. private _depthRenderer;
  54078. private _depthRendererId;
  54079. /**
  54080. * Gets the depth renderer used for the computation.
  54081. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  54082. */
  54083. get depthRenderer(): Nullable<DepthRenderer>;
  54084. /**
  54085. * Creates a depth reducer
  54086. * @param camera The camera used to render the depth texture
  54087. */
  54088. constructor(camera: Camera);
  54089. /**
  54090. * Sets the depth renderer to use to generate the depth map
  54091. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  54092. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  54093. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  54094. */
  54095. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  54096. /** @hidden */
  54097. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  54098. /**
  54099. * Activates the reduction computation.
  54100. * When activated, the observers registered in onAfterReductionPerformed are
  54101. * called after the compuation is performed
  54102. */
  54103. activate(): void;
  54104. /**
  54105. * Deactivates the reduction computation.
  54106. */
  54107. deactivate(): void;
  54108. /**
  54109. * Disposes the depth reducer
  54110. * @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.
  54111. */
  54112. dispose(disposeAll?: boolean): void;
  54113. }
  54114. }
  54115. declare module BABYLON {
  54116. /**
  54117. * A CSM implementation allowing casting shadows on large scenes.
  54118. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54119. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  54120. */
  54121. export class CascadedShadowGenerator extends ShadowGenerator {
  54122. private static readonly frustumCornersNDCSpace;
  54123. /**
  54124. * Name of the CSM class
  54125. */
  54126. static CLASSNAME: string;
  54127. /**
  54128. * Defines the default number of cascades used by the CSM.
  54129. */
  54130. static readonly DEFAULT_CASCADES_COUNT: number;
  54131. /**
  54132. * Defines the minimum number of cascades used by the CSM.
  54133. */
  54134. static readonly MIN_CASCADES_COUNT: number;
  54135. /**
  54136. * Defines the maximum number of cascades used by the CSM.
  54137. */
  54138. static readonly MAX_CASCADES_COUNT: number;
  54139. protected _validateFilter(filter: number): number;
  54140. /**
  54141. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  54142. */
  54143. penumbraDarkness: number;
  54144. private _numCascades;
  54145. /**
  54146. * Gets or set the number of cascades used by the CSM.
  54147. */
  54148. get numCascades(): number;
  54149. set numCascades(value: number);
  54150. /**
  54151. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  54152. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  54153. */
  54154. stabilizeCascades: boolean;
  54155. private _freezeShadowCastersBoundingInfo;
  54156. private _freezeShadowCastersBoundingInfoObservable;
  54157. /**
  54158. * Enables or disables the shadow casters bounding info computation.
  54159. * If your shadow casters don't move, you can disable this feature.
  54160. * If it is enabled, the bounding box computation is done every frame.
  54161. */
  54162. get freezeShadowCastersBoundingInfo(): boolean;
  54163. set freezeShadowCastersBoundingInfo(freeze: boolean);
  54164. private _scbiMin;
  54165. private _scbiMax;
  54166. protected _computeShadowCastersBoundingInfo(): void;
  54167. protected _shadowCastersBoundingInfo: BoundingInfo;
  54168. /**
  54169. * Gets or sets the shadow casters bounding info.
  54170. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  54171. * so that the system won't overwrite the bounds you provide
  54172. */
  54173. get shadowCastersBoundingInfo(): BoundingInfo;
  54174. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  54175. protected _breaksAreDirty: boolean;
  54176. protected _minDistance: number;
  54177. protected _maxDistance: number;
  54178. /**
  54179. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  54180. *
  54181. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  54182. * If you don't know these values, simply leave them to their defaults and don't call this function.
  54183. * @param min minimal distance for the breaks (default to 0.)
  54184. * @param max maximal distance for the breaks (default to 1.)
  54185. */
  54186. setMinMaxDistance(min: number, max: number): void;
  54187. /** Gets the minimal distance used in the cascade break computation */
  54188. get minDistance(): number;
  54189. /** Gets the maximal distance used in the cascade break computation */
  54190. get maxDistance(): number;
  54191. /**
  54192. * Gets the class name of that object
  54193. * @returns "CascadedShadowGenerator"
  54194. */
  54195. getClassName(): string;
  54196. private _cascadeMinExtents;
  54197. private _cascadeMaxExtents;
  54198. /**
  54199. * Gets a cascade minimum extents
  54200. * @param cascadeIndex index of the cascade
  54201. * @returns the minimum cascade extents
  54202. */
  54203. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  54204. /**
  54205. * Gets a cascade maximum extents
  54206. * @param cascadeIndex index of the cascade
  54207. * @returns the maximum cascade extents
  54208. */
  54209. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  54210. private _cascades;
  54211. private _currentLayer;
  54212. private _viewSpaceFrustumsZ;
  54213. private _viewMatrices;
  54214. private _projectionMatrices;
  54215. private _transformMatrices;
  54216. private _transformMatricesAsArray;
  54217. private _frustumLengths;
  54218. private _lightSizeUVCorrection;
  54219. private _depthCorrection;
  54220. private _frustumCornersWorldSpace;
  54221. private _frustumCenter;
  54222. private _shadowCameraPos;
  54223. private _shadowMaxZ;
  54224. /**
  54225. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  54226. * It defaults to camera.maxZ
  54227. */
  54228. get shadowMaxZ(): number;
  54229. /**
  54230. * Sets the shadow max z distance.
  54231. */
  54232. set shadowMaxZ(value: number);
  54233. protected _debug: boolean;
  54234. /**
  54235. * Gets or sets the debug flag.
  54236. * When enabled, the cascades are materialized by different colors on the screen.
  54237. */
  54238. get debug(): boolean;
  54239. set debug(dbg: boolean);
  54240. private _depthClamp;
  54241. /**
  54242. * Gets or sets the depth clamping value.
  54243. *
  54244. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  54245. * to account for the shadow casters far away.
  54246. *
  54247. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  54248. */
  54249. get depthClamp(): boolean;
  54250. set depthClamp(value: boolean);
  54251. private _cascadeBlendPercentage;
  54252. /**
  54253. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  54254. * It defaults to 0.1 (10% blending).
  54255. */
  54256. get cascadeBlendPercentage(): number;
  54257. set cascadeBlendPercentage(value: number);
  54258. private _lambda;
  54259. /**
  54260. * Gets or set the lambda parameter.
  54261. * This parameter is used to split the camera frustum and create the cascades.
  54262. * 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.
  54263. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  54264. */
  54265. get lambda(): number;
  54266. set lambda(value: number);
  54267. /**
  54268. * Gets the view matrix corresponding to a given cascade
  54269. * @param cascadeNum cascade to retrieve the view matrix from
  54270. * @returns the cascade view matrix
  54271. */
  54272. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  54273. /**
  54274. * Gets the projection matrix corresponding to a given cascade
  54275. * @param cascadeNum cascade to retrieve the projection matrix from
  54276. * @returns the cascade projection matrix
  54277. */
  54278. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  54279. /**
  54280. * Gets the transformation matrix corresponding to a given cascade
  54281. * @param cascadeNum cascade to retrieve the transformation matrix from
  54282. * @returns the cascade transformation matrix
  54283. */
  54284. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  54285. private _depthRenderer;
  54286. /**
  54287. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  54288. *
  54289. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  54290. *
  54291. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  54292. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  54293. * @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
  54294. */
  54295. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  54296. private _depthReducer;
  54297. private _autoCalcDepthBounds;
  54298. /**
  54299. * Gets or sets the autoCalcDepthBounds property.
  54300. *
  54301. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  54302. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  54303. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  54304. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  54305. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  54306. */
  54307. get autoCalcDepthBounds(): boolean;
  54308. set autoCalcDepthBounds(value: boolean);
  54309. /**
  54310. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  54311. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  54312. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  54313. * for setting the refresh rate on the renderer yourself!
  54314. */
  54315. get autoCalcDepthBoundsRefreshRate(): number;
  54316. set autoCalcDepthBoundsRefreshRate(value: number);
  54317. /**
  54318. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  54319. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  54320. * you change the camera near/far planes!
  54321. */
  54322. splitFrustum(): void;
  54323. private _splitFrustum;
  54324. private _computeMatrices;
  54325. private _computeFrustumInWorldSpace;
  54326. private _computeCascadeFrustum;
  54327. /** @hidden */
  54328. static _SceneComponentInitialization: (scene: Scene) => void;
  54329. /**
  54330. * Creates a Cascaded Shadow Generator object.
  54331. * A ShadowGenerator is the required tool to use the shadows.
  54332. * Each directional light casting shadows needs to use its own ShadowGenerator.
  54333. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  54334. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  54335. * @param light The directional light object generating the shadows.
  54336. * @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.
  54337. */
  54338. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  54339. protected _initializeGenerator(): void;
  54340. protected _createTargetRenderTexture(): void;
  54341. protected _initializeShadowMap(): void;
  54342. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  54343. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  54344. /**
  54345. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  54346. * @param defines Defines of the material we want to update
  54347. * @param lightIndex Index of the light in the enabled light list of the material
  54348. */
  54349. prepareDefines(defines: any, lightIndex: number): void;
  54350. /**
  54351. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  54352. * defined in the generator but impacting the effect).
  54353. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  54354. * @param effect The effect we are binfing the information for
  54355. */
  54356. bindShadowLight(lightIndex: string, effect: Effect): void;
  54357. /**
  54358. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  54359. * (eq to view projection * shadow projection matrices)
  54360. * @returns The transform matrix used to create the shadow map
  54361. */
  54362. getTransformMatrix(): Matrix;
  54363. /**
  54364. * Disposes the ShadowGenerator.
  54365. * Returns nothing.
  54366. */
  54367. dispose(): void;
  54368. /**
  54369. * Serializes the shadow generator setup to a json object.
  54370. * @returns The serialized JSON object
  54371. */
  54372. serialize(): any;
  54373. /**
  54374. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  54375. * @param parsedShadowGenerator The JSON object to parse
  54376. * @param scene The scene to create the shadow map for
  54377. * @returns The parsed shadow generator
  54378. */
  54379. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  54380. }
  54381. }
  54382. declare module BABYLON {
  54383. /**
  54384. * Defines the shadow generator component responsible to manage any shadow generators
  54385. * in a given scene.
  54386. */
  54387. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  54388. /**
  54389. * The component name helpfull to identify the component in the list of scene components.
  54390. */
  54391. readonly name: string;
  54392. /**
  54393. * The scene the component belongs to.
  54394. */
  54395. scene: Scene;
  54396. /**
  54397. * Creates a new instance of the component for the given scene
  54398. * @param scene Defines the scene to register the component in
  54399. */
  54400. constructor(scene: Scene);
  54401. /**
  54402. * Registers the component in a given scene
  54403. */
  54404. register(): void;
  54405. /**
  54406. * Rebuilds the elements related to this component in case of
  54407. * context lost for instance.
  54408. */
  54409. rebuild(): void;
  54410. /**
  54411. * Serializes the component data to the specified json object
  54412. * @param serializationObject The object to serialize to
  54413. */
  54414. serialize(serializationObject: any): void;
  54415. /**
  54416. * Adds all the elements from the container to the scene
  54417. * @param container the container holding the elements
  54418. */
  54419. addFromContainer(container: AbstractScene): void;
  54420. /**
  54421. * Removes all the elements in the container from the scene
  54422. * @param container contains the elements to remove
  54423. * @param dispose if the removed element should be disposed (default: false)
  54424. */
  54425. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  54426. /**
  54427. * Rebuilds the elements related to this component in case of
  54428. * context lost for instance.
  54429. */
  54430. dispose(): void;
  54431. private _gatherRenderTargets;
  54432. }
  54433. }
  54434. declare module BABYLON {
  54435. /**
  54436. * A point light is a light defined by an unique point in world space.
  54437. * The light is emitted in every direction from this point.
  54438. * A good example of a point light is a standard light bulb.
  54439. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54440. */
  54441. export class PointLight extends ShadowLight {
  54442. private _shadowAngle;
  54443. /**
  54444. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54445. * This specifies what angle the shadow will use to be created.
  54446. *
  54447. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  54448. */
  54449. get shadowAngle(): number;
  54450. /**
  54451. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54452. * This specifies what angle the shadow will use to be created.
  54453. *
  54454. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  54455. */
  54456. set shadowAngle(value: number);
  54457. /**
  54458. * Gets the direction if it has been set.
  54459. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54460. */
  54461. get direction(): Vector3;
  54462. /**
  54463. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  54464. */
  54465. set direction(value: Vector3);
  54466. /**
  54467. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  54468. * A PointLight emits the light in every direction.
  54469. * It can cast shadows.
  54470. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  54471. * ```javascript
  54472. * var pointLight = new PointLight("pl", camera.position, scene);
  54473. * ```
  54474. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54475. * @param name The light friendly name
  54476. * @param position The position of the point light in the scene
  54477. * @param scene The scene the lights belongs to
  54478. */
  54479. constructor(name: string, position: Vector3, scene: Scene);
  54480. /**
  54481. * Returns the string "PointLight"
  54482. * @returns the class name
  54483. */
  54484. getClassName(): string;
  54485. /**
  54486. * Returns the integer 0.
  54487. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54488. */
  54489. getTypeID(): number;
  54490. /**
  54491. * Specifies wether or not the shadowmap should be a cube texture.
  54492. * @returns true if the shadowmap needs to be a cube texture.
  54493. */
  54494. needCube(): boolean;
  54495. /**
  54496. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  54497. * @param faceIndex The index of the face we are computed the direction to generate shadow
  54498. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  54499. */
  54500. getShadowDirection(faceIndex?: number): Vector3;
  54501. /**
  54502. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  54503. * - fov = PI / 2
  54504. * - aspect ratio : 1.0
  54505. * - z-near and far equal to the active camera minZ and maxZ.
  54506. * Returns the PointLight.
  54507. */
  54508. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54509. protected _buildUniformLayout(): void;
  54510. /**
  54511. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  54512. * @param effect The effect to update
  54513. * @param lightIndex The index of the light in the effect to update
  54514. * @returns The point light
  54515. */
  54516. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  54517. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  54518. /**
  54519. * Prepares the list of defines specific to the light type.
  54520. * @param defines the list of defines
  54521. * @param lightIndex defines the index of the light for the effect
  54522. */
  54523. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54524. }
  54525. }
  54526. declare module BABYLON {
  54527. /**
  54528. * Header information of HDR texture files.
  54529. */
  54530. export interface HDRInfo {
  54531. /**
  54532. * The height of the texture in pixels.
  54533. */
  54534. height: number;
  54535. /**
  54536. * The width of the texture in pixels.
  54537. */
  54538. width: number;
  54539. /**
  54540. * The index of the beginning of the data in the binary file.
  54541. */
  54542. dataPosition: number;
  54543. }
  54544. /**
  54545. * This groups tools to convert HDR texture to native colors array.
  54546. */
  54547. export class HDRTools {
  54548. private static Ldexp;
  54549. private static Rgbe2float;
  54550. private static readStringLine;
  54551. /**
  54552. * Reads header information from an RGBE texture stored in a native array.
  54553. * More information on this format are available here:
  54554. * https://en.wikipedia.org/wiki/RGBE_image_format
  54555. *
  54556. * @param uint8array The binary file stored in native array.
  54557. * @return The header information.
  54558. */
  54559. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  54560. /**
  54561. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  54562. * This RGBE texture needs to store the information as a panorama.
  54563. *
  54564. * More information on this format are available here:
  54565. * https://en.wikipedia.org/wiki/RGBE_image_format
  54566. *
  54567. * @param buffer The binary file stored in an array buffer.
  54568. * @param size The expected size of the extracted cubemap.
  54569. * @return The Cube Map information.
  54570. */
  54571. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  54572. /**
  54573. * Returns the pixels data extracted from an RGBE texture.
  54574. * This pixels will be stored left to right up to down in the R G B order in one array.
  54575. *
  54576. * More information on this format are available here:
  54577. * https://en.wikipedia.org/wiki/RGBE_image_format
  54578. *
  54579. * @param uint8array The binary file stored in an array buffer.
  54580. * @param hdrInfo The header information of the file.
  54581. * @return The pixels data in RGB right to left up to down order.
  54582. */
  54583. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  54584. private static RGBE_ReadPixels_RLE;
  54585. }
  54586. }
  54587. declare module BABYLON {
  54588. /**
  54589. * This represents a texture coming from an HDR input.
  54590. *
  54591. * The only supported format is currently panorama picture stored in RGBE format.
  54592. * Example of such files can be found on HDRLib: http://hdrlib.com/
  54593. */
  54594. export class HDRCubeTexture extends BaseTexture {
  54595. private static _facesMapping;
  54596. private _generateHarmonics;
  54597. private _noMipmap;
  54598. private _textureMatrix;
  54599. private _size;
  54600. private _onLoad;
  54601. private _onError;
  54602. /**
  54603. * The texture URL.
  54604. */
  54605. url: string;
  54606. /**
  54607. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  54608. */
  54609. coordinatesMode: number;
  54610. protected _isBlocking: boolean;
  54611. /**
  54612. * Sets wether or not the texture is blocking during loading.
  54613. */
  54614. set isBlocking(value: boolean);
  54615. /**
  54616. * Gets wether or not the texture is blocking during loading.
  54617. */
  54618. get isBlocking(): boolean;
  54619. protected _rotationY: number;
  54620. /**
  54621. * Sets texture matrix rotation angle around Y axis in radians.
  54622. */
  54623. set rotationY(value: number);
  54624. /**
  54625. * Gets texture matrix rotation angle around Y axis radians.
  54626. */
  54627. get rotationY(): number;
  54628. /**
  54629. * Gets or sets the center of the bounding box associated with the cube texture
  54630. * It must define where the camera used to render the texture was set
  54631. */
  54632. boundingBoxPosition: Vector3;
  54633. private _boundingBoxSize;
  54634. /**
  54635. * Gets or sets the size of the bounding box associated with the cube texture
  54636. * When defined, the cubemap will switch to local mode
  54637. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  54638. * @example https://www.babylonjs-playground.com/#RNASML
  54639. */
  54640. set boundingBoxSize(value: Vector3);
  54641. get boundingBoxSize(): Vector3;
  54642. /**
  54643. * Instantiates an HDRTexture from the following parameters.
  54644. *
  54645. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  54646. * @param scene The scene the texture will be used in
  54647. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  54648. * @param noMipmap Forces to not generate the mipmap if true
  54649. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  54650. * @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)
  54651. * @param reserved Reserved flag for internal use.
  54652. */
  54653. 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>);
  54654. /**
  54655. * Get the current class name of the texture useful for serialization or dynamic coding.
  54656. * @returns "HDRCubeTexture"
  54657. */
  54658. getClassName(): string;
  54659. /**
  54660. * Occurs when the file is raw .hdr file.
  54661. */
  54662. private loadTexture;
  54663. clone(): HDRCubeTexture;
  54664. delayLoad(): void;
  54665. /**
  54666. * Get the texture reflection matrix used to rotate/transform the reflection.
  54667. * @returns the reflection matrix
  54668. */
  54669. getReflectionTextureMatrix(): Matrix;
  54670. /**
  54671. * Set the texture reflection matrix used to rotate/transform the reflection.
  54672. * @param value Define the reflection matrix to set
  54673. */
  54674. setReflectionTextureMatrix(value: Matrix): void;
  54675. /**
  54676. * Parses a JSON representation of an HDR Texture in order to create the texture
  54677. * @param parsedTexture Define the JSON representation
  54678. * @param scene Define the scene the texture should be created in
  54679. * @param rootUrl Define the root url in case we need to load relative dependencies
  54680. * @returns the newly created texture after parsing
  54681. */
  54682. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  54683. serialize(): any;
  54684. }
  54685. }
  54686. declare module BABYLON {
  54687. /**
  54688. * Class used to control physics engine
  54689. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  54690. */
  54691. export class PhysicsEngine implements IPhysicsEngine {
  54692. private _physicsPlugin;
  54693. /**
  54694. * Global value used to control the smallest number supported by the simulation
  54695. */
  54696. static Epsilon: number;
  54697. private _impostors;
  54698. private _joints;
  54699. private _subTimeStep;
  54700. /**
  54701. * Gets the gravity vector used by the simulation
  54702. */
  54703. gravity: Vector3;
  54704. /**
  54705. * Factory used to create the default physics plugin.
  54706. * @returns The default physics plugin
  54707. */
  54708. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  54709. /**
  54710. * Creates a new Physics Engine
  54711. * @param gravity defines the gravity vector used by the simulation
  54712. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  54713. */
  54714. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  54715. /**
  54716. * Sets the gravity vector used by the simulation
  54717. * @param gravity defines the gravity vector to use
  54718. */
  54719. setGravity(gravity: Vector3): void;
  54720. /**
  54721. * Set the time step of the physics engine.
  54722. * Default is 1/60.
  54723. * To slow it down, enter 1/600 for example.
  54724. * To speed it up, 1/30
  54725. * @param newTimeStep defines the new timestep to apply to this world.
  54726. */
  54727. setTimeStep(newTimeStep?: number): void;
  54728. /**
  54729. * Get the time step of the physics engine.
  54730. * @returns the current time step
  54731. */
  54732. getTimeStep(): number;
  54733. /**
  54734. * Set the sub time step of the physics engine.
  54735. * Default is 0 meaning there is no sub steps
  54736. * To increase physics resolution precision, set a small value (like 1 ms)
  54737. * @param subTimeStep defines the new sub timestep used for physics resolution.
  54738. */
  54739. setSubTimeStep(subTimeStep?: number): void;
  54740. /**
  54741. * Get the sub time step of the physics engine.
  54742. * @returns the current sub time step
  54743. */
  54744. getSubTimeStep(): number;
  54745. /**
  54746. * Release all resources
  54747. */
  54748. dispose(): void;
  54749. /**
  54750. * Gets the name of the current physics plugin
  54751. * @returns the name of the plugin
  54752. */
  54753. getPhysicsPluginName(): string;
  54754. /**
  54755. * Adding a new impostor for the impostor tracking.
  54756. * This will be done by the impostor itself.
  54757. * @param impostor the impostor to add
  54758. */
  54759. addImpostor(impostor: PhysicsImpostor): void;
  54760. /**
  54761. * Remove an impostor from the engine.
  54762. * This impostor and its mesh will not longer be updated by the physics engine.
  54763. * @param impostor the impostor to remove
  54764. */
  54765. removeImpostor(impostor: PhysicsImpostor): void;
  54766. /**
  54767. * Add a joint to the physics engine
  54768. * @param mainImpostor defines the main impostor to which the joint is added.
  54769. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  54770. * @param joint defines the joint that will connect both impostors.
  54771. */
  54772. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  54773. /**
  54774. * Removes a joint from the simulation
  54775. * @param mainImpostor defines the impostor used with the joint
  54776. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  54777. * @param joint defines the joint to remove
  54778. */
  54779. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  54780. /**
  54781. * Called by the scene. No need to call it.
  54782. * @param delta defines the timespam between frames
  54783. */
  54784. _step(delta: number): void;
  54785. /**
  54786. * Gets the current plugin used to run the simulation
  54787. * @returns current plugin
  54788. */
  54789. getPhysicsPlugin(): IPhysicsEnginePlugin;
  54790. /**
  54791. * Gets the list of physic impostors
  54792. * @returns an array of PhysicsImpostor
  54793. */
  54794. getImpostors(): Array<PhysicsImpostor>;
  54795. /**
  54796. * Gets the impostor for a physics enabled object
  54797. * @param object defines the object impersonated by the impostor
  54798. * @returns the PhysicsImpostor or null if not found
  54799. */
  54800. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  54801. /**
  54802. * Gets the impostor for a physics body object
  54803. * @param body defines physics body used by the impostor
  54804. * @returns the PhysicsImpostor or null if not found
  54805. */
  54806. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  54807. /**
  54808. * Does a raycast in the physics world
  54809. * @param from when should the ray start?
  54810. * @param to when should the ray end?
  54811. * @returns PhysicsRaycastResult
  54812. */
  54813. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54814. }
  54815. }
  54816. declare module BABYLON {
  54817. /** @hidden */
  54818. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  54819. private _useDeltaForWorldStep;
  54820. world: any;
  54821. name: string;
  54822. private _physicsMaterials;
  54823. private _fixedTimeStep;
  54824. private _cannonRaycastResult;
  54825. private _raycastResult;
  54826. private _physicsBodysToRemoveAfterStep;
  54827. BJSCANNON: any;
  54828. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  54829. setGravity(gravity: Vector3): void;
  54830. setTimeStep(timeStep: number): void;
  54831. getTimeStep(): number;
  54832. executeStep(delta: number): void;
  54833. private _removeMarkedPhysicsBodiesFromWorld;
  54834. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54835. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54836. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54837. private _processChildMeshes;
  54838. removePhysicsBody(impostor: PhysicsImpostor): void;
  54839. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54840. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54841. private _addMaterial;
  54842. private _checkWithEpsilon;
  54843. private _createShape;
  54844. private _createHeightmap;
  54845. private _minus90X;
  54846. private _plus90X;
  54847. private _tmpPosition;
  54848. private _tmpDeltaPosition;
  54849. private _tmpUnityRotation;
  54850. private _updatePhysicsBodyTransformation;
  54851. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54852. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54853. isSupported(): boolean;
  54854. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54855. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54856. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54857. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54858. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54859. getBodyMass(impostor: PhysicsImpostor): number;
  54860. getBodyFriction(impostor: PhysicsImpostor): number;
  54861. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54862. getBodyRestitution(impostor: PhysicsImpostor): number;
  54863. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54864. sleepBody(impostor: PhysicsImpostor): void;
  54865. wakeUpBody(impostor: PhysicsImpostor): void;
  54866. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  54867. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  54868. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  54869. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54870. getRadius(impostor: PhysicsImpostor): number;
  54871. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54872. dispose(): void;
  54873. private _extendNamespace;
  54874. /**
  54875. * Does a raycast in the physics world
  54876. * @param from when should the ray start?
  54877. * @param to when should the ray end?
  54878. * @returns PhysicsRaycastResult
  54879. */
  54880. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54881. }
  54882. }
  54883. declare module BABYLON {
  54884. /** @hidden */
  54885. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  54886. world: any;
  54887. name: string;
  54888. BJSOIMO: any;
  54889. private _raycastResult;
  54890. constructor(iterations?: number, oimoInjection?: any);
  54891. setGravity(gravity: Vector3): void;
  54892. setTimeStep(timeStep: number): void;
  54893. getTimeStep(): number;
  54894. private _tmpImpostorsArray;
  54895. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  54896. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54897. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  54898. generatePhysicsBody(impostor: PhysicsImpostor): void;
  54899. private _tmpPositionVector;
  54900. removePhysicsBody(impostor: PhysicsImpostor): void;
  54901. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  54902. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  54903. isSupported(): boolean;
  54904. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  54905. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  54906. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54907. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  54908. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54909. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  54910. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  54911. getBodyMass(impostor: PhysicsImpostor): number;
  54912. getBodyFriction(impostor: PhysicsImpostor): number;
  54913. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  54914. getBodyRestitution(impostor: PhysicsImpostor): number;
  54915. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  54916. sleepBody(impostor: PhysicsImpostor): void;
  54917. wakeUpBody(impostor: PhysicsImpostor): void;
  54918. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  54919. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  54920. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  54921. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  54922. getRadius(impostor: PhysicsImpostor): number;
  54923. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  54924. dispose(): void;
  54925. /**
  54926. * Does a raycast in the physics world
  54927. * @param from when should the ray start?
  54928. * @param to when should the ray end?
  54929. * @returns PhysicsRaycastResult
  54930. */
  54931. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  54932. }
  54933. }
  54934. declare module BABYLON {
  54935. /**
  54936. * Class containing static functions to help procedurally build meshes
  54937. */
  54938. export class RibbonBuilder {
  54939. /**
  54940. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54941. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  54942. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  54943. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  54944. * * 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
  54945. * * 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
  54946. * * 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
  54947. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54948. * * 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
  54949. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54950. * * 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
  54951. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  54952. * * 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
  54953. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  54954. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54955. * @param name defines the name of the mesh
  54956. * @param options defines the options used to create the mesh
  54957. * @param scene defines the hosting scene
  54958. * @returns the ribbon mesh
  54959. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  54960. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54961. */
  54962. static CreateRibbon(name: string, options: {
  54963. pathArray: Vector3[][];
  54964. closeArray?: boolean;
  54965. closePath?: boolean;
  54966. offset?: number;
  54967. updatable?: boolean;
  54968. sideOrientation?: number;
  54969. frontUVs?: Vector4;
  54970. backUVs?: Vector4;
  54971. instance?: Mesh;
  54972. invertUV?: boolean;
  54973. uvs?: Vector2[];
  54974. colors?: Color4[];
  54975. }, scene?: Nullable<Scene>): Mesh;
  54976. }
  54977. }
  54978. declare module BABYLON {
  54979. /**
  54980. * Class containing static functions to help procedurally build meshes
  54981. */
  54982. export class ShapeBuilder {
  54983. /**
  54984. * 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.
  54985. * * 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.
  54986. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54987. * * 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.
  54988. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  54989. * * 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
  54990. * * 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
  54991. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  54992. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54993. * * 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
  54994. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  54995. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54996. * @param name defines the name of the mesh
  54997. * @param options defines the options used to create the mesh
  54998. * @param scene defines the hosting scene
  54999. * @returns the extruded shape mesh
  55000. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55001. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55002. */
  55003. static ExtrudeShape(name: string, options: {
  55004. shape: Vector3[];
  55005. path: Vector3[];
  55006. scale?: number;
  55007. rotation?: number;
  55008. cap?: number;
  55009. updatable?: boolean;
  55010. sideOrientation?: number;
  55011. frontUVs?: Vector4;
  55012. backUVs?: Vector4;
  55013. instance?: Mesh;
  55014. invertUV?: boolean;
  55015. }, scene?: Nullable<Scene>): Mesh;
  55016. /**
  55017. * Creates an custom extruded shape mesh.
  55018. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55019. * * 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.
  55020. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55021. * * 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
  55022. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55023. * * 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
  55024. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55025. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55026. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55027. * * 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
  55028. * * 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
  55029. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55030. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55031. * * 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
  55032. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55033. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55034. * @param name defines the name of the mesh
  55035. * @param options defines the options used to create the mesh
  55036. * @param scene defines the hosting scene
  55037. * @returns the custom extruded shape mesh
  55038. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55039. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55040. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55041. */
  55042. static ExtrudeShapeCustom(name: string, options: {
  55043. shape: Vector3[];
  55044. path: Vector3[];
  55045. scaleFunction?: any;
  55046. rotationFunction?: any;
  55047. ribbonCloseArray?: boolean;
  55048. ribbonClosePath?: boolean;
  55049. cap?: number;
  55050. updatable?: boolean;
  55051. sideOrientation?: number;
  55052. frontUVs?: Vector4;
  55053. backUVs?: Vector4;
  55054. instance?: Mesh;
  55055. invertUV?: boolean;
  55056. }, scene?: Nullable<Scene>): Mesh;
  55057. private static _ExtrudeShapeGeneric;
  55058. }
  55059. }
  55060. declare module BABYLON {
  55061. /**
  55062. * AmmoJS Physics plugin
  55063. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  55064. * @see https://github.com/kripken/ammo.js/
  55065. */
  55066. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  55067. private _useDeltaForWorldStep;
  55068. /**
  55069. * Reference to the Ammo library
  55070. */
  55071. bjsAMMO: any;
  55072. /**
  55073. * Created ammoJS world which physics bodies are added to
  55074. */
  55075. world: any;
  55076. /**
  55077. * Name of the plugin
  55078. */
  55079. name: string;
  55080. private _timeStep;
  55081. private _fixedTimeStep;
  55082. private _maxSteps;
  55083. private _tmpQuaternion;
  55084. private _tmpAmmoTransform;
  55085. private _tmpAmmoQuaternion;
  55086. private _tmpAmmoConcreteContactResultCallback;
  55087. private _collisionConfiguration;
  55088. private _dispatcher;
  55089. private _overlappingPairCache;
  55090. private _solver;
  55091. private _softBodySolver;
  55092. private _tmpAmmoVectorA;
  55093. private _tmpAmmoVectorB;
  55094. private _tmpAmmoVectorC;
  55095. private _tmpAmmoVectorD;
  55096. private _tmpContactCallbackResult;
  55097. private _tmpAmmoVectorRCA;
  55098. private _tmpAmmoVectorRCB;
  55099. private _raycastResult;
  55100. private static readonly DISABLE_COLLISION_FLAG;
  55101. private static readonly KINEMATIC_FLAG;
  55102. private static readonly DISABLE_DEACTIVATION_FLAG;
  55103. /**
  55104. * Initializes the ammoJS plugin
  55105. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  55106. * @param ammoInjection can be used to inject your own ammo reference
  55107. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  55108. */
  55109. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  55110. /**
  55111. * Sets the gravity of the physics world (m/(s^2))
  55112. * @param gravity Gravity to set
  55113. */
  55114. setGravity(gravity: Vector3): void;
  55115. /**
  55116. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  55117. * @param timeStep timestep to use in seconds
  55118. */
  55119. setTimeStep(timeStep: number): void;
  55120. /**
  55121. * 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)
  55122. * @param fixedTimeStep fixedTimeStep to use in seconds
  55123. */
  55124. setFixedTimeStep(fixedTimeStep: number): void;
  55125. /**
  55126. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  55127. * @param maxSteps the maximum number of steps by the physics engine per frame
  55128. */
  55129. setMaxSteps(maxSteps: number): void;
  55130. /**
  55131. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  55132. * @returns the current timestep in seconds
  55133. */
  55134. getTimeStep(): number;
  55135. /**
  55136. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  55137. */
  55138. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  55139. private _isImpostorInContact;
  55140. private _isImpostorPairInContact;
  55141. private _stepSimulation;
  55142. /**
  55143. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  55144. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  55145. * After the step the babylon meshes are set to the position of the physics imposters
  55146. * @param delta amount of time to step forward
  55147. * @param impostors array of imposters to update before/after the step
  55148. */
  55149. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  55150. /**
  55151. * Update babylon mesh to match physics world object
  55152. * @param impostor imposter to match
  55153. */
  55154. private _afterSoftStep;
  55155. /**
  55156. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55157. * @param impostor imposter to match
  55158. */
  55159. private _ropeStep;
  55160. /**
  55161. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  55162. * @param impostor imposter to match
  55163. */
  55164. private _softbodyOrClothStep;
  55165. private _tmpVector;
  55166. private _tmpMatrix;
  55167. /**
  55168. * Applies an impulse on the imposter
  55169. * @param impostor imposter to apply impulse to
  55170. * @param force amount of force to be applied to the imposter
  55171. * @param contactPoint the location to apply the impulse on the imposter
  55172. */
  55173. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55174. /**
  55175. * Applies a force on the imposter
  55176. * @param impostor imposter to apply force
  55177. * @param force amount of force to be applied to the imposter
  55178. * @param contactPoint the location to apply the force on the imposter
  55179. */
  55180. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  55181. /**
  55182. * Creates a physics body using the plugin
  55183. * @param impostor the imposter to create the physics body on
  55184. */
  55185. generatePhysicsBody(impostor: PhysicsImpostor): void;
  55186. /**
  55187. * Removes the physics body from the imposter and disposes of the body's memory
  55188. * @param impostor imposter to remove the physics body from
  55189. */
  55190. removePhysicsBody(impostor: PhysicsImpostor): void;
  55191. /**
  55192. * Generates a joint
  55193. * @param impostorJoint the imposter joint to create the joint with
  55194. */
  55195. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  55196. /**
  55197. * Removes a joint
  55198. * @param impostorJoint the imposter joint to remove the joint from
  55199. */
  55200. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  55201. private _addMeshVerts;
  55202. /**
  55203. * Initialise the soft body vertices to match its object's (mesh) vertices
  55204. * Softbody vertices (nodes) are in world space and to match this
  55205. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  55206. * @param impostor to create the softbody for
  55207. */
  55208. private _softVertexData;
  55209. /**
  55210. * Create an impostor's soft body
  55211. * @param impostor to create the softbody for
  55212. */
  55213. private _createSoftbody;
  55214. /**
  55215. * Create cloth for an impostor
  55216. * @param impostor to create the softbody for
  55217. */
  55218. private _createCloth;
  55219. /**
  55220. * Create rope for an impostor
  55221. * @param impostor to create the softbody for
  55222. */
  55223. private _createRope;
  55224. /**
  55225. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  55226. * @param impostor to create the custom physics shape for
  55227. */
  55228. private _createCustom;
  55229. private _addHullVerts;
  55230. private _createShape;
  55231. /**
  55232. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  55233. * @param impostor imposter containing the physics body and babylon object
  55234. */
  55235. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  55236. /**
  55237. * Sets the babylon object's position/rotation from the physics body's position/rotation
  55238. * @param impostor imposter containing the physics body and babylon object
  55239. * @param newPosition new position
  55240. * @param newRotation new rotation
  55241. */
  55242. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  55243. /**
  55244. * If this plugin is supported
  55245. * @returns true if its supported
  55246. */
  55247. isSupported(): boolean;
  55248. /**
  55249. * Sets the linear velocity of the physics body
  55250. * @param impostor imposter to set the velocity on
  55251. * @param velocity velocity to set
  55252. */
  55253. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55254. /**
  55255. * Sets the angular velocity of the physics body
  55256. * @param impostor imposter to set the velocity on
  55257. * @param velocity velocity to set
  55258. */
  55259. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  55260. /**
  55261. * gets the linear velocity
  55262. * @param impostor imposter to get linear velocity from
  55263. * @returns linear velocity
  55264. */
  55265. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55266. /**
  55267. * gets the angular velocity
  55268. * @param impostor imposter to get angular velocity from
  55269. * @returns angular velocity
  55270. */
  55271. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  55272. /**
  55273. * Sets the mass of physics body
  55274. * @param impostor imposter to set the mass on
  55275. * @param mass mass to set
  55276. */
  55277. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  55278. /**
  55279. * Gets the mass of the physics body
  55280. * @param impostor imposter to get the mass from
  55281. * @returns mass
  55282. */
  55283. getBodyMass(impostor: PhysicsImpostor): number;
  55284. /**
  55285. * Gets friction of the impostor
  55286. * @param impostor impostor to get friction from
  55287. * @returns friction value
  55288. */
  55289. getBodyFriction(impostor: PhysicsImpostor): number;
  55290. /**
  55291. * Sets friction of the impostor
  55292. * @param impostor impostor to set friction on
  55293. * @param friction friction value
  55294. */
  55295. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  55296. /**
  55297. * Gets restitution of the impostor
  55298. * @param impostor impostor to get restitution from
  55299. * @returns restitution value
  55300. */
  55301. getBodyRestitution(impostor: PhysicsImpostor): number;
  55302. /**
  55303. * Sets resitution of the impostor
  55304. * @param impostor impostor to set resitution on
  55305. * @param restitution resitution value
  55306. */
  55307. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  55308. /**
  55309. * Gets pressure inside the impostor
  55310. * @param impostor impostor to get pressure from
  55311. * @returns pressure value
  55312. */
  55313. getBodyPressure(impostor: PhysicsImpostor): number;
  55314. /**
  55315. * Sets pressure inside a soft body impostor
  55316. * Cloth and rope must remain 0 pressure
  55317. * @param impostor impostor to set pressure on
  55318. * @param pressure pressure value
  55319. */
  55320. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  55321. /**
  55322. * Gets stiffness of the impostor
  55323. * @param impostor impostor to get stiffness from
  55324. * @returns pressure value
  55325. */
  55326. getBodyStiffness(impostor: PhysicsImpostor): number;
  55327. /**
  55328. * Sets stiffness of the impostor
  55329. * @param impostor impostor to set stiffness on
  55330. * @param stiffness stiffness value from 0 to 1
  55331. */
  55332. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  55333. /**
  55334. * Gets velocityIterations of the impostor
  55335. * @param impostor impostor to get velocity iterations from
  55336. * @returns velocityIterations value
  55337. */
  55338. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  55339. /**
  55340. * Sets velocityIterations of the impostor
  55341. * @param impostor impostor to set velocity iterations on
  55342. * @param velocityIterations velocityIterations value
  55343. */
  55344. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  55345. /**
  55346. * Gets positionIterations of the impostor
  55347. * @param impostor impostor to get position iterations from
  55348. * @returns positionIterations value
  55349. */
  55350. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  55351. /**
  55352. * Sets positionIterations of the impostor
  55353. * @param impostor impostor to set position on
  55354. * @param positionIterations positionIterations value
  55355. */
  55356. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  55357. /**
  55358. * Append an anchor to a cloth object
  55359. * @param impostor is the cloth impostor to add anchor to
  55360. * @param otherImpostor is the rigid impostor to anchor to
  55361. * @param width ratio across width from 0 to 1
  55362. * @param height ratio up height from 0 to 1
  55363. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  55364. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55365. */
  55366. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55367. /**
  55368. * Append an hook to a rope object
  55369. * @param impostor is the rope impostor to add hook to
  55370. * @param otherImpostor is the rigid impostor to hook to
  55371. * @param length ratio along the rope from 0 to 1
  55372. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  55373. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  55374. */
  55375. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  55376. /**
  55377. * Sleeps the physics body and stops it from being active
  55378. * @param impostor impostor to sleep
  55379. */
  55380. sleepBody(impostor: PhysicsImpostor): void;
  55381. /**
  55382. * Activates the physics body
  55383. * @param impostor impostor to activate
  55384. */
  55385. wakeUpBody(impostor: PhysicsImpostor): void;
  55386. /**
  55387. * Updates the distance parameters of the joint
  55388. * @param joint joint to update
  55389. * @param maxDistance maximum distance of the joint
  55390. * @param minDistance minimum distance of the joint
  55391. */
  55392. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  55393. /**
  55394. * Sets a motor on the joint
  55395. * @param joint joint to set motor on
  55396. * @param speed speed of the motor
  55397. * @param maxForce maximum force of the motor
  55398. * @param motorIndex index of the motor
  55399. */
  55400. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  55401. /**
  55402. * Sets the motors limit
  55403. * @param joint joint to set limit on
  55404. * @param upperLimit upper limit
  55405. * @param lowerLimit lower limit
  55406. */
  55407. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  55408. /**
  55409. * Syncs the position and rotation of a mesh with the impostor
  55410. * @param mesh mesh to sync
  55411. * @param impostor impostor to update the mesh with
  55412. */
  55413. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  55414. /**
  55415. * Gets the radius of the impostor
  55416. * @param impostor impostor to get radius from
  55417. * @returns the radius
  55418. */
  55419. getRadius(impostor: PhysicsImpostor): number;
  55420. /**
  55421. * Gets the box size of the impostor
  55422. * @param impostor impostor to get box size from
  55423. * @param result the resulting box size
  55424. */
  55425. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  55426. /**
  55427. * Disposes of the impostor
  55428. */
  55429. dispose(): void;
  55430. /**
  55431. * Does a raycast in the physics world
  55432. * @param from when should the ray start?
  55433. * @param to when should the ray end?
  55434. * @returns PhysicsRaycastResult
  55435. */
  55436. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  55437. }
  55438. }
  55439. declare module BABYLON {
  55440. interface AbstractScene {
  55441. /**
  55442. * The list of reflection probes added to the scene
  55443. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  55444. */
  55445. reflectionProbes: Array<ReflectionProbe>;
  55446. /**
  55447. * Removes the given reflection probe from this scene.
  55448. * @param toRemove The reflection probe to remove
  55449. * @returns The index of the removed reflection probe
  55450. */
  55451. removeReflectionProbe(toRemove: ReflectionProbe): number;
  55452. /**
  55453. * Adds the given reflection probe to this scene.
  55454. * @param newReflectionProbe The reflection probe to add
  55455. */
  55456. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  55457. }
  55458. /**
  55459. * Class used to generate realtime reflection / refraction cube textures
  55460. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  55461. */
  55462. export class ReflectionProbe {
  55463. /** defines the name of the probe */
  55464. name: string;
  55465. private _scene;
  55466. private _renderTargetTexture;
  55467. private _projectionMatrix;
  55468. private _viewMatrix;
  55469. private _target;
  55470. private _add;
  55471. private _attachedMesh;
  55472. private _invertYAxis;
  55473. /** Gets or sets probe position (center of the cube map) */
  55474. position: Vector3;
  55475. /**
  55476. * Creates a new reflection probe
  55477. * @param name defines the name of the probe
  55478. * @param size defines the texture resolution (for each face)
  55479. * @param scene defines the hosting scene
  55480. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  55481. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  55482. */
  55483. constructor(
  55484. /** defines the name of the probe */
  55485. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  55486. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  55487. get samples(): number;
  55488. set samples(value: number);
  55489. /** Gets or sets the refresh rate to use (on every frame by default) */
  55490. get refreshRate(): number;
  55491. set refreshRate(value: number);
  55492. /**
  55493. * Gets the hosting scene
  55494. * @returns a Scene
  55495. */
  55496. getScene(): Scene;
  55497. /** Gets the internal CubeTexture used to render to */
  55498. get cubeTexture(): RenderTargetTexture;
  55499. /** Gets the list of meshes to render */
  55500. get renderList(): Nullable<AbstractMesh[]>;
  55501. /**
  55502. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  55503. * @param mesh defines the mesh to attach to
  55504. */
  55505. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  55506. /**
  55507. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  55508. * @param renderingGroupId The rendering group id corresponding to its index
  55509. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  55510. */
  55511. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  55512. /**
  55513. * Clean all associated resources
  55514. */
  55515. dispose(): void;
  55516. /**
  55517. * Converts the reflection probe information to a readable string for debug purpose.
  55518. * @param fullDetails Supports for multiple levels of logging within scene loading
  55519. * @returns the human readable reflection probe info
  55520. */
  55521. toString(fullDetails?: boolean): string;
  55522. /**
  55523. * Get the class name of the relfection probe.
  55524. * @returns "ReflectionProbe"
  55525. */
  55526. getClassName(): string;
  55527. /**
  55528. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  55529. * @returns The JSON representation of the texture
  55530. */
  55531. serialize(): any;
  55532. /**
  55533. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  55534. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  55535. * @param scene Define the scene the parsed reflection probe should be instantiated in
  55536. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  55537. * @returns The parsed reflection probe if successful
  55538. */
  55539. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  55540. }
  55541. }
  55542. declare module BABYLON {
  55543. /** @hidden */
  55544. export var _BabylonLoaderRegistered: boolean;
  55545. /**
  55546. * Helps setting up some configuration for the babylon file loader.
  55547. */
  55548. export class BabylonFileLoaderConfiguration {
  55549. /**
  55550. * The loader does not allow injecting custom physix engine into the plugins.
  55551. * Unfortunately in ES6, we need to manually inject them into the plugin.
  55552. * So you could set this variable to your engine import to make it work.
  55553. */
  55554. static LoaderInjectedPhysicsEngine: any;
  55555. }
  55556. }
  55557. declare module BABYLON {
  55558. /**
  55559. * The Physically based simple base material of BJS.
  55560. *
  55561. * This enables better naming and convention enforcements on top of the pbrMaterial.
  55562. * It is used as the base class for both the specGloss and metalRough conventions.
  55563. */
  55564. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  55565. /**
  55566. * Number of Simultaneous lights allowed on the material.
  55567. */
  55568. maxSimultaneousLights: number;
  55569. /**
  55570. * If sets to true, disables all the lights affecting the material.
  55571. */
  55572. disableLighting: boolean;
  55573. /**
  55574. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  55575. */
  55576. environmentTexture: BaseTexture;
  55577. /**
  55578. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  55579. */
  55580. invertNormalMapX: boolean;
  55581. /**
  55582. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  55583. */
  55584. invertNormalMapY: boolean;
  55585. /**
  55586. * Normal map used in the model.
  55587. */
  55588. normalTexture: BaseTexture;
  55589. /**
  55590. * Emissivie color used to self-illuminate the model.
  55591. */
  55592. emissiveColor: Color3;
  55593. /**
  55594. * Emissivie texture used to self-illuminate the model.
  55595. */
  55596. emissiveTexture: BaseTexture;
  55597. /**
  55598. * Occlusion Channel Strenght.
  55599. */
  55600. occlusionStrength: number;
  55601. /**
  55602. * Occlusion Texture of the material (adding extra occlusion effects).
  55603. */
  55604. occlusionTexture: BaseTexture;
  55605. /**
  55606. * Defines the alpha limits in alpha test mode.
  55607. */
  55608. alphaCutOff: number;
  55609. /**
  55610. * Gets the current double sided mode.
  55611. */
  55612. get doubleSided(): boolean;
  55613. /**
  55614. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  55615. */
  55616. set doubleSided(value: boolean);
  55617. /**
  55618. * Stores the pre-calculated light information of a mesh in a texture.
  55619. */
  55620. lightmapTexture: BaseTexture;
  55621. /**
  55622. * If true, the light map contains occlusion information instead of lighting info.
  55623. */
  55624. useLightmapAsShadowmap: boolean;
  55625. /**
  55626. * Instantiates a new PBRMaterial instance.
  55627. *
  55628. * @param name The material name
  55629. * @param scene The scene the material will be use in.
  55630. */
  55631. constructor(name: string, scene: Scene);
  55632. getClassName(): string;
  55633. }
  55634. }
  55635. declare module BABYLON {
  55636. /**
  55637. * The PBR material of BJS following the metal roughness convention.
  55638. *
  55639. * This fits to the PBR convention in the GLTF definition:
  55640. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  55641. */
  55642. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  55643. /**
  55644. * The base color has two different interpretations depending on the value of metalness.
  55645. * When the material is a metal, the base color is the specific measured reflectance value
  55646. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  55647. * of the material.
  55648. */
  55649. baseColor: Color3;
  55650. /**
  55651. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  55652. * well as opacity information in the alpha channel.
  55653. */
  55654. baseTexture: BaseTexture;
  55655. /**
  55656. * Specifies the metallic scalar value of the material.
  55657. * Can also be used to scale the metalness values of the metallic texture.
  55658. */
  55659. metallic: number;
  55660. /**
  55661. * Specifies the roughness scalar value of the material.
  55662. * Can also be used to scale the roughness values of the metallic texture.
  55663. */
  55664. roughness: number;
  55665. /**
  55666. * Texture containing both the metallic value in the B channel and the
  55667. * roughness value in the G channel to keep better precision.
  55668. */
  55669. metallicRoughnessTexture: BaseTexture;
  55670. /**
  55671. * Instantiates a new PBRMetalRoughnessMaterial instance.
  55672. *
  55673. * @param name The material name
  55674. * @param scene The scene the material will be use in.
  55675. */
  55676. constructor(name: string, scene: Scene);
  55677. /**
  55678. * Return the currrent class name of the material.
  55679. */
  55680. getClassName(): string;
  55681. /**
  55682. * Makes a duplicate of the current material.
  55683. * @param name - name to use for the new material.
  55684. */
  55685. clone(name: string): PBRMetallicRoughnessMaterial;
  55686. /**
  55687. * Serialize the material to a parsable JSON object.
  55688. */
  55689. serialize(): any;
  55690. /**
  55691. * Parses a JSON object correponding to the serialize function.
  55692. */
  55693. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  55694. }
  55695. }
  55696. declare module BABYLON {
  55697. /**
  55698. * The PBR material of BJS following the specular glossiness convention.
  55699. *
  55700. * This fits to the PBR convention in the GLTF definition:
  55701. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  55702. */
  55703. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  55704. /**
  55705. * Specifies the diffuse color of the material.
  55706. */
  55707. diffuseColor: Color3;
  55708. /**
  55709. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  55710. * channel.
  55711. */
  55712. diffuseTexture: BaseTexture;
  55713. /**
  55714. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  55715. */
  55716. specularColor: Color3;
  55717. /**
  55718. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  55719. */
  55720. glossiness: number;
  55721. /**
  55722. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  55723. */
  55724. specularGlossinessTexture: BaseTexture;
  55725. /**
  55726. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  55727. *
  55728. * @param name The material name
  55729. * @param scene The scene the material will be use in.
  55730. */
  55731. constructor(name: string, scene: Scene);
  55732. /**
  55733. * Return the currrent class name of the material.
  55734. */
  55735. getClassName(): string;
  55736. /**
  55737. * Makes a duplicate of the current material.
  55738. * @param name - name to use for the new material.
  55739. */
  55740. clone(name: string): PBRSpecularGlossinessMaterial;
  55741. /**
  55742. * Serialize the material to a parsable JSON object.
  55743. */
  55744. serialize(): any;
  55745. /**
  55746. * Parses a JSON object correponding to the serialize function.
  55747. */
  55748. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  55749. }
  55750. }
  55751. declare module BABYLON {
  55752. /**
  55753. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  55754. * It can help converting any input color in a desired output one. This can then be used to create effects
  55755. * from sepia, black and white to sixties or futuristic rendering...
  55756. *
  55757. * The only supported format is currently 3dl.
  55758. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  55759. */
  55760. export class ColorGradingTexture extends BaseTexture {
  55761. /**
  55762. * The current texture matrix. (will always be identity in color grading texture)
  55763. */
  55764. private _textureMatrix;
  55765. /**
  55766. * The texture URL.
  55767. */
  55768. url: string;
  55769. /**
  55770. * Empty line regex stored for GC.
  55771. */
  55772. private static _noneEmptyLineRegex;
  55773. private _engine;
  55774. /**
  55775. * Instantiates a ColorGradingTexture from the following parameters.
  55776. *
  55777. * @param url The location of the color gradind data (currently only supporting 3dl)
  55778. * @param scene The scene the texture will be used in
  55779. */
  55780. constructor(url: string, scene: Scene);
  55781. /**
  55782. * Returns the texture matrix used in most of the material.
  55783. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  55784. */
  55785. getTextureMatrix(): Matrix;
  55786. /**
  55787. * Occurs when the file being loaded is a .3dl LUT file.
  55788. */
  55789. private load3dlTexture;
  55790. /**
  55791. * Starts the loading process of the texture.
  55792. */
  55793. private loadTexture;
  55794. /**
  55795. * Clones the color gradind texture.
  55796. */
  55797. clone(): ColorGradingTexture;
  55798. /**
  55799. * Called during delayed load for textures.
  55800. */
  55801. delayLoad(): void;
  55802. /**
  55803. * Parses a color grading texture serialized by Babylon.
  55804. * @param parsedTexture The texture information being parsedTexture
  55805. * @param scene The scene to load the texture in
  55806. * @param rootUrl The root url of the data assets to load
  55807. * @return A color gradind texture
  55808. */
  55809. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  55810. /**
  55811. * Serializes the LUT texture to json format.
  55812. */
  55813. serialize(): any;
  55814. }
  55815. }
  55816. declare module BABYLON {
  55817. /**
  55818. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  55819. */
  55820. export class EquiRectangularCubeTexture extends BaseTexture {
  55821. /** The six faces of the cube. */
  55822. private static _FacesMapping;
  55823. private _noMipmap;
  55824. private _onLoad;
  55825. private _onError;
  55826. /** The size of the cubemap. */
  55827. private _size;
  55828. /** The buffer of the image. */
  55829. private _buffer;
  55830. /** The width of the input image. */
  55831. private _width;
  55832. /** The height of the input image. */
  55833. private _height;
  55834. /** The URL to the image. */
  55835. url: string;
  55836. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  55837. coordinatesMode: number;
  55838. /**
  55839. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  55840. * @param url The location of the image
  55841. * @param scene The scene the texture will be used in
  55842. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  55843. * @param noMipmap Forces to not generate the mipmap if true
  55844. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  55845. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  55846. * @param onLoad — defines a callback called when texture is loaded
  55847. * @param onError — defines a callback called if there is an error
  55848. */
  55849. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  55850. /**
  55851. * Load the image data, by putting the image on a canvas and extracting its buffer.
  55852. */
  55853. private loadImage;
  55854. /**
  55855. * Convert the image buffer into a cubemap and create a CubeTexture.
  55856. */
  55857. private loadTexture;
  55858. /**
  55859. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  55860. * @param buffer The ArrayBuffer that should be converted.
  55861. * @returns The buffer as Float32Array.
  55862. */
  55863. private getFloat32ArrayFromArrayBuffer;
  55864. /**
  55865. * Get the current class name of the texture useful for serialization or dynamic coding.
  55866. * @returns "EquiRectangularCubeTexture"
  55867. */
  55868. getClassName(): string;
  55869. /**
  55870. * Create a clone of the current EquiRectangularCubeTexture and return it.
  55871. * @returns A clone of the current EquiRectangularCubeTexture.
  55872. */
  55873. clone(): EquiRectangularCubeTexture;
  55874. }
  55875. }
  55876. declare module BABYLON {
  55877. /**
  55878. * Based on jsTGALoader - Javascript loader for TGA file
  55879. * By Vincent Thibault
  55880. * @see http://blog.robrowser.com/javascript-tga-loader.html
  55881. */
  55882. export class TGATools {
  55883. private static _TYPE_INDEXED;
  55884. private static _TYPE_RGB;
  55885. private static _TYPE_GREY;
  55886. private static _TYPE_RLE_INDEXED;
  55887. private static _TYPE_RLE_RGB;
  55888. private static _TYPE_RLE_GREY;
  55889. private static _ORIGIN_MASK;
  55890. private static _ORIGIN_SHIFT;
  55891. private static _ORIGIN_BL;
  55892. private static _ORIGIN_BR;
  55893. private static _ORIGIN_UL;
  55894. private static _ORIGIN_UR;
  55895. /**
  55896. * Gets the header of a TGA file
  55897. * @param data defines the TGA data
  55898. * @returns the header
  55899. */
  55900. static GetTGAHeader(data: Uint8Array): any;
  55901. /**
  55902. * Uploads TGA content to a Babylon Texture
  55903. * @hidden
  55904. */
  55905. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  55906. /** @hidden */
  55907. 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;
  55908. /** @hidden */
  55909. 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;
  55910. /** @hidden */
  55911. 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;
  55912. /** @hidden */
  55913. 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;
  55914. /** @hidden */
  55915. 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;
  55916. /** @hidden */
  55917. 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;
  55918. }
  55919. }
  55920. declare module BABYLON {
  55921. /**
  55922. * Implementation of the TGA Texture Loader.
  55923. * @hidden
  55924. */
  55925. export class _TGATextureLoader implements IInternalTextureLoader {
  55926. /**
  55927. * Defines wether the loader supports cascade loading the different faces.
  55928. */
  55929. readonly supportCascades: boolean;
  55930. /**
  55931. * This returns if the loader support the current file information.
  55932. * @param extension defines the file extension of the file being loaded
  55933. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55934. * @param fallback defines the fallback internal texture if any
  55935. * @param isBase64 defines whether the texture is encoded as a base64
  55936. * @param isBuffer defines whether the texture data are stored as a buffer
  55937. * @returns true if the loader can load the specified file
  55938. */
  55939. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  55940. /**
  55941. * Transform the url before loading if required.
  55942. * @param rootUrl the url of the texture
  55943. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55944. * @returns the transformed texture
  55945. */
  55946. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  55947. /**
  55948. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  55949. * @param rootUrl the url of the texture
  55950. * @param textureFormatInUse defines the current compressed format in use iun the engine
  55951. * @returns the fallback texture
  55952. */
  55953. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  55954. /**
  55955. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  55956. * @param data contains the texture data
  55957. * @param texture defines the BabylonJS internal texture
  55958. * @param createPolynomials will be true if polynomials have been requested
  55959. * @param onLoad defines the callback to trigger once the texture is ready
  55960. * @param onError defines the callback to trigger in case of error
  55961. */
  55962. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55963. /**
  55964. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  55965. * @param data contains the texture data
  55966. * @param texture defines the BabylonJS internal texture
  55967. * @param callback defines the method to call once ready to upload
  55968. */
  55969. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  55970. }
  55971. }
  55972. declare module BABYLON {
  55973. /**
  55974. * Info about the .basis files
  55975. */
  55976. class BasisFileInfo {
  55977. /**
  55978. * If the file has alpha
  55979. */
  55980. hasAlpha: boolean;
  55981. /**
  55982. * Info about each image of the basis file
  55983. */
  55984. images: Array<{
  55985. levels: Array<{
  55986. width: number;
  55987. height: number;
  55988. transcodedPixels: ArrayBufferView;
  55989. }>;
  55990. }>;
  55991. }
  55992. /**
  55993. * Result of transcoding a basis file
  55994. */
  55995. class TranscodeResult {
  55996. /**
  55997. * Info about the .basis file
  55998. */
  55999. fileInfo: BasisFileInfo;
  56000. /**
  56001. * Format to use when loading the file
  56002. */
  56003. format: number;
  56004. }
  56005. /**
  56006. * Configuration options for the Basis transcoder
  56007. */
  56008. export class BasisTranscodeConfiguration {
  56009. /**
  56010. * Supported compression formats used to determine the supported output format of the transcoder
  56011. */
  56012. supportedCompressionFormats?: {
  56013. /**
  56014. * etc1 compression format
  56015. */
  56016. etc1?: boolean;
  56017. /**
  56018. * s3tc compression format
  56019. */
  56020. s3tc?: boolean;
  56021. /**
  56022. * pvrtc compression format
  56023. */
  56024. pvrtc?: boolean;
  56025. /**
  56026. * etc2 compression format
  56027. */
  56028. etc2?: boolean;
  56029. };
  56030. /**
  56031. * If mipmap levels should be loaded for transcoded images (Default: true)
  56032. */
  56033. loadMipmapLevels?: boolean;
  56034. /**
  56035. * Index of a single image to load (Default: all images)
  56036. */
  56037. loadSingleImage?: number;
  56038. }
  56039. /**
  56040. * Used to load .Basis files
  56041. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  56042. */
  56043. export class BasisTools {
  56044. private static _IgnoreSupportedFormats;
  56045. /**
  56046. * URL to use when loading the basis transcoder
  56047. */
  56048. static JSModuleURL: string;
  56049. /**
  56050. * URL to use when loading the wasm module for the transcoder
  56051. */
  56052. static WasmModuleURL: string;
  56053. /**
  56054. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  56055. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  56056. * @returns internal format corresponding to the Basis format
  56057. */
  56058. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  56059. private static _WorkerPromise;
  56060. private static _Worker;
  56061. private static _actionId;
  56062. private static _CreateWorkerAsync;
  56063. /**
  56064. * Transcodes a loaded image file to compressed pixel data
  56065. * @param data image data to transcode
  56066. * @param config configuration options for the transcoding
  56067. * @returns a promise resulting in the transcoded image
  56068. */
  56069. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  56070. /**
  56071. * Loads a texture from the transcode result
  56072. * @param texture texture load to
  56073. * @param transcodeResult the result of transcoding the basis file to load from
  56074. */
  56075. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  56076. }
  56077. }
  56078. declare module BABYLON {
  56079. /**
  56080. * Loader for .basis file format
  56081. */
  56082. export class _BasisTextureLoader implements IInternalTextureLoader {
  56083. /**
  56084. * Defines whether the loader supports cascade loading the different faces.
  56085. */
  56086. readonly supportCascades: boolean;
  56087. /**
  56088. * This returns if the loader support the current file information.
  56089. * @param extension defines the file extension of the file being loaded
  56090. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56091. * @param fallback defines the fallback internal texture if any
  56092. * @param isBase64 defines whether the texture is encoded as a base64
  56093. * @param isBuffer defines whether the texture data are stored as a buffer
  56094. * @returns true if the loader can load the specified file
  56095. */
  56096. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  56097. /**
  56098. * Transform the url before loading if required.
  56099. * @param rootUrl the url of the texture
  56100. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56101. * @returns the transformed texture
  56102. */
  56103. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  56104. /**
  56105. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  56106. * @param rootUrl the url of the texture
  56107. * @param textureFormatInUse defines the current compressed format in use iun the engine
  56108. * @returns the fallback texture
  56109. */
  56110. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  56111. /**
  56112. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  56113. * @param data contains the texture data
  56114. * @param texture defines the BabylonJS internal texture
  56115. * @param createPolynomials will be true if polynomials have been requested
  56116. * @param onLoad defines the callback to trigger once the texture is ready
  56117. * @param onError defines the callback to trigger in case of error
  56118. */
  56119. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56120. /**
  56121. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  56122. * @param data contains the texture data
  56123. * @param texture defines the BabylonJS internal texture
  56124. * @param callback defines the method to call once ready to upload
  56125. */
  56126. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56127. }
  56128. }
  56129. declare module BABYLON {
  56130. /**
  56131. * 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.
  56132. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56133. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56134. */
  56135. export class CustomProceduralTexture extends ProceduralTexture {
  56136. private _animate;
  56137. private _time;
  56138. private _config;
  56139. private _texturePath;
  56140. /**
  56141. * Instantiates a new Custom Procedural Texture.
  56142. * 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.
  56143. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  56144. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  56145. * @param name Define the name of the texture
  56146. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  56147. * @param size Define the size of the texture to create
  56148. * @param scene Define the scene the texture belongs to
  56149. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  56150. * @param generateMipMaps Define if the texture should creates mip maps or not
  56151. */
  56152. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56153. private _loadJson;
  56154. /**
  56155. * Is the texture ready to be used ? (rendered at least once)
  56156. * @returns true if ready, otherwise, false.
  56157. */
  56158. isReady(): boolean;
  56159. /**
  56160. * Render the texture to its associated render target.
  56161. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  56162. */
  56163. render(useCameraPostProcess?: boolean): void;
  56164. /**
  56165. * Update the list of dependant textures samplers in the shader.
  56166. */
  56167. updateTextures(): void;
  56168. /**
  56169. * Update the uniform values of the procedural texture in the shader.
  56170. */
  56171. updateShaderUniforms(): void;
  56172. /**
  56173. * Define if the texture animates or not.
  56174. */
  56175. get animate(): boolean;
  56176. set animate(value: boolean);
  56177. }
  56178. }
  56179. declare module BABYLON {
  56180. /** @hidden */
  56181. export var noisePixelShader: {
  56182. name: string;
  56183. shader: string;
  56184. };
  56185. }
  56186. declare module BABYLON {
  56187. /**
  56188. * Class used to generate noise procedural textures
  56189. */
  56190. export class NoiseProceduralTexture extends ProceduralTexture {
  56191. private _time;
  56192. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  56193. brightness: number;
  56194. /** Defines the number of octaves to process */
  56195. octaves: number;
  56196. /** Defines the level of persistence (0.8 by default) */
  56197. persistence: number;
  56198. /** Gets or sets animation speed factor (default is 1) */
  56199. animationSpeedFactor: number;
  56200. /**
  56201. * Creates a new NoiseProceduralTexture
  56202. * @param name defines the name fo the texture
  56203. * @param size defines the size of the texture (default is 256)
  56204. * @param scene defines the hosting scene
  56205. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  56206. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  56207. */
  56208. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  56209. private _updateShaderUniforms;
  56210. protected _getDefines(): string;
  56211. /** Generate the current state of the procedural texture */
  56212. render(useCameraPostProcess?: boolean): void;
  56213. /**
  56214. * Serializes this noise procedural texture
  56215. * @returns a serialized noise procedural texture object
  56216. */
  56217. serialize(): any;
  56218. /**
  56219. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  56220. * @param parsedTexture defines parsed texture data
  56221. * @param scene defines the current scene
  56222. * @param rootUrl defines the root URL containing noise procedural texture information
  56223. * @returns a parsed NoiseProceduralTexture
  56224. */
  56225. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  56226. }
  56227. }
  56228. declare module BABYLON {
  56229. /**
  56230. * Raw cube texture where the raw buffers are passed in
  56231. */
  56232. export class RawCubeTexture extends CubeTexture {
  56233. /**
  56234. * Creates a cube texture where the raw buffers are passed in.
  56235. * @param scene defines the scene the texture is attached to
  56236. * @param data defines the array of data to use to create each face
  56237. * @param size defines the size of the textures
  56238. * @param format defines the format of the data
  56239. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  56240. * @param generateMipMaps defines if the engine should generate the mip levels
  56241. * @param invertY defines if data must be stored with Y axis inverted
  56242. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  56243. * @param compression defines the compression used (null by default)
  56244. */
  56245. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  56246. /**
  56247. * Updates the raw cube texture.
  56248. * @param data defines the data to store
  56249. * @param format defines the data format
  56250. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  56251. * @param invertY defines if data must be stored with Y axis inverted
  56252. * @param compression defines the compression used (null by default)
  56253. * @param level defines which level of the texture to update
  56254. */
  56255. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  56256. /**
  56257. * Updates a raw cube texture with RGBD encoded data.
  56258. * @param data defines the array of data [mipmap][face] to use to create each face
  56259. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  56260. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  56261. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  56262. * @returns a promsie that resolves when the operation is complete
  56263. */
  56264. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  56265. /**
  56266. * Clones the raw cube texture.
  56267. * @return a new cube texture
  56268. */
  56269. clone(): CubeTexture;
  56270. /** @hidden */
  56271. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  56272. }
  56273. }
  56274. declare module BABYLON {
  56275. /**
  56276. * Class used to store 3D textures containing user data
  56277. */
  56278. export class RawTexture3D extends Texture {
  56279. /** Gets or sets the texture format to use */
  56280. format: number;
  56281. private _engine;
  56282. /**
  56283. * Create a new RawTexture3D
  56284. * @param data defines the data of the texture
  56285. * @param width defines the width of the texture
  56286. * @param height defines the height of the texture
  56287. * @param depth defines the depth of the texture
  56288. * @param format defines the texture format to use
  56289. * @param scene defines the hosting scene
  56290. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56291. * @param invertY defines if texture must be stored with Y axis inverted
  56292. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56293. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56294. */
  56295. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56296. /** Gets or sets the texture format to use */
  56297. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56298. /**
  56299. * Update the texture with new data
  56300. * @param data defines the data to store in the texture
  56301. */
  56302. update(data: ArrayBufferView): void;
  56303. }
  56304. }
  56305. declare module BABYLON {
  56306. /**
  56307. * Class used to store 2D array textures containing user data
  56308. */
  56309. export class RawTexture2DArray extends Texture {
  56310. /** Gets or sets the texture format to use */
  56311. format: number;
  56312. private _engine;
  56313. /**
  56314. * Create a new RawTexture2DArray
  56315. * @param data defines the data of the texture
  56316. * @param width defines the width of the texture
  56317. * @param height defines the height of the texture
  56318. * @param depth defines the number of layers of the texture
  56319. * @param format defines the texture format to use
  56320. * @param scene defines the hosting scene
  56321. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  56322. * @param invertY defines if texture must be stored with Y axis inverted
  56323. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56324. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  56325. */
  56326. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  56327. /** Gets or sets the texture format to use */
  56328. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  56329. /**
  56330. * Update the texture with new data
  56331. * @param data defines the data to store in the texture
  56332. */
  56333. update(data: ArrayBufferView): void;
  56334. }
  56335. }
  56336. declare module BABYLON {
  56337. /**
  56338. * Creates a refraction texture used by refraction channel of the standard material.
  56339. * It is like a mirror but to see through a material.
  56340. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56341. */
  56342. export class RefractionTexture extends RenderTargetTexture {
  56343. /**
  56344. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  56345. * 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.
  56346. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56347. */
  56348. refractionPlane: Plane;
  56349. /**
  56350. * Define how deep under the surface we should see.
  56351. */
  56352. depth: number;
  56353. /**
  56354. * Creates a refraction texture used by refraction channel of the standard material.
  56355. * It is like a mirror but to see through a material.
  56356. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  56357. * @param name Define the texture name
  56358. * @param size Define the size of the underlying texture
  56359. * @param scene Define the scene the refraction belongs to
  56360. * @param generateMipMaps Define if we need to generate mips level for the refraction
  56361. */
  56362. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  56363. /**
  56364. * Clone the refraction texture.
  56365. * @returns the cloned texture
  56366. */
  56367. clone(): RefractionTexture;
  56368. /**
  56369. * Serialize the texture to a JSON representation you could use in Parse later on
  56370. * @returns the serialized JSON representation
  56371. */
  56372. serialize(): any;
  56373. }
  56374. }
  56375. declare module BABYLON {
  56376. /**
  56377. * Defines the options related to the creation of an HtmlElementTexture
  56378. */
  56379. export interface IHtmlElementTextureOptions {
  56380. /**
  56381. * Defines wether mip maps should be created or not.
  56382. */
  56383. generateMipMaps?: boolean;
  56384. /**
  56385. * Defines the sampling mode of the texture.
  56386. */
  56387. samplingMode?: number;
  56388. /**
  56389. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  56390. */
  56391. engine: Nullable<ThinEngine>;
  56392. /**
  56393. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  56394. */
  56395. scene: Nullable<Scene>;
  56396. }
  56397. /**
  56398. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  56399. * To be as efficient as possible depending on your constraints nothing aside the first upload
  56400. * is automatically managed.
  56401. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  56402. * in your application.
  56403. *
  56404. * As the update is not automatic, you need to call them manually.
  56405. */
  56406. export class HtmlElementTexture extends BaseTexture {
  56407. /**
  56408. * The texture URL.
  56409. */
  56410. element: HTMLVideoElement | HTMLCanvasElement;
  56411. private static readonly DefaultOptions;
  56412. private _textureMatrix;
  56413. private _engine;
  56414. private _isVideo;
  56415. private _generateMipMaps;
  56416. private _samplingMode;
  56417. /**
  56418. * Instantiates a HtmlElementTexture from the following parameters.
  56419. *
  56420. * @param name Defines the name of the texture
  56421. * @param element Defines the video or canvas the texture is filled with
  56422. * @param options Defines the other none mandatory texture creation options
  56423. */
  56424. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  56425. private _createInternalTexture;
  56426. /**
  56427. * Returns the texture matrix used in most of the material.
  56428. */
  56429. getTextureMatrix(): Matrix;
  56430. /**
  56431. * Updates the content of the texture.
  56432. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  56433. */
  56434. update(invertY?: Nullable<boolean>): void;
  56435. }
  56436. }
  56437. declare module BABYLON {
  56438. /**
  56439. * Defines the basic options interface of a TexturePacker Frame
  56440. */
  56441. export interface ITexturePackerFrame {
  56442. /**
  56443. * The frame ID
  56444. */
  56445. id: number;
  56446. /**
  56447. * The frames Scale
  56448. */
  56449. scale: Vector2;
  56450. /**
  56451. * The Frames offset
  56452. */
  56453. offset: Vector2;
  56454. }
  56455. /**
  56456. * This is a support class for frame Data on texture packer sets.
  56457. */
  56458. export class TexturePackerFrame implements ITexturePackerFrame {
  56459. /**
  56460. * The frame ID
  56461. */
  56462. id: number;
  56463. /**
  56464. * The frames Scale
  56465. */
  56466. scale: Vector2;
  56467. /**
  56468. * The Frames offset
  56469. */
  56470. offset: Vector2;
  56471. /**
  56472. * Initializes a texture package frame.
  56473. * @param id The numerical frame identifier
  56474. * @param scale Scalar Vector2 for UV frame
  56475. * @param offset Vector2 for the frame position in UV units.
  56476. * @returns TexturePackerFrame
  56477. */
  56478. constructor(id: number, scale: Vector2, offset: Vector2);
  56479. }
  56480. }
  56481. declare module BABYLON {
  56482. /**
  56483. * Defines the basic options interface of a TexturePacker
  56484. */
  56485. export interface ITexturePackerOptions {
  56486. /**
  56487. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  56488. */
  56489. map?: string[];
  56490. /**
  56491. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  56492. */
  56493. uvsIn?: string;
  56494. /**
  56495. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  56496. */
  56497. uvsOut?: string;
  56498. /**
  56499. * number representing the layout style. Defaults to LAYOUT_STRIP
  56500. */
  56501. layout?: number;
  56502. /**
  56503. * number of columns if using custom column count layout(2). This defaults to 4.
  56504. */
  56505. colnum?: number;
  56506. /**
  56507. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  56508. */
  56509. updateInputMeshes?: boolean;
  56510. /**
  56511. * boolean flag to dispose all the source textures. Defaults to true.
  56512. */
  56513. disposeSources?: boolean;
  56514. /**
  56515. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  56516. */
  56517. fillBlanks?: boolean;
  56518. /**
  56519. * string value representing the context fill style color. Defaults to 'black'.
  56520. */
  56521. customFillColor?: string;
  56522. /**
  56523. * Width and Height Value of each Frame in the TexturePacker Sets
  56524. */
  56525. frameSize?: number;
  56526. /**
  56527. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  56528. */
  56529. paddingRatio?: number;
  56530. /**
  56531. * Number that declares the fill method for the padding gutter.
  56532. */
  56533. paddingMode?: number;
  56534. /**
  56535. * If in SUBUV_COLOR padding mode what color to use.
  56536. */
  56537. paddingColor?: Color3 | Color4;
  56538. }
  56539. /**
  56540. * Defines the basic interface of a TexturePacker JSON File
  56541. */
  56542. export interface ITexturePackerJSON {
  56543. /**
  56544. * The frame ID
  56545. */
  56546. name: string;
  56547. /**
  56548. * The base64 channel data
  56549. */
  56550. sets: any;
  56551. /**
  56552. * The options of the Packer
  56553. */
  56554. options: ITexturePackerOptions;
  56555. /**
  56556. * The frame data of the Packer
  56557. */
  56558. frames: Array<number>;
  56559. }
  56560. /**
  56561. * This is a support class that generates a series of packed texture sets.
  56562. * @see https://doc.babylonjs.com/babylon101/materials
  56563. */
  56564. export class TexturePacker {
  56565. /** Packer Layout Constant 0 */
  56566. static readonly LAYOUT_STRIP: number;
  56567. /** Packer Layout Constant 1 */
  56568. static readonly LAYOUT_POWER2: number;
  56569. /** Packer Layout Constant 2 */
  56570. static readonly LAYOUT_COLNUM: number;
  56571. /** Packer Layout Constant 0 */
  56572. static readonly SUBUV_WRAP: number;
  56573. /** Packer Layout Constant 1 */
  56574. static readonly SUBUV_EXTEND: number;
  56575. /** Packer Layout Constant 2 */
  56576. static readonly SUBUV_COLOR: number;
  56577. /** The Name of the Texture Package */
  56578. name: string;
  56579. /** The scene scope of the TexturePacker */
  56580. scene: Scene;
  56581. /** The Meshes to target */
  56582. meshes: AbstractMesh[];
  56583. /** Arguments passed with the Constructor */
  56584. options: ITexturePackerOptions;
  56585. /** The promise that is started upon initialization */
  56586. promise: Nullable<Promise<TexturePacker | string>>;
  56587. /** The Container object for the channel sets that are generated */
  56588. sets: object;
  56589. /** The Container array for the frames that are generated */
  56590. frames: TexturePackerFrame[];
  56591. /** The expected number of textures the system is parsing. */
  56592. private _expecting;
  56593. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  56594. private _paddingValue;
  56595. /**
  56596. * Initializes a texture package series from an array of meshes or a single mesh.
  56597. * @param name The name of the package
  56598. * @param meshes The target meshes to compose the package from
  56599. * @param options The arguments that texture packer should follow while building.
  56600. * @param scene The scene which the textures are scoped to.
  56601. * @returns TexturePacker
  56602. */
  56603. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  56604. /**
  56605. * Starts the package process
  56606. * @param resolve The promises resolution function
  56607. * @returns TexturePacker
  56608. */
  56609. private _createFrames;
  56610. /**
  56611. * Calculates the Size of the Channel Sets
  56612. * @returns Vector2
  56613. */
  56614. private _calculateSize;
  56615. /**
  56616. * Calculates the UV data for the frames.
  56617. * @param baseSize the base frameSize
  56618. * @param padding the base frame padding
  56619. * @param dtSize size of the Dynamic Texture for that channel
  56620. * @param dtUnits is 1/dtSize
  56621. * @param update flag to update the input meshes
  56622. */
  56623. private _calculateMeshUVFrames;
  56624. /**
  56625. * Calculates the frames Offset.
  56626. * @param index of the frame
  56627. * @returns Vector2
  56628. */
  56629. private _getFrameOffset;
  56630. /**
  56631. * Updates a Mesh to the frame data
  56632. * @param mesh that is the target
  56633. * @param frameID or the frame index
  56634. */
  56635. private _updateMeshUV;
  56636. /**
  56637. * Updates a Meshes materials to use the texture packer channels
  56638. * @param m is the mesh to target
  56639. * @param force all channels on the packer to be set.
  56640. */
  56641. private _updateTextureReferences;
  56642. /**
  56643. * Public method to set a Mesh to a frame
  56644. * @param m that is the target
  56645. * @param frameID or the frame index
  56646. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  56647. */
  56648. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  56649. /**
  56650. * Starts the async promise to compile the texture packer.
  56651. * @returns Promise<void>
  56652. */
  56653. processAsync(): Promise<void>;
  56654. /**
  56655. * Disposes all textures associated with this packer
  56656. */
  56657. dispose(): void;
  56658. /**
  56659. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  56660. * @param imageType is the image type to use.
  56661. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  56662. */
  56663. download(imageType?: string, quality?: number): void;
  56664. /**
  56665. * Public method to load a texturePacker JSON file.
  56666. * @param data of the JSON file in string format.
  56667. */
  56668. updateFromJSON(data: string): void;
  56669. }
  56670. }
  56671. declare module BABYLON {
  56672. /**
  56673. * Enum used to define the target of a block
  56674. */
  56675. export enum NodeMaterialBlockTargets {
  56676. /** Vertex shader */
  56677. Vertex = 1,
  56678. /** Fragment shader */
  56679. Fragment = 2,
  56680. /** Neutral */
  56681. Neutral = 4,
  56682. /** Vertex and Fragment */
  56683. VertexAndFragment = 3
  56684. }
  56685. }
  56686. declare module BABYLON {
  56687. /**
  56688. * Defines the kind of connection point for node based material
  56689. */
  56690. export enum NodeMaterialBlockConnectionPointTypes {
  56691. /** Float */
  56692. Float = 1,
  56693. /** Int */
  56694. Int = 2,
  56695. /** Vector2 */
  56696. Vector2 = 4,
  56697. /** Vector3 */
  56698. Vector3 = 8,
  56699. /** Vector4 */
  56700. Vector4 = 16,
  56701. /** Color3 */
  56702. Color3 = 32,
  56703. /** Color4 */
  56704. Color4 = 64,
  56705. /** Matrix */
  56706. Matrix = 128,
  56707. /** Detect type based on connection */
  56708. AutoDetect = 1024,
  56709. /** Output type that will be defined by input type */
  56710. BasedOnInput = 2048
  56711. }
  56712. }
  56713. declare module BABYLON {
  56714. /**
  56715. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  56716. */
  56717. export enum NodeMaterialBlockConnectionPointMode {
  56718. /** Value is an uniform */
  56719. Uniform = 0,
  56720. /** Value is a mesh attribute */
  56721. Attribute = 1,
  56722. /** Value is a varying between vertex and fragment shaders */
  56723. Varying = 2,
  56724. /** Mode is undefined */
  56725. Undefined = 3
  56726. }
  56727. }
  56728. declare module BABYLON {
  56729. /**
  56730. * Enum used to define system values e.g. values automatically provided by the system
  56731. */
  56732. export enum NodeMaterialSystemValues {
  56733. /** World */
  56734. World = 1,
  56735. /** View */
  56736. View = 2,
  56737. /** Projection */
  56738. Projection = 3,
  56739. /** ViewProjection */
  56740. ViewProjection = 4,
  56741. /** WorldView */
  56742. WorldView = 5,
  56743. /** WorldViewProjection */
  56744. WorldViewProjection = 6,
  56745. /** CameraPosition */
  56746. CameraPosition = 7,
  56747. /** Fog Color */
  56748. FogColor = 8,
  56749. /** Delta time */
  56750. DeltaTime = 9
  56751. }
  56752. }
  56753. declare module BABYLON {
  56754. /**
  56755. * Root class for all node material optimizers
  56756. */
  56757. export class NodeMaterialOptimizer {
  56758. /**
  56759. * Function used to optimize a NodeMaterial graph
  56760. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  56761. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  56762. */
  56763. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  56764. }
  56765. }
  56766. declare module BABYLON {
  56767. /**
  56768. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  56769. */
  56770. export class TransformBlock extends NodeMaterialBlock {
  56771. /**
  56772. * Defines the value to use to complement W value to transform it to a Vector4
  56773. */
  56774. complementW: number;
  56775. /**
  56776. * Defines the value to use to complement z value to transform it to a Vector4
  56777. */
  56778. complementZ: number;
  56779. /**
  56780. * Creates a new TransformBlock
  56781. * @param name defines the block name
  56782. */
  56783. constructor(name: string);
  56784. /**
  56785. * Gets the current class name
  56786. * @returns the class name
  56787. */
  56788. getClassName(): string;
  56789. /**
  56790. * Gets the vector input
  56791. */
  56792. get vector(): NodeMaterialConnectionPoint;
  56793. /**
  56794. * Gets the output component
  56795. */
  56796. get output(): NodeMaterialConnectionPoint;
  56797. /**
  56798. * Gets the matrix transform input
  56799. */
  56800. get transform(): NodeMaterialConnectionPoint;
  56801. protected _buildBlock(state: NodeMaterialBuildState): this;
  56802. serialize(): any;
  56803. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56804. protected _dumpPropertiesCode(): string;
  56805. }
  56806. }
  56807. declare module BABYLON {
  56808. /**
  56809. * Block used to output the vertex position
  56810. */
  56811. export class VertexOutputBlock extends NodeMaterialBlock {
  56812. /**
  56813. * Creates a new VertexOutputBlock
  56814. * @param name defines the block name
  56815. */
  56816. constructor(name: string);
  56817. /**
  56818. * Gets the current class name
  56819. * @returns the class name
  56820. */
  56821. getClassName(): string;
  56822. /**
  56823. * Gets the vector input component
  56824. */
  56825. get vector(): NodeMaterialConnectionPoint;
  56826. protected _buildBlock(state: NodeMaterialBuildState): this;
  56827. }
  56828. }
  56829. declare module BABYLON {
  56830. /**
  56831. * Block used to output the final color
  56832. */
  56833. export class FragmentOutputBlock extends NodeMaterialBlock {
  56834. /**
  56835. * Create a new FragmentOutputBlock
  56836. * @param name defines the block name
  56837. */
  56838. constructor(name: string);
  56839. /**
  56840. * Gets the current class name
  56841. * @returns the class name
  56842. */
  56843. getClassName(): string;
  56844. /**
  56845. * Gets the rgba input component
  56846. */
  56847. get rgba(): NodeMaterialConnectionPoint;
  56848. /**
  56849. * Gets the rgb input component
  56850. */
  56851. get rgb(): NodeMaterialConnectionPoint;
  56852. /**
  56853. * Gets the a input component
  56854. */
  56855. get a(): NodeMaterialConnectionPoint;
  56856. protected _buildBlock(state: NodeMaterialBuildState): this;
  56857. }
  56858. }
  56859. declare module BABYLON {
  56860. /**
  56861. * Block used to read a reflection texture from a sampler
  56862. */
  56863. export class ReflectionTextureBlock extends NodeMaterialBlock {
  56864. private _define3DName;
  56865. private _defineCubicName;
  56866. private _defineExplicitName;
  56867. private _defineProjectionName;
  56868. private _defineLocalCubicName;
  56869. private _defineSphericalName;
  56870. private _definePlanarName;
  56871. private _defineEquirectangularName;
  56872. private _defineMirroredEquirectangularFixedName;
  56873. private _defineEquirectangularFixedName;
  56874. private _defineSkyboxName;
  56875. private _cubeSamplerName;
  56876. private _2DSamplerName;
  56877. private _positionUVWName;
  56878. private _directionWName;
  56879. private _reflectionCoordsName;
  56880. private _reflection2DCoordsName;
  56881. private _reflectionColorName;
  56882. private _reflectionMatrixName;
  56883. /**
  56884. * Gets or sets the texture associated with the node
  56885. */
  56886. texture: Nullable<BaseTexture>;
  56887. /**
  56888. * Create a new TextureBlock
  56889. * @param name defines the block name
  56890. */
  56891. constructor(name: string);
  56892. /**
  56893. * Gets the current class name
  56894. * @returns the class name
  56895. */
  56896. getClassName(): string;
  56897. /**
  56898. * Gets the world position input component
  56899. */
  56900. get position(): NodeMaterialConnectionPoint;
  56901. /**
  56902. * Gets the world position input component
  56903. */
  56904. get worldPosition(): NodeMaterialConnectionPoint;
  56905. /**
  56906. * Gets the world normal input component
  56907. */
  56908. get worldNormal(): NodeMaterialConnectionPoint;
  56909. /**
  56910. * Gets the world input component
  56911. */
  56912. get world(): NodeMaterialConnectionPoint;
  56913. /**
  56914. * Gets the camera (or eye) position component
  56915. */
  56916. get cameraPosition(): NodeMaterialConnectionPoint;
  56917. /**
  56918. * Gets the view input component
  56919. */
  56920. get view(): NodeMaterialConnectionPoint;
  56921. /**
  56922. * Gets the rgb output component
  56923. */
  56924. get rgb(): NodeMaterialConnectionPoint;
  56925. /**
  56926. * Gets the r output component
  56927. */
  56928. get r(): NodeMaterialConnectionPoint;
  56929. /**
  56930. * Gets the g output component
  56931. */
  56932. get g(): NodeMaterialConnectionPoint;
  56933. /**
  56934. * Gets the b output component
  56935. */
  56936. get b(): NodeMaterialConnectionPoint;
  56937. autoConfigure(material: NodeMaterial): void;
  56938. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56939. isReady(): boolean;
  56940. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56941. private _injectVertexCode;
  56942. private _writeOutput;
  56943. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56944. protected _dumpPropertiesCode(): string;
  56945. serialize(): any;
  56946. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56947. }
  56948. }
  56949. declare module BABYLON {
  56950. /**
  56951. * Interface used to configure the node material editor
  56952. */
  56953. export interface INodeMaterialEditorOptions {
  56954. /** Define the URl to load node editor script */
  56955. editorURL?: string;
  56956. }
  56957. /** @hidden */
  56958. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  56959. NORMAL: boolean;
  56960. TANGENT: boolean;
  56961. UV1: boolean;
  56962. /** BONES */
  56963. NUM_BONE_INFLUENCERS: number;
  56964. BonesPerMesh: number;
  56965. BONETEXTURE: boolean;
  56966. /** MORPH TARGETS */
  56967. MORPHTARGETS: boolean;
  56968. MORPHTARGETS_NORMAL: boolean;
  56969. MORPHTARGETS_TANGENT: boolean;
  56970. MORPHTARGETS_UV: boolean;
  56971. NUM_MORPH_INFLUENCERS: number;
  56972. /** IMAGE PROCESSING */
  56973. IMAGEPROCESSING: boolean;
  56974. VIGNETTE: boolean;
  56975. VIGNETTEBLENDMODEMULTIPLY: boolean;
  56976. VIGNETTEBLENDMODEOPAQUE: boolean;
  56977. TONEMAPPING: boolean;
  56978. TONEMAPPING_ACES: boolean;
  56979. CONTRAST: boolean;
  56980. EXPOSURE: boolean;
  56981. COLORCURVES: boolean;
  56982. COLORGRADING: boolean;
  56983. COLORGRADING3D: boolean;
  56984. SAMPLER3DGREENDEPTH: boolean;
  56985. SAMPLER3DBGRMAP: boolean;
  56986. IMAGEPROCESSINGPOSTPROCESS: boolean;
  56987. /** MISC. */
  56988. BUMPDIRECTUV: number;
  56989. constructor();
  56990. setValue(name: string, value: boolean): void;
  56991. }
  56992. /**
  56993. * Class used to configure NodeMaterial
  56994. */
  56995. export interface INodeMaterialOptions {
  56996. /**
  56997. * Defines if blocks should emit comments
  56998. */
  56999. emitComments: boolean;
  57000. }
  57001. /**
  57002. * Class used to create a node based material built by assembling shader blocks
  57003. */
  57004. export class NodeMaterial extends PushMaterial {
  57005. private static _BuildIdGenerator;
  57006. private _options;
  57007. private _vertexCompilationState;
  57008. private _fragmentCompilationState;
  57009. private _sharedData;
  57010. private _buildId;
  57011. private _buildWasSuccessful;
  57012. private _cachedWorldViewMatrix;
  57013. private _cachedWorldViewProjectionMatrix;
  57014. private _optimizers;
  57015. private _animationFrame;
  57016. /** Define the Url to load node editor script */
  57017. static EditorURL: string;
  57018. /** Define the Url to load snippets */
  57019. static SnippetUrl: string;
  57020. private BJSNODEMATERIALEDITOR;
  57021. /** Get the inspector from bundle or global */
  57022. private _getGlobalNodeMaterialEditor;
  57023. /**
  57024. * Gets or sets data used by visual editor
  57025. * @see https://nme.babylonjs.com
  57026. */
  57027. editorData: any;
  57028. /**
  57029. * 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)
  57030. */
  57031. ignoreAlpha: boolean;
  57032. /**
  57033. * Defines the maximum number of lights that can be used in the material
  57034. */
  57035. maxSimultaneousLights: number;
  57036. /**
  57037. * Observable raised when the material is built
  57038. */
  57039. onBuildObservable: Observable<NodeMaterial>;
  57040. /**
  57041. * Gets or sets the root nodes of the material vertex shader
  57042. */
  57043. _vertexOutputNodes: NodeMaterialBlock[];
  57044. /**
  57045. * Gets or sets the root nodes of the material fragment (pixel) shader
  57046. */
  57047. _fragmentOutputNodes: NodeMaterialBlock[];
  57048. /** Gets or sets options to control the node material overall behavior */
  57049. get options(): INodeMaterialOptions;
  57050. set options(options: INodeMaterialOptions);
  57051. /**
  57052. * Default configuration related to image processing available in the standard Material.
  57053. */
  57054. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57055. /**
  57056. * Gets the image processing configuration used either in this material.
  57057. */
  57058. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  57059. /**
  57060. * Sets the Default image processing configuration used either in the this material.
  57061. *
  57062. * If sets to null, the scene one is in use.
  57063. */
  57064. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  57065. /**
  57066. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  57067. */
  57068. attachedBlocks: NodeMaterialBlock[];
  57069. /**
  57070. * Create a new node based material
  57071. * @param name defines the material name
  57072. * @param scene defines the hosting scene
  57073. * @param options defines creation option
  57074. */
  57075. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  57076. /**
  57077. * Gets the current class name of the material e.g. "NodeMaterial"
  57078. * @returns the class name
  57079. */
  57080. getClassName(): string;
  57081. /**
  57082. * Keep track of the image processing observer to allow dispose and replace.
  57083. */
  57084. private _imageProcessingObserver;
  57085. /**
  57086. * Attaches a new image processing configuration to the Standard Material.
  57087. * @param configuration
  57088. */
  57089. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57090. /**
  57091. * Get a block by its name
  57092. * @param name defines the name of the block to retrieve
  57093. * @returns the required block or null if not found
  57094. */
  57095. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  57096. /**
  57097. * Get a block by its name
  57098. * @param predicate defines the predicate used to find the good candidate
  57099. * @returns the required block or null if not found
  57100. */
  57101. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  57102. /**
  57103. * Get an input block by its name
  57104. * @param predicate defines the predicate used to find the good candidate
  57105. * @returns the required input block or null if not found
  57106. */
  57107. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  57108. /**
  57109. * Gets the list of input blocks attached to this material
  57110. * @returns an array of InputBlocks
  57111. */
  57112. getInputBlocks(): InputBlock[];
  57113. /**
  57114. * Adds a new optimizer to the list of optimizers
  57115. * @param optimizer defines the optimizers to add
  57116. * @returns the current material
  57117. */
  57118. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57119. /**
  57120. * Remove an optimizer from the list of optimizers
  57121. * @param optimizer defines the optimizers to remove
  57122. * @returns the current material
  57123. */
  57124. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  57125. /**
  57126. * Add a new block to the list of output nodes
  57127. * @param node defines the node to add
  57128. * @returns the current material
  57129. */
  57130. addOutputNode(node: NodeMaterialBlock): this;
  57131. /**
  57132. * Remove a block from the list of root nodes
  57133. * @param node defines the node to remove
  57134. * @returns the current material
  57135. */
  57136. removeOutputNode(node: NodeMaterialBlock): this;
  57137. private _addVertexOutputNode;
  57138. private _removeVertexOutputNode;
  57139. private _addFragmentOutputNode;
  57140. private _removeFragmentOutputNode;
  57141. /**
  57142. * Specifies if the material will require alpha blending
  57143. * @returns a boolean specifying if alpha blending is needed
  57144. */
  57145. needAlphaBlending(): boolean;
  57146. /**
  57147. * Specifies if this material should be rendered in alpha test mode
  57148. * @returns a boolean specifying if an alpha test is needed.
  57149. */
  57150. needAlphaTesting(): boolean;
  57151. private _initializeBlock;
  57152. private _resetDualBlocks;
  57153. /**
  57154. * Remove a block from the current node material
  57155. * @param block defines the block to remove
  57156. */
  57157. removeBlock(block: NodeMaterialBlock): void;
  57158. /**
  57159. * Build the material and generates the inner effect
  57160. * @param verbose defines if the build should log activity
  57161. */
  57162. build(verbose?: boolean): void;
  57163. /**
  57164. * Runs an otpimization phase to try to improve the shader code
  57165. */
  57166. optimize(): void;
  57167. private _prepareDefinesForAttributes;
  57168. /**
  57169. * Get if the submesh is ready to be used and all its information available.
  57170. * Child classes can use it to update shaders
  57171. * @param mesh defines the mesh to check
  57172. * @param subMesh defines which submesh to check
  57173. * @param useInstances specifies that instances should be used
  57174. * @returns a boolean indicating that the submesh is ready or not
  57175. */
  57176. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57177. /**
  57178. * Get a string representing the shaders built by the current node graph
  57179. */
  57180. get compiledShaders(): string;
  57181. /**
  57182. * Binds the world matrix to the material
  57183. * @param world defines the world transformation matrix
  57184. */
  57185. bindOnlyWorldMatrix(world: Matrix): void;
  57186. /**
  57187. * Binds the submesh to this material by preparing the effect and shader to draw
  57188. * @param world defines the world transformation matrix
  57189. * @param mesh defines the mesh containing the submesh
  57190. * @param subMesh defines the submesh to bind the material to
  57191. */
  57192. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57193. /**
  57194. * Gets the active textures from the material
  57195. * @returns an array of textures
  57196. */
  57197. getActiveTextures(): BaseTexture[];
  57198. /**
  57199. * Gets the list of texture blocks
  57200. * @returns an array of texture blocks
  57201. */
  57202. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  57203. /**
  57204. * Specifies if the material uses a texture
  57205. * @param texture defines the texture to check against the material
  57206. * @returns a boolean specifying if the material uses the texture
  57207. */
  57208. hasTexture(texture: BaseTexture): boolean;
  57209. /**
  57210. * Disposes the material
  57211. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  57212. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  57213. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  57214. */
  57215. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  57216. /** Creates the node editor window. */
  57217. private _createNodeEditor;
  57218. /**
  57219. * Launch the node material editor
  57220. * @param config Define the configuration of the editor
  57221. * @return a promise fulfilled when the node editor is visible
  57222. */
  57223. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  57224. /**
  57225. * Clear the current material
  57226. */
  57227. clear(): void;
  57228. /**
  57229. * Clear the current material and set it to a default state
  57230. */
  57231. setToDefault(): void;
  57232. /**
  57233. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  57234. * @param url defines the url to load from
  57235. * @returns a promise that will fullfil when the material is fully loaded
  57236. */
  57237. loadAsync(url: string): Promise<void>;
  57238. private _gatherBlocks;
  57239. /**
  57240. * Generate a string containing the code declaration required to create an equivalent of this material
  57241. * @returns a string
  57242. */
  57243. generateCode(): string;
  57244. /**
  57245. * Serializes this material in a JSON representation
  57246. * @returns the serialized material object
  57247. */
  57248. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  57249. private _restoreConnections;
  57250. /**
  57251. * Clear the current graph and load a new one from a serialization object
  57252. * @param source defines the JSON representation of the material
  57253. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57254. */
  57255. loadFromSerialization(source: any, rootUrl?: string): void;
  57256. /**
  57257. * Creates a node material from parsed material data
  57258. * @param source defines the JSON representation of the material
  57259. * @param scene defines the hosting scene
  57260. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57261. * @returns a new node material
  57262. */
  57263. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  57264. /**
  57265. * Creates a node material from a snippet saved in a remote file
  57266. * @param name defines the name of the material to create
  57267. * @param url defines the url to load from
  57268. * @param scene defines the hosting scene
  57269. * @returns a promise that will resolve to the new node material
  57270. */
  57271. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  57272. /**
  57273. * Creates a node material from a snippet saved by the node material editor
  57274. * @param snippetId defines the snippet to load
  57275. * @param scene defines the hosting scene
  57276. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57277. * @returns a promise that will resolve to the new node material
  57278. */
  57279. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  57280. /**
  57281. * Creates a new node material set to default basic configuration
  57282. * @param name defines the name of the material
  57283. * @param scene defines the hosting scene
  57284. * @returns a new NodeMaterial
  57285. */
  57286. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  57287. }
  57288. }
  57289. declare module BABYLON {
  57290. /**
  57291. * Block used to read a texture from a sampler
  57292. */
  57293. export class TextureBlock extends NodeMaterialBlock {
  57294. private _defineName;
  57295. private _linearDefineName;
  57296. private _tempTextureRead;
  57297. private _samplerName;
  57298. private _transformedUVName;
  57299. private _textureTransformName;
  57300. private _textureInfoName;
  57301. private _mainUVName;
  57302. private _mainUVDefineName;
  57303. /**
  57304. * Gets or sets the texture associated with the node
  57305. */
  57306. texture: Nullable<Texture>;
  57307. /**
  57308. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  57309. */
  57310. convertToGammaSpace: boolean;
  57311. /**
  57312. * Create a new TextureBlock
  57313. * @param name defines the block name
  57314. */
  57315. constructor(name: string);
  57316. /**
  57317. * Gets the current class name
  57318. * @returns the class name
  57319. */
  57320. getClassName(): string;
  57321. /**
  57322. * Gets the uv input component
  57323. */
  57324. get uv(): NodeMaterialConnectionPoint;
  57325. /**
  57326. * Gets the rgba output component
  57327. */
  57328. get rgba(): NodeMaterialConnectionPoint;
  57329. /**
  57330. * Gets the rgb output component
  57331. */
  57332. get rgb(): NodeMaterialConnectionPoint;
  57333. /**
  57334. * Gets the r output component
  57335. */
  57336. get r(): NodeMaterialConnectionPoint;
  57337. /**
  57338. * Gets the g output component
  57339. */
  57340. get g(): NodeMaterialConnectionPoint;
  57341. /**
  57342. * Gets the b output component
  57343. */
  57344. get b(): NodeMaterialConnectionPoint;
  57345. /**
  57346. * Gets the a output component
  57347. */
  57348. get a(): NodeMaterialConnectionPoint;
  57349. get target(): NodeMaterialBlockTargets;
  57350. autoConfigure(material: NodeMaterial): void;
  57351. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57352. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  57353. isReady(): boolean;
  57354. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57355. private get _isMixed();
  57356. private _injectVertexCode;
  57357. private _writeTextureRead;
  57358. private _writeOutput;
  57359. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57360. protected _dumpPropertiesCode(): string;
  57361. serialize(): any;
  57362. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57363. }
  57364. }
  57365. declare module BABYLON {
  57366. /**
  57367. * Class used to store shared data between 2 NodeMaterialBuildState
  57368. */
  57369. export class NodeMaterialBuildStateSharedData {
  57370. /**
  57371. * Gets the list of emitted varyings
  57372. */
  57373. temps: string[];
  57374. /**
  57375. * Gets the list of emitted varyings
  57376. */
  57377. varyings: string[];
  57378. /**
  57379. * Gets the varying declaration string
  57380. */
  57381. varyingDeclaration: string;
  57382. /**
  57383. * Input blocks
  57384. */
  57385. inputBlocks: InputBlock[];
  57386. /**
  57387. * Input blocks
  57388. */
  57389. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  57390. /**
  57391. * Bindable blocks (Blocks that need to set data to the effect)
  57392. */
  57393. bindableBlocks: NodeMaterialBlock[];
  57394. /**
  57395. * List of blocks that can provide a compilation fallback
  57396. */
  57397. blocksWithFallbacks: NodeMaterialBlock[];
  57398. /**
  57399. * List of blocks that can provide a define update
  57400. */
  57401. blocksWithDefines: NodeMaterialBlock[];
  57402. /**
  57403. * List of blocks that can provide a repeatable content
  57404. */
  57405. repeatableContentBlocks: NodeMaterialBlock[];
  57406. /**
  57407. * List of blocks that can provide a dynamic list of uniforms
  57408. */
  57409. dynamicUniformBlocks: NodeMaterialBlock[];
  57410. /**
  57411. * List of blocks that can block the isReady function for the material
  57412. */
  57413. blockingBlocks: NodeMaterialBlock[];
  57414. /**
  57415. * Gets the list of animated inputs
  57416. */
  57417. animatedInputs: InputBlock[];
  57418. /**
  57419. * Build Id used to avoid multiple recompilations
  57420. */
  57421. buildId: number;
  57422. /** List of emitted variables */
  57423. variableNames: {
  57424. [key: string]: number;
  57425. };
  57426. /** List of emitted defines */
  57427. defineNames: {
  57428. [key: string]: number;
  57429. };
  57430. /** Should emit comments? */
  57431. emitComments: boolean;
  57432. /** Emit build activity */
  57433. verbose: boolean;
  57434. /** Gets or sets the hosting scene */
  57435. scene: Scene;
  57436. /**
  57437. * Gets the compilation hints emitted at compilation time
  57438. */
  57439. hints: {
  57440. needWorldViewMatrix: boolean;
  57441. needWorldViewProjectionMatrix: boolean;
  57442. needAlphaBlending: boolean;
  57443. needAlphaTesting: boolean;
  57444. };
  57445. /**
  57446. * List of compilation checks
  57447. */
  57448. checks: {
  57449. emitVertex: boolean;
  57450. emitFragment: boolean;
  57451. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  57452. };
  57453. /** Creates a new shared data */
  57454. constructor();
  57455. /**
  57456. * Emits console errors and exceptions if there is a failing check
  57457. */
  57458. emitErrors(): void;
  57459. }
  57460. }
  57461. declare module BABYLON {
  57462. /**
  57463. * Class used to store node based material build state
  57464. */
  57465. export class NodeMaterialBuildState {
  57466. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  57467. supportUniformBuffers: boolean;
  57468. /**
  57469. * Gets the list of emitted attributes
  57470. */
  57471. attributes: string[];
  57472. /**
  57473. * Gets the list of emitted uniforms
  57474. */
  57475. uniforms: string[];
  57476. /**
  57477. * Gets the list of emitted constants
  57478. */
  57479. constants: string[];
  57480. /**
  57481. * Gets the list of emitted samplers
  57482. */
  57483. samplers: string[];
  57484. /**
  57485. * Gets the list of emitted functions
  57486. */
  57487. functions: {
  57488. [key: string]: string;
  57489. };
  57490. /**
  57491. * Gets the list of emitted extensions
  57492. */
  57493. extensions: {
  57494. [key: string]: string;
  57495. };
  57496. /**
  57497. * Gets the target of the compilation state
  57498. */
  57499. target: NodeMaterialBlockTargets;
  57500. /**
  57501. * Gets the list of emitted counters
  57502. */
  57503. counters: {
  57504. [key: string]: number;
  57505. };
  57506. /**
  57507. * Shared data between multiple NodeMaterialBuildState instances
  57508. */
  57509. sharedData: NodeMaterialBuildStateSharedData;
  57510. /** @hidden */
  57511. _vertexState: NodeMaterialBuildState;
  57512. /** @hidden */
  57513. _attributeDeclaration: string;
  57514. /** @hidden */
  57515. _uniformDeclaration: string;
  57516. /** @hidden */
  57517. _constantDeclaration: string;
  57518. /** @hidden */
  57519. _samplerDeclaration: string;
  57520. /** @hidden */
  57521. _varyingTransfer: string;
  57522. private _repeatableContentAnchorIndex;
  57523. /** @hidden */
  57524. _builtCompilationString: string;
  57525. /**
  57526. * Gets the emitted compilation strings
  57527. */
  57528. compilationString: string;
  57529. /**
  57530. * Finalize the compilation strings
  57531. * @param state defines the current compilation state
  57532. */
  57533. finalize(state: NodeMaterialBuildState): void;
  57534. /** @hidden */
  57535. get _repeatableContentAnchor(): string;
  57536. /** @hidden */
  57537. _getFreeVariableName(prefix: string): string;
  57538. /** @hidden */
  57539. _getFreeDefineName(prefix: string): string;
  57540. /** @hidden */
  57541. _excludeVariableName(name: string): void;
  57542. /** @hidden */
  57543. _emit2DSampler(name: string): void;
  57544. /** @hidden */
  57545. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  57546. /** @hidden */
  57547. _emitExtension(name: string, extension: string): void;
  57548. /** @hidden */
  57549. _emitFunction(name: string, code: string, comments: string): void;
  57550. /** @hidden */
  57551. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  57552. replaceStrings?: {
  57553. search: RegExp;
  57554. replace: string;
  57555. }[];
  57556. repeatKey?: string;
  57557. }): string;
  57558. /** @hidden */
  57559. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  57560. repeatKey?: string;
  57561. removeAttributes?: boolean;
  57562. removeUniforms?: boolean;
  57563. removeVaryings?: boolean;
  57564. removeIfDef?: boolean;
  57565. replaceStrings?: {
  57566. search: RegExp;
  57567. replace: string;
  57568. }[];
  57569. }, storeKey?: string): void;
  57570. /** @hidden */
  57571. _registerTempVariable(name: string): boolean;
  57572. /** @hidden */
  57573. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  57574. /** @hidden */
  57575. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  57576. /** @hidden */
  57577. _emitFloat(value: number): string;
  57578. }
  57579. }
  57580. declare module BABYLON {
  57581. /**
  57582. * Defines a block that can be used inside a node based material
  57583. */
  57584. export class NodeMaterialBlock {
  57585. private _buildId;
  57586. private _buildTarget;
  57587. private _target;
  57588. private _isFinalMerger;
  57589. private _isInput;
  57590. protected _isUnique: boolean;
  57591. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  57592. inputsAreExclusive: boolean;
  57593. /** @hidden */
  57594. _codeVariableName: string;
  57595. /** @hidden */
  57596. _inputs: NodeMaterialConnectionPoint[];
  57597. /** @hidden */
  57598. _outputs: NodeMaterialConnectionPoint[];
  57599. /** @hidden */
  57600. _preparationId: number;
  57601. /**
  57602. * Gets or sets the name of the block
  57603. */
  57604. name: string;
  57605. /**
  57606. * Gets or sets the unique id of the node
  57607. */
  57608. uniqueId: number;
  57609. /**
  57610. * Gets or sets the comments associated with this block
  57611. */
  57612. comments: string;
  57613. /**
  57614. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  57615. */
  57616. get isUnique(): boolean;
  57617. /**
  57618. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  57619. */
  57620. get isFinalMerger(): boolean;
  57621. /**
  57622. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  57623. */
  57624. get isInput(): boolean;
  57625. /**
  57626. * Gets or sets the build Id
  57627. */
  57628. get buildId(): number;
  57629. set buildId(value: number);
  57630. /**
  57631. * Gets or sets the target of the block
  57632. */
  57633. get target(): NodeMaterialBlockTargets;
  57634. set target(value: NodeMaterialBlockTargets);
  57635. /**
  57636. * Gets the list of input points
  57637. */
  57638. get inputs(): NodeMaterialConnectionPoint[];
  57639. /** Gets the list of output points */
  57640. get outputs(): NodeMaterialConnectionPoint[];
  57641. /**
  57642. * Find an input by its name
  57643. * @param name defines the name of the input to look for
  57644. * @returns the input or null if not found
  57645. */
  57646. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  57647. /**
  57648. * Find an output by its name
  57649. * @param name defines the name of the outputto look for
  57650. * @returns the output or null if not found
  57651. */
  57652. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  57653. /**
  57654. * Creates a new NodeMaterialBlock
  57655. * @param name defines the block name
  57656. * @param target defines the target of that block (Vertex by default)
  57657. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  57658. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  57659. */
  57660. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  57661. /**
  57662. * Initialize the block and prepare the context for build
  57663. * @param state defines the state that will be used for the build
  57664. */
  57665. initialize(state: NodeMaterialBuildState): void;
  57666. /**
  57667. * Bind data to effect. Will only be called for blocks with isBindable === true
  57668. * @param effect defines the effect to bind data to
  57669. * @param nodeMaterial defines the hosting NodeMaterial
  57670. * @param mesh defines the mesh that will be rendered
  57671. */
  57672. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  57673. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  57674. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  57675. protected _writeFloat(value: number): string;
  57676. /**
  57677. * Gets the current class name e.g. "NodeMaterialBlock"
  57678. * @returns the class name
  57679. */
  57680. getClassName(): string;
  57681. /**
  57682. * Register a new input. Must be called inside a block constructor
  57683. * @param name defines the connection point name
  57684. * @param type defines the connection point type
  57685. * @param isOptional defines a boolean indicating that this input can be omitted
  57686. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  57687. * @returns the current block
  57688. */
  57689. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  57690. /**
  57691. * Register a new output. Must be called inside a block constructor
  57692. * @param name defines the connection point name
  57693. * @param type defines the connection point type
  57694. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  57695. * @returns the current block
  57696. */
  57697. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  57698. /**
  57699. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  57700. * @param forOutput defines an optional connection point to check compatibility with
  57701. * @returns the first available input or null
  57702. */
  57703. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  57704. /**
  57705. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  57706. * @param forBlock defines an optional block to check compatibility with
  57707. * @returns the first available input or null
  57708. */
  57709. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  57710. /**
  57711. * Gets the sibling of the given output
  57712. * @param current defines the current output
  57713. * @returns the next output in the list or null
  57714. */
  57715. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  57716. /**
  57717. * Connect current block with another block
  57718. * @param other defines the block to connect with
  57719. * @param options define the various options to help pick the right connections
  57720. * @returns the current block
  57721. */
  57722. connectTo(other: NodeMaterialBlock, options?: {
  57723. input?: string;
  57724. output?: string;
  57725. outputSwizzle?: string;
  57726. }): this | undefined;
  57727. protected _buildBlock(state: NodeMaterialBuildState): void;
  57728. /**
  57729. * Add uniforms, samplers and uniform buffers at compilation time
  57730. * @param state defines the state to update
  57731. * @param nodeMaterial defines the node material requesting the update
  57732. * @param defines defines the material defines to update
  57733. * @param uniformBuffers defines the list of uniform buffer names
  57734. */
  57735. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  57736. /**
  57737. * Add potential fallbacks if shader compilation fails
  57738. * @param mesh defines the mesh to be rendered
  57739. * @param fallbacks defines the current prioritized list of fallbacks
  57740. */
  57741. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  57742. /**
  57743. * Initialize defines for shader compilation
  57744. * @param mesh defines the mesh to be rendered
  57745. * @param nodeMaterial defines the node material requesting the update
  57746. * @param defines defines the material defines to update
  57747. * @param useInstances specifies that instances should be used
  57748. */
  57749. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57750. /**
  57751. * Update defines for shader compilation
  57752. * @param mesh defines the mesh to be rendered
  57753. * @param nodeMaterial defines the node material requesting the update
  57754. * @param defines defines the material defines to update
  57755. * @param useInstances specifies that instances should be used
  57756. */
  57757. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  57758. /**
  57759. * Lets the block try to connect some inputs automatically
  57760. * @param material defines the hosting NodeMaterial
  57761. */
  57762. autoConfigure(material: NodeMaterial): void;
  57763. /**
  57764. * Function called when a block is declared as repeatable content generator
  57765. * @param vertexShaderState defines the current compilation state for the vertex shader
  57766. * @param fragmentShaderState defines the current compilation state for the fragment shader
  57767. * @param mesh defines the mesh to be rendered
  57768. * @param defines defines the material defines to update
  57769. */
  57770. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  57771. /**
  57772. * Checks if the block is ready
  57773. * @param mesh defines the mesh to be rendered
  57774. * @param nodeMaterial defines the node material requesting the update
  57775. * @param defines defines the material defines to update
  57776. * @param useInstances specifies that instances should be used
  57777. * @returns true if the block is ready
  57778. */
  57779. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  57780. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  57781. private _processBuild;
  57782. /**
  57783. * Compile the current node and generate the shader code
  57784. * @param state defines the current compilation state (uniforms, samplers, current string)
  57785. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  57786. * @returns true if already built
  57787. */
  57788. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  57789. protected _inputRename(name: string): string;
  57790. protected _outputRename(name: string): string;
  57791. protected _dumpPropertiesCode(): string;
  57792. /** @hidden */
  57793. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  57794. /** @hidden */
  57795. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  57796. /**
  57797. * Clone the current block to a new identical block
  57798. * @param scene defines the hosting scene
  57799. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  57800. * @returns a copy of the current block
  57801. */
  57802. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  57803. /**
  57804. * Serializes this block in a JSON representation
  57805. * @returns the serialized block object
  57806. */
  57807. serialize(): any;
  57808. /** @hidden */
  57809. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57810. /**
  57811. * Release resources
  57812. */
  57813. dispose(): void;
  57814. }
  57815. }
  57816. declare module BABYLON {
  57817. /**
  57818. * Enum defining the type of animations supported by InputBlock
  57819. */
  57820. export enum AnimatedInputBlockTypes {
  57821. /** No animation */
  57822. None = 0,
  57823. /** Time based animation. Will only work for floats */
  57824. Time = 1
  57825. }
  57826. }
  57827. declare module BABYLON {
  57828. /**
  57829. * Block used to expose an input value
  57830. */
  57831. export class InputBlock extends NodeMaterialBlock {
  57832. private _mode;
  57833. private _associatedVariableName;
  57834. private _storedValue;
  57835. private _valueCallback;
  57836. private _type;
  57837. private _animationType;
  57838. /** Gets or set a value used to limit the range of float values */
  57839. min: number;
  57840. /** Gets or set a value used to limit the range of float values */
  57841. max: number;
  57842. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  57843. isBoolean: boolean;
  57844. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  57845. matrixMode: number;
  57846. /** @hidden */
  57847. _systemValue: Nullable<NodeMaterialSystemValues>;
  57848. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  57849. visibleInInspector: boolean;
  57850. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  57851. isConstant: boolean;
  57852. /** Gets or sets the group to use to display this block in the Inspector */
  57853. groupInInspector: string;
  57854. /**
  57855. * Gets or sets the connection point type (default is float)
  57856. */
  57857. get type(): NodeMaterialBlockConnectionPointTypes;
  57858. /**
  57859. * Creates a new InputBlock
  57860. * @param name defines the block name
  57861. * @param target defines the target of that block (Vertex by default)
  57862. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  57863. */
  57864. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  57865. /**
  57866. * Gets the output component
  57867. */
  57868. get output(): NodeMaterialConnectionPoint;
  57869. /**
  57870. * Set the source of this connection point to a vertex attribute
  57871. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  57872. * @returns the current connection point
  57873. */
  57874. setAsAttribute(attributeName?: string): InputBlock;
  57875. /**
  57876. * Set the source of this connection point to a system value
  57877. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  57878. * @returns the current connection point
  57879. */
  57880. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  57881. /**
  57882. * Gets or sets the value of that point.
  57883. * Please note that this value will be ignored if valueCallback is defined
  57884. */
  57885. get value(): any;
  57886. set value(value: any);
  57887. /**
  57888. * Gets or sets a callback used to get the value of that point.
  57889. * Please note that setting this value will force the connection point to ignore the value property
  57890. */
  57891. get valueCallback(): () => any;
  57892. set valueCallback(value: () => any);
  57893. /**
  57894. * Gets or sets the associated variable name in the shader
  57895. */
  57896. get associatedVariableName(): string;
  57897. set associatedVariableName(value: string);
  57898. /** Gets or sets the type of animation applied to the input */
  57899. get animationType(): AnimatedInputBlockTypes;
  57900. set animationType(value: AnimatedInputBlockTypes);
  57901. /**
  57902. * Gets a boolean indicating that this connection point not defined yet
  57903. */
  57904. get isUndefined(): boolean;
  57905. /**
  57906. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  57907. * In this case the connection point name must be the name of the uniform to use.
  57908. * Can only be set on inputs
  57909. */
  57910. get isUniform(): boolean;
  57911. set isUniform(value: boolean);
  57912. /**
  57913. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  57914. * In this case the connection point name must be the name of the attribute to use
  57915. * Can only be set on inputs
  57916. */
  57917. get isAttribute(): boolean;
  57918. set isAttribute(value: boolean);
  57919. /**
  57920. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  57921. * Can only be set on exit points
  57922. */
  57923. get isVarying(): boolean;
  57924. set isVarying(value: boolean);
  57925. /**
  57926. * Gets a boolean indicating that the current connection point is a system value
  57927. */
  57928. get isSystemValue(): boolean;
  57929. /**
  57930. * Gets or sets the current well known value or null if not defined as a system value
  57931. */
  57932. get systemValue(): Nullable<NodeMaterialSystemValues>;
  57933. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  57934. /**
  57935. * Gets the current class name
  57936. * @returns the class name
  57937. */
  57938. getClassName(): string;
  57939. /**
  57940. * Animate the input if animationType !== None
  57941. * @param scene defines the rendering scene
  57942. */
  57943. animate(scene: Scene): void;
  57944. private _emitDefine;
  57945. initialize(state: NodeMaterialBuildState): void;
  57946. /**
  57947. * Set the input block to its default value (based on its type)
  57948. */
  57949. setDefaultValue(): void;
  57950. private _emitConstant;
  57951. private _emit;
  57952. /** @hidden */
  57953. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  57954. /** @hidden */
  57955. _transmit(effect: Effect, scene: Scene): void;
  57956. protected _buildBlock(state: NodeMaterialBuildState): void;
  57957. protected _dumpPropertiesCode(): string;
  57958. serialize(): any;
  57959. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57960. }
  57961. }
  57962. declare module BABYLON {
  57963. /**
  57964. * Enum used to define the compatibility state between two connection points
  57965. */
  57966. export enum NodeMaterialConnectionPointCompatibilityStates {
  57967. /** Points are compatibles */
  57968. Compatible = 0,
  57969. /** Points are incompatible because of their types */
  57970. TypeIncompatible = 1,
  57971. /** Points are incompatible because of their targets (vertex vs fragment) */
  57972. TargetIncompatible = 2
  57973. }
  57974. /**
  57975. * Defines the direction of a connection point
  57976. */
  57977. export enum NodeMaterialConnectionPointDirection {
  57978. /** Input */
  57979. Input = 0,
  57980. /** Output */
  57981. Output = 1
  57982. }
  57983. /**
  57984. * Defines a connection point for a block
  57985. */
  57986. export class NodeMaterialConnectionPoint {
  57987. /** @hidden */
  57988. _ownerBlock: NodeMaterialBlock;
  57989. /** @hidden */
  57990. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  57991. private _endpoints;
  57992. private _associatedVariableName;
  57993. private _direction;
  57994. /** @hidden */
  57995. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  57996. /** @hidden */
  57997. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  57998. private _type;
  57999. /** @hidden */
  58000. _enforceAssociatedVariableName: boolean;
  58001. /** Gets the direction of the point */
  58002. get direction(): NodeMaterialConnectionPointDirection;
  58003. /**
  58004. * Gets or sets the additional types supported by this connection point
  58005. */
  58006. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58007. /**
  58008. * Gets or sets the additional types excluded by this connection point
  58009. */
  58010. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  58011. /**
  58012. * Observable triggered when this point is connected
  58013. */
  58014. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  58015. /**
  58016. * Gets or sets the associated variable name in the shader
  58017. */
  58018. get associatedVariableName(): string;
  58019. set associatedVariableName(value: string);
  58020. /** Get the inner type (ie AutoDetect for isntance instead of the inferred one) */
  58021. get innerType(): NodeMaterialBlockConnectionPointTypes;
  58022. /**
  58023. * Gets or sets the connection point type (default is float)
  58024. */
  58025. get type(): NodeMaterialBlockConnectionPointTypes;
  58026. set type(value: NodeMaterialBlockConnectionPointTypes);
  58027. /**
  58028. * Gets or sets the connection point name
  58029. */
  58030. name: string;
  58031. /**
  58032. * Gets or sets a boolean indicating that this connection point can be omitted
  58033. */
  58034. isOptional: boolean;
  58035. /**
  58036. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  58037. */
  58038. define: string;
  58039. /** @hidden */
  58040. _prioritizeVertex: boolean;
  58041. private _target;
  58042. /** Gets or sets the target of that connection point */
  58043. get target(): NodeMaterialBlockTargets;
  58044. set target(value: NodeMaterialBlockTargets);
  58045. /**
  58046. * Gets a boolean indicating that the current point is connected
  58047. */
  58048. get isConnected(): boolean;
  58049. /**
  58050. * Gets a boolean indicating that the current point is connected to an input block
  58051. */
  58052. get isConnectedToInputBlock(): boolean;
  58053. /**
  58054. * Gets a the connected input block (if any)
  58055. */
  58056. get connectInputBlock(): Nullable<InputBlock>;
  58057. /** Get the other side of the connection (if any) */
  58058. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  58059. /** Get the block that owns this connection point */
  58060. get ownerBlock(): NodeMaterialBlock;
  58061. /** Get the block connected on the other side of this connection (if any) */
  58062. get sourceBlock(): Nullable<NodeMaterialBlock>;
  58063. /** Get the block connected on the endpoints of this connection (if any) */
  58064. get connectedBlocks(): Array<NodeMaterialBlock>;
  58065. /** Gets the list of connected endpoints */
  58066. get endpoints(): NodeMaterialConnectionPoint[];
  58067. /** Gets a boolean indicating if that output point is connected to at least one input */
  58068. get hasEndpoints(): boolean;
  58069. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  58070. get isConnectedInVertexShader(): boolean;
  58071. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  58072. get isConnectedInFragmentShader(): boolean;
  58073. /**
  58074. * Creates a new connection point
  58075. * @param name defines the connection point name
  58076. * @param ownerBlock defines the block hosting this connection point
  58077. * @param direction defines the direction of the connection point
  58078. */
  58079. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  58080. /**
  58081. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  58082. * @returns the class name
  58083. */
  58084. getClassName(): string;
  58085. /**
  58086. * Gets a boolean indicating if the current point can be connected to another point
  58087. * @param connectionPoint defines the other connection point
  58088. * @returns a boolean
  58089. */
  58090. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  58091. /**
  58092. * Gets a number indicating if the current point can be connected to another point
  58093. * @param connectionPoint defines the other connection point
  58094. * @returns a number defining the compatibility state
  58095. */
  58096. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  58097. /**
  58098. * Connect this point to another connection point
  58099. * @param connectionPoint defines the other connection point
  58100. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  58101. * @returns the current connection point
  58102. */
  58103. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  58104. /**
  58105. * Disconnect this point from one of his endpoint
  58106. * @param endpoint defines the other connection point
  58107. * @returns the current connection point
  58108. */
  58109. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  58110. /**
  58111. * Serializes this point in a JSON representation
  58112. * @returns the serialized point object
  58113. */
  58114. serialize(): any;
  58115. /**
  58116. * Release resources
  58117. */
  58118. dispose(): void;
  58119. }
  58120. }
  58121. declare module BABYLON {
  58122. /**
  58123. * Block used to add support for vertex skinning (bones)
  58124. */
  58125. export class BonesBlock extends NodeMaterialBlock {
  58126. /**
  58127. * Creates a new BonesBlock
  58128. * @param name defines the block name
  58129. */
  58130. constructor(name: string);
  58131. /**
  58132. * Initialize the block and prepare the context for build
  58133. * @param state defines the state that will be used for the build
  58134. */
  58135. initialize(state: NodeMaterialBuildState): void;
  58136. /**
  58137. * Gets the current class name
  58138. * @returns the class name
  58139. */
  58140. getClassName(): string;
  58141. /**
  58142. * Gets the matrix indices input component
  58143. */
  58144. get matricesIndices(): NodeMaterialConnectionPoint;
  58145. /**
  58146. * Gets the matrix weights input component
  58147. */
  58148. get matricesWeights(): NodeMaterialConnectionPoint;
  58149. /**
  58150. * Gets the extra matrix indices input component
  58151. */
  58152. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  58153. /**
  58154. * Gets the extra matrix weights input component
  58155. */
  58156. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  58157. /**
  58158. * Gets the world input component
  58159. */
  58160. get world(): NodeMaterialConnectionPoint;
  58161. /**
  58162. * Gets the output component
  58163. */
  58164. get output(): NodeMaterialConnectionPoint;
  58165. autoConfigure(material: NodeMaterial): void;
  58166. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  58167. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58168. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58169. protected _buildBlock(state: NodeMaterialBuildState): this;
  58170. }
  58171. }
  58172. declare module BABYLON {
  58173. /**
  58174. * Block used to add support for instances
  58175. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  58176. */
  58177. export class InstancesBlock extends NodeMaterialBlock {
  58178. /**
  58179. * Creates a new InstancesBlock
  58180. * @param name defines the block name
  58181. */
  58182. constructor(name: string);
  58183. /**
  58184. * Gets the current class name
  58185. * @returns the class name
  58186. */
  58187. getClassName(): string;
  58188. /**
  58189. * Gets the first world row input component
  58190. */
  58191. get world0(): NodeMaterialConnectionPoint;
  58192. /**
  58193. * Gets the second world row input component
  58194. */
  58195. get world1(): NodeMaterialConnectionPoint;
  58196. /**
  58197. * Gets the third world row input component
  58198. */
  58199. get world2(): NodeMaterialConnectionPoint;
  58200. /**
  58201. * Gets the forth world row input component
  58202. */
  58203. get world3(): NodeMaterialConnectionPoint;
  58204. /**
  58205. * Gets the world input component
  58206. */
  58207. get world(): NodeMaterialConnectionPoint;
  58208. /**
  58209. * Gets the output component
  58210. */
  58211. get output(): NodeMaterialConnectionPoint;
  58212. /**
  58213. * Gets the isntanceID component
  58214. */
  58215. get instanceID(): NodeMaterialConnectionPoint;
  58216. autoConfigure(material: NodeMaterial): void;
  58217. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  58218. protected _buildBlock(state: NodeMaterialBuildState): this;
  58219. }
  58220. }
  58221. declare module BABYLON {
  58222. /**
  58223. * Block used to add morph targets support to vertex shader
  58224. */
  58225. export class MorphTargetsBlock extends NodeMaterialBlock {
  58226. private _repeatableContentAnchor;
  58227. /**
  58228. * Create a new MorphTargetsBlock
  58229. * @param name defines the block name
  58230. */
  58231. constructor(name: string);
  58232. /**
  58233. * Gets the current class name
  58234. * @returns the class name
  58235. */
  58236. getClassName(): string;
  58237. /**
  58238. * Gets the position input component
  58239. */
  58240. get position(): NodeMaterialConnectionPoint;
  58241. /**
  58242. * Gets the normal input component
  58243. */
  58244. get normal(): NodeMaterialConnectionPoint;
  58245. /**
  58246. * Gets the tangent input component
  58247. */
  58248. get tangent(): NodeMaterialConnectionPoint;
  58249. /**
  58250. * Gets the tangent input component
  58251. */
  58252. get uv(): NodeMaterialConnectionPoint;
  58253. /**
  58254. * Gets the position output component
  58255. */
  58256. get positionOutput(): NodeMaterialConnectionPoint;
  58257. /**
  58258. * Gets the normal output component
  58259. */
  58260. get normalOutput(): NodeMaterialConnectionPoint;
  58261. /**
  58262. * Gets the tangent output component
  58263. */
  58264. get tangentOutput(): NodeMaterialConnectionPoint;
  58265. /**
  58266. * Gets the tangent output component
  58267. */
  58268. get uvOutput(): NodeMaterialConnectionPoint;
  58269. initialize(state: NodeMaterialBuildState): void;
  58270. autoConfigure(material: NodeMaterial): void;
  58271. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58272. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58273. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  58274. protected _buildBlock(state: NodeMaterialBuildState): this;
  58275. }
  58276. }
  58277. declare module BABYLON {
  58278. /**
  58279. * Block used to get data information from a light
  58280. */
  58281. export class LightInformationBlock extends NodeMaterialBlock {
  58282. private _lightDataUniformName;
  58283. private _lightColorUniformName;
  58284. private _lightTypeDefineName;
  58285. /**
  58286. * Gets or sets the light associated with this block
  58287. */
  58288. light: Nullable<Light>;
  58289. /**
  58290. * Creates a new LightInformationBlock
  58291. * @param name defines the block name
  58292. */
  58293. constructor(name: string);
  58294. /**
  58295. * Gets the current class name
  58296. * @returns the class name
  58297. */
  58298. getClassName(): string;
  58299. /**
  58300. * Gets the world position input component
  58301. */
  58302. get worldPosition(): NodeMaterialConnectionPoint;
  58303. /**
  58304. * Gets the direction output component
  58305. */
  58306. get direction(): NodeMaterialConnectionPoint;
  58307. /**
  58308. * Gets the direction output component
  58309. */
  58310. get color(): NodeMaterialConnectionPoint;
  58311. /**
  58312. * Gets the direction output component
  58313. */
  58314. get intensity(): NodeMaterialConnectionPoint;
  58315. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58316. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58317. protected _buildBlock(state: NodeMaterialBuildState): this;
  58318. serialize(): any;
  58319. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58320. }
  58321. }
  58322. declare module BABYLON {
  58323. /**
  58324. * Block used to add image processing support to fragment shader
  58325. */
  58326. export class ImageProcessingBlock extends NodeMaterialBlock {
  58327. /**
  58328. * Create a new ImageProcessingBlock
  58329. * @param name defines the block name
  58330. */
  58331. constructor(name: string);
  58332. /**
  58333. * Gets the current class name
  58334. * @returns the class name
  58335. */
  58336. getClassName(): string;
  58337. /**
  58338. * Gets the color input component
  58339. */
  58340. get color(): NodeMaterialConnectionPoint;
  58341. /**
  58342. * Gets the output component
  58343. */
  58344. get output(): NodeMaterialConnectionPoint;
  58345. /**
  58346. * Initialize the block and prepare the context for build
  58347. * @param state defines the state that will be used for the build
  58348. */
  58349. initialize(state: NodeMaterialBuildState): void;
  58350. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  58351. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58352. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58353. protected _buildBlock(state: NodeMaterialBuildState): this;
  58354. }
  58355. }
  58356. declare module BABYLON {
  58357. /**
  58358. * Block used to pertub normals based on a normal map
  58359. */
  58360. export class PerturbNormalBlock extends NodeMaterialBlock {
  58361. private _tangentSpaceParameterName;
  58362. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  58363. invertX: boolean;
  58364. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  58365. invertY: boolean;
  58366. /**
  58367. * Create a new PerturbNormalBlock
  58368. * @param name defines the block name
  58369. */
  58370. constructor(name: string);
  58371. /**
  58372. * Gets the current class name
  58373. * @returns the class name
  58374. */
  58375. getClassName(): string;
  58376. /**
  58377. * Gets the world position input component
  58378. */
  58379. get worldPosition(): NodeMaterialConnectionPoint;
  58380. /**
  58381. * Gets the world normal input component
  58382. */
  58383. get worldNormal(): NodeMaterialConnectionPoint;
  58384. /**
  58385. * Gets the world tangent input component
  58386. */
  58387. get worldTangent(): NodeMaterialConnectionPoint;
  58388. /**
  58389. * Gets the uv input component
  58390. */
  58391. get uv(): NodeMaterialConnectionPoint;
  58392. /**
  58393. * Gets the normal map color input component
  58394. */
  58395. get normalMapColor(): NodeMaterialConnectionPoint;
  58396. /**
  58397. * Gets the strength input component
  58398. */
  58399. get strength(): NodeMaterialConnectionPoint;
  58400. /**
  58401. * Gets the output component
  58402. */
  58403. get output(): NodeMaterialConnectionPoint;
  58404. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58405. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58406. autoConfigure(material: NodeMaterial): void;
  58407. protected _buildBlock(state: NodeMaterialBuildState): this;
  58408. protected _dumpPropertiesCode(): string;
  58409. serialize(): any;
  58410. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58411. }
  58412. }
  58413. declare module BABYLON {
  58414. /**
  58415. * Block used to discard a pixel if a value is smaller than a cutoff
  58416. */
  58417. export class DiscardBlock extends NodeMaterialBlock {
  58418. /**
  58419. * Create a new DiscardBlock
  58420. * @param name defines the block name
  58421. */
  58422. constructor(name: string);
  58423. /**
  58424. * Gets the current class name
  58425. * @returns the class name
  58426. */
  58427. getClassName(): string;
  58428. /**
  58429. * Gets the color input component
  58430. */
  58431. get value(): NodeMaterialConnectionPoint;
  58432. /**
  58433. * Gets the cutoff input component
  58434. */
  58435. get cutoff(): NodeMaterialConnectionPoint;
  58436. protected _buildBlock(state: NodeMaterialBuildState): this;
  58437. }
  58438. }
  58439. declare module BABYLON {
  58440. /**
  58441. * Block used to test if the fragment shader is front facing
  58442. */
  58443. export class FrontFacingBlock extends NodeMaterialBlock {
  58444. /**
  58445. * Creates a new FrontFacingBlock
  58446. * @param name defines the block name
  58447. */
  58448. constructor(name: string);
  58449. /**
  58450. * Gets the current class name
  58451. * @returns the class name
  58452. */
  58453. getClassName(): string;
  58454. /**
  58455. * Gets the output component
  58456. */
  58457. get output(): NodeMaterialConnectionPoint;
  58458. protected _buildBlock(state: NodeMaterialBuildState): this;
  58459. }
  58460. }
  58461. declare module BABYLON {
  58462. /**
  58463. * Block used to get the derivative value on x and y of a given input
  58464. */
  58465. export class DerivativeBlock extends NodeMaterialBlock {
  58466. /**
  58467. * Create a new DerivativeBlock
  58468. * @param name defines the block name
  58469. */
  58470. constructor(name: string);
  58471. /**
  58472. * Gets the current class name
  58473. * @returns the class name
  58474. */
  58475. getClassName(): string;
  58476. /**
  58477. * Gets the input component
  58478. */
  58479. get input(): NodeMaterialConnectionPoint;
  58480. /**
  58481. * Gets the derivative output on x
  58482. */
  58483. get dx(): NodeMaterialConnectionPoint;
  58484. /**
  58485. * Gets the derivative output on y
  58486. */
  58487. get dy(): NodeMaterialConnectionPoint;
  58488. protected _buildBlock(state: NodeMaterialBuildState): this;
  58489. }
  58490. }
  58491. declare module BABYLON {
  58492. /**
  58493. * Block used to add support for scene fog
  58494. */
  58495. export class FogBlock extends NodeMaterialBlock {
  58496. private _fogDistanceName;
  58497. private _fogParameters;
  58498. /**
  58499. * Create a new FogBlock
  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 world position input component
  58510. */
  58511. get worldPosition(): NodeMaterialConnectionPoint;
  58512. /**
  58513. * Gets the view input component
  58514. */
  58515. get view(): NodeMaterialConnectionPoint;
  58516. /**
  58517. * Gets the color input component
  58518. */
  58519. get input(): NodeMaterialConnectionPoint;
  58520. /**
  58521. * Gets the fog color input component
  58522. */
  58523. get fogColor(): NodeMaterialConnectionPoint;
  58524. /**
  58525. * Gets the output component
  58526. */
  58527. get output(): NodeMaterialConnectionPoint;
  58528. autoConfigure(material: NodeMaterial): void;
  58529. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58530. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58531. protected _buildBlock(state: NodeMaterialBuildState): this;
  58532. }
  58533. }
  58534. declare module BABYLON {
  58535. /**
  58536. * Block used to add light in the fragment shader
  58537. */
  58538. export class LightBlock extends NodeMaterialBlock {
  58539. private _lightId;
  58540. /**
  58541. * Gets or sets the light associated with this block
  58542. */
  58543. light: Nullable<Light>;
  58544. /**
  58545. * Create a new LightBlock
  58546. * @param name defines the block name
  58547. */
  58548. constructor(name: string);
  58549. /**
  58550. * Gets the current class name
  58551. * @returns the class name
  58552. */
  58553. getClassName(): string;
  58554. /**
  58555. * Gets the world position input component
  58556. */
  58557. get worldPosition(): NodeMaterialConnectionPoint;
  58558. /**
  58559. * Gets the world normal input component
  58560. */
  58561. get worldNormal(): NodeMaterialConnectionPoint;
  58562. /**
  58563. * Gets the camera (or eye) position component
  58564. */
  58565. get cameraPosition(): NodeMaterialConnectionPoint;
  58566. /**
  58567. * Gets the glossiness component
  58568. */
  58569. get glossiness(): NodeMaterialConnectionPoint;
  58570. /**
  58571. * Gets the glossinness power component
  58572. */
  58573. get glossPower(): NodeMaterialConnectionPoint;
  58574. /**
  58575. * Gets the diffuse color component
  58576. */
  58577. get diffuseColor(): NodeMaterialConnectionPoint;
  58578. /**
  58579. * Gets the specular color component
  58580. */
  58581. get specularColor(): NodeMaterialConnectionPoint;
  58582. /**
  58583. * Gets the diffuse output component
  58584. */
  58585. get diffuseOutput(): NodeMaterialConnectionPoint;
  58586. /**
  58587. * Gets the specular output component
  58588. */
  58589. get specularOutput(): NodeMaterialConnectionPoint;
  58590. /**
  58591. * Gets the shadow output component
  58592. */
  58593. get shadow(): NodeMaterialConnectionPoint;
  58594. autoConfigure(material: NodeMaterial): void;
  58595. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  58596. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  58597. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  58598. private _injectVertexCode;
  58599. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58600. serialize(): any;
  58601. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58602. }
  58603. }
  58604. declare module BABYLON {
  58605. /**
  58606. * Block used to multiply 2 values
  58607. */
  58608. export class MultiplyBlock extends NodeMaterialBlock {
  58609. /**
  58610. * Creates a new MultiplyBlock
  58611. * @param name defines the block name
  58612. */
  58613. constructor(name: string);
  58614. /**
  58615. * Gets the current class name
  58616. * @returns the class name
  58617. */
  58618. getClassName(): string;
  58619. /**
  58620. * Gets the left operand input component
  58621. */
  58622. get left(): NodeMaterialConnectionPoint;
  58623. /**
  58624. * Gets the right operand input component
  58625. */
  58626. get right(): NodeMaterialConnectionPoint;
  58627. /**
  58628. * Gets the output component
  58629. */
  58630. get output(): NodeMaterialConnectionPoint;
  58631. protected _buildBlock(state: NodeMaterialBuildState): this;
  58632. }
  58633. }
  58634. declare module BABYLON {
  58635. /**
  58636. * Block used to add 2 vectors
  58637. */
  58638. export class AddBlock extends NodeMaterialBlock {
  58639. /**
  58640. * Creates a new AddBlock
  58641. * @param name defines the block name
  58642. */
  58643. constructor(name: string);
  58644. /**
  58645. * Gets the current class name
  58646. * @returns the class name
  58647. */
  58648. getClassName(): string;
  58649. /**
  58650. * Gets the left operand input component
  58651. */
  58652. get left(): NodeMaterialConnectionPoint;
  58653. /**
  58654. * Gets the right operand input component
  58655. */
  58656. get right(): NodeMaterialConnectionPoint;
  58657. /**
  58658. * Gets the output component
  58659. */
  58660. get output(): NodeMaterialConnectionPoint;
  58661. protected _buildBlock(state: NodeMaterialBuildState): this;
  58662. }
  58663. }
  58664. declare module BABYLON {
  58665. /**
  58666. * Block used to scale a vector by a float
  58667. */
  58668. export class ScaleBlock extends NodeMaterialBlock {
  58669. /**
  58670. * Creates a new ScaleBlock
  58671. * @param name defines the block name
  58672. */
  58673. constructor(name: string);
  58674. /**
  58675. * Gets the current class name
  58676. * @returns the class name
  58677. */
  58678. getClassName(): string;
  58679. /**
  58680. * Gets the input component
  58681. */
  58682. get input(): NodeMaterialConnectionPoint;
  58683. /**
  58684. * Gets the factor input component
  58685. */
  58686. get factor(): NodeMaterialConnectionPoint;
  58687. /**
  58688. * Gets the output component
  58689. */
  58690. get output(): NodeMaterialConnectionPoint;
  58691. protected _buildBlock(state: NodeMaterialBuildState): this;
  58692. }
  58693. }
  58694. declare module BABYLON {
  58695. /**
  58696. * Block used to clamp a float
  58697. */
  58698. export class ClampBlock extends NodeMaterialBlock {
  58699. /** Gets or sets the minimum range */
  58700. minimum: number;
  58701. /** Gets or sets the maximum range */
  58702. maximum: number;
  58703. /**
  58704. * Creates a new ClampBlock
  58705. * @param name defines the block name
  58706. */
  58707. constructor(name: string);
  58708. /**
  58709. * Gets the current class name
  58710. * @returns the class name
  58711. */
  58712. getClassName(): string;
  58713. /**
  58714. * Gets the value input component
  58715. */
  58716. get value(): NodeMaterialConnectionPoint;
  58717. /**
  58718. * Gets the output component
  58719. */
  58720. get output(): NodeMaterialConnectionPoint;
  58721. protected _buildBlock(state: NodeMaterialBuildState): this;
  58722. protected _dumpPropertiesCode(): string;
  58723. serialize(): any;
  58724. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58725. }
  58726. }
  58727. declare module BABYLON {
  58728. /**
  58729. * Block used to apply a cross product between 2 vectors
  58730. */
  58731. export class CrossBlock extends NodeMaterialBlock {
  58732. /**
  58733. * Creates a new CrossBlock
  58734. * @param name defines the block name
  58735. */
  58736. constructor(name: string);
  58737. /**
  58738. * Gets the current class name
  58739. * @returns the class name
  58740. */
  58741. getClassName(): string;
  58742. /**
  58743. * Gets the left operand input component
  58744. */
  58745. get left(): NodeMaterialConnectionPoint;
  58746. /**
  58747. * Gets the right operand input component
  58748. */
  58749. get right(): NodeMaterialConnectionPoint;
  58750. /**
  58751. * Gets the output component
  58752. */
  58753. get output(): NodeMaterialConnectionPoint;
  58754. protected _buildBlock(state: NodeMaterialBuildState): this;
  58755. }
  58756. }
  58757. declare module BABYLON {
  58758. /**
  58759. * Block used to apply a dot product between 2 vectors
  58760. */
  58761. export class DotBlock extends NodeMaterialBlock {
  58762. /**
  58763. * Creates a new DotBlock
  58764. * @param name defines the block name
  58765. */
  58766. constructor(name: string);
  58767. /**
  58768. * Gets the current class name
  58769. * @returns the class name
  58770. */
  58771. getClassName(): string;
  58772. /**
  58773. * Gets the left operand input component
  58774. */
  58775. get left(): NodeMaterialConnectionPoint;
  58776. /**
  58777. * Gets the right operand input component
  58778. */
  58779. get right(): NodeMaterialConnectionPoint;
  58780. /**
  58781. * Gets the output component
  58782. */
  58783. get output(): NodeMaterialConnectionPoint;
  58784. protected _buildBlock(state: NodeMaterialBuildState): this;
  58785. }
  58786. }
  58787. declare module BABYLON {
  58788. /**
  58789. * Block used to remap a float from a range to a new one
  58790. */
  58791. export class RemapBlock extends NodeMaterialBlock {
  58792. /**
  58793. * Gets or sets the source range
  58794. */
  58795. sourceRange: Vector2;
  58796. /**
  58797. * Gets or sets the target range
  58798. */
  58799. targetRange: Vector2;
  58800. /**
  58801. * Creates a new RemapBlock
  58802. * @param name defines the block name
  58803. */
  58804. constructor(name: string);
  58805. /**
  58806. * Gets the current class name
  58807. * @returns the class name
  58808. */
  58809. getClassName(): string;
  58810. /**
  58811. * Gets the input component
  58812. */
  58813. get input(): NodeMaterialConnectionPoint;
  58814. /**
  58815. * Gets the source min input component
  58816. */
  58817. get sourceMin(): NodeMaterialConnectionPoint;
  58818. /**
  58819. * Gets the source max input component
  58820. */
  58821. get sourceMax(): NodeMaterialConnectionPoint;
  58822. /**
  58823. * Gets the target min input component
  58824. */
  58825. get targetMin(): NodeMaterialConnectionPoint;
  58826. /**
  58827. * Gets the target max input component
  58828. */
  58829. get targetMax(): NodeMaterialConnectionPoint;
  58830. /**
  58831. * Gets the output component
  58832. */
  58833. get output(): NodeMaterialConnectionPoint;
  58834. protected _buildBlock(state: NodeMaterialBuildState): this;
  58835. protected _dumpPropertiesCode(): string;
  58836. serialize(): any;
  58837. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58838. }
  58839. }
  58840. declare module BABYLON {
  58841. /**
  58842. * Block used to normalize a vector
  58843. */
  58844. export class NormalizeBlock extends NodeMaterialBlock {
  58845. /**
  58846. * Creates a new NormalizeBlock
  58847. * @param name defines the block name
  58848. */
  58849. constructor(name: string);
  58850. /**
  58851. * Gets the current class name
  58852. * @returns the class name
  58853. */
  58854. getClassName(): string;
  58855. /**
  58856. * Gets the input component
  58857. */
  58858. get input(): NodeMaterialConnectionPoint;
  58859. /**
  58860. * Gets the output component
  58861. */
  58862. get output(): NodeMaterialConnectionPoint;
  58863. protected _buildBlock(state: NodeMaterialBuildState): this;
  58864. }
  58865. }
  58866. declare module BABYLON {
  58867. /**
  58868. * Operations supported by the Trigonometry block
  58869. */
  58870. export enum TrigonometryBlockOperations {
  58871. /** Cos */
  58872. Cos = 0,
  58873. /** Sin */
  58874. Sin = 1,
  58875. /** Abs */
  58876. Abs = 2,
  58877. /** Exp */
  58878. Exp = 3,
  58879. /** Exp2 */
  58880. Exp2 = 4,
  58881. /** Round */
  58882. Round = 5,
  58883. /** Floor */
  58884. Floor = 6,
  58885. /** Ceiling */
  58886. Ceiling = 7,
  58887. /** Square root */
  58888. Sqrt = 8,
  58889. /** Log */
  58890. Log = 9,
  58891. /** Tangent */
  58892. Tan = 10,
  58893. /** Arc tangent */
  58894. ArcTan = 11,
  58895. /** Arc cosinus */
  58896. ArcCos = 12,
  58897. /** Arc sinus */
  58898. ArcSin = 13,
  58899. /** Fraction */
  58900. Fract = 14,
  58901. /** Sign */
  58902. Sign = 15,
  58903. /** To radians (from degrees) */
  58904. Radians = 16,
  58905. /** To degrees (from radians) */
  58906. Degrees = 17
  58907. }
  58908. /**
  58909. * Block used to apply trigonometry operation to floats
  58910. */
  58911. export class TrigonometryBlock extends NodeMaterialBlock {
  58912. /**
  58913. * Gets or sets the operation applied by the block
  58914. */
  58915. operation: TrigonometryBlockOperations;
  58916. /**
  58917. * Creates a new TrigonometryBlock
  58918. * @param name defines the block name
  58919. */
  58920. constructor(name: string);
  58921. /**
  58922. * Gets the current class name
  58923. * @returns the class name
  58924. */
  58925. getClassName(): string;
  58926. /**
  58927. * Gets the input component
  58928. */
  58929. get input(): NodeMaterialConnectionPoint;
  58930. /**
  58931. * Gets the output component
  58932. */
  58933. get output(): NodeMaterialConnectionPoint;
  58934. protected _buildBlock(state: NodeMaterialBuildState): this;
  58935. serialize(): any;
  58936. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58937. protected _dumpPropertiesCode(): string;
  58938. }
  58939. }
  58940. declare module BABYLON {
  58941. /**
  58942. * Block used to create a Color3/4 out of individual inputs (one for each component)
  58943. */
  58944. export class ColorMergerBlock extends NodeMaterialBlock {
  58945. /**
  58946. * Create a new ColorMergerBlock
  58947. * @param name defines the block name
  58948. */
  58949. constructor(name: string);
  58950. /**
  58951. * Gets the current class name
  58952. * @returns the class name
  58953. */
  58954. getClassName(): string;
  58955. /**
  58956. * Gets the rgb component (input)
  58957. */
  58958. get rgbIn(): NodeMaterialConnectionPoint;
  58959. /**
  58960. * Gets the r component (input)
  58961. */
  58962. get r(): NodeMaterialConnectionPoint;
  58963. /**
  58964. * Gets the g component (input)
  58965. */
  58966. get g(): NodeMaterialConnectionPoint;
  58967. /**
  58968. * Gets the b component (input)
  58969. */
  58970. get b(): NodeMaterialConnectionPoint;
  58971. /**
  58972. * Gets the a component (input)
  58973. */
  58974. get a(): NodeMaterialConnectionPoint;
  58975. /**
  58976. * Gets the rgba component (output)
  58977. */
  58978. get rgba(): NodeMaterialConnectionPoint;
  58979. /**
  58980. * Gets the rgb component (output)
  58981. */
  58982. get rgbOut(): NodeMaterialConnectionPoint;
  58983. /**
  58984. * Gets the rgb component (output)
  58985. * @deprecated Please use rgbOut instead.
  58986. */
  58987. get rgb(): NodeMaterialConnectionPoint;
  58988. protected _buildBlock(state: NodeMaterialBuildState): this;
  58989. }
  58990. }
  58991. declare module BABYLON {
  58992. /**
  58993. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  58994. */
  58995. export class VectorMergerBlock extends NodeMaterialBlock {
  58996. /**
  58997. * Create a new VectorMergerBlock
  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 xyz component (input)
  59008. */
  59009. get xyzIn(): NodeMaterialConnectionPoint;
  59010. /**
  59011. * Gets the xy component (input)
  59012. */
  59013. get xyIn(): NodeMaterialConnectionPoint;
  59014. /**
  59015. * Gets the x component (input)
  59016. */
  59017. get x(): NodeMaterialConnectionPoint;
  59018. /**
  59019. * Gets the y component (input)
  59020. */
  59021. get y(): NodeMaterialConnectionPoint;
  59022. /**
  59023. * Gets the z component (input)
  59024. */
  59025. get z(): NodeMaterialConnectionPoint;
  59026. /**
  59027. * Gets the w component (input)
  59028. */
  59029. get w(): NodeMaterialConnectionPoint;
  59030. /**
  59031. * Gets the xyzw component (output)
  59032. */
  59033. get xyzw(): NodeMaterialConnectionPoint;
  59034. /**
  59035. * Gets the xyz component (output)
  59036. */
  59037. get xyzOut(): NodeMaterialConnectionPoint;
  59038. /**
  59039. * Gets the xy component (output)
  59040. */
  59041. get xyOut(): NodeMaterialConnectionPoint;
  59042. /**
  59043. * Gets the xy component (output)
  59044. * @deprecated Please use xyOut instead.
  59045. */
  59046. get xy(): NodeMaterialConnectionPoint;
  59047. /**
  59048. * Gets the xyz component (output)
  59049. * @deprecated Please use xyzOut instead.
  59050. */
  59051. get xyz(): NodeMaterialConnectionPoint;
  59052. protected _buildBlock(state: NodeMaterialBuildState): this;
  59053. }
  59054. }
  59055. declare module BABYLON {
  59056. /**
  59057. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  59058. */
  59059. export class ColorSplitterBlock extends NodeMaterialBlock {
  59060. /**
  59061. * Create a new ColorSplitterBlock
  59062. * @param name defines the block name
  59063. */
  59064. constructor(name: string);
  59065. /**
  59066. * Gets the current class name
  59067. * @returns the class name
  59068. */
  59069. getClassName(): string;
  59070. /**
  59071. * Gets the rgba component (input)
  59072. */
  59073. get rgba(): NodeMaterialConnectionPoint;
  59074. /**
  59075. * Gets the rgb component (input)
  59076. */
  59077. get rgbIn(): NodeMaterialConnectionPoint;
  59078. /**
  59079. * Gets the rgb component (output)
  59080. */
  59081. get rgbOut(): NodeMaterialConnectionPoint;
  59082. /**
  59083. * Gets the r component (output)
  59084. */
  59085. get r(): NodeMaterialConnectionPoint;
  59086. /**
  59087. * Gets the g component (output)
  59088. */
  59089. get g(): NodeMaterialConnectionPoint;
  59090. /**
  59091. * Gets the b component (output)
  59092. */
  59093. get b(): NodeMaterialConnectionPoint;
  59094. /**
  59095. * Gets the a component (output)
  59096. */
  59097. get a(): NodeMaterialConnectionPoint;
  59098. protected _inputRename(name: string): string;
  59099. protected _outputRename(name: string): string;
  59100. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59101. }
  59102. }
  59103. declare module BABYLON {
  59104. /**
  59105. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  59106. */
  59107. export class VectorSplitterBlock extends NodeMaterialBlock {
  59108. /**
  59109. * Create a new VectorSplitterBlock
  59110. * @param name defines the block name
  59111. */
  59112. constructor(name: string);
  59113. /**
  59114. * Gets the current class name
  59115. * @returns the class name
  59116. */
  59117. getClassName(): string;
  59118. /**
  59119. * Gets the xyzw component (input)
  59120. */
  59121. get xyzw(): NodeMaterialConnectionPoint;
  59122. /**
  59123. * Gets the xyz component (input)
  59124. */
  59125. get xyzIn(): NodeMaterialConnectionPoint;
  59126. /**
  59127. * Gets the xy component (input)
  59128. */
  59129. get xyIn(): NodeMaterialConnectionPoint;
  59130. /**
  59131. * Gets the xyz component (output)
  59132. */
  59133. get xyzOut(): NodeMaterialConnectionPoint;
  59134. /**
  59135. * Gets the xy component (output)
  59136. */
  59137. get xyOut(): NodeMaterialConnectionPoint;
  59138. /**
  59139. * Gets the x component (output)
  59140. */
  59141. get x(): NodeMaterialConnectionPoint;
  59142. /**
  59143. * Gets the y component (output)
  59144. */
  59145. get y(): NodeMaterialConnectionPoint;
  59146. /**
  59147. * Gets the z component (output)
  59148. */
  59149. get z(): NodeMaterialConnectionPoint;
  59150. /**
  59151. * Gets the w component (output)
  59152. */
  59153. get w(): NodeMaterialConnectionPoint;
  59154. protected _inputRename(name: string): string;
  59155. protected _outputRename(name: string): string;
  59156. protected _buildBlock(state: NodeMaterialBuildState): this;
  59157. }
  59158. }
  59159. declare module BABYLON {
  59160. /**
  59161. * Block used to lerp between 2 values
  59162. */
  59163. export class LerpBlock extends NodeMaterialBlock {
  59164. /**
  59165. * Creates a new LerpBlock
  59166. * @param name defines the block name
  59167. */
  59168. constructor(name: string);
  59169. /**
  59170. * Gets the current class name
  59171. * @returns the class name
  59172. */
  59173. getClassName(): string;
  59174. /**
  59175. * Gets the left operand input component
  59176. */
  59177. get left(): NodeMaterialConnectionPoint;
  59178. /**
  59179. * Gets the right operand input component
  59180. */
  59181. get right(): NodeMaterialConnectionPoint;
  59182. /**
  59183. * Gets the gradient operand input component
  59184. */
  59185. get gradient(): NodeMaterialConnectionPoint;
  59186. /**
  59187. * Gets the output component
  59188. */
  59189. get output(): NodeMaterialConnectionPoint;
  59190. protected _buildBlock(state: NodeMaterialBuildState): this;
  59191. }
  59192. }
  59193. declare module BABYLON {
  59194. /**
  59195. * Block used to divide 2 vectors
  59196. */
  59197. export class DivideBlock extends NodeMaterialBlock {
  59198. /**
  59199. * Creates a new DivideBlock
  59200. * @param name defines the block name
  59201. */
  59202. constructor(name: string);
  59203. /**
  59204. * Gets the current class name
  59205. * @returns the class name
  59206. */
  59207. getClassName(): string;
  59208. /**
  59209. * Gets the left operand input component
  59210. */
  59211. get left(): NodeMaterialConnectionPoint;
  59212. /**
  59213. * Gets the right operand input component
  59214. */
  59215. get right(): NodeMaterialConnectionPoint;
  59216. /**
  59217. * Gets the output component
  59218. */
  59219. get output(): NodeMaterialConnectionPoint;
  59220. protected _buildBlock(state: NodeMaterialBuildState): this;
  59221. }
  59222. }
  59223. declare module BABYLON {
  59224. /**
  59225. * Block used to subtract 2 vectors
  59226. */
  59227. export class SubtractBlock extends NodeMaterialBlock {
  59228. /**
  59229. * Creates a new SubtractBlock
  59230. * @param name defines the block name
  59231. */
  59232. constructor(name: string);
  59233. /**
  59234. * Gets the current class name
  59235. * @returns the class name
  59236. */
  59237. getClassName(): string;
  59238. /**
  59239. * Gets the left operand input component
  59240. */
  59241. get left(): NodeMaterialConnectionPoint;
  59242. /**
  59243. * Gets the right operand input component
  59244. */
  59245. get right(): NodeMaterialConnectionPoint;
  59246. /**
  59247. * Gets the output component
  59248. */
  59249. get output(): NodeMaterialConnectionPoint;
  59250. protected _buildBlock(state: NodeMaterialBuildState): this;
  59251. }
  59252. }
  59253. declare module BABYLON {
  59254. /**
  59255. * Block used to step a value
  59256. */
  59257. export class StepBlock extends NodeMaterialBlock {
  59258. /**
  59259. * Creates a new StepBlock
  59260. * @param name defines the block name
  59261. */
  59262. constructor(name: string);
  59263. /**
  59264. * Gets the current class name
  59265. * @returns the class name
  59266. */
  59267. getClassName(): string;
  59268. /**
  59269. * Gets the value operand input component
  59270. */
  59271. get value(): NodeMaterialConnectionPoint;
  59272. /**
  59273. * Gets the edge operand input component
  59274. */
  59275. get edge(): NodeMaterialConnectionPoint;
  59276. /**
  59277. * Gets the output component
  59278. */
  59279. get output(): NodeMaterialConnectionPoint;
  59280. protected _buildBlock(state: NodeMaterialBuildState): this;
  59281. }
  59282. }
  59283. declare module BABYLON {
  59284. /**
  59285. * Block used to get the opposite (1 - x) of a value
  59286. */
  59287. export class OneMinusBlock extends NodeMaterialBlock {
  59288. /**
  59289. * Creates a new OneMinusBlock
  59290. * @param name defines the block name
  59291. */
  59292. constructor(name: string);
  59293. /**
  59294. * Gets the current class name
  59295. * @returns the class name
  59296. */
  59297. getClassName(): string;
  59298. /**
  59299. * Gets the input component
  59300. */
  59301. get input(): NodeMaterialConnectionPoint;
  59302. /**
  59303. * Gets the output component
  59304. */
  59305. get output(): NodeMaterialConnectionPoint;
  59306. protected _buildBlock(state: NodeMaterialBuildState): this;
  59307. }
  59308. }
  59309. declare module BABYLON {
  59310. /**
  59311. * Block used to get the view direction
  59312. */
  59313. export class ViewDirectionBlock extends NodeMaterialBlock {
  59314. /**
  59315. * Creates a new ViewDirectionBlock
  59316. * @param name defines the block name
  59317. */
  59318. constructor(name: string);
  59319. /**
  59320. * Gets the current class name
  59321. * @returns the class name
  59322. */
  59323. getClassName(): string;
  59324. /**
  59325. * Gets the world position component
  59326. */
  59327. get worldPosition(): NodeMaterialConnectionPoint;
  59328. /**
  59329. * Gets the camera position component
  59330. */
  59331. get cameraPosition(): NodeMaterialConnectionPoint;
  59332. /**
  59333. * Gets the output component
  59334. */
  59335. get output(): NodeMaterialConnectionPoint;
  59336. autoConfigure(material: NodeMaterial): void;
  59337. protected _buildBlock(state: NodeMaterialBuildState): this;
  59338. }
  59339. }
  59340. declare module BABYLON {
  59341. /**
  59342. * Block used to compute fresnel value
  59343. */
  59344. export class FresnelBlock extends NodeMaterialBlock {
  59345. /**
  59346. * Create a new FresnelBlock
  59347. * @param name defines the block name
  59348. */
  59349. constructor(name: string);
  59350. /**
  59351. * Gets the current class name
  59352. * @returns the class name
  59353. */
  59354. getClassName(): string;
  59355. /**
  59356. * Gets the world normal input component
  59357. */
  59358. get worldNormal(): NodeMaterialConnectionPoint;
  59359. /**
  59360. * Gets the view direction input component
  59361. */
  59362. get viewDirection(): NodeMaterialConnectionPoint;
  59363. /**
  59364. * Gets the bias input component
  59365. */
  59366. get bias(): NodeMaterialConnectionPoint;
  59367. /**
  59368. * Gets the camera (or eye) position component
  59369. */
  59370. get power(): NodeMaterialConnectionPoint;
  59371. /**
  59372. * Gets the fresnel output component
  59373. */
  59374. get fresnel(): NodeMaterialConnectionPoint;
  59375. autoConfigure(material: NodeMaterial): void;
  59376. protected _buildBlock(state: NodeMaterialBuildState): this;
  59377. }
  59378. }
  59379. declare module BABYLON {
  59380. /**
  59381. * Block used to get the max of 2 values
  59382. */
  59383. export class MaxBlock extends NodeMaterialBlock {
  59384. /**
  59385. * Creates a new MaxBlock
  59386. * @param name defines the block name
  59387. */
  59388. constructor(name: string);
  59389. /**
  59390. * Gets the current class name
  59391. * @returns the class name
  59392. */
  59393. getClassName(): string;
  59394. /**
  59395. * Gets the left operand input component
  59396. */
  59397. get left(): NodeMaterialConnectionPoint;
  59398. /**
  59399. * Gets the right operand input component
  59400. */
  59401. get right(): NodeMaterialConnectionPoint;
  59402. /**
  59403. * Gets the output component
  59404. */
  59405. get output(): NodeMaterialConnectionPoint;
  59406. protected _buildBlock(state: NodeMaterialBuildState): this;
  59407. }
  59408. }
  59409. declare module BABYLON {
  59410. /**
  59411. * Block used to get the min of 2 values
  59412. */
  59413. export class MinBlock extends NodeMaterialBlock {
  59414. /**
  59415. * Creates a new MinBlock
  59416. * @param name defines the block name
  59417. */
  59418. constructor(name: string);
  59419. /**
  59420. * Gets the current class name
  59421. * @returns the class name
  59422. */
  59423. getClassName(): string;
  59424. /**
  59425. * Gets the left operand input component
  59426. */
  59427. get left(): NodeMaterialConnectionPoint;
  59428. /**
  59429. * Gets the right operand input component
  59430. */
  59431. get right(): NodeMaterialConnectionPoint;
  59432. /**
  59433. * Gets the output component
  59434. */
  59435. get output(): NodeMaterialConnectionPoint;
  59436. protected _buildBlock(state: NodeMaterialBuildState): this;
  59437. }
  59438. }
  59439. declare module BABYLON {
  59440. /**
  59441. * Block used to get the distance between 2 values
  59442. */
  59443. export class DistanceBlock extends NodeMaterialBlock {
  59444. /**
  59445. * Creates a new DistanceBlock
  59446. * @param name defines the block name
  59447. */
  59448. constructor(name: string);
  59449. /**
  59450. * Gets the current class name
  59451. * @returns the class name
  59452. */
  59453. getClassName(): string;
  59454. /**
  59455. * Gets the left operand input component
  59456. */
  59457. get left(): NodeMaterialConnectionPoint;
  59458. /**
  59459. * Gets the right operand input component
  59460. */
  59461. get right(): NodeMaterialConnectionPoint;
  59462. /**
  59463. * Gets the output component
  59464. */
  59465. get output(): NodeMaterialConnectionPoint;
  59466. protected _buildBlock(state: NodeMaterialBuildState): this;
  59467. }
  59468. }
  59469. declare module BABYLON {
  59470. /**
  59471. * Block used to get the length of a vector
  59472. */
  59473. export class LengthBlock extends NodeMaterialBlock {
  59474. /**
  59475. * Creates a new LengthBlock
  59476. * @param name defines the block name
  59477. */
  59478. constructor(name: string);
  59479. /**
  59480. * Gets the current class name
  59481. * @returns the class name
  59482. */
  59483. getClassName(): string;
  59484. /**
  59485. * Gets the value input component
  59486. */
  59487. get value(): NodeMaterialConnectionPoint;
  59488. /**
  59489. * Gets the output component
  59490. */
  59491. get output(): NodeMaterialConnectionPoint;
  59492. protected _buildBlock(state: NodeMaterialBuildState): this;
  59493. }
  59494. }
  59495. declare module BABYLON {
  59496. /**
  59497. * Block used to get negative version of a value (i.e. x * -1)
  59498. */
  59499. export class NegateBlock extends NodeMaterialBlock {
  59500. /**
  59501. * Creates a new NegateBlock
  59502. * @param name defines the block name
  59503. */
  59504. constructor(name: string);
  59505. /**
  59506. * Gets the current class name
  59507. * @returns the class name
  59508. */
  59509. getClassName(): string;
  59510. /**
  59511. * Gets the value input component
  59512. */
  59513. get value(): NodeMaterialConnectionPoint;
  59514. /**
  59515. * Gets the output component
  59516. */
  59517. get output(): NodeMaterialConnectionPoint;
  59518. protected _buildBlock(state: NodeMaterialBuildState): this;
  59519. }
  59520. }
  59521. declare module BABYLON {
  59522. /**
  59523. * Block used to get the value of the first parameter raised to the power of the second
  59524. */
  59525. export class PowBlock extends NodeMaterialBlock {
  59526. /**
  59527. * Creates a new PowBlock
  59528. * @param name defines the block name
  59529. */
  59530. constructor(name: string);
  59531. /**
  59532. * Gets the current class name
  59533. * @returns the class name
  59534. */
  59535. getClassName(): string;
  59536. /**
  59537. * Gets the value operand input component
  59538. */
  59539. get value(): NodeMaterialConnectionPoint;
  59540. /**
  59541. * Gets the power operand input component
  59542. */
  59543. get power(): NodeMaterialConnectionPoint;
  59544. /**
  59545. * Gets the output component
  59546. */
  59547. get output(): NodeMaterialConnectionPoint;
  59548. protected _buildBlock(state: NodeMaterialBuildState): this;
  59549. }
  59550. }
  59551. declare module BABYLON {
  59552. /**
  59553. * Block used to get a random number
  59554. */
  59555. export class RandomNumberBlock extends NodeMaterialBlock {
  59556. /**
  59557. * Creates a new RandomNumberBlock
  59558. * @param name defines the block name
  59559. */
  59560. constructor(name: string);
  59561. /**
  59562. * Gets the current class name
  59563. * @returns the class name
  59564. */
  59565. getClassName(): string;
  59566. /**
  59567. * Gets the seed input component
  59568. */
  59569. get seed(): NodeMaterialConnectionPoint;
  59570. /**
  59571. * Gets the output component
  59572. */
  59573. get output(): NodeMaterialConnectionPoint;
  59574. protected _buildBlock(state: NodeMaterialBuildState): this;
  59575. }
  59576. }
  59577. declare module BABYLON {
  59578. /**
  59579. * Block used to compute arc tangent of 2 values
  59580. */
  59581. export class ArcTan2Block extends NodeMaterialBlock {
  59582. /**
  59583. * Creates a new ArcTan2Block
  59584. * @param name defines the block name
  59585. */
  59586. constructor(name: string);
  59587. /**
  59588. * Gets the current class name
  59589. * @returns the class name
  59590. */
  59591. getClassName(): string;
  59592. /**
  59593. * Gets the x operand input component
  59594. */
  59595. get x(): NodeMaterialConnectionPoint;
  59596. /**
  59597. * Gets the y operand input component
  59598. */
  59599. get y(): NodeMaterialConnectionPoint;
  59600. /**
  59601. * Gets the output component
  59602. */
  59603. get output(): NodeMaterialConnectionPoint;
  59604. protected _buildBlock(state: NodeMaterialBuildState): this;
  59605. }
  59606. }
  59607. declare module BABYLON {
  59608. /**
  59609. * Block used to smooth step a value
  59610. */
  59611. export class SmoothStepBlock extends NodeMaterialBlock {
  59612. /**
  59613. * Creates a new SmoothStepBlock
  59614. * @param name defines the block name
  59615. */
  59616. constructor(name: string);
  59617. /**
  59618. * Gets the current class name
  59619. * @returns the class name
  59620. */
  59621. getClassName(): string;
  59622. /**
  59623. * Gets the value operand input component
  59624. */
  59625. get value(): NodeMaterialConnectionPoint;
  59626. /**
  59627. * Gets the first edge operand input component
  59628. */
  59629. get edge0(): NodeMaterialConnectionPoint;
  59630. /**
  59631. * Gets the second edge operand input component
  59632. */
  59633. get edge1(): NodeMaterialConnectionPoint;
  59634. /**
  59635. * Gets the output component
  59636. */
  59637. get output(): NodeMaterialConnectionPoint;
  59638. protected _buildBlock(state: NodeMaterialBuildState): this;
  59639. }
  59640. }
  59641. declare module BABYLON {
  59642. /**
  59643. * Block used to get the reciprocal (1 / x) of a value
  59644. */
  59645. export class ReciprocalBlock extends NodeMaterialBlock {
  59646. /**
  59647. * Creates a new ReciprocalBlock
  59648. * @param name defines the block name
  59649. */
  59650. constructor(name: string);
  59651. /**
  59652. * Gets the current class name
  59653. * @returns the class name
  59654. */
  59655. getClassName(): string;
  59656. /**
  59657. * Gets the input component
  59658. */
  59659. get input(): NodeMaterialConnectionPoint;
  59660. /**
  59661. * Gets the output component
  59662. */
  59663. get output(): NodeMaterialConnectionPoint;
  59664. protected _buildBlock(state: NodeMaterialBuildState): this;
  59665. }
  59666. }
  59667. declare module BABYLON {
  59668. /**
  59669. * Block used to replace a color by another one
  59670. */
  59671. export class ReplaceColorBlock extends NodeMaterialBlock {
  59672. /**
  59673. * Creates a new ReplaceColorBlock
  59674. * @param name defines the block name
  59675. */
  59676. constructor(name: string);
  59677. /**
  59678. * Gets the current class name
  59679. * @returns the class name
  59680. */
  59681. getClassName(): string;
  59682. /**
  59683. * Gets the value input component
  59684. */
  59685. get value(): NodeMaterialConnectionPoint;
  59686. /**
  59687. * Gets the reference input component
  59688. */
  59689. get reference(): NodeMaterialConnectionPoint;
  59690. /**
  59691. * Gets the distance input component
  59692. */
  59693. get distance(): NodeMaterialConnectionPoint;
  59694. /**
  59695. * Gets the replacement input component
  59696. */
  59697. get replacement(): NodeMaterialConnectionPoint;
  59698. /**
  59699. * Gets the output component
  59700. */
  59701. get output(): NodeMaterialConnectionPoint;
  59702. protected _buildBlock(state: NodeMaterialBuildState): this;
  59703. }
  59704. }
  59705. declare module BABYLON {
  59706. /**
  59707. * Block used to posterize a value
  59708. * @see https://en.wikipedia.org/wiki/Posterization
  59709. */
  59710. export class PosterizeBlock extends NodeMaterialBlock {
  59711. /**
  59712. * Creates a new PosterizeBlock
  59713. * @param name defines the block name
  59714. */
  59715. constructor(name: string);
  59716. /**
  59717. * Gets the current class name
  59718. * @returns the class name
  59719. */
  59720. getClassName(): string;
  59721. /**
  59722. * Gets the value input component
  59723. */
  59724. get value(): NodeMaterialConnectionPoint;
  59725. /**
  59726. * Gets the steps input component
  59727. */
  59728. get steps(): NodeMaterialConnectionPoint;
  59729. /**
  59730. * Gets the output component
  59731. */
  59732. get output(): NodeMaterialConnectionPoint;
  59733. protected _buildBlock(state: NodeMaterialBuildState): this;
  59734. }
  59735. }
  59736. declare module BABYLON {
  59737. /**
  59738. * Operations supported by the Wave block
  59739. */
  59740. export enum WaveBlockKind {
  59741. /** SawTooth */
  59742. SawTooth = 0,
  59743. /** Square */
  59744. Square = 1,
  59745. /** Triangle */
  59746. Triangle = 2
  59747. }
  59748. /**
  59749. * Block used to apply wave operation to floats
  59750. */
  59751. export class WaveBlock extends NodeMaterialBlock {
  59752. /**
  59753. * Gets or sets the kibnd of wave to be applied by the block
  59754. */
  59755. kind: WaveBlockKind;
  59756. /**
  59757. * Creates a new WaveBlock
  59758. * @param name defines the block name
  59759. */
  59760. constructor(name: string);
  59761. /**
  59762. * Gets the current class name
  59763. * @returns the class name
  59764. */
  59765. getClassName(): string;
  59766. /**
  59767. * Gets the input component
  59768. */
  59769. get input(): NodeMaterialConnectionPoint;
  59770. /**
  59771. * Gets the output component
  59772. */
  59773. get output(): NodeMaterialConnectionPoint;
  59774. protected _buildBlock(state: NodeMaterialBuildState): this;
  59775. serialize(): any;
  59776. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59777. }
  59778. }
  59779. declare module BABYLON {
  59780. /**
  59781. * Class used to store a color step for the GradientBlock
  59782. */
  59783. export class GradientBlockColorStep {
  59784. /**
  59785. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59786. */
  59787. step: number;
  59788. /**
  59789. * Gets or sets the color associated with this step
  59790. */
  59791. color: Color3;
  59792. /**
  59793. * Creates a new GradientBlockColorStep
  59794. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  59795. * @param color defines the color associated with this step
  59796. */
  59797. constructor(
  59798. /**
  59799. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  59800. */
  59801. step: number,
  59802. /**
  59803. * Gets or sets the color associated with this step
  59804. */
  59805. color: Color3);
  59806. }
  59807. /**
  59808. * Block used to return a color from a gradient based on an input value between 0 and 1
  59809. */
  59810. export class GradientBlock extends NodeMaterialBlock {
  59811. /**
  59812. * Gets or sets the list of color steps
  59813. */
  59814. colorSteps: GradientBlockColorStep[];
  59815. /**
  59816. * Creates a new GradientBlock
  59817. * @param name defines the block name
  59818. */
  59819. constructor(name: string);
  59820. /**
  59821. * Gets the current class name
  59822. * @returns the class name
  59823. */
  59824. getClassName(): string;
  59825. /**
  59826. * Gets the gradient input component
  59827. */
  59828. get gradient(): NodeMaterialConnectionPoint;
  59829. /**
  59830. * Gets the output component
  59831. */
  59832. get output(): NodeMaterialConnectionPoint;
  59833. private _writeColorConstant;
  59834. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59835. serialize(): any;
  59836. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59837. protected _dumpPropertiesCode(): string;
  59838. }
  59839. }
  59840. declare module BABYLON {
  59841. /**
  59842. * Block used to normalize lerp between 2 values
  59843. */
  59844. export class NLerpBlock extends NodeMaterialBlock {
  59845. /**
  59846. * Creates a new NLerpBlock
  59847. * @param name defines the block name
  59848. */
  59849. constructor(name: string);
  59850. /**
  59851. * Gets the current class name
  59852. * @returns the class name
  59853. */
  59854. getClassName(): string;
  59855. /**
  59856. * Gets the left operand input component
  59857. */
  59858. get left(): NodeMaterialConnectionPoint;
  59859. /**
  59860. * Gets the right operand input component
  59861. */
  59862. get right(): NodeMaterialConnectionPoint;
  59863. /**
  59864. * Gets the gradient operand input component
  59865. */
  59866. get gradient(): NodeMaterialConnectionPoint;
  59867. /**
  59868. * Gets the output component
  59869. */
  59870. get output(): NodeMaterialConnectionPoint;
  59871. protected _buildBlock(state: NodeMaterialBuildState): this;
  59872. }
  59873. }
  59874. declare module BABYLON {
  59875. /**
  59876. * block used to Generate a Worley Noise 3D Noise Pattern
  59877. */
  59878. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  59879. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  59880. manhattanDistance: boolean;
  59881. /**
  59882. * Creates a new WorleyNoise3DBlock
  59883. * @param name defines the block name
  59884. */
  59885. constructor(name: string);
  59886. /**
  59887. * Gets the current class name
  59888. * @returns the class name
  59889. */
  59890. getClassName(): string;
  59891. /**
  59892. * Gets the seed input component
  59893. */
  59894. get seed(): NodeMaterialConnectionPoint;
  59895. /**
  59896. * Gets the jitter input component
  59897. */
  59898. get jitter(): NodeMaterialConnectionPoint;
  59899. /**
  59900. * Gets the output component
  59901. */
  59902. get output(): NodeMaterialConnectionPoint;
  59903. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59904. /**
  59905. * Exposes the properties to the UI?
  59906. */
  59907. protected _dumpPropertiesCode(): string;
  59908. /**
  59909. * Exposes the properties to the Seralize?
  59910. */
  59911. serialize(): any;
  59912. /**
  59913. * Exposes the properties to the deseralize?
  59914. */
  59915. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59916. }
  59917. }
  59918. declare module BABYLON {
  59919. /**
  59920. * block used to Generate a Simplex Perlin 3d Noise Pattern
  59921. */
  59922. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  59923. /**
  59924. * Creates a new SimplexPerlin3DBlock
  59925. * @param name defines the block name
  59926. */
  59927. constructor(name: string);
  59928. /**
  59929. * Gets the current class name
  59930. * @returns the class name
  59931. */
  59932. getClassName(): string;
  59933. /**
  59934. * Gets the seed operand input component
  59935. */
  59936. get seed(): NodeMaterialConnectionPoint;
  59937. /**
  59938. * Gets the output component
  59939. */
  59940. get output(): NodeMaterialConnectionPoint;
  59941. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59942. }
  59943. }
  59944. declare module BABYLON {
  59945. /**
  59946. * Block used to blend normals
  59947. */
  59948. export class NormalBlendBlock extends NodeMaterialBlock {
  59949. /**
  59950. * Creates a new NormalBlendBlock
  59951. * @param name defines the block name
  59952. */
  59953. constructor(name: string);
  59954. /**
  59955. * Gets the current class name
  59956. * @returns the class name
  59957. */
  59958. getClassName(): string;
  59959. /**
  59960. * Gets the first input component
  59961. */
  59962. get normalMap0(): NodeMaterialConnectionPoint;
  59963. /**
  59964. * Gets the second input component
  59965. */
  59966. get normalMap1(): NodeMaterialConnectionPoint;
  59967. /**
  59968. * Gets the output component
  59969. */
  59970. get output(): NodeMaterialConnectionPoint;
  59971. protected _buildBlock(state: NodeMaterialBuildState): this;
  59972. }
  59973. }
  59974. declare module BABYLON {
  59975. /**
  59976. * Block used to rotate a 2d vector by a given angle
  59977. */
  59978. export class Rotate2dBlock extends NodeMaterialBlock {
  59979. /**
  59980. * Creates a new Rotate2dBlock
  59981. * @param name defines the block name
  59982. */
  59983. constructor(name: string);
  59984. /**
  59985. * Gets the current class name
  59986. * @returns the class name
  59987. */
  59988. getClassName(): string;
  59989. /**
  59990. * Gets the input vector
  59991. */
  59992. get input(): NodeMaterialConnectionPoint;
  59993. /**
  59994. * Gets the input angle
  59995. */
  59996. get angle(): NodeMaterialConnectionPoint;
  59997. /**
  59998. * Gets the output component
  59999. */
  60000. get output(): NodeMaterialConnectionPoint;
  60001. autoConfigure(material: NodeMaterial): void;
  60002. protected _buildBlock(state: NodeMaterialBuildState): this;
  60003. }
  60004. }
  60005. declare module BABYLON {
  60006. /**
  60007. * Block used to get the reflected vector from a direction and a normal
  60008. */
  60009. export class ReflectBlock extends NodeMaterialBlock {
  60010. /**
  60011. * Creates a new ReflectBlock
  60012. * @param name defines the block name
  60013. */
  60014. constructor(name: string);
  60015. /**
  60016. * Gets the current class name
  60017. * @returns the class name
  60018. */
  60019. getClassName(): string;
  60020. /**
  60021. * Gets the incident component
  60022. */
  60023. get incident(): NodeMaterialConnectionPoint;
  60024. /**
  60025. * Gets the normal component
  60026. */
  60027. get normal(): NodeMaterialConnectionPoint;
  60028. /**
  60029. * Gets the output component
  60030. */
  60031. get output(): NodeMaterialConnectionPoint;
  60032. protected _buildBlock(state: NodeMaterialBuildState): this;
  60033. }
  60034. }
  60035. declare module BABYLON {
  60036. /**
  60037. * Block used to get the refracted vector from a direction and a normal
  60038. */
  60039. export class RefractBlock extends NodeMaterialBlock {
  60040. /**
  60041. * Creates a new RefractBlock
  60042. * @param name defines the block name
  60043. */
  60044. constructor(name: string);
  60045. /**
  60046. * Gets the current class name
  60047. * @returns the class name
  60048. */
  60049. getClassName(): string;
  60050. /**
  60051. * Gets the incident component
  60052. */
  60053. get incident(): NodeMaterialConnectionPoint;
  60054. /**
  60055. * Gets the normal component
  60056. */
  60057. get normal(): NodeMaterialConnectionPoint;
  60058. /**
  60059. * Gets the index of refraction component
  60060. */
  60061. get ior(): NodeMaterialConnectionPoint;
  60062. /**
  60063. * Gets the output component
  60064. */
  60065. get output(): NodeMaterialConnectionPoint;
  60066. protected _buildBlock(state: NodeMaterialBuildState): this;
  60067. }
  60068. }
  60069. declare module BABYLON {
  60070. /**
  60071. * Block used to desaturate a color
  60072. */
  60073. export class DesaturateBlock extends NodeMaterialBlock {
  60074. /**
  60075. * Creates a new DesaturateBlock
  60076. * @param name defines the block name
  60077. */
  60078. constructor(name: string);
  60079. /**
  60080. * Gets the current class name
  60081. * @returns the class name
  60082. */
  60083. getClassName(): string;
  60084. /**
  60085. * Gets the color operand input component
  60086. */
  60087. get color(): NodeMaterialConnectionPoint;
  60088. /**
  60089. * Gets the level operand input component
  60090. */
  60091. get level(): NodeMaterialConnectionPoint;
  60092. /**
  60093. * Gets the output component
  60094. */
  60095. get output(): NodeMaterialConnectionPoint;
  60096. protected _buildBlock(state: NodeMaterialBuildState): this;
  60097. }
  60098. }
  60099. declare module BABYLON {
  60100. /**
  60101. * Effect Render Options
  60102. */
  60103. export interface IEffectRendererOptions {
  60104. /**
  60105. * Defines the vertices positions.
  60106. */
  60107. positions?: number[];
  60108. /**
  60109. * Defines the indices.
  60110. */
  60111. indices?: number[];
  60112. }
  60113. /**
  60114. * Helper class to render one or more effects
  60115. */
  60116. export class EffectRenderer {
  60117. private engine;
  60118. private static _DefaultOptions;
  60119. private _vertexBuffers;
  60120. private _indexBuffer;
  60121. private _ringBufferIndex;
  60122. private _ringScreenBuffer;
  60123. private _fullscreenViewport;
  60124. private _getNextFrameBuffer;
  60125. /**
  60126. * Creates an effect renderer
  60127. * @param engine the engine to use for rendering
  60128. * @param options defines the options of the effect renderer
  60129. */
  60130. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  60131. /**
  60132. * Sets the current viewport in normalized coordinates 0-1
  60133. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  60134. */
  60135. setViewport(viewport?: Viewport): void;
  60136. /**
  60137. * Binds the embedded attributes buffer to the effect.
  60138. * @param effect Defines the effect to bind the attributes for
  60139. */
  60140. bindBuffers(effect: Effect): void;
  60141. /**
  60142. * Sets the current effect wrapper to use during draw.
  60143. * The effect needs to be ready before calling this api.
  60144. * This also sets the default full screen position attribute.
  60145. * @param effectWrapper Defines the effect to draw with
  60146. */
  60147. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  60148. /**
  60149. * Draws a full screen quad.
  60150. */
  60151. draw(): void;
  60152. /**
  60153. * renders one or more effects to a specified texture
  60154. * @param effectWrappers list of effects to renderer
  60155. * @param outputTexture texture to draw to, if null it will render to the screen
  60156. */
  60157. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  60158. /**
  60159. * Disposes of the effect renderer
  60160. */
  60161. dispose(): void;
  60162. }
  60163. /**
  60164. * Options to create an EffectWrapper
  60165. */
  60166. interface EffectWrapperCreationOptions {
  60167. /**
  60168. * Engine to use to create the effect
  60169. */
  60170. engine: ThinEngine;
  60171. /**
  60172. * Fragment shader for the effect
  60173. */
  60174. fragmentShader: string;
  60175. /**
  60176. * Vertex shader for the effect
  60177. */
  60178. vertexShader?: string;
  60179. /**
  60180. * Attributes to use in the shader
  60181. */
  60182. attributeNames?: Array<string>;
  60183. /**
  60184. * Uniforms to use in the shader
  60185. */
  60186. uniformNames?: Array<string>;
  60187. /**
  60188. * Texture sampler names to use in the shader
  60189. */
  60190. samplerNames?: Array<string>;
  60191. /**
  60192. * The friendly name of the effect displayed in Spector.
  60193. */
  60194. name?: string;
  60195. }
  60196. /**
  60197. * Wraps an effect to be used for rendering
  60198. */
  60199. export class EffectWrapper {
  60200. /**
  60201. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  60202. */
  60203. onApplyObservable: Observable<{}>;
  60204. /**
  60205. * The underlying effect
  60206. */
  60207. effect: Effect;
  60208. /**
  60209. * Creates an effect to be renderer
  60210. * @param creationOptions options to create the effect
  60211. */
  60212. constructor(creationOptions: EffectWrapperCreationOptions);
  60213. /**
  60214. * Disposes of the effect wrapper
  60215. */
  60216. dispose(): void;
  60217. }
  60218. }
  60219. declare module BABYLON {
  60220. /**
  60221. * Helper class to push actions to a pool of workers.
  60222. */
  60223. export class WorkerPool implements IDisposable {
  60224. private _workerInfos;
  60225. private _pendingActions;
  60226. /**
  60227. * Constructor
  60228. * @param workers Array of workers to use for actions
  60229. */
  60230. constructor(workers: Array<Worker>);
  60231. /**
  60232. * Terminates all workers and clears any pending actions.
  60233. */
  60234. dispose(): void;
  60235. /**
  60236. * Pushes an action to the worker pool. If all the workers are active, the action will be
  60237. * pended until a worker has completed its action.
  60238. * @param action The action to perform. Call onComplete when the action is complete.
  60239. */
  60240. push(action: (worker: Worker, onComplete: () => void) => void): void;
  60241. private _execute;
  60242. }
  60243. }
  60244. declare module BABYLON {
  60245. /**
  60246. * Configuration for Draco compression
  60247. */
  60248. export interface IDracoCompressionConfiguration {
  60249. /**
  60250. * Configuration for the decoder.
  60251. */
  60252. decoder: {
  60253. /**
  60254. * The url to the WebAssembly module.
  60255. */
  60256. wasmUrl?: string;
  60257. /**
  60258. * The url to the WebAssembly binary.
  60259. */
  60260. wasmBinaryUrl?: string;
  60261. /**
  60262. * The url to the fallback JavaScript module.
  60263. */
  60264. fallbackUrl?: string;
  60265. };
  60266. }
  60267. /**
  60268. * Draco compression (https://google.github.io/draco/)
  60269. *
  60270. * This class wraps the Draco module.
  60271. *
  60272. * **Encoder**
  60273. *
  60274. * The encoder is not currently implemented.
  60275. *
  60276. * **Decoder**
  60277. *
  60278. * 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.
  60279. *
  60280. * To update the configuration, use the following code:
  60281. * ```javascript
  60282. * DracoCompression.Configuration = {
  60283. * decoder: {
  60284. * wasmUrl: "<url to the WebAssembly library>",
  60285. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  60286. * fallbackUrl: "<url to the fallback JavaScript library>",
  60287. * }
  60288. * };
  60289. * ```
  60290. *
  60291. * 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.
  60292. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  60293. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  60294. *
  60295. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  60296. * ```javascript
  60297. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  60298. * ```
  60299. *
  60300. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  60301. */
  60302. export class DracoCompression implements IDisposable {
  60303. private _workerPoolPromise?;
  60304. private _decoderModulePromise?;
  60305. /**
  60306. * The configuration. Defaults to the following urls:
  60307. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  60308. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  60309. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  60310. */
  60311. static Configuration: IDracoCompressionConfiguration;
  60312. /**
  60313. * Returns true if the decoder configuration is available.
  60314. */
  60315. static get DecoderAvailable(): boolean;
  60316. /**
  60317. * Default number of workers to create when creating the draco compression object.
  60318. */
  60319. static DefaultNumWorkers: number;
  60320. private static GetDefaultNumWorkers;
  60321. private static _Default;
  60322. /**
  60323. * Default instance for the draco compression object.
  60324. */
  60325. static get Default(): DracoCompression;
  60326. /**
  60327. * Constructor
  60328. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  60329. */
  60330. constructor(numWorkers?: number);
  60331. /**
  60332. * Stop all async operations and release resources.
  60333. */
  60334. dispose(): void;
  60335. /**
  60336. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  60337. * @returns a promise that resolves when ready
  60338. */
  60339. whenReadyAsync(): Promise<void>;
  60340. /**
  60341. * Decode Draco compressed mesh data to vertex data.
  60342. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  60343. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  60344. * @returns A promise that resolves with the decoded vertex data
  60345. */
  60346. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  60347. [kind: string]: number;
  60348. }): Promise<VertexData>;
  60349. }
  60350. }
  60351. declare module BABYLON {
  60352. /**
  60353. * Class for building Constructive Solid Geometry
  60354. */
  60355. export class CSG {
  60356. private polygons;
  60357. /**
  60358. * The world matrix
  60359. */
  60360. matrix: Matrix;
  60361. /**
  60362. * Stores the position
  60363. */
  60364. position: Vector3;
  60365. /**
  60366. * Stores the rotation
  60367. */
  60368. rotation: Vector3;
  60369. /**
  60370. * Stores the rotation quaternion
  60371. */
  60372. rotationQuaternion: Nullable<Quaternion>;
  60373. /**
  60374. * Stores the scaling vector
  60375. */
  60376. scaling: Vector3;
  60377. /**
  60378. * Convert the Mesh to CSG
  60379. * @param mesh The Mesh to convert to CSG
  60380. * @returns A new CSG from the Mesh
  60381. */
  60382. static FromMesh(mesh: Mesh): CSG;
  60383. /**
  60384. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  60385. * @param polygons Polygons used to construct a CSG solid
  60386. */
  60387. private static FromPolygons;
  60388. /**
  60389. * Clones, or makes a deep copy, of the CSG
  60390. * @returns A new CSG
  60391. */
  60392. clone(): CSG;
  60393. /**
  60394. * Unions this CSG with another CSG
  60395. * @param csg The CSG to union against this CSG
  60396. * @returns The unioned CSG
  60397. */
  60398. union(csg: CSG): CSG;
  60399. /**
  60400. * Unions this CSG with another CSG in place
  60401. * @param csg The CSG to union against this CSG
  60402. */
  60403. unionInPlace(csg: CSG): void;
  60404. /**
  60405. * Subtracts this CSG with another CSG
  60406. * @param csg The CSG to subtract against this CSG
  60407. * @returns A new CSG
  60408. */
  60409. subtract(csg: CSG): CSG;
  60410. /**
  60411. * Subtracts this CSG with another CSG in place
  60412. * @param csg The CSG to subtact against this CSG
  60413. */
  60414. subtractInPlace(csg: CSG): void;
  60415. /**
  60416. * Intersect this CSG with another CSG
  60417. * @param csg The CSG to intersect against this CSG
  60418. * @returns A new CSG
  60419. */
  60420. intersect(csg: CSG): CSG;
  60421. /**
  60422. * Intersects this CSG with another CSG in place
  60423. * @param csg The CSG to intersect against this CSG
  60424. */
  60425. intersectInPlace(csg: CSG): void;
  60426. /**
  60427. * Return a new CSG solid with solid and empty space switched. This solid is
  60428. * not modified.
  60429. * @returns A new CSG solid with solid and empty space switched
  60430. */
  60431. inverse(): CSG;
  60432. /**
  60433. * Inverses the CSG in place
  60434. */
  60435. inverseInPlace(): void;
  60436. /**
  60437. * This is used to keep meshes transformations so they can be restored
  60438. * when we build back a Babylon Mesh
  60439. * NB : All CSG operations are performed in world coordinates
  60440. * @param csg The CSG to copy the transform attributes from
  60441. * @returns This CSG
  60442. */
  60443. copyTransformAttributes(csg: CSG): CSG;
  60444. /**
  60445. * Build Raw mesh from CSG
  60446. * Coordinates here are in world space
  60447. * @param name The name of the mesh geometry
  60448. * @param scene The Scene
  60449. * @param keepSubMeshes Specifies if the submeshes should be kept
  60450. * @returns A new Mesh
  60451. */
  60452. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  60453. /**
  60454. * Build Mesh from CSG taking material and transforms into account
  60455. * @param name The name of the Mesh
  60456. * @param material The material of the Mesh
  60457. * @param scene The Scene
  60458. * @param keepSubMeshes Specifies if submeshes should be kept
  60459. * @returns The new Mesh
  60460. */
  60461. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  60462. }
  60463. }
  60464. declare module BABYLON {
  60465. /**
  60466. * Class used to create a trail following a mesh
  60467. */
  60468. export class TrailMesh extends Mesh {
  60469. private _generator;
  60470. private _autoStart;
  60471. private _running;
  60472. private _diameter;
  60473. private _length;
  60474. private _sectionPolygonPointsCount;
  60475. private _sectionVectors;
  60476. private _sectionNormalVectors;
  60477. private _beforeRenderObserver;
  60478. /**
  60479. * @constructor
  60480. * @param name The value used by scene.getMeshByName() to do a lookup.
  60481. * @param generator The mesh or transform node to generate a trail.
  60482. * @param scene The scene to add this mesh to.
  60483. * @param diameter Diameter of trailing mesh. Default is 1.
  60484. * @param length Length of trailing mesh. Default is 60.
  60485. * @param autoStart Automatically start trailing mesh. Default true.
  60486. */
  60487. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  60488. /**
  60489. * "TrailMesh"
  60490. * @returns "TrailMesh"
  60491. */
  60492. getClassName(): string;
  60493. private _createMesh;
  60494. /**
  60495. * Start trailing mesh.
  60496. */
  60497. start(): void;
  60498. /**
  60499. * Stop trailing mesh.
  60500. */
  60501. stop(): void;
  60502. /**
  60503. * Update trailing mesh geometry.
  60504. */
  60505. update(): void;
  60506. /**
  60507. * Returns a new TrailMesh object.
  60508. * @param name is a string, the name given to the new mesh
  60509. * @param newGenerator use new generator object for cloned trail mesh
  60510. * @returns a new mesh
  60511. */
  60512. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  60513. /**
  60514. * Serializes this trail mesh
  60515. * @param serializationObject object to write serialization to
  60516. */
  60517. serialize(serializationObject: any): void;
  60518. /**
  60519. * Parses a serialized trail mesh
  60520. * @param parsedMesh the serialized mesh
  60521. * @param scene the scene to create the trail mesh in
  60522. * @returns the created trail mesh
  60523. */
  60524. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  60525. }
  60526. }
  60527. declare module BABYLON {
  60528. /**
  60529. * Class containing static functions to help procedurally build meshes
  60530. */
  60531. export class TiledBoxBuilder {
  60532. /**
  60533. * Creates a box mesh
  60534. * 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)
  60535. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60536. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60537. * * 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
  60538. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60539. * @param name defines the name of the mesh
  60540. * @param options defines the options used to create the mesh
  60541. * @param scene defines the hosting scene
  60542. * @returns the box mesh
  60543. */
  60544. static CreateTiledBox(name: string, options: {
  60545. pattern?: number;
  60546. width?: number;
  60547. height?: number;
  60548. depth?: number;
  60549. tileSize?: number;
  60550. tileWidth?: number;
  60551. tileHeight?: number;
  60552. alignHorizontal?: number;
  60553. alignVertical?: number;
  60554. faceUV?: Vector4[];
  60555. faceColors?: Color4[];
  60556. sideOrientation?: number;
  60557. updatable?: boolean;
  60558. }, scene?: Nullable<Scene>): Mesh;
  60559. }
  60560. }
  60561. declare module BABYLON {
  60562. /**
  60563. * Class containing static functions to help procedurally build meshes
  60564. */
  60565. export class TorusKnotBuilder {
  60566. /**
  60567. * Creates a torus knot mesh
  60568. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  60569. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  60570. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  60571. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  60572. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60573. * * 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
  60574. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60575. * @param name defines the name of the mesh
  60576. * @param options defines the options used to create the mesh
  60577. * @param scene defines the hosting scene
  60578. * @returns the torus knot mesh
  60579. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  60580. */
  60581. static CreateTorusKnot(name: string, options: {
  60582. radius?: number;
  60583. tube?: number;
  60584. radialSegments?: number;
  60585. tubularSegments?: number;
  60586. p?: number;
  60587. q?: number;
  60588. updatable?: boolean;
  60589. sideOrientation?: number;
  60590. frontUVs?: Vector4;
  60591. backUVs?: Vector4;
  60592. }, scene: any): Mesh;
  60593. }
  60594. }
  60595. declare module BABYLON {
  60596. /**
  60597. * Polygon
  60598. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  60599. */
  60600. export class Polygon {
  60601. /**
  60602. * Creates a rectangle
  60603. * @param xmin bottom X coord
  60604. * @param ymin bottom Y coord
  60605. * @param xmax top X coord
  60606. * @param ymax top Y coord
  60607. * @returns points that make the resulting rectation
  60608. */
  60609. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  60610. /**
  60611. * Creates a circle
  60612. * @param radius radius of circle
  60613. * @param cx scale in x
  60614. * @param cy scale in y
  60615. * @param numberOfSides number of sides that make up the circle
  60616. * @returns points that make the resulting circle
  60617. */
  60618. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  60619. /**
  60620. * Creates a polygon from input string
  60621. * @param input Input polygon data
  60622. * @returns the parsed points
  60623. */
  60624. static Parse(input: string): Vector2[];
  60625. /**
  60626. * Starts building a polygon from x and y coordinates
  60627. * @param x x coordinate
  60628. * @param y y coordinate
  60629. * @returns the started path2
  60630. */
  60631. static StartingAt(x: number, y: number): Path2;
  60632. }
  60633. /**
  60634. * Builds a polygon
  60635. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  60636. */
  60637. export class PolygonMeshBuilder {
  60638. private _points;
  60639. private _outlinepoints;
  60640. private _holes;
  60641. private _name;
  60642. private _scene;
  60643. private _epoints;
  60644. private _eholes;
  60645. private _addToepoint;
  60646. /**
  60647. * Babylon reference to the earcut plugin.
  60648. */
  60649. bjsEarcut: any;
  60650. /**
  60651. * Creates a PolygonMeshBuilder
  60652. * @param name name of the builder
  60653. * @param contours Path of the polygon
  60654. * @param scene scene to add to when creating the mesh
  60655. * @param earcutInjection can be used to inject your own earcut reference
  60656. */
  60657. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  60658. /**
  60659. * Adds a whole within the polygon
  60660. * @param hole Array of points defining the hole
  60661. * @returns this
  60662. */
  60663. addHole(hole: Vector2[]): PolygonMeshBuilder;
  60664. /**
  60665. * Creates the polygon
  60666. * @param updatable If the mesh should be updatable
  60667. * @param depth The depth of the mesh created
  60668. * @returns the created mesh
  60669. */
  60670. build(updatable?: boolean, depth?: number): Mesh;
  60671. /**
  60672. * Creates the polygon
  60673. * @param depth The depth of the mesh created
  60674. * @returns the created VertexData
  60675. */
  60676. buildVertexData(depth?: number): VertexData;
  60677. /**
  60678. * Adds a side to the polygon
  60679. * @param positions points that make the polygon
  60680. * @param normals normals of the polygon
  60681. * @param uvs uvs of the polygon
  60682. * @param indices indices of the polygon
  60683. * @param bounds bounds of the polygon
  60684. * @param points points of the polygon
  60685. * @param depth depth of the polygon
  60686. * @param flip flip of the polygon
  60687. */
  60688. private addSide;
  60689. }
  60690. }
  60691. declare module BABYLON {
  60692. /**
  60693. * Class containing static functions to help procedurally build meshes
  60694. */
  60695. export class PolygonBuilder {
  60696. /**
  60697. * Creates a polygon mesh
  60698. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  60699. * * 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
  60700. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60701. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60702. * * 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)
  60703. * * Remember you can only change the shape positions, not their number when updating a polygon
  60704. * @param name defines the name of the mesh
  60705. * @param options defines the options used to create the mesh
  60706. * @param scene defines the hosting scene
  60707. * @param earcutInjection can be used to inject your own earcut reference
  60708. * @returns the polygon mesh
  60709. */
  60710. static CreatePolygon(name: string, options: {
  60711. shape: Vector3[];
  60712. holes?: Vector3[][];
  60713. depth?: number;
  60714. faceUV?: Vector4[];
  60715. faceColors?: Color4[];
  60716. updatable?: boolean;
  60717. sideOrientation?: number;
  60718. frontUVs?: Vector4;
  60719. backUVs?: Vector4;
  60720. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60721. /**
  60722. * Creates an extruded polygon mesh, with depth in the Y direction.
  60723. * * 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)
  60724. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60725. * @param name defines the name of the mesh
  60726. * @param options defines the options used to create the mesh
  60727. * @param scene defines the hosting scene
  60728. * @param earcutInjection can be used to inject your own earcut reference
  60729. * @returns the polygon mesh
  60730. */
  60731. static ExtrudePolygon(name: string, options: {
  60732. shape: Vector3[];
  60733. holes?: Vector3[][];
  60734. depth?: number;
  60735. faceUV?: Vector4[];
  60736. faceColors?: Color4[];
  60737. updatable?: boolean;
  60738. sideOrientation?: number;
  60739. frontUVs?: Vector4;
  60740. backUVs?: Vector4;
  60741. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  60742. }
  60743. }
  60744. declare module BABYLON {
  60745. /**
  60746. * Class containing static functions to help procedurally build meshes
  60747. */
  60748. export class LatheBuilder {
  60749. /**
  60750. * Creates lathe mesh.
  60751. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  60752. * * 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
  60753. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  60754. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  60755. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  60756. * * 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
  60757. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  60758. * * 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
  60759. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60760. * * 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
  60761. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60762. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60763. * @param name defines the name of the mesh
  60764. * @param options defines the options used to create the mesh
  60765. * @param scene defines the hosting scene
  60766. * @returns the lathe mesh
  60767. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  60768. */
  60769. static CreateLathe(name: string, options: {
  60770. shape: Vector3[];
  60771. radius?: number;
  60772. tessellation?: number;
  60773. clip?: number;
  60774. arc?: number;
  60775. closed?: boolean;
  60776. updatable?: boolean;
  60777. sideOrientation?: number;
  60778. frontUVs?: Vector4;
  60779. backUVs?: Vector4;
  60780. cap?: number;
  60781. invertUV?: boolean;
  60782. }, scene?: Nullable<Scene>): Mesh;
  60783. }
  60784. }
  60785. declare module BABYLON {
  60786. /**
  60787. * Class containing static functions to help procedurally build meshes
  60788. */
  60789. export class TiledPlaneBuilder {
  60790. /**
  60791. * Creates a tiled plane mesh
  60792. * * The parameter `pattern` will, depending on value, do nothing or
  60793. * * * flip (reflect about central vertical) alternate tiles across and up
  60794. * * * flip every tile on alternate rows
  60795. * * * rotate (180 degs) alternate tiles across and up
  60796. * * * rotate every tile on alternate rows
  60797. * * * flip and rotate alternate tiles across and up
  60798. * * * flip and rotate every tile on alternate rows
  60799. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  60800. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  60801. * * 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
  60802. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  60803. * * 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)
  60804. * * 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)
  60805. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  60806. * @param name defines the name of the mesh
  60807. * @param options defines the options used to create the mesh
  60808. * @param scene defines the hosting scene
  60809. * @returns the box mesh
  60810. */
  60811. static CreateTiledPlane(name: string, options: {
  60812. pattern?: number;
  60813. tileSize?: number;
  60814. tileWidth?: number;
  60815. tileHeight?: number;
  60816. size?: number;
  60817. width?: number;
  60818. height?: number;
  60819. alignHorizontal?: number;
  60820. alignVertical?: number;
  60821. sideOrientation?: number;
  60822. frontUVs?: Vector4;
  60823. backUVs?: Vector4;
  60824. updatable?: boolean;
  60825. }, scene?: Nullable<Scene>): Mesh;
  60826. }
  60827. }
  60828. declare module BABYLON {
  60829. /**
  60830. * Class containing static functions to help procedurally build meshes
  60831. */
  60832. export class TubeBuilder {
  60833. /**
  60834. * Creates a tube mesh.
  60835. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60836. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  60837. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  60838. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  60839. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  60840. * * 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)
  60841. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  60842. * * 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
  60843. * * 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
  60844. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60845. * * 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
  60846. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60847. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60848. * @param name defines the name of the mesh
  60849. * @param options defines the options used to create the mesh
  60850. * @param scene defines the hosting scene
  60851. * @returns the tube mesh
  60852. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60853. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  60854. */
  60855. static CreateTube(name: string, options: {
  60856. path: Vector3[];
  60857. radius?: number;
  60858. tessellation?: number;
  60859. radiusFunction?: {
  60860. (i: number, distance: number): number;
  60861. };
  60862. cap?: number;
  60863. arc?: number;
  60864. updatable?: boolean;
  60865. sideOrientation?: number;
  60866. frontUVs?: Vector4;
  60867. backUVs?: Vector4;
  60868. instance?: Mesh;
  60869. invertUV?: boolean;
  60870. }, scene?: Nullable<Scene>): Mesh;
  60871. }
  60872. }
  60873. declare module BABYLON {
  60874. /**
  60875. * Class containing static functions to help procedurally build meshes
  60876. */
  60877. export class IcoSphereBuilder {
  60878. /**
  60879. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  60880. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  60881. * * 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`)
  60882. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  60883. * * 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
  60884. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60885. * * 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
  60886. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60887. * @param name defines the name of the mesh
  60888. * @param options defines the options used to create the mesh
  60889. * @param scene defines the hosting scene
  60890. * @returns the icosahedron mesh
  60891. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  60892. */
  60893. static CreateIcoSphere(name: string, options: {
  60894. radius?: number;
  60895. radiusX?: number;
  60896. radiusY?: number;
  60897. radiusZ?: number;
  60898. flat?: boolean;
  60899. subdivisions?: number;
  60900. sideOrientation?: number;
  60901. frontUVs?: Vector4;
  60902. backUVs?: Vector4;
  60903. updatable?: boolean;
  60904. }, scene?: Nullable<Scene>): Mesh;
  60905. }
  60906. }
  60907. declare module BABYLON {
  60908. /**
  60909. * Class containing static functions to help procedurally build meshes
  60910. */
  60911. export class DecalBuilder {
  60912. /**
  60913. * Creates a decal mesh.
  60914. * 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
  60915. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  60916. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  60917. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  60918. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  60919. * @param name defines the name of the mesh
  60920. * @param sourceMesh defines the mesh where the decal must be applied
  60921. * @param options defines the options used to create the mesh
  60922. * @param scene defines the hosting scene
  60923. * @returns the decal mesh
  60924. * @see https://doc.babylonjs.com/how_to/decals
  60925. */
  60926. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  60927. position?: Vector3;
  60928. normal?: Vector3;
  60929. size?: Vector3;
  60930. angle?: number;
  60931. }): Mesh;
  60932. }
  60933. }
  60934. declare module BABYLON {
  60935. /**
  60936. * Class containing static functions to help procedurally build meshes
  60937. */
  60938. export class MeshBuilder {
  60939. /**
  60940. * Creates a box mesh
  60941. * * The parameter `size` sets the size (float) of each box side (default 1)
  60942. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  60943. * * 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)
  60944. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  60945. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60946. * * 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
  60947. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60948. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  60949. * @param name defines the name of the mesh
  60950. * @param options defines the options used to create the mesh
  60951. * @param scene defines the hosting scene
  60952. * @returns the box mesh
  60953. */
  60954. static CreateBox(name: string, options: {
  60955. size?: number;
  60956. width?: number;
  60957. height?: number;
  60958. depth?: number;
  60959. faceUV?: Vector4[];
  60960. faceColors?: Color4[];
  60961. sideOrientation?: number;
  60962. frontUVs?: Vector4;
  60963. backUVs?: Vector4;
  60964. updatable?: boolean;
  60965. }, scene?: Nullable<Scene>): Mesh;
  60966. /**
  60967. * Creates a tiled box mesh
  60968. * * faceTiles sets the pattern, tile size and number of tiles for a face
  60969. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60970. * @param name defines the name of the mesh
  60971. * @param options defines the options used to create the mesh
  60972. * @param scene defines the hosting scene
  60973. * @returns the tiled box mesh
  60974. */
  60975. static CreateTiledBox(name: string, options: {
  60976. pattern?: number;
  60977. size?: number;
  60978. width?: number;
  60979. height?: number;
  60980. depth: number;
  60981. tileSize?: number;
  60982. tileWidth?: number;
  60983. tileHeight?: number;
  60984. faceUV?: Vector4[];
  60985. faceColors?: Color4[];
  60986. alignHorizontal?: number;
  60987. alignVertical?: number;
  60988. sideOrientation?: number;
  60989. updatable?: boolean;
  60990. }, scene?: Nullable<Scene>): Mesh;
  60991. /**
  60992. * Creates a sphere mesh
  60993. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  60994. * * 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`)
  60995. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  60996. * * 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
  60997. * * 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)
  60998. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60999. * * 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
  61000. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61001. * @param name defines the name of the mesh
  61002. * @param options defines the options used to create the mesh
  61003. * @param scene defines the hosting scene
  61004. * @returns the sphere mesh
  61005. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  61006. */
  61007. static CreateSphere(name: string, options: {
  61008. segments?: number;
  61009. diameter?: number;
  61010. diameterX?: number;
  61011. diameterY?: number;
  61012. diameterZ?: number;
  61013. arc?: number;
  61014. slice?: number;
  61015. sideOrientation?: number;
  61016. frontUVs?: Vector4;
  61017. backUVs?: Vector4;
  61018. updatable?: boolean;
  61019. }, scene?: Nullable<Scene>): Mesh;
  61020. /**
  61021. * Creates a plane polygonal mesh. By default, this is a disc
  61022. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  61023. * * 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
  61024. * * 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
  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. * @param name defines the name of the mesh
  61029. * @param options defines the options used to create the mesh
  61030. * @param scene defines the hosting scene
  61031. * @returns the plane polygonal mesh
  61032. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  61033. */
  61034. static CreateDisc(name: string, options: {
  61035. radius?: number;
  61036. tessellation?: number;
  61037. arc?: number;
  61038. updatable?: boolean;
  61039. sideOrientation?: number;
  61040. frontUVs?: Vector4;
  61041. backUVs?: Vector4;
  61042. }, scene?: Nullable<Scene>): Mesh;
  61043. /**
  61044. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  61045. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  61046. * * 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`)
  61047. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  61048. * * 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
  61049. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61050. * * 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
  61051. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61052. * @param name defines the name of the mesh
  61053. * @param options defines the options used to create the mesh
  61054. * @param scene defines the hosting scene
  61055. * @returns the icosahedron mesh
  61056. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  61057. */
  61058. static CreateIcoSphere(name: string, options: {
  61059. radius?: number;
  61060. radiusX?: number;
  61061. radiusY?: number;
  61062. radiusZ?: number;
  61063. flat?: boolean;
  61064. subdivisions?: number;
  61065. sideOrientation?: number;
  61066. frontUVs?: Vector4;
  61067. backUVs?: Vector4;
  61068. updatable?: boolean;
  61069. }, scene?: Nullable<Scene>): Mesh;
  61070. /**
  61071. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61072. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  61073. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  61074. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  61075. * * 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
  61076. * * 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
  61077. * * 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
  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 optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61081. * * 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
  61082. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  61083. * * 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
  61084. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  61085. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61086. * @param name defines the name of the mesh
  61087. * @param options defines the options used to create the mesh
  61088. * @param scene defines the hosting scene
  61089. * @returns the ribbon mesh
  61090. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  61091. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61092. */
  61093. static CreateRibbon(name: string, options: {
  61094. pathArray: Vector3[][];
  61095. closeArray?: boolean;
  61096. closePath?: boolean;
  61097. offset?: number;
  61098. updatable?: boolean;
  61099. sideOrientation?: number;
  61100. frontUVs?: Vector4;
  61101. backUVs?: Vector4;
  61102. instance?: Mesh;
  61103. invertUV?: boolean;
  61104. uvs?: Vector2[];
  61105. colors?: Color4[];
  61106. }, scene?: Nullable<Scene>): Mesh;
  61107. /**
  61108. * Creates a cylinder or a cone mesh
  61109. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  61110. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  61111. * * 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.
  61112. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  61113. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  61114. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  61115. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  61116. * * 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).
  61117. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  61118. * * 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).
  61119. * * 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
  61120. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  61121. * * 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
  61122. * * 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.
  61123. * * If `enclose` is false, a ring surface is one element.
  61124. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  61125. * * 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
  61126. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61127. * * 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
  61128. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61129. * @param name defines the name of the mesh
  61130. * @param options defines the options used to create the mesh
  61131. * @param scene defines the hosting scene
  61132. * @returns the cylinder mesh
  61133. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  61134. */
  61135. static CreateCylinder(name: string, options: {
  61136. height?: number;
  61137. diameterTop?: number;
  61138. diameterBottom?: number;
  61139. diameter?: number;
  61140. tessellation?: number;
  61141. subdivisions?: number;
  61142. arc?: number;
  61143. faceColors?: Color4[];
  61144. faceUV?: Vector4[];
  61145. updatable?: boolean;
  61146. hasRings?: boolean;
  61147. enclose?: boolean;
  61148. cap?: number;
  61149. sideOrientation?: number;
  61150. frontUVs?: Vector4;
  61151. backUVs?: Vector4;
  61152. }, scene?: Nullable<Scene>): Mesh;
  61153. /**
  61154. * Creates a torus mesh
  61155. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  61156. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  61157. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  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 mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61161. * @param name defines the name of the mesh
  61162. * @param options defines the options used to create the mesh
  61163. * @param scene defines the hosting scene
  61164. * @returns the torus mesh
  61165. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  61166. */
  61167. static CreateTorus(name: string, options: {
  61168. diameter?: number;
  61169. thickness?: number;
  61170. tessellation?: number;
  61171. updatable?: boolean;
  61172. sideOrientation?: number;
  61173. frontUVs?: Vector4;
  61174. backUVs?: Vector4;
  61175. }, scene?: Nullable<Scene>): Mesh;
  61176. /**
  61177. * Creates a torus knot mesh
  61178. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  61179. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  61180. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  61181. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  61182. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61183. * * 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
  61184. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61185. * @param name defines the name of the mesh
  61186. * @param options defines the options used to create the mesh
  61187. * @param scene defines the hosting scene
  61188. * @returns the torus knot mesh
  61189. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  61190. */
  61191. static CreateTorusKnot(name: string, options: {
  61192. radius?: number;
  61193. tube?: number;
  61194. radialSegments?: number;
  61195. tubularSegments?: number;
  61196. p?: number;
  61197. q?: number;
  61198. updatable?: boolean;
  61199. sideOrientation?: number;
  61200. frontUVs?: Vector4;
  61201. backUVs?: Vector4;
  61202. }, scene?: Nullable<Scene>): Mesh;
  61203. /**
  61204. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  61205. * * 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
  61206. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  61207. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  61208. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  61209. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  61210. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  61211. * * 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
  61212. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  61213. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61214. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  61215. * @param name defines the name of the new line system
  61216. * @param options defines the options used to create the line system
  61217. * @param scene defines the hosting scene
  61218. * @returns a new line system mesh
  61219. */
  61220. static CreateLineSystem(name: string, options: {
  61221. lines: Vector3[][];
  61222. updatable?: boolean;
  61223. instance?: Nullable<LinesMesh>;
  61224. colors?: Nullable<Color4[][]>;
  61225. useVertexAlpha?: boolean;
  61226. }, scene: Nullable<Scene>): LinesMesh;
  61227. /**
  61228. * Creates a line mesh
  61229. * 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
  61230. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61231. * * The parameter `points` is an array successive Vector3
  61232. * * 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
  61233. * * The optional parameter `colors` is an array of successive Color4, one per line point
  61234. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  61235. * * When updating an instance, remember that only point positions can change, not the number of points
  61236. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61237. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  61238. * @param name defines the name of the new line system
  61239. * @param options defines the options used to create the line system
  61240. * @param scene defines the hosting scene
  61241. * @returns a new line mesh
  61242. */
  61243. static CreateLines(name: string, options: {
  61244. points: Vector3[];
  61245. updatable?: boolean;
  61246. instance?: Nullable<LinesMesh>;
  61247. colors?: Color4[];
  61248. useVertexAlpha?: boolean;
  61249. }, scene?: Nullable<Scene>): LinesMesh;
  61250. /**
  61251. * Creates a dashed line mesh
  61252. * * 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
  61253. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  61254. * * The parameter `points` is an array successive Vector3
  61255. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  61256. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  61257. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  61258. * * 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
  61259. * * When updating an instance, remember that only point positions can change, not the number of points
  61260. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61261. * @param name defines the name of the mesh
  61262. * @param options defines the options used to create the mesh
  61263. * @param scene defines the hosting scene
  61264. * @returns the dashed line mesh
  61265. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  61266. */
  61267. static CreateDashedLines(name: string, options: {
  61268. points: Vector3[];
  61269. dashSize?: number;
  61270. gapSize?: number;
  61271. dashNb?: number;
  61272. updatable?: boolean;
  61273. instance?: LinesMesh;
  61274. }, scene?: Nullable<Scene>): LinesMesh;
  61275. /**
  61276. * 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.
  61277. * * 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.
  61278. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61279. * * 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.
  61280. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  61281. * * 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
  61282. * * 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
  61283. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  61284. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61285. * * 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
  61286. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  61287. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61288. * @param name defines the name of the mesh
  61289. * @param options defines the options used to create the mesh
  61290. * @param scene defines the hosting scene
  61291. * @returns the extruded shape mesh
  61292. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61293. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61294. */
  61295. static ExtrudeShape(name: string, options: {
  61296. shape: Vector3[];
  61297. path: Vector3[];
  61298. scale?: number;
  61299. rotation?: number;
  61300. cap?: number;
  61301. updatable?: boolean;
  61302. sideOrientation?: number;
  61303. frontUVs?: Vector4;
  61304. backUVs?: Vector4;
  61305. instance?: Mesh;
  61306. invertUV?: boolean;
  61307. }, scene?: Nullable<Scene>): Mesh;
  61308. /**
  61309. * Creates an custom extruded shape mesh.
  61310. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  61311. * * 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.
  61312. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  61313. * * 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
  61314. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  61315. * * 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
  61316. * * It must returns a float value that will be the scale value applied to the shape on each path point
  61317. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  61318. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  61319. * * 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
  61320. * * 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
  61321. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  61322. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61323. * * 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
  61324. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61325. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61326. * @param name defines the name of the mesh
  61327. * @param options defines the options used to create the mesh
  61328. * @param scene defines the hosting scene
  61329. * @returns the custom extruded shape mesh
  61330. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  61331. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61332. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  61333. */
  61334. static ExtrudeShapeCustom(name: string, options: {
  61335. shape: Vector3[];
  61336. path: Vector3[];
  61337. scaleFunction?: any;
  61338. rotationFunction?: any;
  61339. ribbonCloseArray?: boolean;
  61340. ribbonClosePath?: boolean;
  61341. cap?: number;
  61342. updatable?: boolean;
  61343. sideOrientation?: number;
  61344. frontUVs?: Vector4;
  61345. backUVs?: Vector4;
  61346. instance?: Mesh;
  61347. invertUV?: boolean;
  61348. }, scene?: Nullable<Scene>): Mesh;
  61349. /**
  61350. * Creates lathe mesh.
  61351. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  61352. * * 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
  61353. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  61354. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  61355. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  61356. * * 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
  61357. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  61358. * * 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
  61359. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61360. * * 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
  61361. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  61362. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61363. * @param name defines the name of the mesh
  61364. * @param options defines the options used to create the mesh
  61365. * @param scene defines the hosting scene
  61366. * @returns the lathe mesh
  61367. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  61368. */
  61369. static CreateLathe(name: string, options: {
  61370. shape: Vector3[];
  61371. radius?: number;
  61372. tessellation?: number;
  61373. clip?: number;
  61374. arc?: number;
  61375. closed?: boolean;
  61376. updatable?: boolean;
  61377. sideOrientation?: number;
  61378. frontUVs?: Vector4;
  61379. backUVs?: Vector4;
  61380. cap?: number;
  61381. invertUV?: boolean;
  61382. }, scene?: Nullable<Scene>): Mesh;
  61383. /**
  61384. * Creates a tiled plane mesh
  61385. * * You can set a limited pattern arrangement with the tiles
  61386. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61387. * * 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
  61388. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61389. * @param name defines the name of the mesh
  61390. * @param options defines the options used to create the mesh
  61391. * @param scene defines the hosting scene
  61392. * @returns the plane mesh
  61393. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61394. */
  61395. static CreateTiledPlane(name: string, options: {
  61396. pattern?: number;
  61397. tileSize?: number;
  61398. tileWidth?: number;
  61399. tileHeight?: number;
  61400. size?: number;
  61401. width?: number;
  61402. height?: number;
  61403. alignHorizontal?: number;
  61404. alignVertical?: number;
  61405. sideOrientation?: number;
  61406. frontUVs?: Vector4;
  61407. backUVs?: Vector4;
  61408. updatable?: boolean;
  61409. }, scene?: Nullable<Scene>): Mesh;
  61410. /**
  61411. * Creates a plane mesh
  61412. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  61413. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  61414. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  61415. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61416. * * 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
  61417. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61418. * @param name defines the name of the mesh
  61419. * @param options defines the options used to create the mesh
  61420. * @param scene defines the hosting scene
  61421. * @returns the plane mesh
  61422. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  61423. */
  61424. static CreatePlane(name: string, options: {
  61425. size?: number;
  61426. width?: number;
  61427. height?: number;
  61428. sideOrientation?: number;
  61429. frontUVs?: Vector4;
  61430. backUVs?: Vector4;
  61431. updatable?: boolean;
  61432. sourcePlane?: Plane;
  61433. }, scene?: Nullable<Scene>): Mesh;
  61434. /**
  61435. * Creates a ground mesh
  61436. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  61437. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  61438. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61439. * @param name defines the name of the mesh
  61440. * @param options defines the options used to create the mesh
  61441. * @param scene defines the hosting scene
  61442. * @returns the ground mesh
  61443. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  61444. */
  61445. static CreateGround(name: string, options: {
  61446. width?: number;
  61447. height?: number;
  61448. subdivisions?: number;
  61449. subdivisionsX?: number;
  61450. subdivisionsY?: number;
  61451. updatable?: boolean;
  61452. }, scene?: Nullable<Scene>): Mesh;
  61453. /**
  61454. * Creates a tiled ground mesh
  61455. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  61456. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  61457. * * 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
  61458. * * 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
  61459. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61460. * @param name defines the name of the mesh
  61461. * @param options defines the options used to create the mesh
  61462. * @param scene defines the hosting scene
  61463. * @returns the tiled ground mesh
  61464. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  61465. */
  61466. static CreateTiledGround(name: string, options: {
  61467. xmin: number;
  61468. zmin: number;
  61469. xmax: number;
  61470. zmax: number;
  61471. subdivisions?: {
  61472. w: number;
  61473. h: number;
  61474. };
  61475. precision?: {
  61476. w: number;
  61477. h: number;
  61478. };
  61479. updatable?: boolean;
  61480. }, scene?: Nullable<Scene>): Mesh;
  61481. /**
  61482. * Creates a ground mesh from a height map
  61483. * * The parameter `url` sets the URL of the height map image resource.
  61484. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  61485. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  61486. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  61487. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  61488. * * 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.
  61489. * * 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).
  61490. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  61491. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  61492. * @param name defines the name of the mesh
  61493. * @param url defines the url to the height map
  61494. * @param options defines the options used to create the mesh
  61495. * @param scene defines the hosting scene
  61496. * @returns the ground mesh
  61497. * @see https://doc.babylonjs.com/babylon101/height_map
  61498. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  61499. */
  61500. static CreateGroundFromHeightMap(name: string, url: string, options: {
  61501. width?: number;
  61502. height?: number;
  61503. subdivisions?: number;
  61504. minHeight?: number;
  61505. maxHeight?: number;
  61506. colorFilter?: Color3;
  61507. alphaFilter?: number;
  61508. updatable?: boolean;
  61509. onReady?: (mesh: GroundMesh) => void;
  61510. }, scene?: Nullable<Scene>): GroundMesh;
  61511. /**
  61512. * Creates a polygon mesh
  61513. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  61514. * * 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
  61515. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  61516. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61517. * * 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)
  61518. * * Remember you can only change the shape positions, not their number when updating a polygon
  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. * @param earcutInjection can be used to inject your own earcut reference
  61523. * @returns the polygon mesh
  61524. */
  61525. static CreatePolygon(name: string, options: {
  61526. shape: Vector3[];
  61527. holes?: Vector3[][];
  61528. depth?: number;
  61529. faceUV?: Vector4[];
  61530. faceColors?: Color4[];
  61531. updatable?: boolean;
  61532. sideOrientation?: number;
  61533. frontUVs?: Vector4;
  61534. backUVs?: Vector4;
  61535. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61536. /**
  61537. * Creates an extruded polygon mesh, with depth in the Y direction.
  61538. * * 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)
  61539. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  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. * @param earcutInjection can be used to inject your own earcut reference
  61544. * @returns the polygon mesh
  61545. */
  61546. static ExtrudePolygon(name: string, options: {
  61547. shape: Vector3[];
  61548. holes?: Vector3[][];
  61549. depth?: number;
  61550. faceUV?: Vector4[];
  61551. faceColors?: Color4[];
  61552. updatable?: boolean;
  61553. sideOrientation?: number;
  61554. frontUVs?: Vector4;
  61555. backUVs?: Vector4;
  61556. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  61557. /**
  61558. * Creates a tube mesh.
  61559. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  61560. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  61561. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  61562. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  61563. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  61564. * * 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)
  61565. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  61566. * * 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
  61567. * * 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
  61568. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61569. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  61570. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  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 options defines the options used to create the mesh
  61574. * @param scene defines the hosting scene
  61575. * @returns the tube mesh
  61576. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  61577. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  61578. */
  61579. static CreateTube(name: string, options: {
  61580. path: Vector3[];
  61581. radius?: number;
  61582. tessellation?: number;
  61583. radiusFunction?: {
  61584. (i: number, distance: number): number;
  61585. };
  61586. cap?: number;
  61587. arc?: number;
  61588. updatable?: boolean;
  61589. sideOrientation?: number;
  61590. frontUVs?: Vector4;
  61591. backUVs?: Vector4;
  61592. instance?: Mesh;
  61593. invertUV?: boolean;
  61594. }, scene?: Nullable<Scene>): Mesh;
  61595. /**
  61596. * Creates a polyhedron mesh
  61597. * * 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
  61598. * * The parameter `size` (positive float, default 1) sets the polygon size
  61599. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  61600. * * 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`
  61601. * * 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
  61602. * * 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)`)
  61603. * * 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
  61604. * * 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
  61605. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  61606. * * 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
  61607. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  61608. * @param name defines the name of the mesh
  61609. * @param options defines the options used to create the mesh
  61610. * @param scene defines the hosting scene
  61611. * @returns the polyhedron mesh
  61612. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  61613. */
  61614. static CreatePolyhedron(name: string, options: {
  61615. type?: number;
  61616. size?: number;
  61617. sizeX?: number;
  61618. sizeY?: number;
  61619. sizeZ?: number;
  61620. custom?: any;
  61621. faceUV?: Vector4[];
  61622. faceColors?: Color4[];
  61623. flat?: boolean;
  61624. updatable?: boolean;
  61625. sideOrientation?: number;
  61626. frontUVs?: Vector4;
  61627. backUVs?: Vector4;
  61628. }, scene?: Nullable<Scene>): Mesh;
  61629. /**
  61630. * Creates a decal mesh.
  61631. * 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
  61632. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  61633. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  61634. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  61635. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  61636. * @param name defines the name of the mesh
  61637. * @param sourceMesh defines the mesh where the decal must be applied
  61638. * @param options defines the options used to create the mesh
  61639. * @param scene defines the hosting scene
  61640. * @returns the decal mesh
  61641. * @see https://doc.babylonjs.com/how_to/decals
  61642. */
  61643. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  61644. position?: Vector3;
  61645. normal?: Vector3;
  61646. size?: Vector3;
  61647. angle?: number;
  61648. }): Mesh;
  61649. }
  61650. }
  61651. declare module BABYLON {
  61652. /**
  61653. * A simplifier interface for future simplification implementations
  61654. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61655. */
  61656. export interface ISimplifier {
  61657. /**
  61658. * Simplification of a given mesh according to the given settings.
  61659. * Since this requires computation, it is assumed that the function runs async.
  61660. * @param settings The settings of the simplification, including quality and distance
  61661. * @param successCallback A callback that will be called after the mesh was simplified.
  61662. * @param errorCallback in case of an error, this callback will be called. optional.
  61663. */
  61664. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  61665. }
  61666. /**
  61667. * Expected simplification settings.
  61668. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  61669. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61670. */
  61671. export interface ISimplificationSettings {
  61672. /**
  61673. * Gets or sets the expected quality
  61674. */
  61675. quality: number;
  61676. /**
  61677. * Gets or sets the distance when this optimized version should be used
  61678. */
  61679. distance: number;
  61680. /**
  61681. * Gets an already optimized mesh
  61682. */
  61683. optimizeMesh?: boolean;
  61684. }
  61685. /**
  61686. * Class used to specify simplification options
  61687. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61688. */
  61689. export class SimplificationSettings implements ISimplificationSettings {
  61690. /** expected quality */
  61691. quality: number;
  61692. /** distance when this optimized version should be used */
  61693. distance: number;
  61694. /** already optimized mesh */
  61695. optimizeMesh?: boolean | undefined;
  61696. /**
  61697. * Creates a SimplificationSettings
  61698. * @param quality expected quality
  61699. * @param distance distance when this optimized version should be used
  61700. * @param optimizeMesh already optimized mesh
  61701. */
  61702. constructor(
  61703. /** expected quality */
  61704. quality: number,
  61705. /** distance when this optimized version should be used */
  61706. distance: number,
  61707. /** already optimized mesh */
  61708. optimizeMesh?: boolean | undefined);
  61709. }
  61710. /**
  61711. * Interface used to define a simplification task
  61712. */
  61713. export interface ISimplificationTask {
  61714. /**
  61715. * Array of settings
  61716. */
  61717. settings: Array<ISimplificationSettings>;
  61718. /**
  61719. * Simplification type
  61720. */
  61721. simplificationType: SimplificationType;
  61722. /**
  61723. * Mesh to simplify
  61724. */
  61725. mesh: Mesh;
  61726. /**
  61727. * Callback called on success
  61728. */
  61729. successCallback?: () => void;
  61730. /**
  61731. * Defines if parallel processing can be used
  61732. */
  61733. parallelProcessing: boolean;
  61734. }
  61735. /**
  61736. * Queue used to order the simplification tasks
  61737. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61738. */
  61739. export class SimplificationQueue {
  61740. private _simplificationArray;
  61741. /**
  61742. * Gets a boolean indicating that the process is still running
  61743. */
  61744. running: boolean;
  61745. /**
  61746. * Creates a new queue
  61747. */
  61748. constructor();
  61749. /**
  61750. * Adds a new simplification task
  61751. * @param task defines a task to add
  61752. */
  61753. addTask(task: ISimplificationTask): void;
  61754. /**
  61755. * Execute next task
  61756. */
  61757. executeNext(): void;
  61758. /**
  61759. * Execute a simplification task
  61760. * @param task defines the task to run
  61761. */
  61762. runSimplification(task: ISimplificationTask): void;
  61763. private getSimplifier;
  61764. }
  61765. /**
  61766. * The implemented types of simplification
  61767. * At the moment only Quadratic Error Decimation is implemented
  61768. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61769. */
  61770. export enum SimplificationType {
  61771. /** Quadratic error decimation */
  61772. QUADRATIC = 0
  61773. }
  61774. }
  61775. declare module BABYLON {
  61776. interface Scene {
  61777. /** @hidden (Backing field) */
  61778. _simplificationQueue: SimplificationQueue;
  61779. /**
  61780. * Gets or sets the simplification queue attached to the scene
  61781. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  61782. */
  61783. simplificationQueue: SimplificationQueue;
  61784. }
  61785. interface Mesh {
  61786. /**
  61787. * Simplify the mesh according to the given array of settings.
  61788. * Function will return immediately and will simplify async
  61789. * @param settings a collection of simplification settings
  61790. * @param parallelProcessing should all levels calculate parallel or one after the other
  61791. * @param simplificationType the type of simplification to run
  61792. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  61793. * @returns the current mesh
  61794. */
  61795. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  61796. }
  61797. /**
  61798. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  61799. * created in a scene
  61800. */
  61801. export class SimplicationQueueSceneComponent implements ISceneComponent {
  61802. /**
  61803. * The component name helpfull to identify the component in the list of scene components.
  61804. */
  61805. readonly name: string;
  61806. /**
  61807. * The scene the component belongs to.
  61808. */
  61809. scene: Scene;
  61810. /**
  61811. * Creates a new instance of the component for the given scene
  61812. * @param scene Defines the scene to register the component in
  61813. */
  61814. constructor(scene: Scene);
  61815. /**
  61816. * Registers the component in a given scene
  61817. */
  61818. register(): void;
  61819. /**
  61820. * Rebuilds the elements related to this component in case of
  61821. * context lost for instance.
  61822. */
  61823. rebuild(): void;
  61824. /**
  61825. * Disposes the component and the associated ressources
  61826. */
  61827. dispose(): void;
  61828. private _beforeCameraUpdate;
  61829. }
  61830. }
  61831. declare module BABYLON {
  61832. /**
  61833. * Navigation plugin interface to add navigation constrained by a navigation mesh
  61834. */
  61835. export interface INavigationEnginePlugin {
  61836. /**
  61837. * plugin name
  61838. */
  61839. name: string;
  61840. /**
  61841. * Creates a navigation mesh
  61842. * @param meshes array of all the geometry used to compute the navigatio mesh
  61843. * @param parameters bunch of parameters used to filter geometry
  61844. */
  61845. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  61846. /**
  61847. * Create a navigation mesh debug mesh
  61848. * @param scene is where the mesh will be added
  61849. * @returns debug display mesh
  61850. */
  61851. createDebugNavMesh(scene: Scene): Mesh;
  61852. /**
  61853. * Get a navigation mesh constrained position, closest to the parameter position
  61854. * @param position world position
  61855. * @returns the closest point to position constrained by the navigation mesh
  61856. */
  61857. getClosestPoint(position: Vector3): Vector3;
  61858. /**
  61859. * Get a navigation mesh constrained position, within a particular radius
  61860. * @param position world position
  61861. * @param maxRadius the maximum distance to the constrained world position
  61862. * @returns the closest point to position constrained by the navigation mesh
  61863. */
  61864. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  61865. /**
  61866. * Compute the final position from a segment made of destination-position
  61867. * @param position world position
  61868. * @param destination world position
  61869. * @returns the resulting point along the navmesh
  61870. */
  61871. moveAlong(position: Vector3, destination: Vector3): Vector3;
  61872. /**
  61873. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  61874. * @param start world position
  61875. * @param end world position
  61876. * @returns array containing world position composing the path
  61877. */
  61878. computePath(start: Vector3, end: Vector3): Vector3[];
  61879. /**
  61880. * If this plugin is supported
  61881. * @returns true if plugin is supported
  61882. */
  61883. isSupported(): boolean;
  61884. /**
  61885. * Create a new Crowd so you can add agents
  61886. * @param maxAgents the maximum agent count in the crowd
  61887. * @param maxAgentRadius the maximum radius an agent can have
  61888. * @param scene to attach the crowd to
  61889. * @returns the crowd you can add agents to
  61890. */
  61891. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  61892. /**
  61893. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61894. * The queries will try to find a solution within those bounds
  61895. * default is (1,1,1)
  61896. * @param extent x,y,z value that define the extent around the queries point of reference
  61897. */
  61898. setDefaultQueryExtent(extent: Vector3): void;
  61899. /**
  61900. * Get the Bounding box extent specified by setDefaultQueryExtent
  61901. * @returns the box extent values
  61902. */
  61903. getDefaultQueryExtent(): Vector3;
  61904. /**
  61905. * Release all resources
  61906. */
  61907. dispose(): void;
  61908. }
  61909. /**
  61910. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  61911. */
  61912. export interface ICrowd {
  61913. /**
  61914. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  61915. * You can attach anything to that node. The node position is updated in the scene update tick.
  61916. * @param pos world position that will be constrained by the navigation mesh
  61917. * @param parameters agent parameters
  61918. * @param transform hooked to the agent that will be update by the scene
  61919. * @returns agent index
  61920. */
  61921. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  61922. /**
  61923. * Returns the agent position in world space
  61924. * @param index agent index returned by addAgent
  61925. * @returns world space position
  61926. */
  61927. getAgentPosition(index: number): Vector3;
  61928. /**
  61929. * Gets the agent velocity in world space
  61930. * @param index agent index returned by addAgent
  61931. * @returns world space velocity
  61932. */
  61933. getAgentVelocity(index: number): Vector3;
  61934. /**
  61935. * remove a particular agent previously created
  61936. * @param index agent index returned by addAgent
  61937. */
  61938. removeAgent(index: number): void;
  61939. /**
  61940. * get the list of all agents attached to this crowd
  61941. * @returns list of agent indices
  61942. */
  61943. getAgents(): number[];
  61944. /**
  61945. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  61946. * @param deltaTime in seconds
  61947. */
  61948. update(deltaTime: number): void;
  61949. /**
  61950. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  61951. * @param index agent index returned by addAgent
  61952. * @param destination targeted world position
  61953. */
  61954. agentGoto(index: number, destination: Vector3): void;
  61955. /**
  61956. * Teleport the agent to a new position
  61957. * @param index agent index returned by addAgent
  61958. * @param destination targeted world position
  61959. */
  61960. agentTeleport(index: number, destination: Vector3): void;
  61961. /**
  61962. * Update agent parameters
  61963. * @param index agent index returned by addAgent
  61964. * @param parameters agent parameters
  61965. */
  61966. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  61967. /**
  61968. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  61969. * The queries will try to find a solution within those bounds
  61970. * default is (1,1,1)
  61971. * @param extent x,y,z value that define the extent around the queries point of reference
  61972. */
  61973. setDefaultQueryExtent(extent: Vector3): void;
  61974. /**
  61975. * Get the Bounding box extent specified by setDefaultQueryExtent
  61976. * @returns the box extent values
  61977. */
  61978. getDefaultQueryExtent(): Vector3;
  61979. /**
  61980. * Release all resources
  61981. */
  61982. dispose(): void;
  61983. }
  61984. /**
  61985. * Configures an agent
  61986. */
  61987. export interface IAgentParameters {
  61988. /**
  61989. * Agent radius. [Limit: >= 0]
  61990. */
  61991. radius: number;
  61992. /**
  61993. * Agent height. [Limit: > 0]
  61994. */
  61995. height: number;
  61996. /**
  61997. * Maximum allowed acceleration. [Limit: >= 0]
  61998. */
  61999. maxAcceleration: number;
  62000. /**
  62001. * Maximum allowed speed. [Limit: >= 0]
  62002. */
  62003. maxSpeed: number;
  62004. /**
  62005. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  62006. */
  62007. collisionQueryRange: number;
  62008. /**
  62009. * The path visibility optimization range. [Limit: > 0]
  62010. */
  62011. pathOptimizationRange: number;
  62012. /**
  62013. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  62014. */
  62015. separationWeight: number;
  62016. }
  62017. /**
  62018. * Configures the navigation mesh creation
  62019. */
  62020. export interface INavMeshParameters {
  62021. /**
  62022. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  62023. */
  62024. cs: number;
  62025. /**
  62026. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  62027. */
  62028. ch: number;
  62029. /**
  62030. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  62031. */
  62032. walkableSlopeAngle: number;
  62033. /**
  62034. * Minimum floor to 'ceiling' height that will still allow the floor area to
  62035. * be considered walkable. [Limit: >= 3] [Units: vx]
  62036. */
  62037. walkableHeight: number;
  62038. /**
  62039. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  62040. */
  62041. walkableClimb: number;
  62042. /**
  62043. * The distance to erode/shrink the walkable area of the heightfield away from
  62044. * obstructions. [Limit: >=0] [Units: vx]
  62045. */
  62046. walkableRadius: number;
  62047. /**
  62048. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  62049. */
  62050. maxEdgeLen: number;
  62051. /**
  62052. * The maximum distance a simplfied contour's border edges should deviate
  62053. * the original raw contour. [Limit: >=0] [Units: vx]
  62054. */
  62055. maxSimplificationError: number;
  62056. /**
  62057. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  62058. */
  62059. minRegionArea: number;
  62060. /**
  62061. * Any regions with a span count smaller than this value will, if possible,
  62062. * be merged with larger regions. [Limit: >=0] [Units: vx]
  62063. */
  62064. mergeRegionArea: number;
  62065. /**
  62066. * The maximum number of vertices allowed for polygons generated during the
  62067. * contour to polygon conversion process. [Limit: >= 3]
  62068. */
  62069. maxVertsPerPoly: number;
  62070. /**
  62071. * Sets the sampling distance to use when generating the detail mesh.
  62072. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  62073. */
  62074. detailSampleDist: number;
  62075. /**
  62076. * The maximum distance the detail mesh surface should deviate from heightfield
  62077. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  62078. */
  62079. detailSampleMaxError: number;
  62080. }
  62081. }
  62082. declare module BABYLON {
  62083. /**
  62084. * RecastJS navigation plugin
  62085. */
  62086. export class RecastJSPlugin implements INavigationEnginePlugin {
  62087. /**
  62088. * Reference to the Recast library
  62089. */
  62090. bjsRECAST: any;
  62091. /**
  62092. * plugin name
  62093. */
  62094. name: string;
  62095. /**
  62096. * the first navmesh created. We might extend this to support multiple navmeshes
  62097. */
  62098. navMesh: any;
  62099. /**
  62100. * Initializes the recastJS plugin
  62101. * @param recastInjection can be used to inject your own recast reference
  62102. */
  62103. constructor(recastInjection?: any);
  62104. /**
  62105. * Creates a navigation mesh
  62106. * @param meshes array of all the geometry used to compute the navigatio mesh
  62107. * @param parameters bunch of parameters used to filter geometry
  62108. */
  62109. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  62110. /**
  62111. * Create a navigation mesh debug mesh
  62112. * @param scene is where the mesh will be added
  62113. * @returns debug display mesh
  62114. */
  62115. createDebugNavMesh(scene: Scene): Mesh;
  62116. /**
  62117. * Get a navigation mesh constrained position, closest to the parameter position
  62118. * @param position world position
  62119. * @returns the closest point to position constrained by the navigation mesh
  62120. */
  62121. getClosestPoint(position: Vector3): Vector3;
  62122. /**
  62123. * Get a navigation mesh constrained position, within a particular radius
  62124. * @param position world position
  62125. * @param maxRadius the maximum distance to the constrained world position
  62126. * @returns the closest point to position constrained by the navigation mesh
  62127. */
  62128. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  62129. /**
  62130. * Compute the final position from a segment made of destination-position
  62131. * @param position world position
  62132. * @param destination world position
  62133. * @returns the resulting point along the navmesh
  62134. */
  62135. moveAlong(position: Vector3, destination: Vector3): Vector3;
  62136. /**
  62137. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  62138. * @param start world position
  62139. * @param end world position
  62140. * @returns array containing world position composing the path
  62141. */
  62142. computePath(start: Vector3, end: Vector3): Vector3[];
  62143. /**
  62144. * Create a new Crowd so you can add agents
  62145. * @param maxAgents the maximum agent count in the crowd
  62146. * @param maxAgentRadius the maximum radius an agent can have
  62147. * @param scene to attach the crowd to
  62148. * @returns the crowd you can add agents to
  62149. */
  62150. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  62151. /**
  62152. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62153. * The queries will try to find a solution within those bounds
  62154. * default is (1,1,1)
  62155. * @param extent x,y,z value that define the extent around the queries point of reference
  62156. */
  62157. setDefaultQueryExtent(extent: Vector3): void;
  62158. /**
  62159. * Get the Bounding box extent specified by setDefaultQueryExtent
  62160. * @returns the box extent values
  62161. */
  62162. getDefaultQueryExtent(): Vector3;
  62163. /**
  62164. * Disposes
  62165. */
  62166. dispose(): void;
  62167. /**
  62168. * If this plugin is supported
  62169. * @returns true if plugin is supported
  62170. */
  62171. isSupported(): boolean;
  62172. }
  62173. /**
  62174. * Recast detour crowd implementation
  62175. */
  62176. export class RecastJSCrowd implements ICrowd {
  62177. /**
  62178. * Recast/detour plugin
  62179. */
  62180. bjsRECASTPlugin: RecastJSPlugin;
  62181. /**
  62182. * Link to the detour crowd
  62183. */
  62184. recastCrowd: any;
  62185. /**
  62186. * One transform per agent
  62187. */
  62188. transforms: TransformNode[];
  62189. /**
  62190. * All agents created
  62191. */
  62192. agents: number[];
  62193. /**
  62194. * Link to the scene is kept to unregister the crowd from the scene
  62195. */
  62196. private _scene;
  62197. /**
  62198. * Observer for crowd updates
  62199. */
  62200. private _onBeforeAnimationsObserver;
  62201. /**
  62202. * Constructor
  62203. * @param plugin recastJS plugin
  62204. * @param maxAgents the maximum agent count in the crowd
  62205. * @param maxAgentRadius the maximum radius an agent can have
  62206. * @param scene to attach the crowd to
  62207. * @returns the crowd you can add agents to
  62208. */
  62209. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  62210. /**
  62211. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  62212. * You can attach anything to that node. The node position is updated in the scene update tick.
  62213. * @param pos world position that will be constrained by the navigation mesh
  62214. * @param parameters agent parameters
  62215. * @param transform hooked to the agent that will be update by the scene
  62216. * @returns agent index
  62217. */
  62218. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  62219. /**
  62220. * Returns the agent position in world space
  62221. * @param index agent index returned by addAgent
  62222. * @returns world space position
  62223. */
  62224. getAgentPosition(index: number): Vector3;
  62225. /**
  62226. * Returns the agent velocity in world space
  62227. * @param index agent index returned by addAgent
  62228. * @returns world space velocity
  62229. */
  62230. getAgentVelocity(index: number): Vector3;
  62231. /**
  62232. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  62233. * @param index agent index returned by addAgent
  62234. * @param destination targeted world position
  62235. */
  62236. agentGoto(index: number, destination: Vector3): void;
  62237. /**
  62238. * Teleport the agent to a new position
  62239. * @param index agent index returned by addAgent
  62240. * @param destination targeted world position
  62241. */
  62242. agentTeleport(index: number, destination: Vector3): void;
  62243. /**
  62244. * Update agent parameters
  62245. * @param index agent index returned by addAgent
  62246. * @param parameters agent parameters
  62247. */
  62248. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  62249. /**
  62250. * remove a particular agent previously created
  62251. * @param index agent index returned by addAgent
  62252. */
  62253. removeAgent(index: number): void;
  62254. /**
  62255. * get the list of all agents attached to this crowd
  62256. * @returns list of agent indices
  62257. */
  62258. getAgents(): number[];
  62259. /**
  62260. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  62261. * @param deltaTime in seconds
  62262. */
  62263. update(deltaTime: number): void;
  62264. /**
  62265. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  62266. * The queries will try to find a solution within those bounds
  62267. * default is (1,1,1)
  62268. * @param extent x,y,z value that define the extent around the queries point of reference
  62269. */
  62270. setDefaultQueryExtent(extent: Vector3): void;
  62271. /**
  62272. * Get the Bounding box extent specified by setDefaultQueryExtent
  62273. * @returns the box extent values
  62274. */
  62275. getDefaultQueryExtent(): Vector3;
  62276. /**
  62277. * Release all resources
  62278. */
  62279. dispose(): void;
  62280. }
  62281. }
  62282. declare module BABYLON {
  62283. /**
  62284. * Class used to enable access to IndexedDB
  62285. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  62286. */
  62287. export class Database implements IOfflineProvider {
  62288. private _callbackManifestChecked;
  62289. private _currentSceneUrl;
  62290. private _db;
  62291. private _enableSceneOffline;
  62292. private _enableTexturesOffline;
  62293. private _manifestVersionFound;
  62294. private _mustUpdateRessources;
  62295. private _hasReachedQuota;
  62296. private _isSupported;
  62297. private _idbFactory;
  62298. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  62299. private static IsUASupportingBlobStorage;
  62300. /**
  62301. * Gets a boolean indicating if Database storate is enabled (off by default)
  62302. */
  62303. static IDBStorageEnabled: boolean;
  62304. /**
  62305. * Gets a boolean indicating if scene must be saved in the database
  62306. */
  62307. get enableSceneOffline(): boolean;
  62308. /**
  62309. * Gets a boolean indicating if textures must be saved in the database
  62310. */
  62311. get enableTexturesOffline(): boolean;
  62312. /**
  62313. * Creates a new Database
  62314. * @param urlToScene defines the url to load the scene
  62315. * @param callbackManifestChecked defines the callback to use when manifest is checked
  62316. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  62317. */
  62318. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  62319. private static _ParseURL;
  62320. private static _ReturnFullUrlLocation;
  62321. private _checkManifestFile;
  62322. /**
  62323. * Open the database and make it available
  62324. * @param successCallback defines the callback to call on success
  62325. * @param errorCallback defines the callback to call on error
  62326. */
  62327. open(successCallback: () => void, errorCallback: () => void): void;
  62328. /**
  62329. * Loads an image from the database
  62330. * @param url defines the url to load from
  62331. * @param image defines the target DOM image
  62332. */
  62333. loadImage(url: string, image: HTMLImageElement): void;
  62334. private _loadImageFromDBAsync;
  62335. private _saveImageIntoDBAsync;
  62336. private _checkVersionFromDB;
  62337. private _loadVersionFromDBAsync;
  62338. private _saveVersionIntoDBAsync;
  62339. /**
  62340. * Loads a file from database
  62341. * @param url defines the URL to load from
  62342. * @param sceneLoaded defines a callback to call on success
  62343. * @param progressCallBack defines a callback to call when progress changed
  62344. * @param errorCallback defines a callback to call on error
  62345. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  62346. */
  62347. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  62348. private _loadFileAsync;
  62349. private _saveFileAsync;
  62350. /**
  62351. * Validates if xhr data is correct
  62352. * @param xhr defines the request to validate
  62353. * @param dataType defines the expected data type
  62354. * @returns true if data is correct
  62355. */
  62356. private static _ValidateXHRData;
  62357. }
  62358. }
  62359. declare module BABYLON {
  62360. /** @hidden */
  62361. export var gpuUpdateParticlesPixelShader: {
  62362. name: string;
  62363. shader: string;
  62364. };
  62365. }
  62366. declare module BABYLON {
  62367. /** @hidden */
  62368. export var gpuUpdateParticlesVertexShader: {
  62369. name: string;
  62370. shader: string;
  62371. };
  62372. }
  62373. declare module BABYLON {
  62374. /** @hidden */
  62375. export var clipPlaneFragmentDeclaration2: {
  62376. name: string;
  62377. shader: string;
  62378. };
  62379. }
  62380. declare module BABYLON {
  62381. /** @hidden */
  62382. export var gpuRenderParticlesPixelShader: {
  62383. name: string;
  62384. shader: string;
  62385. };
  62386. }
  62387. declare module BABYLON {
  62388. /** @hidden */
  62389. export var clipPlaneVertexDeclaration2: {
  62390. name: string;
  62391. shader: string;
  62392. };
  62393. }
  62394. declare module BABYLON {
  62395. /** @hidden */
  62396. export var gpuRenderParticlesVertexShader: {
  62397. name: string;
  62398. shader: string;
  62399. };
  62400. }
  62401. declare module BABYLON {
  62402. /**
  62403. * This represents a GPU particle system in Babylon
  62404. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  62405. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  62406. */
  62407. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  62408. /**
  62409. * The layer mask we are rendering the particles through.
  62410. */
  62411. layerMask: number;
  62412. private _capacity;
  62413. private _activeCount;
  62414. private _currentActiveCount;
  62415. private _accumulatedCount;
  62416. private _renderEffect;
  62417. private _updateEffect;
  62418. private _buffer0;
  62419. private _buffer1;
  62420. private _spriteBuffer;
  62421. private _updateVAO;
  62422. private _renderVAO;
  62423. private _targetIndex;
  62424. private _sourceBuffer;
  62425. private _targetBuffer;
  62426. private _engine;
  62427. private _currentRenderId;
  62428. private _started;
  62429. private _stopped;
  62430. private _timeDelta;
  62431. private _randomTexture;
  62432. private _randomTexture2;
  62433. private _attributesStrideSize;
  62434. private _updateEffectOptions;
  62435. private _randomTextureSize;
  62436. private _actualFrame;
  62437. private readonly _rawTextureWidth;
  62438. /**
  62439. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  62440. */
  62441. static get IsSupported(): boolean;
  62442. /**
  62443. * An event triggered when the system is disposed.
  62444. */
  62445. onDisposeObservable: Observable<GPUParticleSystem>;
  62446. /**
  62447. * Gets the maximum number of particles active at the same time.
  62448. * @returns The max number of active particles.
  62449. */
  62450. getCapacity(): number;
  62451. /**
  62452. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  62453. * to override the particles.
  62454. */
  62455. forceDepthWrite: boolean;
  62456. /**
  62457. * Gets or set the number of active particles
  62458. */
  62459. get activeParticleCount(): number;
  62460. set activeParticleCount(value: number);
  62461. private _preWarmDone;
  62462. /**
  62463. * Is this system ready to be used/rendered
  62464. * @return true if the system is ready
  62465. */
  62466. isReady(): boolean;
  62467. /**
  62468. * Gets if the system has been started. (Note: this will still be true after stop is called)
  62469. * @returns True if it has been started, otherwise false.
  62470. */
  62471. isStarted(): boolean;
  62472. /**
  62473. * Starts the particle system and begins to emit
  62474. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  62475. */
  62476. start(delay?: number): void;
  62477. /**
  62478. * Stops the particle system.
  62479. */
  62480. stop(): void;
  62481. /**
  62482. * Remove all active particles
  62483. */
  62484. reset(): void;
  62485. /**
  62486. * Returns the string "GPUParticleSystem"
  62487. * @returns a string containing the class name
  62488. */
  62489. getClassName(): string;
  62490. private _colorGradientsTexture;
  62491. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  62492. /**
  62493. * Adds a new color gradient
  62494. * @param gradient defines the gradient to use (between 0 and 1)
  62495. * @param color1 defines the color to affect to the specified gradient
  62496. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  62497. * @returns the current particle system
  62498. */
  62499. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  62500. /**
  62501. * Remove a specific color gradient
  62502. * @param gradient defines the gradient to remove
  62503. * @returns the current particle system
  62504. */
  62505. removeColorGradient(gradient: number): GPUParticleSystem;
  62506. private _angularSpeedGradientsTexture;
  62507. private _sizeGradientsTexture;
  62508. private _velocityGradientsTexture;
  62509. private _limitVelocityGradientsTexture;
  62510. private _dragGradientsTexture;
  62511. private _addFactorGradient;
  62512. /**
  62513. * Adds a new size gradient
  62514. * @param gradient defines the gradient to use (between 0 and 1)
  62515. * @param factor defines the size factor to affect to the specified gradient
  62516. * @returns the current particle system
  62517. */
  62518. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  62519. /**
  62520. * Remove a specific size gradient
  62521. * @param gradient defines the gradient to remove
  62522. * @returns the current particle system
  62523. */
  62524. removeSizeGradient(gradient: number): GPUParticleSystem;
  62525. /**
  62526. * Adds a new angular speed gradient
  62527. * @param gradient defines the gradient to use (between 0 and 1)
  62528. * @param factor defines the angular speed to affect to the specified gradient
  62529. * @returns the current particle system
  62530. */
  62531. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  62532. /**
  62533. * Remove a specific angular speed gradient
  62534. * @param gradient defines the gradient to remove
  62535. * @returns the current particle system
  62536. */
  62537. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  62538. /**
  62539. * Adds a new velocity gradient
  62540. * @param gradient defines the gradient to use (between 0 and 1)
  62541. * @param factor defines the velocity to affect to the specified gradient
  62542. * @returns the current particle system
  62543. */
  62544. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  62545. /**
  62546. * Remove a specific velocity gradient
  62547. * @param gradient defines the gradient to remove
  62548. * @returns the current particle system
  62549. */
  62550. removeVelocityGradient(gradient: number): GPUParticleSystem;
  62551. /**
  62552. * Adds a new limit velocity gradient
  62553. * @param gradient defines the gradient to use (between 0 and 1)
  62554. * @param factor defines the limit velocity value to affect to the specified gradient
  62555. * @returns the current particle system
  62556. */
  62557. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  62558. /**
  62559. * Remove a specific limit velocity gradient
  62560. * @param gradient defines the gradient to remove
  62561. * @returns the current particle system
  62562. */
  62563. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  62564. /**
  62565. * Adds a new drag gradient
  62566. * @param gradient defines the gradient to use (between 0 and 1)
  62567. * @param factor defines the drag value to affect to the specified gradient
  62568. * @returns the current particle system
  62569. */
  62570. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  62571. /**
  62572. * Remove a specific drag gradient
  62573. * @param gradient defines the gradient to remove
  62574. * @returns the current particle system
  62575. */
  62576. removeDragGradient(gradient: number): GPUParticleSystem;
  62577. /**
  62578. * Not supported by GPUParticleSystem
  62579. * @param gradient defines the gradient to use (between 0 and 1)
  62580. * @param factor defines the emit rate value to affect to the specified gradient
  62581. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62582. * @returns the current particle system
  62583. */
  62584. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62585. /**
  62586. * Not supported by GPUParticleSystem
  62587. * @param gradient defines the gradient to remove
  62588. * @returns the current particle system
  62589. */
  62590. removeEmitRateGradient(gradient: number): IParticleSystem;
  62591. /**
  62592. * Not supported by GPUParticleSystem
  62593. * @param gradient defines the gradient to use (between 0 and 1)
  62594. * @param factor defines the start size value to affect to the specified gradient
  62595. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62596. * @returns the current particle system
  62597. */
  62598. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62599. /**
  62600. * Not supported by GPUParticleSystem
  62601. * @param gradient defines the gradient to remove
  62602. * @returns the current particle system
  62603. */
  62604. removeStartSizeGradient(gradient: number): IParticleSystem;
  62605. /**
  62606. * Not supported by GPUParticleSystem
  62607. * @param gradient defines the gradient to use (between 0 and 1)
  62608. * @param min defines the color remap minimal range
  62609. * @param max defines the color remap maximal range
  62610. * @returns the current particle system
  62611. */
  62612. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  62613. /**
  62614. * Not supported by GPUParticleSystem
  62615. * @param gradient defines the gradient to remove
  62616. * @returns the current particle system
  62617. */
  62618. removeColorRemapGradient(): IParticleSystem;
  62619. /**
  62620. * Not supported by GPUParticleSystem
  62621. * @param gradient defines the gradient to use (between 0 and 1)
  62622. * @param min defines the alpha remap minimal range
  62623. * @param max defines the alpha remap maximal range
  62624. * @returns the current particle system
  62625. */
  62626. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  62627. /**
  62628. * Not supported by GPUParticleSystem
  62629. * @param gradient defines the gradient to remove
  62630. * @returns the current particle system
  62631. */
  62632. removeAlphaRemapGradient(): IParticleSystem;
  62633. /**
  62634. * Not supported by GPUParticleSystem
  62635. * @param gradient defines the gradient to use (between 0 and 1)
  62636. * @param color defines the color to affect to the specified gradient
  62637. * @returns the current particle system
  62638. */
  62639. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  62640. /**
  62641. * Not supported by GPUParticleSystem
  62642. * @param gradient defines the gradient to remove
  62643. * @returns the current particle system
  62644. */
  62645. removeRampGradient(): IParticleSystem;
  62646. /**
  62647. * Not supported by GPUParticleSystem
  62648. * @returns the list of ramp gradients
  62649. */
  62650. getRampGradients(): Nullable<Array<Color3Gradient>>;
  62651. /**
  62652. * Not supported by GPUParticleSystem
  62653. * Gets or sets a boolean indicating that ramp gradients must be used
  62654. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  62655. */
  62656. get useRampGradients(): boolean;
  62657. set useRampGradients(value: boolean);
  62658. /**
  62659. * Not supported by GPUParticleSystem
  62660. * @param gradient defines the gradient to use (between 0 and 1)
  62661. * @param factor defines the life time factor to affect to the specified gradient
  62662. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  62663. * @returns the current particle system
  62664. */
  62665. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  62666. /**
  62667. * Not supported by GPUParticleSystem
  62668. * @param gradient defines the gradient to remove
  62669. * @returns the current particle system
  62670. */
  62671. removeLifeTimeGradient(gradient: number): IParticleSystem;
  62672. /**
  62673. * Instantiates a GPU particle system.
  62674. * 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.
  62675. * @param name The name of the particle system
  62676. * @param options The options used to create the system
  62677. * @param scene The scene the particle system belongs to
  62678. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  62679. */
  62680. constructor(name: string, options: Partial<{
  62681. capacity: number;
  62682. randomTextureSize: number;
  62683. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  62684. protected _reset(): void;
  62685. private _createUpdateVAO;
  62686. private _createRenderVAO;
  62687. private _initialize;
  62688. /** @hidden */
  62689. _recreateUpdateEffect(): void;
  62690. /** @hidden */
  62691. _recreateRenderEffect(): void;
  62692. /**
  62693. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  62694. * @param preWarm defines if we are in the pre-warmimg phase
  62695. */
  62696. animate(preWarm?: boolean): void;
  62697. private _createFactorGradientTexture;
  62698. private _createSizeGradientTexture;
  62699. private _createAngularSpeedGradientTexture;
  62700. private _createVelocityGradientTexture;
  62701. private _createLimitVelocityGradientTexture;
  62702. private _createDragGradientTexture;
  62703. private _createColorGradientTexture;
  62704. /**
  62705. * Renders the particle system in its current state
  62706. * @param preWarm defines if the system should only update the particles but not render them
  62707. * @returns the current number of particles
  62708. */
  62709. render(preWarm?: boolean): number;
  62710. /**
  62711. * Rebuilds the particle system
  62712. */
  62713. rebuild(): void;
  62714. private _releaseBuffers;
  62715. private _releaseVAOs;
  62716. /**
  62717. * Disposes the particle system and free the associated resources
  62718. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  62719. */
  62720. dispose(disposeTexture?: boolean): void;
  62721. /**
  62722. * Clones the particle system.
  62723. * @param name The name of the cloned object
  62724. * @param newEmitter The new emitter to use
  62725. * @returns the cloned particle system
  62726. */
  62727. clone(name: string, newEmitter: any): GPUParticleSystem;
  62728. /**
  62729. * Serializes the particle system to a JSON object.
  62730. * @returns the JSON object
  62731. */
  62732. serialize(): any;
  62733. /**
  62734. * Parses a JSON object to create a GPU particle system.
  62735. * @param parsedParticleSystem The JSON object to parse
  62736. * @param scene The scene to create the particle system in
  62737. * @param rootUrl The root url to use to load external dependencies like texture
  62738. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  62739. * @returns the parsed GPU particle system
  62740. */
  62741. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  62742. }
  62743. }
  62744. declare module BABYLON {
  62745. /**
  62746. * Represents a set of particle systems working together to create a specific effect
  62747. */
  62748. export class ParticleSystemSet implements IDisposable {
  62749. /**
  62750. * Gets or sets base Assets URL
  62751. */
  62752. static BaseAssetsUrl: string;
  62753. private _emitterCreationOptions;
  62754. private _emitterNode;
  62755. /**
  62756. * Gets the particle system list
  62757. */
  62758. systems: IParticleSystem[];
  62759. /**
  62760. * Gets the emitter node used with this set
  62761. */
  62762. get emitterNode(): Nullable<TransformNode>;
  62763. /**
  62764. * Creates a new emitter mesh as a sphere
  62765. * @param options defines the options used to create the sphere
  62766. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  62767. * @param scene defines the hosting scene
  62768. */
  62769. setEmitterAsSphere(options: {
  62770. diameter: number;
  62771. segments: number;
  62772. color: Color3;
  62773. }, renderingGroupId: number, scene: Scene): void;
  62774. /**
  62775. * Starts all particle systems of the set
  62776. * @param emitter defines an optional mesh to use as emitter for the particle systems
  62777. */
  62778. start(emitter?: AbstractMesh): void;
  62779. /**
  62780. * Release all associated resources
  62781. */
  62782. dispose(): void;
  62783. /**
  62784. * Serialize the set into a JSON compatible object
  62785. * @returns a JSON compatible representation of the set
  62786. */
  62787. serialize(): any;
  62788. /**
  62789. * Parse a new ParticleSystemSet from a serialized source
  62790. * @param data defines a JSON compatible representation of the set
  62791. * @param scene defines the hosting scene
  62792. * @param gpu defines if we want GPU particles or CPU particles
  62793. * @returns a new ParticleSystemSet
  62794. */
  62795. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  62796. }
  62797. }
  62798. declare module BABYLON {
  62799. /**
  62800. * This class is made for on one-liner static method to help creating particle system set.
  62801. */
  62802. export class ParticleHelper {
  62803. /**
  62804. * Gets or sets base Assets URL
  62805. */
  62806. static BaseAssetsUrl: string;
  62807. /**
  62808. * Create a default particle system that you can tweak
  62809. * @param emitter defines the emitter to use
  62810. * @param capacity defines the system capacity (default is 500 particles)
  62811. * @param scene defines the hosting scene
  62812. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  62813. * @returns the new Particle system
  62814. */
  62815. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  62816. /**
  62817. * This is the main static method (one-liner) of this helper to create different particle systems
  62818. * @param type This string represents the type to the particle system to create
  62819. * @param scene The scene where the particle system should live
  62820. * @param gpu If the system will use gpu
  62821. * @returns the ParticleSystemSet created
  62822. */
  62823. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  62824. /**
  62825. * Static function used to export a particle system to a ParticleSystemSet variable.
  62826. * Please note that the emitter shape is not exported
  62827. * @param systems defines the particle systems to export
  62828. * @returns the created particle system set
  62829. */
  62830. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  62831. }
  62832. }
  62833. declare module BABYLON {
  62834. interface Engine {
  62835. /**
  62836. * Create an effect to use with particle systems.
  62837. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  62838. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  62839. * @param uniformsNames defines a list of attribute names
  62840. * @param samplers defines an array of string used to represent textures
  62841. * @param defines defines the string containing the defines to use to compile the shaders
  62842. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  62843. * @param onCompiled defines a function to call when the effect creation is successful
  62844. * @param onError defines a function to call when the effect creation has failed
  62845. * @returns the new Effect
  62846. */
  62847. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  62848. }
  62849. interface Mesh {
  62850. /**
  62851. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  62852. * @returns an array of IParticleSystem
  62853. */
  62854. getEmittedParticleSystems(): IParticleSystem[];
  62855. /**
  62856. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  62857. * @returns an array of IParticleSystem
  62858. */
  62859. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  62860. }
  62861. /**
  62862. * @hidden
  62863. */
  62864. export var _IDoNeedToBeInTheBuild: number;
  62865. }
  62866. declare module BABYLON {
  62867. /** Defines the 4 color options */
  62868. export enum PointColor {
  62869. /** color value */
  62870. Color = 2,
  62871. /** uv value */
  62872. UV = 1,
  62873. /** random value */
  62874. Random = 0,
  62875. /** stated value */
  62876. Stated = 3
  62877. }
  62878. /**
  62879. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  62880. * 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.
  62881. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  62882. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  62883. *
  62884. * Full documentation here : TO BE ENTERED
  62885. */
  62886. export class PointsCloudSystem implements IDisposable {
  62887. /**
  62888. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  62889. * Example : var p = SPS.particles[i];
  62890. */
  62891. particles: CloudPoint[];
  62892. /**
  62893. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  62894. */
  62895. nbParticles: number;
  62896. /**
  62897. * This a counter for your own usage. It's not set by any SPS functions.
  62898. */
  62899. counter: number;
  62900. /**
  62901. * The PCS name. This name is also given to the underlying mesh.
  62902. */
  62903. name: string;
  62904. /**
  62905. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  62906. */
  62907. mesh: Mesh;
  62908. /**
  62909. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  62910. * Please read :
  62911. */
  62912. vars: any;
  62913. /**
  62914. * @hidden
  62915. */
  62916. _size: number;
  62917. private _scene;
  62918. private _promises;
  62919. private _positions;
  62920. private _indices;
  62921. private _normals;
  62922. private _colors;
  62923. private _uvs;
  62924. private _indices32;
  62925. private _positions32;
  62926. private _colors32;
  62927. private _uvs32;
  62928. private _updatable;
  62929. private _isVisibilityBoxLocked;
  62930. private _alwaysVisible;
  62931. private _groups;
  62932. private _groupCounter;
  62933. private _computeParticleColor;
  62934. private _computeParticleTexture;
  62935. private _computeParticleRotation;
  62936. private _computeBoundingBox;
  62937. private _isReady;
  62938. /**
  62939. * Creates a PCS (Points Cloud System) object
  62940. * @param name (String) is the PCS name, this will be the underlying mesh name
  62941. * @param pointSize (number) is the size for each point
  62942. * @param scene (Scene) is the scene in which the PCS is added
  62943. * @param options defines the options of the PCS e.g.
  62944. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  62945. */
  62946. constructor(name: string, pointSize: number, scene: Scene, options?: {
  62947. updatable?: boolean;
  62948. });
  62949. /**
  62950. * Builds the PCS underlying mesh. Returns a standard Mesh.
  62951. * If no points were added to the PCS, the returned mesh is just a single point.
  62952. * @returns a promise for the created mesh
  62953. */
  62954. buildMeshAsync(): Promise<Mesh>;
  62955. /**
  62956. * @hidden
  62957. */
  62958. private _buildMesh;
  62959. private _addParticle;
  62960. private _randomUnitVector;
  62961. private _getColorIndicesForCoord;
  62962. private _setPointsColorOrUV;
  62963. private _colorFromTexture;
  62964. private _calculateDensity;
  62965. /**
  62966. * Adds points to the PCS in random positions within a unit sphere
  62967. * @param nb (positive integer) the number of particles to be created from this model
  62968. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  62969. * @returns the number of groups in the system
  62970. */
  62971. addPoints(nb: number, pointFunction?: any): number;
  62972. /**
  62973. * Adds points to the PCS from the surface of the model shape
  62974. * @param mesh is any Mesh object that will be used as a surface model for the points
  62975. * @param nb (positive integer) the number of particles to be created from this model
  62976. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  62977. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  62978. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  62979. * @returns the number of groups in the system
  62980. */
  62981. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  62982. /**
  62983. * Adds points to the PCS inside the model shape
  62984. * @param mesh is any Mesh object that will be used as a surface model for the points
  62985. * @param nb (positive integer) the number of particles to be created from this model
  62986. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  62987. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  62988. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  62989. * @returns the number of groups in the system
  62990. */
  62991. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  62992. /**
  62993. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  62994. * This method calls `updateParticle()` for each particle of the SPS.
  62995. * For an animated SPS, it is usually called within the render loop.
  62996. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  62997. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  62998. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  62999. * @returns the PCS.
  63000. */
  63001. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  63002. /**
  63003. * Disposes the PCS.
  63004. */
  63005. dispose(): void;
  63006. /**
  63007. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  63008. * doc :
  63009. * @returns the PCS.
  63010. */
  63011. refreshVisibleSize(): PointsCloudSystem;
  63012. /**
  63013. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  63014. * @param size the size (float) of the visibility box
  63015. * note : this doesn't lock the PCS mesh bounding box.
  63016. * doc :
  63017. */
  63018. setVisibilityBox(size: number): void;
  63019. /**
  63020. * Gets whether the PCS is always visible or not
  63021. * doc :
  63022. */
  63023. get isAlwaysVisible(): boolean;
  63024. /**
  63025. * Sets the PCS as always visible or not
  63026. * doc :
  63027. */
  63028. set isAlwaysVisible(val: boolean);
  63029. /**
  63030. * Tells to `setParticles()` to compute the particle rotations or not
  63031. * Default value : false. The PCS is faster when it's set to false
  63032. * Note : particle rotations are only applied to parent particles
  63033. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  63034. */
  63035. set computeParticleRotation(val: boolean);
  63036. /**
  63037. * Tells to `setParticles()` to compute the particle colors or not.
  63038. * Default value : true. The PCS is faster when it's set to false.
  63039. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63040. */
  63041. set computeParticleColor(val: boolean);
  63042. set computeParticleTexture(val: boolean);
  63043. /**
  63044. * Gets if `setParticles()` computes the particle colors or not.
  63045. * Default value : false. The PCS is faster when it's set to false.
  63046. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  63047. */
  63048. get computeParticleColor(): boolean;
  63049. /**
  63050. * Gets if `setParticles()` computes the particle textures or not.
  63051. * Default value : false. The PCS is faster when it's set to false.
  63052. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  63053. */
  63054. get computeParticleTexture(): boolean;
  63055. /**
  63056. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  63057. */
  63058. set computeBoundingBox(val: boolean);
  63059. /**
  63060. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  63061. */
  63062. get computeBoundingBox(): boolean;
  63063. /**
  63064. * This function does nothing. It may be overwritten to set all the particle first values.
  63065. * The PCS doesn't call this function, you may have to call it by your own.
  63066. * doc :
  63067. */
  63068. initParticles(): void;
  63069. /**
  63070. * This function does nothing. It may be overwritten to recycle a particle
  63071. * The PCS doesn't call this function, you can to call it
  63072. * doc :
  63073. * @param particle The particle to recycle
  63074. * @returns the recycled particle
  63075. */
  63076. recycleParticle(particle: CloudPoint): CloudPoint;
  63077. /**
  63078. * Updates a particle : this function should be overwritten by the user.
  63079. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  63080. * doc :
  63081. * @example : just set a particle position or velocity and recycle conditions
  63082. * @param particle The particle to update
  63083. * @returns the updated particle
  63084. */
  63085. updateParticle(particle: CloudPoint): CloudPoint;
  63086. /**
  63087. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  63088. * This does nothing and may be overwritten by the user.
  63089. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63090. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63091. * @param update the boolean update value actually passed to setParticles()
  63092. */
  63093. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63094. /**
  63095. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  63096. * This will be passed three parameters.
  63097. * This does nothing and may be overwritten by the user.
  63098. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  63099. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  63100. * @param update the boolean update value actually passed to setParticles()
  63101. */
  63102. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  63103. }
  63104. }
  63105. declare module BABYLON {
  63106. /**
  63107. * Represents one particle of a points cloud system.
  63108. */
  63109. export class CloudPoint {
  63110. /**
  63111. * particle global index
  63112. */
  63113. idx: number;
  63114. /**
  63115. * The color of the particle
  63116. */
  63117. color: Nullable<Color4>;
  63118. /**
  63119. * The world space position of the particle.
  63120. */
  63121. position: Vector3;
  63122. /**
  63123. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  63124. */
  63125. rotation: Vector3;
  63126. /**
  63127. * The world space rotation quaternion of the particle.
  63128. */
  63129. rotationQuaternion: Nullable<Quaternion>;
  63130. /**
  63131. * The uv of the particle.
  63132. */
  63133. uv: Nullable<Vector2>;
  63134. /**
  63135. * The current speed of the particle.
  63136. */
  63137. velocity: Vector3;
  63138. /**
  63139. * The pivot point in the particle local space.
  63140. */
  63141. pivot: Vector3;
  63142. /**
  63143. * Must the particle be translated from its pivot point in its local space ?
  63144. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  63145. * Default : false
  63146. */
  63147. translateFromPivot: boolean;
  63148. /**
  63149. * Index of this particle in the global "positions" array (Internal use)
  63150. * @hidden
  63151. */
  63152. _pos: number;
  63153. /**
  63154. * @hidden Index of this particle in the global "indices" array (Internal use)
  63155. */
  63156. _ind: number;
  63157. /**
  63158. * Group this particle belongs to
  63159. */
  63160. _group: PointsGroup;
  63161. /**
  63162. * Group id of this particle
  63163. */
  63164. groupId: number;
  63165. /**
  63166. * Index of the particle in its group id (Internal use)
  63167. */
  63168. idxInGroup: number;
  63169. /**
  63170. * @hidden Particle BoundingInfo object (Internal use)
  63171. */
  63172. _boundingInfo: BoundingInfo;
  63173. /**
  63174. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  63175. */
  63176. _pcs: PointsCloudSystem;
  63177. /**
  63178. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  63179. */
  63180. _stillInvisible: boolean;
  63181. /**
  63182. * @hidden Last computed particle rotation matrix
  63183. */
  63184. _rotationMatrix: number[];
  63185. /**
  63186. * Parent particle Id, if any.
  63187. * Default null.
  63188. */
  63189. parentId: Nullable<number>;
  63190. /**
  63191. * @hidden Internal global position in the PCS.
  63192. */
  63193. _globalPosition: Vector3;
  63194. /**
  63195. * Creates a Point Cloud object.
  63196. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  63197. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  63198. * @param group (PointsGroup) is the group the particle belongs to
  63199. * @param groupId (integer) is the group identifier in the PCS.
  63200. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  63201. * @param pcs defines the PCS it is associated to
  63202. */
  63203. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  63204. /**
  63205. * get point size
  63206. */
  63207. get size(): Vector3;
  63208. /**
  63209. * Set point size
  63210. */
  63211. set size(scale: Vector3);
  63212. /**
  63213. * Legacy support, changed quaternion to rotationQuaternion
  63214. */
  63215. get quaternion(): Nullable<Quaternion>;
  63216. /**
  63217. * Legacy support, changed quaternion to rotationQuaternion
  63218. */
  63219. set quaternion(q: Nullable<Quaternion>);
  63220. /**
  63221. * Returns a boolean. True if the particle intersects a mesh, else false
  63222. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  63223. * @param target is the object (point or mesh) what the intersection is computed against
  63224. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  63225. * @returns true if it intersects
  63226. */
  63227. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  63228. /**
  63229. * get the rotation matrix of the particle
  63230. * @hidden
  63231. */
  63232. getRotationMatrix(m: Matrix): void;
  63233. }
  63234. /**
  63235. * Represents a group of points in a points cloud system
  63236. * * PCS internal tool, don't use it manually.
  63237. */
  63238. export class PointsGroup {
  63239. /**
  63240. * The group id
  63241. * @hidden
  63242. */
  63243. groupID: number;
  63244. /**
  63245. * image data for group (internal use)
  63246. * @hidden
  63247. */
  63248. _groupImageData: Nullable<ArrayBufferView>;
  63249. /**
  63250. * Image Width (internal use)
  63251. * @hidden
  63252. */
  63253. _groupImgWidth: number;
  63254. /**
  63255. * Image Height (internal use)
  63256. * @hidden
  63257. */
  63258. _groupImgHeight: number;
  63259. /**
  63260. * Custom position function (internal use)
  63261. * @hidden
  63262. */
  63263. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  63264. /**
  63265. * density per facet for surface points
  63266. * @hidden
  63267. */
  63268. _groupDensity: number[];
  63269. /**
  63270. * Only when points are colored by texture carries pointer to texture list array
  63271. * @hidden
  63272. */
  63273. _textureNb: number;
  63274. /**
  63275. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  63276. * PCS internal tool, don't use it manually.
  63277. * @hidden
  63278. */
  63279. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  63280. }
  63281. }
  63282. declare module BABYLON {
  63283. interface Scene {
  63284. /** @hidden (Backing field) */
  63285. _physicsEngine: Nullable<IPhysicsEngine>;
  63286. /** @hidden */
  63287. _physicsTimeAccumulator: number;
  63288. /**
  63289. * Gets the current physics engine
  63290. * @returns a IPhysicsEngine or null if none attached
  63291. */
  63292. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  63293. /**
  63294. * Enables physics to the current scene
  63295. * @param gravity defines the scene's gravity for the physics engine
  63296. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  63297. * @return a boolean indicating if the physics engine was initialized
  63298. */
  63299. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  63300. /**
  63301. * Disables and disposes the physics engine associated with the scene
  63302. */
  63303. disablePhysicsEngine(): void;
  63304. /**
  63305. * Gets a boolean indicating if there is an active physics engine
  63306. * @returns a boolean indicating if there is an active physics engine
  63307. */
  63308. isPhysicsEnabled(): boolean;
  63309. /**
  63310. * Deletes a physics compound impostor
  63311. * @param compound defines the compound to delete
  63312. */
  63313. deleteCompoundImpostor(compound: any): void;
  63314. /**
  63315. * An event triggered when physic simulation is about to be run
  63316. */
  63317. onBeforePhysicsObservable: Observable<Scene>;
  63318. /**
  63319. * An event triggered when physic simulation has been done
  63320. */
  63321. onAfterPhysicsObservable: Observable<Scene>;
  63322. }
  63323. interface AbstractMesh {
  63324. /** @hidden */
  63325. _physicsImpostor: Nullable<PhysicsImpostor>;
  63326. /**
  63327. * Gets or sets impostor used for physic simulation
  63328. * @see http://doc.babylonjs.com/features/physics_engine
  63329. */
  63330. physicsImpostor: Nullable<PhysicsImpostor>;
  63331. /**
  63332. * Gets the current physics impostor
  63333. * @see http://doc.babylonjs.com/features/physics_engine
  63334. * @returns a physics impostor or null
  63335. */
  63336. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  63337. /** Apply a physic impulse to the mesh
  63338. * @param force defines the force to apply
  63339. * @param contactPoint defines where to apply the force
  63340. * @returns the current mesh
  63341. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  63342. */
  63343. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  63344. /**
  63345. * Creates a physic joint between two meshes
  63346. * @param otherMesh defines the other mesh to use
  63347. * @param pivot1 defines the pivot to use on this mesh
  63348. * @param pivot2 defines the pivot to use on the other mesh
  63349. * @param options defines additional options (can be plugin dependent)
  63350. * @returns the current mesh
  63351. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  63352. */
  63353. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  63354. /** @hidden */
  63355. _disposePhysicsObserver: Nullable<Observer<Node>>;
  63356. }
  63357. /**
  63358. * Defines the physics engine scene component responsible to manage a physics engine
  63359. */
  63360. export class PhysicsEngineSceneComponent implements ISceneComponent {
  63361. /**
  63362. * The component name helpful to identify the component in the list of scene components.
  63363. */
  63364. readonly name: string;
  63365. /**
  63366. * The scene the component belongs to.
  63367. */
  63368. scene: Scene;
  63369. /**
  63370. * Creates a new instance of the component for the given scene
  63371. * @param scene Defines the scene to register the component in
  63372. */
  63373. constructor(scene: Scene);
  63374. /**
  63375. * Registers the component in a given scene
  63376. */
  63377. register(): void;
  63378. /**
  63379. * Rebuilds the elements related to this component in case of
  63380. * context lost for instance.
  63381. */
  63382. rebuild(): void;
  63383. /**
  63384. * Disposes the component and the associated ressources
  63385. */
  63386. dispose(): void;
  63387. }
  63388. }
  63389. declare module BABYLON {
  63390. /**
  63391. * A helper for physics simulations
  63392. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63393. */
  63394. export class PhysicsHelper {
  63395. private _scene;
  63396. private _physicsEngine;
  63397. /**
  63398. * Initializes the Physics helper
  63399. * @param scene Babylon.js scene
  63400. */
  63401. constructor(scene: Scene);
  63402. /**
  63403. * Applies a radial explosion impulse
  63404. * @param origin the origin of the explosion
  63405. * @param radiusOrEventOptions the radius or the options of radial explosion
  63406. * @param strength the explosion strength
  63407. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63408. * @returns A physics radial explosion event, or null
  63409. */
  63410. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  63411. /**
  63412. * Applies a radial explosion force
  63413. * @param origin the origin of the explosion
  63414. * @param radiusOrEventOptions the radius or the options of radial explosion
  63415. * @param strength the explosion strength
  63416. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63417. * @returns A physics radial explosion event, or null
  63418. */
  63419. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  63420. /**
  63421. * Creates a gravitational field
  63422. * @param origin the origin of the explosion
  63423. * @param radiusOrEventOptions the radius or the options of radial explosion
  63424. * @param strength the explosion strength
  63425. * @param falloff possible options: Constant & Linear. Defaults to Constant
  63426. * @returns A physics gravitational field event, or null
  63427. */
  63428. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  63429. /**
  63430. * Creates a physics updraft event
  63431. * @param origin the origin of the updraft
  63432. * @param radiusOrEventOptions the radius or the options of the updraft
  63433. * @param strength the strength of the updraft
  63434. * @param height the height of the updraft
  63435. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  63436. * @returns A physics updraft event, or null
  63437. */
  63438. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  63439. /**
  63440. * Creates a physics vortex event
  63441. * @param origin the of the vortex
  63442. * @param radiusOrEventOptions the radius or the options of the vortex
  63443. * @param strength the strength of the vortex
  63444. * @param height the height of the vortex
  63445. * @returns a Physics vortex event, or null
  63446. * A physics vortex event or null
  63447. */
  63448. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  63449. }
  63450. /**
  63451. * Represents a physics radial explosion event
  63452. */
  63453. class PhysicsRadialExplosionEvent {
  63454. private _scene;
  63455. private _options;
  63456. private _sphere;
  63457. private _dataFetched;
  63458. /**
  63459. * Initializes a radial explosioin event
  63460. * @param _scene BabylonJS scene
  63461. * @param _options The options for the vortex event
  63462. */
  63463. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  63464. /**
  63465. * Returns the data related to the radial explosion event (sphere).
  63466. * @returns The radial explosion event data
  63467. */
  63468. getData(): PhysicsRadialExplosionEventData;
  63469. /**
  63470. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  63471. * @param impostor A physics imposter
  63472. * @param origin the origin of the explosion
  63473. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  63474. */
  63475. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  63476. /**
  63477. * Triggers affecterd impostors callbacks
  63478. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  63479. */
  63480. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  63481. /**
  63482. * Disposes the sphere.
  63483. * @param force Specifies if the sphere should be disposed by force
  63484. */
  63485. dispose(force?: boolean): void;
  63486. /*** Helpers ***/
  63487. private _prepareSphere;
  63488. private _intersectsWithSphere;
  63489. }
  63490. /**
  63491. * Represents a gravitational field event
  63492. */
  63493. class PhysicsGravitationalFieldEvent {
  63494. private _physicsHelper;
  63495. private _scene;
  63496. private _origin;
  63497. private _options;
  63498. private _tickCallback;
  63499. private _sphere;
  63500. private _dataFetched;
  63501. /**
  63502. * Initializes the physics gravitational field event
  63503. * @param _physicsHelper A physics helper
  63504. * @param _scene BabylonJS scene
  63505. * @param _origin The origin position of the gravitational field event
  63506. * @param _options The options for the vortex event
  63507. */
  63508. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  63509. /**
  63510. * Returns the data related to the gravitational field event (sphere).
  63511. * @returns A gravitational field event
  63512. */
  63513. getData(): PhysicsGravitationalFieldEventData;
  63514. /**
  63515. * Enables the gravitational field.
  63516. */
  63517. enable(): void;
  63518. /**
  63519. * Disables the gravitational field.
  63520. */
  63521. disable(): void;
  63522. /**
  63523. * Disposes the sphere.
  63524. * @param force The force to dispose from the gravitational field event
  63525. */
  63526. dispose(force?: boolean): void;
  63527. private _tick;
  63528. }
  63529. /**
  63530. * Represents a physics updraft event
  63531. */
  63532. class PhysicsUpdraftEvent {
  63533. private _scene;
  63534. private _origin;
  63535. private _options;
  63536. private _physicsEngine;
  63537. private _originTop;
  63538. private _originDirection;
  63539. private _tickCallback;
  63540. private _cylinder;
  63541. private _cylinderPosition;
  63542. private _dataFetched;
  63543. /**
  63544. * Initializes the physics updraft event
  63545. * @param _scene BabylonJS scene
  63546. * @param _origin The origin position of the updraft
  63547. * @param _options The options for the updraft event
  63548. */
  63549. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  63550. /**
  63551. * Returns the data related to the updraft event (cylinder).
  63552. * @returns A physics updraft event
  63553. */
  63554. getData(): PhysicsUpdraftEventData;
  63555. /**
  63556. * Enables the updraft.
  63557. */
  63558. enable(): void;
  63559. /**
  63560. * Disables the updraft.
  63561. */
  63562. disable(): void;
  63563. /**
  63564. * Disposes the cylinder.
  63565. * @param force Specifies if the updraft should be disposed by force
  63566. */
  63567. dispose(force?: boolean): void;
  63568. private getImpostorHitData;
  63569. private _tick;
  63570. /*** Helpers ***/
  63571. private _prepareCylinder;
  63572. private _intersectsWithCylinder;
  63573. }
  63574. /**
  63575. * Represents a physics vortex event
  63576. */
  63577. class PhysicsVortexEvent {
  63578. private _scene;
  63579. private _origin;
  63580. private _options;
  63581. private _physicsEngine;
  63582. private _originTop;
  63583. private _tickCallback;
  63584. private _cylinder;
  63585. private _cylinderPosition;
  63586. private _dataFetched;
  63587. /**
  63588. * Initializes the physics vortex event
  63589. * @param _scene The BabylonJS scene
  63590. * @param _origin The origin position of the vortex
  63591. * @param _options The options for the vortex event
  63592. */
  63593. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  63594. /**
  63595. * Returns the data related to the vortex event (cylinder).
  63596. * @returns The physics vortex event data
  63597. */
  63598. getData(): PhysicsVortexEventData;
  63599. /**
  63600. * Enables the vortex.
  63601. */
  63602. enable(): void;
  63603. /**
  63604. * Disables the cortex.
  63605. */
  63606. disable(): void;
  63607. /**
  63608. * Disposes the sphere.
  63609. * @param force
  63610. */
  63611. dispose(force?: boolean): void;
  63612. private getImpostorHitData;
  63613. private _tick;
  63614. /*** Helpers ***/
  63615. private _prepareCylinder;
  63616. private _intersectsWithCylinder;
  63617. }
  63618. /**
  63619. * Options fot the radial explosion event
  63620. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63621. */
  63622. export class PhysicsRadialExplosionEventOptions {
  63623. /**
  63624. * The radius of the sphere for the radial explosion.
  63625. */
  63626. radius: number;
  63627. /**
  63628. * The strenth of the explosion.
  63629. */
  63630. strength: number;
  63631. /**
  63632. * The strenght of the force in correspondence to the distance of the affected object
  63633. */
  63634. falloff: PhysicsRadialImpulseFalloff;
  63635. /**
  63636. * Sphere options for the radial explosion.
  63637. */
  63638. sphere: {
  63639. segments: number;
  63640. diameter: number;
  63641. };
  63642. /**
  63643. * Sphere options for the radial explosion.
  63644. */
  63645. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  63646. }
  63647. /**
  63648. * Options fot the updraft event
  63649. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63650. */
  63651. export class PhysicsUpdraftEventOptions {
  63652. /**
  63653. * The radius of the cylinder for the vortex
  63654. */
  63655. radius: number;
  63656. /**
  63657. * The strenth of the updraft.
  63658. */
  63659. strength: number;
  63660. /**
  63661. * The height of the cylinder for the updraft.
  63662. */
  63663. height: number;
  63664. /**
  63665. * The mode for the the updraft.
  63666. */
  63667. updraftMode: PhysicsUpdraftMode;
  63668. }
  63669. /**
  63670. * Options fot the vortex event
  63671. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63672. */
  63673. export class PhysicsVortexEventOptions {
  63674. /**
  63675. * The radius of the cylinder for the vortex
  63676. */
  63677. radius: number;
  63678. /**
  63679. * The strenth of the vortex.
  63680. */
  63681. strength: number;
  63682. /**
  63683. * The height of the cylinder for the vortex.
  63684. */
  63685. height: number;
  63686. /**
  63687. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  63688. */
  63689. centripetalForceThreshold: number;
  63690. /**
  63691. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  63692. */
  63693. centripetalForceMultiplier: number;
  63694. /**
  63695. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  63696. */
  63697. centrifugalForceMultiplier: number;
  63698. /**
  63699. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  63700. */
  63701. updraftForceMultiplier: number;
  63702. }
  63703. /**
  63704. * The strenght of the force in correspondence to the distance of the affected object
  63705. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63706. */
  63707. export enum PhysicsRadialImpulseFalloff {
  63708. /** Defines that impulse is constant in strength across it's whole radius */
  63709. Constant = 0,
  63710. /** Defines that impulse gets weaker if it's further from the origin */
  63711. Linear = 1
  63712. }
  63713. /**
  63714. * The strength of the force in correspondence to the distance of the affected object
  63715. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63716. */
  63717. export enum PhysicsUpdraftMode {
  63718. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  63719. Center = 0,
  63720. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  63721. Perpendicular = 1
  63722. }
  63723. /**
  63724. * Interface for a physics hit data
  63725. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63726. */
  63727. export interface PhysicsHitData {
  63728. /**
  63729. * The force applied at the contact point
  63730. */
  63731. force: Vector3;
  63732. /**
  63733. * The contact point
  63734. */
  63735. contactPoint: Vector3;
  63736. /**
  63737. * The distance from the origin to the contact point
  63738. */
  63739. distanceFromOrigin: number;
  63740. }
  63741. /**
  63742. * Interface for radial explosion event data
  63743. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63744. */
  63745. export interface PhysicsRadialExplosionEventData {
  63746. /**
  63747. * A sphere used for the radial explosion event
  63748. */
  63749. sphere: Mesh;
  63750. }
  63751. /**
  63752. * Interface for gravitational field event data
  63753. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63754. */
  63755. export interface PhysicsGravitationalFieldEventData {
  63756. /**
  63757. * A sphere mesh used for the gravitational field event
  63758. */
  63759. sphere: Mesh;
  63760. }
  63761. /**
  63762. * Interface for updraft event data
  63763. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63764. */
  63765. export interface PhysicsUpdraftEventData {
  63766. /**
  63767. * A cylinder used for the updraft event
  63768. */
  63769. cylinder: Mesh;
  63770. }
  63771. /**
  63772. * Interface for vortex event data
  63773. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63774. */
  63775. export interface PhysicsVortexEventData {
  63776. /**
  63777. * A cylinder used for the vortex event
  63778. */
  63779. cylinder: Mesh;
  63780. }
  63781. /**
  63782. * Interface for an affected physics impostor
  63783. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  63784. */
  63785. export interface PhysicsAffectedImpostorWithData {
  63786. /**
  63787. * The impostor affected by the effect
  63788. */
  63789. impostor: PhysicsImpostor;
  63790. /**
  63791. * The data about the hit/horce from the explosion
  63792. */
  63793. hitData: PhysicsHitData;
  63794. }
  63795. }
  63796. declare module BABYLON {
  63797. /** @hidden */
  63798. export var blackAndWhitePixelShader: {
  63799. name: string;
  63800. shader: string;
  63801. };
  63802. }
  63803. declare module BABYLON {
  63804. /**
  63805. * Post process used to render in black and white
  63806. */
  63807. export class BlackAndWhitePostProcess extends PostProcess {
  63808. /**
  63809. * Linear about to convert he result to black and white (default: 1)
  63810. */
  63811. degree: number;
  63812. /**
  63813. * Creates a black and white post process
  63814. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  63815. * @param name The name of the effect.
  63816. * @param options The required width/height ratio to downsize to before computing the render pass.
  63817. * @param camera The camera to apply the render pass to.
  63818. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63819. * @param engine The engine which the post process will be applied. (default: current engine)
  63820. * @param reusable If the post process can be reused on the same frame. (default: false)
  63821. */
  63822. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63823. }
  63824. }
  63825. declare module BABYLON {
  63826. /**
  63827. * This represents a set of one or more post processes in Babylon.
  63828. * A post process can be used to apply a shader to a texture after it is rendered.
  63829. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63830. */
  63831. export class PostProcessRenderEffect {
  63832. private _postProcesses;
  63833. private _getPostProcesses;
  63834. private _singleInstance;
  63835. private _cameras;
  63836. private _indicesForCamera;
  63837. /**
  63838. * Name of the effect
  63839. * @hidden
  63840. */
  63841. _name: string;
  63842. /**
  63843. * Instantiates a post process render effect.
  63844. * A post process can be used to apply a shader to a texture after it is rendered.
  63845. * @param engine The engine the effect is tied to
  63846. * @param name The name of the effect
  63847. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  63848. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  63849. */
  63850. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  63851. /**
  63852. * Checks if all the post processes in the effect are supported.
  63853. */
  63854. get isSupported(): boolean;
  63855. /**
  63856. * Updates the current state of the effect
  63857. * @hidden
  63858. */
  63859. _update(): void;
  63860. /**
  63861. * Attaches the effect on cameras
  63862. * @param cameras The camera to attach to.
  63863. * @hidden
  63864. */
  63865. _attachCameras(cameras: Camera): void;
  63866. /**
  63867. * Attaches the effect on cameras
  63868. * @param cameras The camera to attach to.
  63869. * @hidden
  63870. */
  63871. _attachCameras(cameras: Camera[]): void;
  63872. /**
  63873. * Detaches the effect on cameras
  63874. * @param cameras The camera to detatch from.
  63875. * @hidden
  63876. */
  63877. _detachCameras(cameras: Camera): void;
  63878. /**
  63879. * Detatches the effect on cameras
  63880. * @param cameras The camera to detatch from.
  63881. * @hidden
  63882. */
  63883. _detachCameras(cameras: Camera[]): void;
  63884. /**
  63885. * Enables the effect on given cameras
  63886. * @param cameras The camera to enable.
  63887. * @hidden
  63888. */
  63889. _enable(cameras: Camera): void;
  63890. /**
  63891. * Enables the effect on given cameras
  63892. * @param cameras The camera to enable.
  63893. * @hidden
  63894. */
  63895. _enable(cameras: Nullable<Camera[]>): void;
  63896. /**
  63897. * Disables the effect on the given cameras
  63898. * @param cameras The camera to disable.
  63899. * @hidden
  63900. */
  63901. _disable(cameras: Camera): void;
  63902. /**
  63903. * Disables the effect on the given cameras
  63904. * @param cameras The camera to disable.
  63905. * @hidden
  63906. */
  63907. _disable(cameras: Nullable<Camera[]>): void;
  63908. /**
  63909. * Gets a list of the post processes contained in the effect.
  63910. * @param camera The camera to get the post processes on.
  63911. * @returns The list of the post processes in the effect.
  63912. */
  63913. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  63914. }
  63915. }
  63916. declare module BABYLON {
  63917. /** @hidden */
  63918. export var extractHighlightsPixelShader: {
  63919. name: string;
  63920. shader: string;
  63921. };
  63922. }
  63923. declare module BABYLON {
  63924. /**
  63925. * 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.
  63926. */
  63927. export class ExtractHighlightsPostProcess extends PostProcess {
  63928. /**
  63929. * The luminance threshold, pixels below this value will be set to black.
  63930. */
  63931. threshold: number;
  63932. /** @hidden */
  63933. _exposure: number;
  63934. /**
  63935. * Post process which has the input texture to be used when performing highlight extraction
  63936. * @hidden
  63937. */
  63938. _inputPostProcess: Nullable<PostProcess>;
  63939. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63940. }
  63941. }
  63942. declare module BABYLON {
  63943. /** @hidden */
  63944. export var bloomMergePixelShader: {
  63945. name: string;
  63946. shader: string;
  63947. };
  63948. }
  63949. declare module BABYLON {
  63950. /**
  63951. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  63952. */
  63953. export class BloomMergePostProcess extends PostProcess {
  63954. /** Weight of the bloom to be added to the original input. */
  63955. weight: number;
  63956. /**
  63957. * Creates a new instance of @see BloomMergePostProcess
  63958. * @param name The name of the effect.
  63959. * @param originalFromInput Post process which's input will be used for the merge.
  63960. * @param blurred Blurred highlights post process which's output will be used.
  63961. * @param weight Weight of the bloom to be added to the original input.
  63962. * @param options The required width/height ratio to downsize to before computing the render pass.
  63963. * @param camera The camera to apply the render pass to.
  63964. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63965. * @param engine The engine which the post process will be applied. (default: current engine)
  63966. * @param reusable If the post process can be reused on the same frame. (default: false)
  63967. * @param textureType Type of textures used when performing the post process. (default: 0)
  63968. * @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)
  63969. */
  63970. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  63971. /** Weight of the bloom to be added to the original input. */
  63972. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63973. }
  63974. }
  63975. declare module BABYLON {
  63976. /**
  63977. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  63978. */
  63979. export class BloomEffect extends PostProcessRenderEffect {
  63980. private bloomScale;
  63981. /**
  63982. * @hidden Internal
  63983. */
  63984. _effects: Array<PostProcess>;
  63985. /**
  63986. * @hidden Internal
  63987. */
  63988. _downscale: ExtractHighlightsPostProcess;
  63989. private _blurX;
  63990. private _blurY;
  63991. private _merge;
  63992. /**
  63993. * The luminance threshold to find bright areas of the image to bloom.
  63994. */
  63995. get threshold(): number;
  63996. set threshold(value: number);
  63997. /**
  63998. * The strength of the bloom.
  63999. */
  64000. get weight(): number;
  64001. set weight(value: number);
  64002. /**
  64003. * Specifies the size of the bloom blur kernel, relative to the final output size
  64004. */
  64005. get kernel(): number;
  64006. set kernel(value: number);
  64007. /**
  64008. * Creates a new instance of @see BloomEffect
  64009. * @param scene The scene the effect belongs to.
  64010. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  64011. * @param bloomKernel The size of the kernel to be used when applying the blur.
  64012. * @param bloomWeight The the strength of bloom.
  64013. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64014. * @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)
  64015. */
  64016. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  64017. /**
  64018. * Disposes each of the internal effects for a given camera.
  64019. * @param camera The camera to dispose the effect on.
  64020. */
  64021. disposeEffects(camera: Camera): void;
  64022. /**
  64023. * @hidden Internal
  64024. */
  64025. _updateEffects(): void;
  64026. /**
  64027. * Internal
  64028. * @returns if all the contained post processes are ready.
  64029. * @hidden
  64030. */
  64031. _isReady(): boolean;
  64032. }
  64033. }
  64034. declare module BABYLON {
  64035. /** @hidden */
  64036. export var chromaticAberrationPixelShader: {
  64037. name: string;
  64038. shader: string;
  64039. };
  64040. }
  64041. declare module BABYLON {
  64042. /**
  64043. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  64044. */
  64045. export class ChromaticAberrationPostProcess extends PostProcess {
  64046. /**
  64047. * The amount of seperation of rgb channels (default: 30)
  64048. */
  64049. aberrationAmount: number;
  64050. /**
  64051. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  64052. */
  64053. radialIntensity: number;
  64054. /**
  64055. * 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))
  64056. */
  64057. direction: Vector2;
  64058. /**
  64059. * 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))
  64060. */
  64061. centerPosition: Vector2;
  64062. /**
  64063. * Creates a new instance ChromaticAberrationPostProcess
  64064. * @param name The name of the effect.
  64065. * @param screenWidth The width of the screen to apply the effect on.
  64066. * @param screenHeight The height of the screen to apply the effect on.
  64067. * @param options The required width/height ratio to downsize to before computing the render pass.
  64068. * @param camera The camera to apply the render pass to.
  64069. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64070. * @param engine The engine which the post process will be applied. (default: current engine)
  64071. * @param reusable If the post process can be reused on the same frame. (default: false)
  64072. * @param textureType Type of textures used when performing the post process. (default: 0)
  64073. * @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)
  64074. */
  64075. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64076. }
  64077. }
  64078. declare module BABYLON {
  64079. /** @hidden */
  64080. export var circleOfConfusionPixelShader: {
  64081. name: string;
  64082. shader: string;
  64083. };
  64084. }
  64085. declare module BABYLON {
  64086. /**
  64087. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  64088. */
  64089. export class CircleOfConfusionPostProcess extends PostProcess {
  64090. /**
  64091. * 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.
  64092. */
  64093. lensSize: number;
  64094. /**
  64095. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64096. */
  64097. fStop: number;
  64098. /**
  64099. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64100. */
  64101. focusDistance: number;
  64102. /**
  64103. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  64104. */
  64105. focalLength: number;
  64106. private _depthTexture;
  64107. /**
  64108. * Creates a new instance CircleOfConfusionPostProcess
  64109. * @param name The name of the effect.
  64110. * @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.
  64111. * @param options The required width/height ratio to downsize to before computing the render pass.
  64112. * @param camera The camera to apply the render pass to.
  64113. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64114. * @param engine The engine which the post process will be applied. (default: current engine)
  64115. * @param reusable If the post process can be reused on the same frame. (default: false)
  64116. * @param textureType Type of textures used when performing the post process. (default: 0)
  64117. * @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)
  64118. */
  64119. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64120. /**
  64121. * 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.
  64122. */
  64123. set depthTexture(value: RenderTargetTexture);
  64124. }
  64125. }
  64126. declare module BABYLON {
  64127. /** @hidden */
  64128. export var colorCorrectionPixelShader: {
  64129. name: string;
  64130. shader: string;
  64131. };
  64132. }
  64133. declare module BABYLON {
  64134. /**
  64135. *
  64136. * This post-process allows the modification of rendered colors by using
  64137. * a 'look-up table' (LUT). This effect is also called Color Grading.
  64138. *
  64139. * The object needs to be provided an url to a texture containing the color
  64140. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  64141. * Use an image editing software to tweak the LUT to match your needs.
  64142. *
  64143. * For an example of a color LUT, see here:
  64144. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  64145. * For explanations on color grading, see here:
  64146. * @see http://udn.epicgames.com/Three/ColorGrading.html
  64147. *
  64148. */
  64149. export class ColorCorrectionPostProcess extends PostProcess {
  64150. private _colorTableTexture;
  64151. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64152. }
  64153. }
  64154. declare module BABYLON {
  64155. /** @hidden */
  64156. export var convolutionPixelShader: {
  64157. name: string;
  64158. shader: string;
  64159. };
  64160. }
  64161. declare module BABYLON {
  64162. /**
  64163. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  64164. * input texture to perform effects such as edge detection or sharpening
  64165. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  64166. */
  64167. export class ConvolutionPostProcess extends PostProcess {
  64168. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64169. kernel: number[];
  64170. /**
  64171. * Creates a new instance ConvolutionPostProcess
  64172. * @param name The name of the effect.
  64173. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  64174. * @param options The required width/height ratio to downsize to before computing the render pass.
  64175. * @param camera The camera to apply the render pass to.
  64176. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64177. * @param engine The engine which the post process will be applied. (default: current engine)
  64178. * @param reusable If the post process can be reused on the same frame. (default: false)
  64179. * @param textureType Type of textures used when performing the post process. (default: 0)
  64180. */
  64181. constructor(name: string,
  64182. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  64183. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64184. /**
  64185. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64186. */
  64187. static EdgeDetect0Kernel: number[];
  64188. /**
  64189. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64190. */
  64191. static EdgeDetect1Kernel: number[];
  64192. /**
  64193. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64194. */
  64195. static EdgeDetect2Kernel: number[];
  64196. /**
  64197. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64198. */
  64199. static SharpenKernel: number[];
  64200. /**
  64201. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64202. */
  64203. static EmbossKernel: number[];
  64204. /**
  64205. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  64206. */
  64207. static GaussianKernel: number[];
  64208. }
  64209. }
  64210. declare module BABYLON {
  64211. /**
  64212. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  64213. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  64214. * based on samples that have a large difference in distance than the center pixel.
  64215. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  64216. */
  64217. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  64218. direction: Vector2;
  64219. /**
  64220. * Creates a new instance CircleOfConfusionPostProcess
  64221. * @param name The name of the effect.
  64222. * @param scene The scene the effect belongs to.
  64223. * @param direction The direction the blur should be applied.
  64224. * @param kernel The size of the kernel used to blur.
  64225. * @param options The required width/height ratio to downsize to before computing the render pass.
  64226. * @param camera The camera to apply the render pass to.
  64227. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  64228. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  64229. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64230. * @param engine The engine which the post process will be applied. (default: current engine)
  64231. * @param reusable If the post process can be reused on the same frame. (default: false)
  64232. * @param textureType Type of textures used when performing the post process. (default: 0)
  64233. * @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)
  64234. */
  64235. 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);
  64236. }
  64237. }
  64238. declare module BABYLON {
  64239. /** @hidden */
  64240. export var depthOfFieldMergePixelShader: {
  64241. name: string;
  64242. shader: string;
  64243. };
  64244. }
  64245. declare module BABYLON {
  64246. /**
  64247. * Options to be set when merging outputs from the default pipeline.
  64248. */
  64249. export class DepthOfFieldMergePostProcessOptions {
  64250. /**
  64251. * The original image to merge on top of
  64252. */
  64253. originalFromInput: PostProcess;
  64254. /**
  64255. * Parameters to perform the merge of the depth of field effect
  64256. */
  64257. depthOfField?: {
  64258. circleOfConfusion: PostProcess;
  64259. blurSteps: Array<PostProcess>;
  64260. };
  64261. /**
  64262. * Parameters to perform the merge of bloom effect
  64263. */
  64264. bloom?: {
  64265. blurred: PostProcess;
  64266. weight: number;
  64267. };
  64268. }
  64269. /**
  64270. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  64271. */
  64272. export class DepthOfFieldMergePostProcess extends PostProcess {
  64273. private blurSteps;
  64274. /**
  64275. * Creates a new instance of DepthOfFieldMergePostProcess
  64276. * @param name The name of the effect.
  64277. * @param originalFromInput Post process which's input will be used for the merge.
  64278. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  64279. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  64280. * @param options The required width/height ratio to downsize to before computing the render pass.
  64281. * @param camera The camera to apply the render pass to.
  64282. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64283. * @param engine The engine which the post process will be applied. (default: current engine)
  64284. * @param reusable If the post process can be reused on the same frame. (default: false)
  64285. * @param textureType Type of textures used when performing the post process. (default: 0)
  64286. * @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)
  64287. */
  64288. 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);
  64289. /**
  64290. * Updates the effect with the current post process compile time values and recompiles the shader.
  64291. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  64292. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  64293. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  64294. * @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
  64295. * @param onCompiled Called when the shader has been compiled.
  64296. * @param onError Called if there is an error when compiling a shader.
  64297. */
  64298. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  64299. }
  64300. }
  64301. declare module BABYLON {
  64302. /**
  64303. * Specifies the level of max blur that should be applied when using the depth of field effect
  64304. */
  64305. export enum DepthOfFieldEffectBlurLevel {
  64306. /**
  64307. * Subtle blur
  64308. */
  64309. Low = 0,
  64310. /**
  64311. * Medium blur
  64312. */
  64313. Medium = 1,
  64314. /**
  64315. * Large blur
  64316. */
  64317. High = 2
  64318. }
  64319. /**
  64320. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  64321. */
  64322. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  64323. private _circleOfConfusion;
  64324. /**
  64325. * @hidden Internal, blurs from high to low
  64326. */
  64327. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  64328. private _depthOfFieldBlurY;
  64329. private _dofMerge;
  64330. /**
  64331. * @hidden Internal post processes in depth of field effect
  64332. */
  64333. _effects: Array<PostProcess>;
  64334. /**
  64335. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  64336. */
  64337. set focalLength(value: number);
  64338. get focalLength(): number;
  64339. /**
  64340. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  64341. */
  64342. set fStop(value: number);
  64343. get fStop(): number;
  64344. /**
  64345. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  64346. */
  64347. set focusDistance(value: number);
  64348. get focusDistance(): number;
  64349. /**
  64350. * 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.
  64351. */
  64352. set lensSize(value: number);
  64353. get lensSize(): number;
  64354. /**
  64355. * Creates a new instance DepthOfFieldEffect
  64356. * @param scene The scene the effect belongs to.
  64357. * @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.
  64358. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  64359. * @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)
  64360. */
  64361. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  64362. /**
  64363. * Get the current class name of the current effet
  64364. * @returns "DepthOfFieldEffect"
  64365. */
  64366. getClassName(): string;
  64367. /**
  64368. * 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.
  64369. */
  64370. set depthTexture(value: RenderTargetTexture);
  64371. /**
  64372. * Disposes each of the internal effects for a given camera.
  64373. * @param camera The camera to dispose the effect on.
  64374. */
  64375. disposeEffects(camera: Camera): void;
  64376. /**
  64377. * @hidden Internal
  64378. */
  64379. _updateEffects(): void;
  64380. /**
  64381. * Internal
  64382. * @returns if all the contained post processes are ready.
  64383. * @hidden
  64384. */
  64385. _isReady(): boolean;
  64386. }
  64387. }
  64388. declare module BABYLON {
  64389. /** @hidden */
  64390. export var displayPassPixelShader: {
  64391. name: string;
  64392. shader: string;
  64393. };
  64394. }
  64395. declare module BABYLON {
  64396. /**
  64397. * DisplayPassPostProcess which produces an output the same as it's input
  64398. */
  64399. export class DisplayPassPostProcess extends PostProcess {
  64400. /**
  64401. * Creates the DisplayPassPostProcess
  64402. * @param name The name of the effect.
  64403. * @param options The required width/height ratio to downsize to before computing the render pass.
  64404. * @param camera The camera to apply the render pass to.
  64405. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64406. * @param engine The engine which the post process will be applied. (default: current engine)
  64407. * @param reusable If the post process can be reused on the same frame. (default: false)
  64408. */
  64409. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64410. }
  64411. }
  64412. declare module BABYLON {
  64413. /** @hidden */
  64414. export var filterPixelShader: {
  64415. name: string;
  64416. shader: string;
  64417. };
  64418. }
  64419. declare module BABYLON {
  64420. /**
  64421. * Applies a kernel filter to the image
  64422. */
  64423. export class FilterPostProcess extends PostProcess {
  64424. /** The matrix to be applied to the image */
  64425. kernelMatrix: Matrix;
  64426. /**
  64427. *
  64428. * @param name The name of the effect.
  64429. * @param kernelMatrix The matrix to be applied to the image
  64430. * @param options The required width/height ratio to downsize to before computing the render pass.
  64431. * @param camera The camera to apply the render pass to.
  64432. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64433. * @param engine The engine which the post process will be applied. (default: current engine)
  64434. * @param reusable If the post process can be reused on the same frame. (default: false)
  64435. */
  64436. constructor(name: string,
  64437. /** The matrix to be applied to the image */
  64438. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64439. }
  64440. }
  64441. declare module BABYLON {
  64442. /** @hidden */
  64443. export var fxaaPixelShader: {
  64444. name: string;
  64445. shader: string;
  64446. };
  64447. }
  64448. declare module BABYLON {
  64449. /** @hidden */
  64450. export var fxaaVertexShader: {
  64451. name: string;
  64452. shader: string;
  64453. };
  64454. }
  64455. declare module BABYLON {
  64456. /**
  64457. * Fxaa post process
  64458. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  64459. */
  64460. export class FxaaPostProcess extends PostProcess {
  64461. /** @hidden */
  64462. texelWidth: number;
  64463. /** @hidden */
  64464. texelHeight: number;
  64465. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64466. private _getDefines;
  64467. }
  64468. }
  64469. declare module BABYLON {
  64470. /** @hidden */
  64471. export var grainPixelShader: {
  64472. name: string;
  64473. shader: string;
  64474. };
  64475. }
  64476. declare module BABYLON {
  64477. /**
  64478. * The GrainPostProcess adds noise to the image at mid luminance levels
  64479. */
  64480. export class GrainPostProcess extends PostProcess {
  64481. /**
  64482. * The intensity of the grain added (default: 30)
  64483. */
  64484. intensity: number;
  64485. /**
  64486. * If the grain should be randomized on every frame
  64487. */
  64488. animated: boolean;
  64489. /**
  64490. * Creates a new instance of @see GrainPostProcess
  64491. * @param name The name of the effect.
  64492. * @param options The required width/height ratio to downsize to before computing the render pass.
  64493. * @param camera The camera to apply the render pass to.
  64494. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64495. * @param engine The engine which the post process will be applied. (default: current engine)
  64496. * @param reusable If the post process can be reused on the same frame. (default: false)
  64497. * @param textureType Type of textures used when performing the post process. (default: 0)
  64498. * @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)
  64499. */
  64500. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64501. }
  64502. }
  64503. declare module BABYLON {
  64504. /** @hidden */
  64505. export var highlightsPixelShader: {
  64506. name: string;
  64507. shader: string;
  64508. };
  64509. }
  64510. declare module BABYLON {
  64511. /**
  64512. * Extracts highlights from the image
  64513. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  64514. */
  64515. export class HighlightsPostProcess extends PostProcess {
  64516. /**
  64517. * Extracts highlights from the image
  64518. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  64519. * @param name The name of the effect.
  64520. * @param options The required width/height ratio to downsize to before computing the render pass.
  64521. * @param camera The camera to apply the render pass to.
  64522. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64523. * @param engine The engine which the post process will be applied. (default: current engine)
  64524. * @param reusable If the post process can be reused on the same frame. (default: false)
  64525. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  64526. */
  64527. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  64528. }
  64529. }
  64530. declare module BABYLON {
  64531. /** @hidden */
  64532. export var mrtFragmentDeclaration: {
  64533. name: string;
  64534. shader: string;
  64535. };
  64536. }
  64537. declare module BABYLON {
  64538. /** @hidden */
  64539. export var geometryPixelShader: {
  64540. name: string;
  64541. shader: string;
  64542. };
  64543. }
  64544. declare module BABYLON {
  64545. /** @hidden */
  64546. export var geometryVertexShader: {
  64547. name: string;
  64548. shader: string;
  64549. };
  64550. }
  64551. declare module BABYLON {
  64552. /** @hidden */
  64553. interface ISavedTransformationMatrix {
  64554. world: Matrix;
  64555. viewProjection: Matrix;
  64556. }
  64557. /**
  64558. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  64559. */
  64560. export class GeometryBufferRenderer {
  64561. /**
  64562. * Constant used to retrieve the position texture index in the G-Buffer textures array
  64563. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  64564. */
  64565. static readonly POSITION_TEXTURE_TYPE: number;
  64566. /**
  64567. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  64568. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  64569. */
  64570. static readonly VELOCITY_TEXTURE_TYPE: number;
  64571. /**
  64572. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  64573. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  64574. */
  64575. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  64576. /**
  64577. * Dictionary used to store the previous transformation matrices of each rendered mesh
  64578. * in order to compute objects velocities when enableVelocity is set to "true"
  64579. * @hidden
  64580. */
  64581. _previousTransformationMatrices: {
  64582. [index: number]: ISavedTransformationMatrix;
  64583. };
  64584. /**
  64585. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  64586. * in order to compute objects velocities when enableVelocity is set to "true"
  64587. * @hidden
  64588. */
  64589. _previousBonesTransformationMatrices: {
  64590. [index: number]: Float32Array;
  64591. };
  64592. /**
  64593. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  64594. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  64595. */
  64596. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  64597. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  64598. renderTransparentMeshes: boolean;
  64599. private _scene;
  64600. private _multiRenderTarget;
  64601. private _ratio;
  64602. private _enablePosition;
  64603. private _enableVelocity;
  64604. private _enableReflectivity;
  64605. private _positionIndex;
  64606. private _velocityIndex;
  64607. private _reflectivityIndex;
  64608. protected _effect: Effect;
  64609. protected _cachedDefines: string;
  64610. /**
  64611. * Set the render list (meshes to be rendered) used in the G buffer.
  64612. */
  64613. set renderList(meshes: Mesh[]);
  64614. /**
  64615. * Gets wether or not G buffer are supported by the running hardware.
  64616. * This requires draw buffer supports
  64617. */
  64618. get isSupported(): boolean;
  64619. /**
  64620. * Returns the index of the given texture type in the G-Buffer textures array
  64621. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  64622. * @returns the index of the given texture type in the G-Buffer textures array
  64623. */
  64624. getTextureIndex(textureType: number): number;
  64625. /**
  64626. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  64627. */
  64628. get enablePosition(): boolean;
  64629. /**
  64630. * Sets whether or not objects positions are enabled for the G buffer.
  64631. */
  64632. set enablePosition(enable: boolean);
  64633. /**
  64634. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  64635. */
  64636. get enableVelocity(): boolean;
  64637. /**
  64638. * Sets wether or not objects velocities are enabled for the G buffer.
  64639. */
  64640. set enableVelocity(enable: boolean);
  64641. /**
  64642. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  64643. */
  64644. get enableReflectivity(): boolean;
  64645. /**
  64646. * Sets wether or not objects roughness are enabled for the G buffer.
  64647. */
  64648. set enableReflectivity(enable: boolean);
  64649. /**
  64650. * Gets the scene associated with the buffer.
  64651. */
  64652. get scene(): Scene;
  64653. /**
  64654. * Gets the ratio used by the buffer during its creation.
  64655. * How big is the buffer related to the main canvas.
  64656. */
  64657. get ratio(): number;
  64658. /** @hidden */
  64659. static _SceneComponentInitialization: (scene: Scene) => void;
  64660. /**
  64661. * Creates a new G Buffer for the scene
  64662. * @param scene The scene the buffer belongs to
  64663. * @param ratio How big is the buffer related to the main canvas.
  64664. */
  64665. constructor(scene: Scene, ratio?: number);
  64666. /**
  64667. * Checks wether everything is ready to render a submesh to the G buffer.
  64668. * @param subMesh the submesh to check readiness for
  64669. * @param useInstances is the mesh drawn using instance or not
  64670. * @returns true if ready otherwise false
  64671. */
  64672. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64673. /**
  64674. * Gets the current underlying G Buffer.
  64675. * @returns the buffer
  64676. */
  64677. getGBuffer(): MultiRenderTarget;
  64678. /**
  64679. * Gets the number of samples used to render the buffer (anti aliasing).
  64680. */
  64681. get samples(): number;
  64682. /**
  64683. * Sets the number of samples used to render the buffer (anti aliasing).
  64684. */
  64685. set samples(value: number);
  64686. /**
  64687. * Disposes the renderer and frees up associated resources.
  64688. */
  64689. dispose(): void;
  64690. protected _createRenderTargets(): void;
  64691. private _copyBonesTransformationMatrices;
  64692. }
  64693. }
  64694. declare module BABYLON {
  64695. interface Scene {
  64696. /** @hidden (Backing field) */
  64697. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  64698. /**
  64699. * Gets or Sets the current geometry buffer associated to the scene.
  64700. */
  64701. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  64702. /**
  64703. * Enables a GeometryBufferRender and associates it with the scene
  64704. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  64705. * @returns the GeometryBufferRenderer
  64706. */
  64707. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  64708. /**
  64709. * Disables the GeometryBufferRender associated with the scene
  64710. */
  64711. disableGeometryBufferRenderer(): void;
  64712. }
  64713. /**
  64714. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  64715. * in several rendering techniques.
  64716. */
  64717. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  64718. /**
  64719. * The component name helpful to identify the component in the list of scene components.
  64720. */
  64721. readonly name: string;
  64722. /**
  64723. * The scene the component belongs to.
  64724. */
  64725. scene: Scene;
  64726. /**
  64727. * Creates a new instance of the component for the given scene
  64728. * @param scene Defines the scene to register the component in
  64729. */
  64730. constructor(scene: Scene);
  64731. /**
  64732. * Registers the component in a given scene
  64733. */
  64734. register(): void;
  64735. /**
  64736. * Rebuilds the elements related to this component in case of
  64737. * context lost for instance.
  64738. */
  64739. rebuild(): void;
  64740. /**
  64741. * Disposes the component and the associated ressources
  64742. */
  64743. dispose(): void;
  64744. private _gatherRenderTargets;
  64745. }
  64746. }
  64747. declare module BABYLON {
  64748. /** @hidden */
  64749. export var motionBlurPixelShader: {
  64750. name: string;
  64751. shader: string;
  64752. };
  64753. }
  64754. declare module BABYLON {
  64755. /**
  64756. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  64757. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  64758. * As an example, all you have to do is to create the post-process:
  64759. * var mb = new BABYLON.MotionBlurPostProcess(
  64760. * 'mb', // The name of the effect.
  64761. * scene, // The scene containing the objects to blur according to their velocity.
  64762. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  64763. * camera // The camera to apply the render pass to.
  64764. * );
  64765. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  64766. */
  64767. export class MotionBlurPostProcess extends PostProcess {
  64768. /**
  64769. * Defines how much the image is blurred by the movement. Default value is equal to 1
  64770. */
  64771. motionStrength: number;
  64772. /**
  64773. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  64774. */
  64775. get motionBlurSamples(): number;
  64776. /**
  64777. * Sets the number of iterations to be used for motion blur quality
  64778. */
  64779. set motionBlurSamples(samples: number);
  64780. private _motionBlurSamples;
  64781. private _geometryBufferRenderer;
  64782. /**
  64783. * Creates a new instance MotionBlurPostProcess
  64784. * @param name The name of the effect.
  64785. * @param scene The scene containing the objects to blur according to their velocity.
  64786. * @param options The required width/height ratio to downsize to before computing the render pass.
  64787. * @param camera The camera to apply the render pass to.
  64788. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64789. * @param engine The engine which the post process will be applied. (default: current engine)
  64790. * @param reusable If the post process can be reused on the same frame. (default: false)
  64791. * @param textureType Type of textures used when performing the post process. (default: 0)
  64792. * @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)
  64793. */
  64794. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64795. /**
  64796. * Excludes the given skinned mesh from computing bones velocities.
  64797. * 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.
  64798. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  64799. */
  64800. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  64801. /**
  64802. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  64803. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  64804. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  64805. */
  64806. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  64807. /**
  64808. * Disposes the post process.
  64809. * @param camera The camera to dispose the post process on.
  64810. */
  64811. dispose(camera?: Camera): void;
  64812. }
  64813. }
  64814. declare module BABYLON {
  64815. /** @hidden */
  64816. export var refractionPixelShader: {
  64817. name: string;
  64818. shader: string;
  64819. };
  64820. }
  64821. declare module BABYLON {
  64822. /**
  64823. * Post process which applies a refractin texture
  64824. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  64825. */
  64826. export class RefractionPostProcess extends PostProcess {
  64827. /** the base color of the refraction (used to taint the rendering) */
  64828. color: Color3;
  64829. /** simulated refraction depth */
  64830. depth: number;
  64831. /** the coefficient of the base color (0 to remove base color tainting) */
  64832. colorLevel: number;
  64833. private _refTexture;
  64834. private _ownRefractionTexture;
  64835. /**
  64836. * Gets or sets the refraction texture
  64837. * Please note that you are responsible for disposing the texture if you set it manually
  64838. */
  64839. get refractionTexture(): Texture;
  64840. set refractionTexture(value: Texture);
  64841. /**
  64842. * Initializes the RefractionPostProcess
  64843. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  64844. * @param name The name of the effect.
  64845. * @param refractionTextureUrl Url of the refraction texture to use
  64846. * @param color the base color of the refraction (used to taint the rendering)
  64847. * @param depth simulated refraction depth
  64848. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  64849. * @param camera The camera to apply the render pass to.
  64850. * @param options The required width/height ratio to downsize to before computing the render pass.
  64851. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64852. * @param engine The engine which the post process will be applied. (default: current engine)
  64853. * @param reusable If the post process can be reused on the same frame. (default: false)
  64854. */
  64855. constructor(name: string, refractionTextureUrl: string,
  64856. /** the base color of the refraction (used to taint the rendering) */
  64857. color: Color3,
  64858. /** simulated refraction depth */
  64859. depth: number,
  64860. /** the coefficient of the base color (0 to remove base color tainting) */
  64861. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  64862. /**
  64863. * Disposes of the post process
  64864. * @param camera Camera to dispose post process on
  64865. */
  64866. dispose(camera: Camera): void;
  64867. }
  64868. }
  64869. declare module BABYLON {
  64870. /** @hidden */
  64871. export var sharpenPixelShader: {
  64872. name: string;
  64873. shader: string;
  64874. };
  64875. }
  64876. declare module BABYLON {
  64877. /**
  64878. * The SharpenPostProcess applies a sharpen kernel to every pixel
  64879. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  64880. */
  64881. export class SharpenPostProcess extends PostProcess {
  64882. /**
  64883. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  64884. */
  64885. colorAmount: number;
  64886. /**
  64887. * How much sharpness should be applied (default: 0.3)
  64888. */
  64889. edgeAmount: number;
  64890. /**
  64891. * Creates a new instance ConvolutionPostProcess
  64892. * @param name The name of the effect.
  64893. * @param options The required width/height ratio to downsize to before computing the render pass.
  64894. * @param camera The camera to apply the render pass to.
  64895. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  64896. * @param engine The engine which the post process will be applied. (default: current engine)
  64897. * @param reusable If the post process can be reused on the same frame. (default: false)
  64898. * @param textureType Type of textures used when performing the post process. (default: 0)
  64899. * @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)
  64900. */
  64901. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  64902. }
  64903. }
  64904. declare module BABYLON {
  64905. /**
  64906. * PostProcessRenderPipeline
  64907. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64908. */
  64909. export class PostProcessRenderPipeline {
  64910. private engine;
  64911. private _renderEffects;
  64912. private _renderEffectsForIsolatedPass;
  64913. /**
  64914. * List of inspectable custom properties (used by the Inspector)
  64915. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  64916. */
  64917. inspectableCustomProperties: IInspectable[];
  64918. /**
  64919. * @hidden
  64920. */
  64921. protected _cameras: Camera[];
  64922. /** @hidden */
  64923. _name: string;
  64924. /**
  64925. * Gets pipeline name
  64926. */
  64927. get name(): string;
  64928. /** Gets the list of attached cameras */
  64929. get cameras(): Camera[];
  64930. /**
  64931. * Initializes a PostProcessRenderPipeline
  64932. * @param engine engine to add the pipeline to
  64933. * @param name name of the pipeline
  64934. */
  64935. constructor(engine: Engine, name: string);
  64936. /**
  64937. * Gets the class name
  64938. * @returns "PostProcessRenderPipeline"
  64939. */
  64940. getClassName(): string;
  64941. /**
  64942. * If all the render effects in the pipeline are supported
  64943. */
  64944. get isSupported(): boolean;
  64945. /**
  64946. * Adds an effect to the pipeline
  64947. * @param renderEffect the effect to add
  64948. */
  64949. addEffect(renderEffect: PostProcessRenderEffect): void;
  64950. /** @hidden */
  64951. _rebuild(): void;
  64952. /** @hidden */
  64953. _enableEffect(renderEffectName: string, cameras: Camera): void;
  64954. /** @hidden */
  64955. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  64956. /** @hidden */
  64957. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  64958. /** @hidden */
  64959. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  64960. /** @hidden */
  64961. _attachCameras(cameras: Camera, unique: boolean): void;
  64962. /** @hidden */
  64963. _attachCameras(cameras: Camera[], unique: boolean): void;
  64964. /** @hidden */
  64965. _detachCameras(cameras: Camera): void;
  64966. /** @hidden */
  64967. _detachCameras(cameras: Nullable<Camera[]>): void;
  64968. /** @hidden */
  64969. _update(): void;
  64970. /** @hidden */
  64971. _reset(): void;
  64972. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  64973. /**
  64974. * Disposes of the pipeline
  64975. */
  64976. dispose(): void;
  64977. }
  64978. }
  64979. declare module BABYLON {
  64980. /**
  64981. * PostProcessRenderPipelineManager class
  64982. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64983. */
  64984. export class PostProcessRenderPipelineManager {
  64985. private _renderPipelines;
  64986. /**
  64987. * Initializes a PostProcessRenderPipelineManager
  64988. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  64989. */
  64990. constructor();
  64991. /**
  64992. * Gets the list of supported render pipelines
  64993. */
  64994. get supportedPipelines(): PostProcessRenderPipeline[];
  64995. /**
  64996. * Adds a pipeline to the manager
  64997. * @param renderPipeline The pipeline to add
  64998. */
  64999. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  65000. /**
  65001. * Attaches a camera to the pipeline
  65002. * @param renderPipelineName The name of the pipeline to attach to
  65003. * @param cameras the camera to attach
  65004. * @param unique if the camera can be attached multiple times to the pipeline
  65005. */
  65006. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  65007. /**
  65008. * Detaches a camera from the pipeline
  65009. * @param renderPipelineName The name of the pipeline to detach from
  65010. * @param cameras the camera to detach
  65011. */
  65012. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  65013. /**
  65014. * Enables an effect by name on a pipeline
  65015. * @param renderPipelineName the name of the pipeline to enable the effect in
  65016. * @param renderEffectName the name of the effect to enable
  65017. * @param cameras the cameras that the effect should be enabled on
  65018. */
  65019. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65020. /**
  65021. * Disables an effect by name on a pipeline
  65022. * @param renderPipelineName the name of the pipeline to disable the effect in
  65023. * @param renderEffectName the name of the effect to disable
  65024. * @param cameras the cameras that the effect should be disabled on
  65025. */
  65026. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  65027. /**
  65028. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  65029. */
  65030. update(): void;
  65031. /** @hidden */
  65032. _rebuild(): void;
  65033. /**
  65034. * Disposes of the manager and pipelines
  65035. */
  65036. dispose(): void;
  65037. }
  65038. }
  65039. declare module BABYLON {
  65040. interface Scene {
  65041. /** @hidden (Backing field) */
  65042. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65043. /**
  65044. * Gets the postprocess render pipeline manager
  65045. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  65046. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65047. */
  65048. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  65049. }
  65050. /**
  65051. * Defines the Render Pipeline scene component responsible to rendering pipelines
  65052. */
  65053. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  65054. /**
  65055. * The component name helpfull to identify the component in the list of scene components.
  65056. */
  65057. readonly name: string;
  65058. /**
  65059. * The scene the component belongs to.
  65060. */
  65061. scene: Scene;
  65062. /**
  65063. * Creates a new instance of the component for the given scene
  65064. * @param scene Defines the scene to register the component in
  65065. */
  65066. constructor(scene: Scene);
  65067. /**
  65068. * Registers the component in a given scene
  65069. */
  65070. register(): void;
  65071. /**
  65072. * Rebuilds the elements related to this component in case of
  65073. * context lost for instance.
  65074. */
  65075. rebuild(): void;
  65076. /**
  65077. * Disposes the component and the associated ressources
  65078. */
  65079. dispose(): void;
  65080. private _gatherRenderTargets;
  65081. }
  65082. }
  65083. declare module BABYLON {
  65084. /**
  65085. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  65086. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  65087. */
  65088. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  65089. private _scene;
  65090. private _camerasToBeAttached;
  65091. /**
  65092. * ID of the sharpen post process,
  65093. */
  65094. private readonly SharpenPostProcessId;
  65095. /**
  65096. * @ignore
  65097. * ID of the image processing post process;
  65098. */
  65099. readonly ImageProcessingPostProcessId: string;
  65100. /**
  65101. * @ignore
  65102. * ID of the Fast Approximate Anti-Aliasing post process;
  65103. */
  65104. readonly FxaaPostProcessId: string;
  65105. /**
  65106. * ID of the chromatic aberration post process,
  65107. */
  65108. private readonly ChromaticAberrationPostProcessId;
  65109. /**
  65110. * ID of the grain post process
  65111. */
  65112. private readonly GrainPostProcessId;
  65113. /**
  65114. * Sharpen post process which will apply a sharpen convolution to enhance edges
  65115. */
  65116. sharpen: SharpenPostProcess;
  65117. private _sharpenEffect;
  65118. private bloom;
  65119. /**
  65120. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  65121. */
  65122. depthOfField: DepthOfFieldEffect;
  65123. /**
  65124. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  65125. */
  65126. fxaa: FxaaPostProcess;
  65127. /**
  65128. * Image post processing pass used to perform operations such as tone mapping or color grading.
  65129. */
  65130. imageProcessing: ImageProcessingPostProcess;
  65131. /**
  65132. * Chromatic aberration post process which will shift rgb colors in the image
  65133. */
  65134. chromaticAberration: ChromaticAberrationPostProcess;
  65135. private _chromaticAberrationEffect;
  65136. /**
  65137. * Grain post process which add noise to the image
  65138. */
  65139. grain: GrainPostProcess;
  65140. private _grainEffect;
  65141. /**
  65142. * Glow post process which adds a glow to emissive areas of the image
  65143. */
  65144. private _glowLayer;
  65145. /**
  65146. * Animations which can be used to tweak settings over a period of time
  65147. */
  65148. animations: Animation[];
  65149. private _imageProcessingConfigurationObserver;
  65150. private _sharpenEnabled;
  65151. private _bloomEnabled;
  65152. private _depthOfFieldEnabled;
  65153. private _depthOfFieldBlurLevel;
  65154. private _fxaaEnabled;
  65155. private _imageProcessingEnabled;
  65156. private _defaultPipelineTextureType;
  65157. private _bloomScale;
  65158. private _chromaticAberrationEnabled;
  65159. private _grainEnabled;
  65160. private _buildAllowed;
  65161. /**
  65162. * Gets active scene
  65163. */
  65164. get scene(): Scene;
  65165. /**
  65166. * Enable or disable the sharpen process from the pipeline
  65167. */
  65168. set sharpenEnabled(enabled: boolean);
  65169. get sharpenEnabled(): boolean;
  65170. private _resizeObserver;
  65171. private _hardwareScaleLevel;
  65172. private _bloomKernel;
  65173. /**
  65174. * Specifies the size of the bloom blur kernel, relative to the final output size
  65175. */
  65176. get bloomKernel(): number;
  65177. set bloomKernel(value: number);
  65178. /**
  65179. * Specifies the weight of the bloom in the final rendering
  65180. */
  65181. private _bloomWeight;
  65182. /**
  65183. * Specifies the luma threshold for the area that will be blurred by the bloom
  65184. */
  65185. private _bloomThreshold;
  65186. private _hdr;
  65187. /**
  65188. * The strength of the bloom.
  65189. */
  65190. set bloomWeight(value: number);
  65191. get bloomWeight(): number;
  65192. /**
  65193. * The strength of the bloom.
  65194. */
  65195. set bloomThreshold(value: number);
  65196. get bloomThreshold(): number;
  65197. /**
  65198. * The scale of the bloom, lower value will provide better performance.
  65199. */
  65200. set bloomScale(value: number);
  65201. get bloomScale(): number;
  65202. /**
  65203. * Enable or disable the bloom from the pipeline
  65204. */
  65205. set bloomEnabled(enabled: boolean);
  65206. get bloomEnabled(): boolean;
  65207. private _rebuildBloom;
  65208. /**
  65209. * If the depth of field is enabled.
  65210. */
  65211. get depthOfFieldEnabled(): boolean;
  65212. set depthOfFieldEnabled(enabled: boolean);
  65213. /**
  65214. * Blur level of the depth of field effect. (Higher blur will effect performance)
  65215. */
  65216. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  65217. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  65218. /**
  65219. * If the anti aliasing is enabled.
  65220. */
  65221. set fxaaEnabled(enabled: boolean);
  65222. get fxaaEnabled(): boolean;
  65223. private _samples;
  65224. /**
  65225. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  65226. */
  65227. set samples(sampleCount: number);
  65228. get samples(): number;
  65229. /**
  65230. * If image processing is enabled.
  65231. */
  65232. set imageProcessingEnabled(enabled: boolean);
  65233. get imageProcessingEnabled(): boolean;
  65234. /**
  65235. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  65236. */
  65237. set glowLayerEnabled(enabled: boolean);
  65238. get glowLayerEnabled(): boolean;
  65239. /**
  65240. * Gets the glow layer (or null if not defined)
  65241. */
  65242. get glowLayer(): Nullable<GlowLayer>;
  65243. /**
  65244. * Enable or disable the chromaticAberration process from the pipeline
  65245. */
  65246. set chromaticAberrationEnabled(enabled: boolean);
  65247. get chromaticAberrationEnabled(): boolean;
  65248. /**
  65249. * Enable or disable the grain process from the pipeline
  65250. */
  65251. set grainEnabled(enabled: boolean);
  65252. get grainEnabled(): boolean;
  65253. /**
  65254. * @constructor
  65255. * @param name - The rendering pipeline name (default: "")
  65256. * @param hdr - If high dynamic range textures should be used (default: true)
  65257. * @param scene - The scene linked to this pipeline (default: the last created scene)
  65258. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  65259. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  65260. */
  65261. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  65262. /**
  65263. * Get the class name
  65264. * @returns "DefaultRenderingPipeline"
  65265. */
  65266. getClassName(): string;
  65267. /**
  65268. * Force the compilation of the entire pipeline.
  65269. */
  65270. prepare(): void;
  65271. private _hasCleared;
  65272. private _prevPostProcess;
  65273. private _prevPrevPostProcess;
  65274. private _setAutoClearAndTextureSharing;
  65275. private _depthOfFieldSceneObserver;
  65276. private _buildPipeline;
  65277. private _disposePostProcesses;
  65278. /**
  65279. * Adds a camera to the pipeline
  65280. * @param camera the camera to be added
  65281. */
  65282. addCamera(camera: Camera): void;
  65283. /**
  65284. * Removes a camera from the pipeline
  65285. * @param camera the camera to remove
  65286. */
  65287. removeCamera(camera: Camera): void;
  65288. /**
  65289. * Dispose of the pipeline and stop all post processes
  65290. */
  65291. dispose(): void;
  65292. /**
  65293. * Serialize the rendering pipeline (Used when exporting)
  65294. * @returns the serialized object
  65295. */
  65296. serialize(): any;
  65297. /**
  65298. * Parse the serialized pipeline
  65299. * @param source Source pipeline.
  65300. * @param scene The scene to load the pipeline to.
  65301. * @param rootUrl The URL of the serialized pipeline.
  65302. * @returns An instantiated pipeline from the serialized object.
  65303. */
  65304. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  65305. }
  65306. }
  65307. declare module BABYLON {
  65308. /** @hidden */
  65309. export var lensHighlightsPixelShader: {
  65310. name: string;
  65311. shader: string;
  65312. };
  65313. }
  65314. declare module BABYLON {
  65315. /** @hidden */
  65316. export var depthOfFieldPixelShader: {
  65317. name: string;
  65318. shader: string;
  65319. };
  65320. }
  65321. declare module BABYLON {
  65322. /**
  65323. * BABYLON.JS Chromatic Aberration GLSL Shader
  65324. * Author: Olivier Guyot
  65325. * Separates very slightly R, G and B colors on the edges of the screen
  65326. * Inspired by Francois Tarlier & Martins Upitis
  65327. */
  65328. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  65329. /**
  65330. * @ignore
  65331. * The chromatic aberration PostProcess id in the pipeline
  65332. */
  65333. LensChromaticAberrationEffect: string;
  65334. /**
  65335. * @ignore
  65336. * The highlights enhancing PostProcess id in the pipeline
  65337. */
  65338. HighlightsEnhancingEffect: string;
  65339. /**
  65340. * @ignore
  65341. * The depth-of-field PostProcess id in the pipeline
  65342. */
  65343. LensDepthOfFieldEffect: string;
  65344. private _scene;
  65345. private _depthTexture;
  65346. private _grainTexture;
  65347. private _chromaticAberrationPostProcess;
  65348. private _highlightsPostProcess;
  65349. private _depthOfFieldPostProcess;
  65350. private _edgeBlur;
  65351. private _grainAmount;
  65352. private _chromaticAberration;
  65353. private _distortion;
  65354. private _highlightsGain;
  65355. private _highlightsThreshold;
  65356. private _dofDistance;
  65357. private _dofAperture;
  65358. private _dofDarken;
  65359. private _dofPentagon;
  65360. private _blurNoise;
  65361. /**
  65362. * @constructor
  65363. *
  65364. * Effect parameters are as follow:
  65365. * {
  65366. * chromatic_aberration: number; // from 0 to x (1 for realism)
  65367. * edge_blur: number; // from 0 to x (1 for realism)
  65368. * distortion: number; // from 0 to x (1 for realism)
  65369. * grain_amount: number; // from 0 to 1
  65370. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  65371. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  65372. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  65373. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  65374. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  65375. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  65376. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  65377. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  65378. * }
  65379. * Note: if an effect parameter is unset, effect is disabled
  65380. *
  65381. * @param name The rendering pipeline name
  65382. * @param parameters - An object containing all parameters (see above)
  65383. * @param scene The scene linked to this pipeline
  65384. * @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)
  65385. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65386. */
  65387. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  65388. /**
  65389. * Get the class name
  65390. * @returns "LensRenderingPipeline"
  65391. */
  65392. getClassName(): string;
  65393. /**
  65394. * Gets associated scene
  65395. */
  65396. get scene(): Scene;
  65397. /**
  65398. * Gets or sets the edge blur
  65399. */
  65400. get edgeBlur(): number;
  65401. set edgeBlur(value: number);
  65402. /**
  65403. * Gets or sets the grain amount
  65404. */
  65405. get grainAmount(): number;
  65406. set grainAmount(value: number);
  65407. /**
  65408. * Gets or sets the chromatic aberration amount
  65409. */
  65410. get chromaticAberration(): number;
  65411. set chromaticAberration(value: number);
  65412. /**
  65413. * Gets or sets the depth of field aperture
  65414. */
  65415. get dofAperture(): number;
  65416. set dofAperture(value: number);
  65417. /**
  65418. * Gets or sets the edge distortion
  65419. */
  65420. get edgeDistortion(): number;
  65421. set edgeDistortion(value: number);
  65422. /**
  65423. * Gets or sets the depth of field distortion
  65424. */
  65425. get dofDistortion(): number;
  65426. set dofDistortion(value: number);
  65427. /**
  65428. * Gets or sets the darken out of focus amount
  65429. */
  65430. get darkenOutOfFocus(): number;
  65431. set darkenOutOfFocus(value: number);
  65432. /**
  65433. * Gets or sets a boolean indicating if blur noise is enabled
  65434. */
  65435. get blurNoise(): boolean;
  65436. set blurNoise(value: boolean);
  65437. /**
  65438. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  65439. */
  65440. get pentagonBokeh(): boolean;
  65441. set pentagonBokeh(value: boolean);
  65442. /**
  65443. * Gets or sets the highlight grain amount
  65444. */
  65445. get highlightsGain(): number;
  65446. set highlightsGain(value: number);
  65447. /**
  65448. * Gets or sets the highlight threshold
  65449. */
  65450. get highlightsThreshold(): number;
  65451. set highlightsThreshold(value: number);
  65452. /**
  65453. * Sets the amount of blur at the edges
  65454. * @param amount blur amount
  65455. */
  65456. setEdgeBlur(amount: number): void;
  65457. /**
  65458. * Sets edge blur to 0
  65459. */
  65460. disableEdgeBlur(): void;
  65461. /**
  65462. * Sets the amout of grain
  65463. * @param amount Amount of grain
  65464. */
  65465. setGrainAmount(amount: number): void;
  65466. /**
  65467. * Set grain amount to 0
  65468. */
  65469. disableGrain(): void;
  65470. /**
  65471. * Sets the chromatic aberration amount
  65472. * @param amount amount of chromatic aberration
  65473. */
  65474. setChromaticAberration(amount: number): void;
  65475. /**
  65476. * Sets chromatic aberration amount to 0
  65477. */
  65478. disableChromaticAberration(): void;
  65479. /**
  65480. * Sets the EdgeDistortion amount
  65481. * @param amount amount of EdgeDistortion
  65482. */
  65483. setEdgeDistortion(amount: number): void;
  65484. /**
  65485. * Sets edge distortion to 0
  65486. */
  65487. disableEdgeDistortion(): void;
  65488. /**
  65489. * Sets the FocusDistance amount
  65490. * @param amount amount of FocusDistance
  65491. */
  65492. setFocusDistance(amount: number): void;
  65493. /**
  65494. * Disables depth of field
  65495. */
  65496. disableDepthOfField(): void;
  65497. /**
  65498. * Sets the Aperture amount
  65499. * @param amount amount of Aperture
  65500. */
  65501. setAperture(amount: number): void;
  65502. /**
  65503. * Sets the DarkenOutOfFocus amount
  65504. * @param amount amount of DarkenOutOfFocus
  65505. */
  65506. setDarkenOutOfFocus(amount: number): void;
  65507. private _pentagonBokehIsEnabled;
  65508. /**
  65509. * Creates a pentagon bokeh effect
  65510. */
  65511. enablePentagonBokeh(): void;
  65512. /**
  65513. * Disables the pentagon bokeh effect
  65514. */
  65515. disablePentagonBokeh(): void;
  65516. /**
  65517. * Enables noise blur
  65518. */
  65519. enableNoiseBlur(): void;
  65520. /**
  65521. * Disables noise blur
  65522. */
  65523. disableNoiseBlur(): void;
  65524. /**
  65525. * Sets the HighlightsGain amount
  65526. * @param amount amount of HighlightsGain
  65527. */
  65528. setHighlightsGain(amount: number): void;
  65529. /**
  65530. * Sets the HighlightsThreshold amount
  65531. * @param amount amount of HighlightsThreshold
  65532. */
  65533. setHighlightsThreshold(amount: number): void;
  65534. /**
  65535. * Disables highlights
  65536. */
  65537. disableHighlights(): void;
  65538. /**
  65539. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  65540. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  65541. */
  65542. dispose(disableDepthRender?: boolean): void;
  65543. private _createChromaticAberrationPostProcess;
  65544. private _createHighlightsPostProcess;
  65545. private _createDepthOfFieldPostProcess;
  65546. private _createGrainTexture;
  65547. }
  65548. }
  65549. declare module BABYLON {
  65550. /** @hidden */
  65551. export var ssao2PixelShader: {
  65552. name: string;
  65553. shader: string;
  65554. };
  65555. }
  65556. declare module BABYLON {
  65557. /** @hidden */
  65558. export var ssaoCombinePixelShader: {
  65559. name: string;
  65560. shader: string;
  65561. };
  65562. }
  65563. declare module BABYLON {
  65564. /**
  65565. * Render pipeline to produce ssao effect
  65566. */
  65567. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  65568. /**
  65569. * @ignore
  65570. * The PassPostProcess id in the pipeline that contains the original scene color
  65571. */
  65572. SSAOOriginalSceneColorEffect: string;
  65573. /**
  65574. * @ignore
  65575. * The SSAO PostProcess id in the pipeline
  65576. */
  65577. SSAORenderEffect: string;
  65578. /**
  65579. * @ignore
  65580. * The horizontal blur PostProcess id in the pipeline
  65581. */
  65582. SSAOBlurHRenderEffect: string;
  65583. /**
  65584. * @ignore
  65585. * The vertical blur PostProcess id in the pipeline
  65586. */
  65587. SSAOBlurVRenderEffect: string;
  65588. /**
  65589. * @ignore
  65590. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65591. */
  65592. SSAOCombineRenderEffect: string;
  65593. /**
  65594. * The output strength of the SSAO post-process. Default value is 1.0.
  65595. */
  65596. totalStrength: number;
  65597. /**
  65598. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  65599. */
  65600. maxZ: number;
  65601. /**
  65602. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  65603. */
  65604. minZAspect: number;
  65605. private _samples;
  65606. /**
  65607. * Number of samples used for the SSAO calculations. Default value is 8
  65608. */
  65609. set samples(n: number);
  65610. get samples(): number;
  65611. private _textureSamples;
  65612. /**
  65613. * Number of samples to use for antialiasing
  65614. */
  65615. set textureSamples(n: number);
  65616. get textureSamples(): number;
  65617. /**
  65618. * Ratio object used for SSAO ratio and blur ratio
  65619. */
  65620. private _ratio;
  65621. /**
  65622. * Dynamically generated sphere sampler.
  65623. */
  65624. private _sampleSphere;
  65625. /**
  65626. * Blur filter offsets
  65627. */
  65628. private _samplerOffsets;
  65629. private _expensiveBlur;
  65630. /**
  65631. * If bilateral blur should be used
  65632. */
  65633. set expensiveBlur(b: boolean);
  65634. get expensiveBlur(): boolean;
  65635. /**
  65636. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  65637. */
  65638. radius: number;
  65639. /**
  65640. * The base color of the SSAO post-process
  65641. * The final result is "base + ssao" between [0, 1]
  65642. */
  65643. base: number;
  65644. /**
  65645. * Support test.
  65646. */
  65647. static get IsSupported(): boolean;
  65648. private _scene;
  65649. private _depthTexture;
  65650. private _normalTexture;
  65651. private _randomTexture;
  65652. private _originalColorPostProcess;
  65653. private _ssaoPostProcess;
  65654. private _blurHPostProcess;
  65655. private _blurVPostProcess;
  65656. private _ssaoCombinePostProcess;
  65657. /**
  65658. * Gets active scene
  65659. */
  65660. get scene(): Scene;
  65661. /**
  65662. * @constructor
  65663. * @param name The rendering pipeline name
  65664. * @param scene The scene linked to this pipeline
  65665. * @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 }
  65666. * @param cameras The array of cameras that the rendering pipeline will be attached to
  65667. */
  65668. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  65669. /**
  65670. * Get the class name
  65671. * @returns "SSAO2RenderingPipeline"
  65672. */
  65673. getClassName(): string;
  65674. /**
  65675. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  65676. */
  65677. dispose(disableGeometryBufferRenderer?: boolean): void;
  65678. private _createBlurPostProcess;
  65679. /** @hidden */
  65680. _rebuild(): void;
  65681. private _bits;
  65682. private _radicalInverse_VdC;
  65683. private _hammersley;
  65684. private _hemisphereSample_uniform;
  65685. private _generateHemisphere;
  65686. private _createSSAOPostProcess;
  65687. private _createSSAOCombinePostProcess;
  65688. private _createRandomTexture;
  65689. /**
  65690. * Serialize the rendering pipeline (Used when exporting)
  65691. * @returns the serialized object
  65692. */
  65693. serialize(): any;
  65694. /**
  65695. * Parse the serialized pipeline
  65696. * @param source Source pipeline.
  65697. * @param scene The scene to load the pipeline to.
  65698. * @param rootUrl The URL of the serialized pipeline.
  65699. * @returns An instantiated pipeline from the serialized object.
  65700. */
  65701. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  65702. }
  65703. }
  65704. declare module BABYLON {
  65705. /** @hidden */
  65706. export var ssaoPixelShader: {
  65707. name: string;
  65708. shader: string;
  65709. };
  65710. }
  65711. declare module BABYLON {
  65712. /**
  65713. * Render pipeline to produce ssao effect
  65714. */
  65715. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  65716. /**
  65717. * @ignore
  65718. * The PassPostProcess id in the pipeline that contains the original scene color
  65719. */
  65720. SSAOOriginalSceneColorEffect: string;
  65721. /**
  65722. * @ignore
  65723. * The SSAO PostProcess id in the pipeline
  65724. */
  65725. SSAORenderEffect: string;
  65726. /**
  65727. * @ignore
  65728. * The horizontal blur PostProcess id in the pipeline
  65729. */
  65730. SSAOBlurHRenderEffect: string;
  65731. /**
  65732. * @ignore
  65733. * The vertical blur PostProcess id in the pipeline
  65734. */
  65735. SSAOBlurVRenderEffect: string;
  65736. /**
  65737. * @ignore
  65738. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  65739. */
  65740. SSAOCombineRenderEffect: string;
  65741. /**
  65742. * The output strength of the SSAO post-process. Default value is 1.0.
  65743. */
  65744. totalStrength: number;
  65745. /**
  65746. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  65747. */
  65748. radius: number;
  65749. /**
  65750. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  65751. * Must not be equal to fallOff and superior to fallOff.
  65752. * Default value is 0.0075
  65753. */
  65754. area: number;
  65755. /**
  65756. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  65757. * Must not be equal to area and inferior to area.
  65758. * Default value is 0.000001
  65759. */
  65760. fallOff: number;
  65761. /**
  65762. * The base color of the SSAO post-process
  65763. * The final result is "base + ssao" between [0, 1]
  65764. */
  65765. base: number;
  65766. private _scene;
  65767. private _depthTexture;
  65768. private _randomTexture;
  65769. private _originalColorPostProcess;
  65770. private _ssaoPostProcess;
  65771. private _blurHPostProcess;
  65772. private _blurVPostProcess;
  65773. private _ssaoCombinePostProcess;
  65774. private _firstUpdate;
  65775. /**
  65776. * Gets active scene
  65777. */
  65778. get scene(): Scene;
  65779. /**
  65780. * @constructor
  65781. * @param name - The rendering pipeline name
  65782. * @param scene - The scene linked to this pipeline
  65783. * @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 }
  65784. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  65785. */
  65786. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  65787. /**
  65788. * Get the class name
  65789. * @returns "SSAORenderingPipeline"
  65790. */
  65791. getClassName(): string;
  65792. /**
  65793. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  65794. */
  65795. dispose(disableDepthRender?: boolean): void;
  65796. private _createBlurPostProcess;
  65797. /** @hidden */
  65798. _rebuild(): void;
  65799. private _createSSAOPostProcess;
  65800. private _createSSAOCombinePostProcess;
  65801. private _createRandomTexture;
  65802. }
  65803. }
  65804. declare module BABYLON {
  65805. /** @hidden */
  65806. export var screenSpaceReflectionPixelShader: {
  65807. name: string;
  65808. shader: string;
  65809. };
  65810. }
  65811. declare module BABYLON {
  65812. /**
  65813. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  65814. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  65815. */
  65816. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  65817. /**
  65818. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  65819. */
  65820. threshold: number;
  65821. /**
  65822. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  65823. */
  65824. strength: number;
  65825. /**
  65826. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  65827. */
  65828. reflectionSpecularFalloffExponent: number;
  65829. /**
  65830. * Gets or sets the step size used to iterate until the effect finds the color of the reflection's pixel. Typically in interval [0.1, 1.0]
  65831. */
  65832. step: number;
  65833. /**
  65834. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  65835. */
  65836. roughnessFactor: number;
  65837. private _geometryBufferRenderer;
  65838. private _enableSmoothReflections;
  65839. private _reflectionSamples;
  65840. private _smoothSteps;
  65841. /**
  65842. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  65843. * @param name The name of the effect.
  65844. * @param scene The scene containing the objects to calculate reflections.
  65845. * @param options The required width/height ratio to downsize to before computing the render pass.
  65846. * @param camera The camera to apply the render pass to.
  65847. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  65848. * @param engine The engine which the post process will be applied. (default: current engine)
  65849. * @param reusable If the post process can be reused on the same frame. (default: false)
  65850. * @param textureType Type of textures used when performing the post process. (default: 0)
  65851. * @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)
  65852. */
  65853. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  65854. /**
  65855. * Gets wether or not smoothing reflections is enabled.
  65856. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  65857. */
  65858. get enableSmoothReflections(): boolean;
  65859. /**
  65860. * Sets wether or not smoothing reflections is enabled.
  65861. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  65862. */
  65863. set enableSmoothReflections(enabled: boolean);
  65864. /**
  65865. * Gets the number of samples taken while computing reflections. More samples count is high,
  65866. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  65867. */
  65868. get reflectionSamples(): number;
  65869. /**
  65870. * Sets the number of samples taken while computing reflections. More samples count is high,
  65871. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  65872. */
  65873. set reflectionSamples(samples: number);
  65874. /**
  65875. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  65876. * more the post-process will require GPU power and can generate a drop in FPS.
  65877. * Default value (5.0) work pretty well in all cases but can be adjusted.
  65878. */
  65879. get smoothSteps(): number;
  65880. set smoothSteps(steps: number);
  65881. private _updateEffectDefines;
  65882. }
  65883. }
  65884. declare module BABYLON {
  65885. /** @hidden */
  65886. export var standardPixelShader: {
  65887. name: string;
  65888. shader: string;
  65889. };
  65890. }
  65891. declare module BABYLON {
  65892. /**
  65893. * Standard rendering pipeline
  65894. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  65895. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  65896. */
  65897. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  65898. /**
  65899. * Public members
  65900. */
  65901. /**
  65902. * Post-process which contains the original scene color before the pipeline applies all the effects
  65903. */
  65904. originalPostProcess: Nullable<PostProcess>;
  65905. /**
  65906. * Post-process used to down scale an image x4
  65907. */
  65908. downSampleX4PostProcess: Nullable<PostProcess>;
  65909. /**
  65910. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  65911. */
  65912. brightPassPostProcess: Nullable<PostProcess>;
  65913. /**
  65914. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  65915. */
  65916. blurHPostProcesses: PostProcess[];
  65917. /**
  65918. * Post-process array storing all the vertical blur post-processes used by the pipeline
  65919. */
  65920. blurVPostProcesses: PostProcess[];
  65921. /**
  65922. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  65923. */
  65924. textureAdderPostProcess: Nullable<PostProcess>;
  65925. /**
  65926. * Post-process used to create volumetric lighting effect
  65927. */
  65928. volumetricLightPostProcess: Nullable<PostProcess>;
  65929. /**
  65930. * Post-process used to smooth the previous volumetric light post-process on the X axis
  65931. */
  65932. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  65933. /**
  65934. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  65935. */
  65936. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  65937. /**
  65938. * Post-process used to merge the volumetric light effect and the real scene color
  65939. */
  65940. volumetricLightMergePostProces: Nullable<PostProcess>;
  65941. /**
  65942. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  65943. */
  65944. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  65945. /**
  65946. * Base post-process used to calculate the average luminance of the final image for HDR
  65947. */
  65948. luminancePostProcess: Nullable<PostProcess>;
  65949. /**
  65950. * Post-processes used to create down sample post-processes in order to get
  65951. * the average luminance of the final image for HDR
  65952. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  65953. */
  65954. luminanceDownSamplePostProcesses: PostProcess[];
  65955. /**
  65956. * Post-process used to create a HDR effect (light adaptation)
  65957. */
  65958. hdrPostProcess: Nullable<PostProcess>;
  65959. /**
  65960. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  65961. */
  65962. textureAdderFinalPostProcess: Nullable<PostProcess>;
  65963. /**
  65964. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  65965. */
  65966. lensFlareFinalPostProcess: Nullable<PostProcess>;
  65967. /**
  65968. * Post-process used to merge the final HDR post-process and the real scene color
  65969. */
  65970. hdrFinalPostProcess: Nullable<PostProcess>;
  65971. /**
  65972. * Post-process used to create a lens flare effect
  65973. */
  65974. lensFlarePostProcess: Nullable<PostProcess>;
  65975. /**
  65976. * Post-process that merges the result of the lens flare post-process and the real scene color
  65977. */
  65978. lensFlareComposePostProcess: Nullable<PostProcess>;
  65979. /**
  65980. * Post-process used to create a motion blur effect
  65981. */
  65982. motionBlurPostProcess: Nullable<PostProcess>;
  65983. /**
  65984. * Post-process used to create a depth of field effect
  65985. */
  65986. depthOfFieldPostProcess: Nullable<PostProcess>;
  65987. /**
  65988. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  65989. */
  65990. fxaaPostProcess: Nullable<FxaaPostProcess>;
  65991. /**
  65992. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  65993. */
  65994. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  65995. /**
  65996. * Represents the brightness threshold in order to configure the illuminated surfaces
  65997. */
  65998. brightThreshold: number;
  65999. /**
  66000. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  66001. */
  66002. blurWidth: number;
  66003. /**
  66004. * Sets if the blur for highlighted surfaces must be only horizontal
  66005. */
  66006. horizontalBlur: boolean;
  66007. /**
  66008. * Gets the overall exposure used by the pipeline
  66009. */
  66010. get exposure(): number;
  66011. /**
  66012. * Sets the overall exposure used by the pipeline
  66013. */
  66014. set exposure(value: number);
  66015. /**
  66016. * Texture used typically to simulate "dirty" on camera lens
  66017. */
  66018. lensTexture: Nullable<Texture>;
  66019. /**
  66020. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  66021. */
  66022. volumetricLightCoefficient: number;
  66023. /**
  66024. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  66025. */
  66026. volumetricLightPower: number;
  66027. /**
  66028. * Used the set the blur intensity to smooth the volumetric lights
  66029. */
  66030. volumetricLightBlurScale: number;
  66031. /**
  66032. * Light (spot or directional) used to generate the volumetric lights rays
  66033. * The source light must have a shadow generate so the pipeline can get its
  66034. * depth map
  66035. */
  66036. sourceLight: Nullable<SpotLight | DirectionalLight>;
  66037. /**
  66038. * For eye adaptation, represents the minimum luminance the eye can see
  66039. */
  66040. hdrMinimumLuminance: number;
  66041. /**
  66042. * For eye adaptation, represents the decrease luminance speed
  66043. */
  66044. hdrDecreaseRate: number;
  66045. /**
  66046. * For eye adaptation, represents the increase luminance speed
  66047. */
  66048. hdrIncreaseRate: number;
  66049. /**
  66050. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66051. */
  66052. get hdrAutoExposure(): boolean;
  66053. /**
  66054. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  66055. */
  66056. set hdrAutoExposure(value: boolean);
  66057. /**
  66058. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  66059. */
  66060. lensColorTexture: Nullable<Texture>;
  66061. /**
  66062. * The overall strengh for the lens flare effect
  66063. */
  66064. lensFlareStrength: number;
  66065. /**
  66066. * Dispersion coefficient for lens flare ghosts
  66067. */
  66068. lensFlareGhostDispersal: number;
  66069. /**
  66070. * Main lens flare halo width
  66071. */
  66072. lensFlareHaloWidth: number;
  66073. /**
  66074. * Based on the lens distortion effect, defines how much the lens flare result
  66075. * is distorted
  66076. */
  66077. lensFlareDistortionStrength: number;
  66078. /**
  66079. * Configures the blur intensity used for for lens flare (halo)
  66080. */
  66081. lensFlareBlurWidth: number;
  66082. /**
  66083. * Lens star texture must be used to simulate rays on the flares and is available
  66084. * in the documentation
  66085. */
  66086. lensStarTexture: Nullable<Texture>;
  66087. /**
  66088. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  66089. * flare effect by taking account of the dirt texture
  66090. */
  66091. lensFlareDirtTexture: Nullable<Texture>;
  66092. /**
  66093. * Represents the focal length for the depth of field effect
  66094. */
  66095. depthOfFieldDistance: number;
  66096. /**
  66097. * Represents the blur intensity for the blurred part of the depth of field effect
  66098. */
  66099. depthOfFieldBlurWidth: number;
  66100. /**
  66101. * Gets how much the image is blurred by the movement while using the motion blur post-process
  66102. */
  66103. get motionStrength(): number;
  66104. /**
  66105. * Sets how much the image is blurred by the movement while using the motion blur post-process
  66106. */
  66107. set motionStrength(strength: number);
  66108. /**
  66109. * Gets wether or not the motion blur post-process is object based or screen based.
  66110. */
  66111. get objectBasedMotionBlur(): boolean;
  66112. /**
  66113. * Sets wether or not the motion blur post-process should be object based or screen based
  66114. */
  66115. set objectBasedMotionBlur(value: boolean);
  66116. /**
  66117. * List of animations for the pipeline (IAnimatable implementation)
  66118. */
  66119. animations: Animation[];
  66120. /**
  66121. * Private members
  66122. */
  66123. private _scene;
  66124. private _currentDepthOfFieldSource;
  66125. private _basePostProcess;
  66126. private _fixedExposure;
  66127. private _currentExposure;
  66128. private _hdrAutoExposure;
  66129. private _hdrCurrentLuminance;
  66130. private _motionStrength;
  66131. private _isObjectBasedMotionBlur;
  66132. private _floatTextureType;
  66133. private _camerasToBeAttached;
  66134. private _ratio;
  66135. private _bloomEnabled;
  66136. private _depthOfFieldEnabled;
  66137. private _vlsEnabled;
  66138. private _lensFlareEnabled;
  66139. private _hdrEnabled;
  66140. private _motionBlurEnabled;
  66141. private _fxaaEnabled;
  66142. private _screenSpaceReflectionsEnabled;
  66143. private _motionBlurSamples;
  66144. private _volumetricLightStepsCount;
  66145. private _samples;
  66146. /**
  66147. * @ignore
  66148. * Specifies if the bloom pipeline is enabled
  66149. */
  66150. get BloomEnabled(): boolean;
  66151. set BloomEnabled(enabled: boolean);
  66152. /**
  66153. * @ignore
  66154. * Specifies if the depth of field pipeline is enabed
  66155. */
  66156. get DepthOfFieldEnabled(): boolean;
  66157. set DepthOfFieldEnabled(enabled: boolean);
  66158. /**
  66159. * @ignore
  66160. * Specifies if the lens flare pipeline is enabed
  66161. */
  66162. get LensFlareEnabled(): boolean;
  66163. set LensFlareEnabled(enabled: boolean);
  66164. /**
  66165. * @ignore
  66166. * Specifies if the HDR pipeline is enabled
  66167. */
  66168. get HDREnabled(): boolean;
  66169. set HDREnabled(enabled: boolean);
  66170. /**
  66171. * @ignore
  66172. * Specifies if the volumetric lights scattering effect is enabled
  66173. */
  66174. get VLSEnabled(): boolean;
  66175. set VLSEnabled(enabled: boolean);
  66176. /**
  66177. * @ignore
  66178. * Specifies if the motion blur effect is enabled
  66179. */
  66180. get MotionBlurEnabled(): boolean;
  66181. set MotionBlurEnabled(enabled: boolean);
  66182. /**
  66183. * Specifies if anti-aliasing is enabled
  66184. */
  66185. get fxaaEnabled(): boolean;
  66186. set fxaaEnabled(enabled: boolean);
  66187. /**
  66188. * Specifies if screen space reflections are enabled.
  66189. */
  66190. get screenSpaceReflectionsEnabled(): boolean;
  66191. set screenSpaceReflectionsEnabled(enabled: boolean);
  66192. /**
  66193. * Specifies the number of steps used to calculate the volumetric lights
  66194. * Typically in interval [50, 200]
  66195. */
  66196. get volumetricLightStepsCount(): number;
  66197. set volumetricLightStepsCount(count: number);
  66198. /**
  66199. * Specifies the number of samples used for the motion blur effect
  66200. * Typically in interval [16, 64]
  66201. */
  66202. get motionBlurSamples(): number;
  66203. set motionBlurSamples(samples: number);
  66204. /**
  66205. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  66206. */
  66207. get samples(): number;
  66208. set samples(sampleCount: number);
  66209. /**
  66210. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  66211. * @constructor
  66212. * @param name The rendering pipeline name
  66213. * @param scene The scene linked to this pipeline
  66214. * @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)
  66215. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  66216. * @param cameras The array of cameras that the rendering pipeline will be attached to
  66217. */
  66218. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  66219. private _buildPipeline;
  66220. private _createDownSampleX4PostProcess;
  66221. private _createBrightPassPostProcess;
  66222. private _createBlurPostProcesses;
  66223. private _createTextureAdderPostProcess;
  66224. private _createVolumetricLightPostProcess;
  66225. private _createLuminancePostProcesses;
  66226. private _createHdrPostProcess;
  66227. private _createLensFlarePostProcess;
  66228. private _createDepthOfFieldPostProcess;
  66229. private _createMotionBlurPostProcess;
  66230. private _getDepthTexture;
  66231. private _disposePostProcesses;
  66232. /**
  66233. * Dispose of the pipeline and stop all post processes
  66234. */
  66235. dispose(): void;
  66236. /**
  66237. * Serialize the rendering pipeline (Used when exporting)
  66238. * @returns the serialized object
  66239. */
  66240. serialize(): any;
  66241. /**
  66242. * Parse the serialized pipeline
  66243. * @param source Source pipeline.
  66244. * @param scene The scene to load the pipeline to.
  66245. * @param rootUrl The URL of the serialized pipeline.
  66246. * @returns An instantiated pipeline from the serialized object.
  66247. */
  66248. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  66249. /**
  66250. * Luminance steps
  66251. */
  66252. static LuminanceSteps: number;
  66253. }
  66254. }
  66255. declare module BABYLON {
  66256. /** @hidden */
  66257. export var tonemapPixelShader: {
  66258. name: string;
  66259. shader: string;
  66260. };
  66261. }
  66262. declare module BABYLON {
  66263. /** Defines operator used for tonemapping */
  66264. export enum TonemappingOperator {
  66265. /** Hable */
  66266. Hable = 0,
  66267. /** Reinhard */
  66268. Reinhard = 1,
  66269. /** HejiDawson */
  66270. HejiDawson = 2,
  66271. /** Photographic */
  66272. Photographic = 3
  66273. }
  66274. /**
  66275. * Defines a post process to apply tone mapping
  66276. */
  66277. export class TonemapPostProcess extends PostProcess {
  66278. private _operator;
  66279. /** Defines the required exposure adjustement */
  66280. exposureAdjustment: number;
  66281. /**
  66282. * Creates a new TonemapPostProcess
  66283. * @param name defines the name of the postprocess
  66284. * @param _operator defines the operator to use
  66285. * @param exposureAdjustment defines the required exposure adjustement
  66286. * @param camera defines the camera to use (can be null)
  66287. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  66288. * @param engine defines the hosting engine (can be ignore if camera is set)
  66289. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  66290. */
  66291. constructor(name: string, _operator: TonemappingOperator,
  66292. /** Defines the required exposure adjustement */
  66293. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  66294. }
  66295. }
  66296. declare module BABYLON {
  66297. /** @hidden */
  66298. export var volumetricLightScatteringPixelShader: {
  66299. name: string;
  66300. shader: string;
  66301. };
  66302. }
  66303. declare module BABYLON {
  66304. /** @hidden */
  66305. export var volumetricLightScatteringPassVertexShader: {
  66306. name: string;
  66307. shader: string;
  66308. };
  66309. }
  66310. declare module BABYLON {
  66311. /** @hidden */
  66312. export var volumetricLightScatteringPassPixelShader: {
  66313. name: string;
  66314. shader: string;
  66315. };
  66316. }
  66317. declare module BABYLON {
  66318. /**
  66319. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  66320. */
  66321. export class VolumetricLightScatteringPostProcess extends PostProcess {
  66322. private _volumetricLightScatteringPass;
  66323. private _volumetricLightScatteringRTT;
  66324. private _viewPort;
  66325. private _screenCoordinates;
  66326. private _cachedDefines;
  66327. /**
  66328. * If not undefined, the mesh position is computed from the attached node position
  66329. */
  66330. attachedNode: {
  66331. position: Vector3;
  66332. };
  66333. /**
  66334. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  66335. */
  66336. customMeshPosition: Vector3;
  66337. /**
  66338. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  66339. */
  66340. useCustomMeshPosition: boolean;
  66341. /**
  66342. * If the post-process should inverse the light scattering direction
  66343. */
  66344. invert: boolean;
  66345. /**
  66346. * The internal mesh used by the post-process
  66347. */
  66348. mesh: Mesh;
  66349. /**
  66350. * @hidden
  66351. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  66352. */
  66353. get useDiffuseColor(): boolean;
  66354. set useDiffuseColor(useDiffuseColor: boolean);
  66355. /**
  66356. * Array containing the excluded meshes not rendered in the internal pass
  66357. */
  66358. excludedMeshes: AbstractMesh[];
  66359. /**
  66360. * Controls the overall intensity of the post-process
  66361. */
  66362. exposure: number;
  66363. /**
  66364. * Dissipates each sample's contribution in range [0, 1]
  66365. */
  66366. decay: number;
  66367. /**
  66368. * Controls the overall intensity of each sample
  66369. */
  66370. weight: number;
  66371. /**
  66372. * Controls the density of each sample
  66373. */
  66374. density: number;
  66375. /**
  66376. * @constructor
  66377. * @param name The post-process name
  66378. * @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)
  66379. * @param camera The camera that the post-process will be attached to
  66380. * @param mesh The mesh used to create the light scattering
  66381. * @param samples The post-process quality, default 100
  66382. * @param samplingModeThe post-process filtering mode
  66383. * @param engine The babylon engine
  66384. * @param reusable If the post-process is reusable
  66385. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  66386. */
  66387. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  66388. /**
  66389. * Returns the string "VolumetricLightScatteringPostProcess"
  66390. * @returns "VolumetricLightScatteringPostProcess"
  66391. */
  66392. getClassName(): string;
  66393. private _isReady;
  66394. /**
  66395. * Sets the new light position for light scattering effect
  66396. * @param position The new custom light position
  66397. */
  66398. setCustomMeshPosition(position: Vector3): void;
  66399. /**
  66400. * Returns the light position for light scattering effect
  66401. * @return Vector3 The custom light position
  66402. */
  66403. getCustomMeshPosition(): Vector3;
  66404. /**
  66405. * Disposes the internal assets and detaches the post-process from the camera
  66406. */
  66407. dispose(camera: Camera): void;
  66408. /**
  66409. * Returns the render target texture used by the post-process
  66410. * @return the render target texture used by the post-process
  66411. */
  66412. getPass(): RenderTargetTexture;
  66413. private _meshExcluded;
  66414. private _createPass;
  66415. private _updateMeshScreenCoordinates;
  66416. /**
  66417. * Creates a default mesh for the Volumeric Light Scattering post-process
  66418. * @param name The mesh name
  66419. * @param scene The scene where to create the mesh
  66420. * @return the default mesh
  66421. */
  66422. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  66423. }
  66424. }
  66425. declare module BABYLON {
  66426. interface Scene {
  66427. /** @hidden (Backing field) */
  66428. _boundingBoxRenderer: BoundingBoxRenderer;
  66429. /** @hidden (Backing field) */
  66430. _forceShowBoundingBoxes: boolean;
  66431. /**
  66432. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  66433. */
  66434. forceShowBoundingBoxes: boolean;
  66435. /**
  66436. * Gets the bounding box renderer associated with the scene
  66437. * @returns a BoundingBoxRenderer
  66438. */
  66439. getBoundingBoxRenderer(): BoundingBoxRenderer;
  66440. }
  66441. interface AbstractMesh {
  66442. /** @hidden (Backing field) */
  66443. _showBoundingBox: boolean;
  66444. /**
  66445. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  66446. */
  66447. showBoundingBox: boolean;
  66448. }
  66449. /**
  66450. * Component responsible of rendering the bounding box of the meshes in a scene.
  66451. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  66452. */
  66453. export class BoundingBoxRenderer implements ISceneComponent {
  66454. /**
  66455. * The component name helpfull to identify the component in the list of scene components.
  66456. */
  66457. readonly name: string;
  66458. /**
  66459. * The scene the component belongs to.
  66460. */
  66461. scene: Scene;
  66462. /**
  66463. * Color of the bounding box lines placed in front of an object
  66464. */
  66465. frontColor: Color3;
  66466. /**
  66467. * Color of the bounding box lines placed behind an object
  66468. */
  66469. backColor: Color3;
  66470. /**
  66471. * Defines if the renderer should show the back lines or not
  66472. */
  66473. showBackLines: boolean;
  66474. /**
  66475. * @hidden
  66476. */
  66477. renderList: SmartArray<BoundingBox>;
  66478. private _colorShader;
  66479. private _vertexBuffers;
  66480. private _indexBuffer;
  66481. private _fillIndexBuffer;
  66482. private _fillIndexData;
  66483. /**
  66484. * Instantiates a new bounding box renderer in a scene.
  66485. * @param scene the scene the renderer renders in
  66486. */
  66487. constructor(scene: Scene);
  66488. /**
  66489. * Registers the component in a given scene
  66490. */
  66491. register(): void;
  66492. private _evaluateSubMesh;
  66493. private _activeMesh;
  66494. private _prepareRessources;
  66495. private _createIndexBuffer;
  66496. /**
  66497. * Rebuilds the elements related to this component in case of
  66498. * context lost for instance.
  66499. */
  66500. rebuild(): void;
  66501. /**
  66502. * @hidden
  66503. */
  66504. reset(): void;
  66505. /**
  66506. * Render the bounding boxes of a specific rendering group
  66507. * @param renderingGroupId defines the rendering group to render
  66508. */
  66509. render(renderingGroupId: number): void;
  66510. /**
  66511. * In case of occlusion queries, we can render the occlusion bounding box through this method
  66512. * @param mesh Define the mesh to render the occlusion bounding box for
  66513. */
  66514. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  66515. /**
  66516. * Dispose and release the resources attached to this renderer.
  66517. */
  66518. dispose(): void;
  66519. }
  66520. }
  66521. declare module BABYLON {
  66522. interface Scene {
  66523. /** @hidden (Backing field) */
  66524. _depthRenderer: {
  66525. [id: string]: DepthRenderer;
  66526. };
  66527. /**
  66528. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  66529. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  66530. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  66531. * @returns the created depth renderer
  66532. */
  66533. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  66534. /**
  66535. * Disables a depth renderer for a given camera
  66536. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  66537. */
  66538. disableDepthRenderer(camera?: Nullable<Camera>): void;
  66539. }
  66540. /**
  66541. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  66542. * in several rendering techniques.
  66543. */
  66544. export class DepthRendererSceneComponent implements ISceneComponent {
  66545. /**
  66546. * The component name helpfull to identify the component in the list of scene components.
  66547. */
  66548. readonly name: string;
  66549. /**
  66550. * The scene the component belongs to.
  66551. */
  66552. scene: Scene;
  66553. /**
  66554. * Creates a new instance of the component for the given scene
  66555. * @param scene Defines the scene to register the component in
  66556. */
  66557. constructor(scene: Scene);
  66558. /**
  66559. * Registers the component in a given scene
  66560. */
  66561. register(): void;
  66562. /**
  66563. * Rebuilds the elements related to this component in case of
  66564. * context lost for instance.
  66565. */
  66566. rebuild(): void;
  66567. /**
  66568. * Disposes the component and the associated ressources
  66569. */
  66570. dispose(): void;
  66571. private _gatherRenderTargets;
  66572. private _gatherActiveCameraRenderTargets;
  66573. }
  66574. }
  66575. declare module BABYLON {
  66576. /** @hidden */
  66577. export var outlinePixelShader: {
  66578. name: string;
  66579. shader: string;
  66580. };
  66581. }
  66582. declare module BABYLON {
  66583. /** @hidden */
  66584. export var outlineVertexShader: {
  66585. name: string;
  66586. shader: string;
  66587. };
  66588. }
  66589. declare module BABYLON {
  66590. interface Scene {
  66591. /** @hidden */
  66592. _outlineRenderer: OutlineRenderer;
  66593. /**
  66594. * Gets the outline renderer associated with the scene
  66595. * @returns a OutlineRenderer
  66596. */
  66597. getOutlineRenderer(): OutlineRenderer;
  66598. }
  66599. interface AbstractMesh {
  66600. /** @hidden (Backing field) */
  66601. _renderOutline: boolean;
  66602. /**
  66603. * Gets or sets a boolean indicating if the outline must be rendered as well
  66604. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  66605. */
  66606. renderOutline: boolean;
  66607. /** @hidden (Backing field) */
  66608. _renderOverlay: boolean;
  66609. /**
  66610. * Gets or sets a boolean indicating if the overlay must be rendered as well
  66611. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  66612. */
  66613. renderOverlay: boolean;
  66614. }
  66615. /**
  66616. * This class is responsible to draw bothe outline/overlay of meshes.
  66617. * It should not be used directly but through the available method on mesh.
  66618. */
  66619. export class OutlineRenderer implements ISceneComponent {
  66620. /**
  66621. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  66622. */
  66623. private static _StencilReference;
  66624. /**
  66625. * The name of the component. Each component must have a unique name.
  66626. */
  66627. name: string;
  66628. /**
  66629. * The scene the component belongs to.
  66630. */
  66631. scene: Scene;
  66632. /**
  66633. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  66634. */
  66635. zOffset: number;
  66636. private _engine;
  66637. private _effect;
  66638. private _cachedDefines;
  66639. private _savedDepthWrite;
  66640. /**
  66641. * Instantiates a new outline renderer. (There could be only one per scene).
  66642. * @param scene Defines the scene it belongs to
  66643. */
  66644. constructor(scene: Scene);
  66645. /**
  66646. * Register the component to one instance of a scene.
  66647. */
  66648. register(): void;
  66649. /**
  66650. * Rebuilds the elements related to this component in case of
  66651. * context lost for instance.
  66652. */
  66653. rebuild(): void;
  66654. /**
  66655. * Disposes the component and the associated ressources.
  66656. */
  66657. dispose(): void;
  66658. /**
  66659. * Renders the outline in the canvas.
  66660. * @param subMesh Defines the sumesh to render
  66661. * @param batch Defines the batch of meshes in case of instances
  66662. * @param useOverlay Defines if the rendering is for the overlay or the outline
  66663. */
  66664. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  66665. /**
  66666. * Returns whether or not the outline renderer is ready for a given submesh.
  66667. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  66668. * @param subMesh Defines the submesh to check readyness for
  66669. * @param useInstances Defines wheter wee are trying to render instances or not
  66670. * @returns true if ready otherwise false
  66671. */
  66672. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  66673. private _beforeRenderingMesh;
  66674. private _afterRenderingMesh;
  66675. }
  66676. }
  66677. declare module BABYLON {
  66678. /**
  66679. * Defines the basic options interface of a Sprite Frame Source Size.
  66680. */
  66681. export interface ISpriteJSONSpriteSourceSize {
  66682. /**
  66683. * number of the original width of the Frame
  66684. */
  66685. w: number;
  66686. /**
  66687. * number of the original height of the Frame
  66688. */
  66689. h: number;
  66690. }
  66691. /**
  66692. * Defines the basic options interface of a Sprite Frame Data.
  66693. */
  66694. export interface ISpriteJSONSpriteFrameData {
  66695. /**
  66696. * number of the x offset of the Frame
  66697. */
  66698. x: number;
  66699. /**
  66700. * number of the y offset of the Frame
  66701. */
  66702. y: number;
  66703. /**
  66704. * number of the width of the Frame
  66705. */
  66706. w: number;
  66707. /**
  66708. * number of the height of the Frame
  66709. */
  66710. h: number;
  66711. }
  66712. /**
  66713. * Defines the basic options interface of a JSON Sprite.
  66714. */
  66715. export interface ISpriteJSONSprite {
  66716. /**
  66717. * string name of the Frame
  66718. */
  66719. filename: string;
  66720. /**
  66721. * ISpriteJSONSpriteFrame basic object of the frame data
  66722. */
  66723. frame: ISpriteJSONSpriteFrameData;
  66724. /**
  66725. * boolean to flag is the frame was rotated.
  66726. */
  66727. rotated: boolean;
  66728. /**
  66729. * boolean to flag is the frame was trimmed.
  66730. */
  66731. trimmed: boolean;
  66732. /**
  66733. * ISpriteJSONSpriteFrame basic object of the source data
  66734. */
  66735. spriteSourceSize: ISpriteJSONSpriteFrameData;
  66736. /**
  66737. * ISpriteJSONSpriteFrame basic object of the source data
  66738. */
  66739. sourceSize: ISpriteJSONSpriteSourceSize;
  66740. }
  66741. /**
  66742. * Defines the basic options interface of a JSON atlas.
  66743. */
  66744. export interface ISpriteJSONAtlas {
  66745. /**
  66746. * Array of objects that contain the frame data.
  66747. */
  66748. frames: Array<ISpriteJSONSprite>;
  66749. /**
  66750. * object basic object containing the sprite meta data.
  66751. */
  66752. meta?: object;
  66753. }
  66754. }
  66755. declare module BABYLON {
  66756. /** @hidden */
  66757. export var spriteMapPixelShader: {
  66758. name: string;
  66759. shader: string;
  66760. };
  66761. }
  66762. declare module BABYLON {
  66763. /** @hidden */
  66764. export var spriteMapVertexShader: {
  66765. name: string;
  66766. shader: string;
  66767. };
  66768. }
  66769. declare module BABYLON {
  66770. /**
  66771. * Defines the basic options interface of a SpriteMap
  66772. */
  66773. export interface ISpriteMapOptions {
  66774. /**
  66775. * Vector2 of the number of cells in the grid.
  66776. */
  66777. stageSize?: Vector2;
  66778. /**
  66779. * Vector2 of the size of the output plane in World Units.
  66780. */
  66781. outputSize?: Vector2;
  66782. /**
  66783. * Vector3 of the position of the output plane in World Units.
  66784. */
  66785. outputPosition?: Vector3;
  66786. /**
  66787. * Vector3 of the rotation of the output plane.
  66788. */
  66789. outputRotation?: Vector3;
  66790. /**
  66791. * number of layers that the system will reserve in resources.
  66792. */
  66793. layerCount?: number;
  66794. /**
  66795. * number of max animation frames a single cell will reserve in resources.
  66796. */
  66797. maxAnimationFrames?: number;
  66798. /**
  66799. * number cell index of the base tile when the system compiles.
  66800. */
  66801. baseTile?: number;
  66802. /**
  66803. * boolean flip the sprite after its been repositioned by the framing data.
  66804. */
  66805. flipU?: boolean;
  66806. /**
  66807. * Vector3 scalar of the global RGB values of the SpriteMap.
  66808. */
  66809. colorMultiply?: Vector3;
  66810. }
  66811. /**
  66812. * Defines the IDisposable interface in order to be cleanable from resources.
  66813. */
  66814. export interface ISpriteMap extends IDisposable {
  66815. /**
  66816. * String name of the SpriteMap.
  66817. */
  66818. name: string;
  66819. /**
  66820. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  66821. */
  66822. atlasJSON: ISpriteJSONAtlas;
  66823. /**
  66824. * Texture of the SpriteMap.
  66825. */
  66826. spriteSheet: Texture;
  66827. /**
  66828. * The parameters to initialize the SpriteMap with.
  66829. */
  66830. options: ISpriteMapOptions;
  66831. }
  66832. /**
  66833. * Class used to manage a grid restricted sprite deployment on an Output plane.
  66834. */
  66835. export class SpriteMap implements ISpriteMap {
  66836. /** The Name of the spriteMap */
  66837. name: string;
  66838. /** The JSON file with the frame and meta data */
  66839. atlasJSON: ISpriteJSONAtlas;
  66840. /** The systems Sprite Sheet Texture */
  66841. spriteSheet: Texture;
  66842. /** Arguments passed with the Constructor */
  66843. options: ISpriteMapOptions;
  66844. /** Public Sprite Storage array, parsed from atlasJSON */
  66845. sprites: Array<ISpriteJSONSprite>;
  66846. /** Returns the Number of Sprites in the System */
  66847. get spriteCount(): number;
  66848. /** Returns the Position of Output Plane*/
  66849. get position(): Vector3;
  66850. /** Returns the Position of Output Plane*/
  66851. set position(v: Vector3);
  66852. /** Returns the Rotation of Output Plane*/
  66853. get rotation(): Vector3;
  66854. /** Returns the Rotation of Output Plane*/
  66855. set rotation(v: Vector3);
  66856. /** Sets the AnimationMap*/
  66857. get animationMap(): RawTexture;
  66858. /** Sets the AnimationMap*/
  66859. set animationMap(v: RawTexture);
  66860. /** Scene that the SpriteMap was created in */
  66861. private _scene;
  66862. /** Texture Buffer of Float32 that holds tile frame data*/
  66863. private _frameMap;
  66864. /** Texture Buffers of Float32 that holds tileMap data*/
  66865. private _tileMaps;
  66866. /** Texture Buffer of Float32 that holds Animation Data*/
  66867. private _animationMap;
  66868. /** Custom ShaderMaterial Central to the System*/
  66869. private _material;
  66870. /** Custom ShaderMaterial Central to the System*/
  66871. private _output;
  66872. /** Systems Time Ticker*/
  66873. private _time;
  66874. /**
  66875. * Creates a new SpriteMap
  66876. * @param name defines the SpriteMaps Name
  66877. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  66878. * @param spriteSheet is the Texture that the Sprites are on.
  66879. * @param options a basic deployment configuration
  66880. * @param scene The Scene that the map is deployed on
  66881. */
  66882. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  66883. /**
  66884. * Returns tileID location
  66885. * @returns Vector2 the cell position ID
  66886. */
  66887. getTileID(): Vector2;
  66888. /**
  66889. * Gets the UV location of the mouse over the SpriteMap.
  66890. * @returns Vector2 the UV position of the mouse interaction
  66891. */
  66892. getMousePosition(): Vector2;
  66893. /**
  66894. * Creates the "frame" texture Buffer
  66895. * -------------------------------------
  66896. * Structure of frames
  66897. * "filename": "Falling-Water-2.png",
  66898. * "frame": {"x":69,"y":103,"w":24,"h":32},
  66899. * "rotated": true,
  66900. * "trimmed": true,
  66901. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  66902. * "sourceSize": {"w":32,"h":32}
  66903. * @returns RawTexture of the frameMap
  66904. */
  66905. private _createFrameBuffer;
  66906. /**
  66907. * Creates the tileMap texture Buffer
  66908. * @param buffer normally and array of numbers, or a false to generate from scratch
  66909. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  66910. * @returns RawTexture of the tileMap
  66911. */
  66912. private _createTileBuffer;
  66913. /**
  66914. * Modifies the data of the tileMaps
  66915. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  66916. * @param pos is the iVector2 Coordinates of the Tile
  66917. * @param tile The SpriteIndex of the new Tile
  66918. */
  66919. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  66920. /**
  66921. * Creates the animationMap texture Buffer
  66922. * @param buffer normally and array of numbers, or a false to generate from scratch
  66923. * @returns RawTexture of the animationMap
  66924. */
  66925. private _createTileAnimationBuffer;
  66926. /**
  66927. * Modifies the data of the animationMap
  66928. * @param cellID is the Index of the Sprite
  66929. * @param _frame is the target Animation frame
  66930. * @param toCell is the Target Index of the next frame of the animation
  66931. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  66932. * @param speed is a global scalar of the time variable on the map.
  66933. */
  66934. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  66935. /**
  66936. * Exports the .tilemaps file
  66937. */
  66938. saveTileMaps(): void;
  66939. /**
  66940. * Imports the .tilemaps file
  66941. * @param url of the .tilemaps file
  66942. */
  66943. loadTileMaps(url: string): void;
  66944. /**
  66945. * Release associated resources
  66946. */
  66947. dispose(): void;
  66948. }
  66949. }
  66950. declare module BABYLON {
  66951. /**
  66952. * Class used to manage multiple sprites of different sizes on the same spritesheet
  66953. * @see http://doc.babylonjs.com/babylon101/sprites
  66954. */
  66955. export class SpritePackedManager extends SpriteManager {
  66956. /** defines the packed manager's name */
  66957. name: string;
  66958. /**
  66959. * Creates a new sprite manager from a packed sprite sheet
  66960. * @param name defines the manager's name
  66961. * @param imgUrl defines the sprite sheet url
  66962. * @param capacity defines the maximum allowed number of sprites
  66963. * @param scene defines the hosting scene
  66964. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  66965. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  66966. * @param samplingMode defines the smapling mode to use with spritesheet
  66967. * @param fromPacked set to true; do not alter
  66968. */
  66969. constructor(
  66970. /** defines the packed manager's name */
  66971. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  66972. }
  66973. }
  66974. declare module BABYLON {
  66975. /**
  66976. * Defines the list of states available for a task inside a AssetsManager
  66977. */
  66978. export enum AssetTaskState {
  66979. /**
  66980. * Initialization
  66981. */
  66982. INIT = 0,
  66983. /**
  66984. * Running
  66985. */
  66986. RUNNING = 1,
  66987. /**
  66988. * Done
  66989. */
  66990. DONE = 2,
  66991. /**
  66992. * Error
  66993. */
  66994. ERROR = 3
  66995. }
  66996. /**
  66997. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  66998. */
  66999. export abstract class AbstractAssetTask {
  67000. /**
  67001. * Task name
  67002. */ name: string;
  67003. /**
  67004. * Callback called when the task is successful
  67005. */
  67006. onSuccess: (task: any) => void;
  67007. /**
  67008. * Callback called when the task is not successful
  67009. */
  67010. onError: (task: any, message?: string, exception?: any) => void;
  67011. /**
  67012. * Creates a new AssetsManager
  67013. * @param name defines the name of the task
  67014. */
  67015. constructor(
  67016. /**
  67017. * Task name
  67018. */ name: string);
  67019. private _isCompleted;
  67020. private _taskState;
  67021. private _errorObject;
  67022. /**
  67023. * Get if the task is completed
  67024. */
  67025. get isCompleted(): boolean;
  67026. /**
  67027. * Gets the current state of the task
  67028. */
  67029. get taskState(): AssetTaskState;
  67030. /**
  67031. * Gets the current error object (if task is in error)
  67032. */
  67033. get errorObject(): {
  67034. message?: string;
  67035. exception?: any;
  67036. };
  67037. /**
  67038. * Internal only
  67039. * @hidden
  67040. */
  67041. _setErrorObject(message?: string, exception?: any): void;
  67042. /**
  67043. * Execute the current task
  67044. * @param scene defines the scene where you want your assets to be loaded
  67045. * @param onSuccess is a callback called when the task is successfully executed
  67046. * @param onError is a callback called if an error occurs
  67047. */
  67048. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67049. /**
  67050. * Execute the current task
  67051. * @param scene defines the scene where you want your assets to be loaded
  67052. * @param onSuccess is a callback called when the task is successfully executed
  67053. * @param onError is a callback called if an error occurs
  67054. */
  67055. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67056. /**
  67057. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  67058. * This can be used with failed tasks that have the reason for failure fixed.
  67059. */
  67060. reset(): void;
  67061. private onErrorCallback;
  67062. private onDoneCallback;
  67063. }
  67064. /**
  67065. * Define the interface used by progress events raised during assets loading
  67066. */
  67067. export interface IAssetsProgressEvent {
  67068. /**
  67069. * Defines the number of remaining tasks to process
  67070. */
  67071. remainingCount: number;
  67072. /**
  67073. * Defines the total number of tasks
  67074. */
  67075. totalCount: number;
  67076. /**
  67077. * Defines the task that was just processed
  67078. */
  67079. task: AbstractAssetTask;
  67080. }
  67081. /**
  67082. * Class used to share progress information about assets loading
  67083. */
  67084. export class AssetsProgressEvent implements IAssetsProgressEvent {
  67085. /**
  67086. * Defines the number of remaining tasks to process
  67087. */
  67088. remainingCount: number;
  67089. /**
  67090. * Defines the total number of tasks
  67091. */
  67092. totalCount: number;
  67093. /**
  67094. * Defines the task that was just processed
  67095. */
  67096. task: AbstractAssetTask;
  67097. /**
  67098. * Creates a AssetsProgressEvent
  67099. * @param remainingCount defines the number of remaining tasks to process
  67100. * @param totalCount defines the total number of tasks
  67101. * @param task defines the task that was just processed
  67102. */
  67103. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  67104. }
  67105. /**
  67106. * Define a task used by AssetsManager to load meshes
  67107. */
  67108. export class MeshAssetTask extends AbstractAssetTask {
  67109. /**
  67110. * Defines the name of the task
  67111. */
  67112. name: string;
  67113. /**
  67114. * Defines the list of mesh's names you want to load
  67115. */
  67116. meshesNames: any;
  67117. /**
  67118. * Defines the root url to use as a base to load your meshes and associated resources
  67119. */
  67120. rootUrl: string;
  67121. /**
  67122. * Defines the filename of the scene to load from
  67123. */
  67124. sceneFilename: string;
  67125. /**
  67126. * Gets the list of loaded meshes
  67127. */
  67128. loadedMeshes: Array<AbstractMesh>;
  67129. /**
  67130. * Gets the list of loaded particle systems
  67131. */
  67132. loadedParticleSystems: Array<IParticleSystem>;
  67133. /**
  67134. * Gets the list of loaded skeletons
  67135. */
  67136. loadedSkeletons: Array<Skeleton>;
  67137. /**
  67138. * Gets the list of loaded animation groups
  67139. */
  67140. loadedAnimationGroups: Array<AnimationGroup>;
  67141. /**
  67142. * Callback called when the task is successful
  67143. */
  67144. onSuccess: (task: MeshAssetTask) => void;
  67145. /**
  67146. * Callback called when the task is successful
  67147. */
  67148. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  67149. /**
  67150. * Creates a new MeshAssetTask
  67151. * @param name defines the name of the task
  67152. * @param meshesNames defines the list of mesh's names you want to load
  67153. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  67154. * @param sceneFilename defines the filename of the scene to load from
  67155. */
  67156. constructor(
  67157. /**
  67158. * Defines the name of the task
  67159. */
  67160. name: string,
  67161. /**
  67162. * Defines the list of mesh's names you want to load
  67163. */
  67164. meshesNames: any,
  67165. /**
  67166. * Defines the root url to use as a base to load your meshes and associated resources
  67167. */
  67168. rootUrl: string,
  67169. /**
  67170. * Defines the filename of the scene to load from
  67171. */
  67172. sceneFilename: string);
  67173. /**
  67174. * Execute the current task
  67175. * @param scene defines the scene where you want your assets to be loaded
  67176. * @param onSuccess is a callback called when the task is successfully executed
  67177. * @param onError is a callback called if an error occurs
  67178. */
  67179. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67180. }
  67181. /**
  67182. * Define a task used by AssetsManager to load text content
  67183. */
  67184. export class TextFileAssetTask extends AbstractAssetTask {
  67185. /**
  67186. * Defines the name of the task
  67187. */
  67188. name: string;
  67189. /**
  67190. * Defines the location of the file to load
  67191. */
  67192. url: string;
  67193. /**
  67194. * Gets the loaded text string
  67195. */
  67196. text: string;
  67197. /**
  67198. * Callback called when the task is successful
  67199. */
  67200. onSuccess: (task: TextFileAssetTask) => void;
  67201. /**
  67202. * Callback called when the task is successful
  67203. */
  67204. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  67205. /**
  67206. * Creates a new TextFileAssetTask object
  67207. * @param name defines the name of the task
  67208. * @param url defines the location of the file to load
  67209. */
  67210. constructor(
  67211. /**
  67212. * Defines the name of the task
  67213. */
  67214. name: string,
  67215. /**
  67216. * Defines the location of the file to load
  67217. */
  67218. url: string);
  67219. /**
  67220. * Execute the current task
  67221. * @param scene defines the scene where you want your assets to be loaded
  67222. * @param onSuccess is a callback called when the task is successfully executed
  67223. * @param onError is a callback called if an error occurs
  67224. */
  67225. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67226. }
  67227. /**
  67228. * Define a task used by AssetsManager to load binary data
  67229. */
  67230. export class BinaryFileAssetTask extends AbstractAssetTask {
  67231. /**
  67232. * Defines the name of the task
  67233. */
  67234. name: string;
  67235. /**
  67236. * Defines the location of the file to load
  67237. */
  67238. url: string;
  67239. /**
  67240. * Gets the lodaded data (as an array buffer)
  67241. */
  67242. data: ArrayBuffer;
  67243. /**
  67244. * Callback called when the task is successful
  67245. */
  67246. onSuccess: (task: BinaryFileAssetTask) => void;
  67247. /**
  67248. * Callback called when the task is successful
  67249. */
  67250. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  67251. /**
  67252. * Creates a new BinaryFileAssetTask object
  67253. * @param name defines the name of the new task
  67254. * @param url defines the location of the file to load
  67255. */
  67256. constructor(
  67257. /**
  67258. * Defines the name of the task
  67259. */
  67260. name: string,
  67261. /**
  67262. * Defines the location of the file to load
  67263. */
  67264. url: string);
  67265. /**
  67266. * Execute the current task
  67267. * @param scene defines the scene where you want your assets to be loaded
  67268. * @param onSuccess is a callback called when the task is successfully executed
  67269. * @param onError is a callback called if an error occurs
  67270. */
  67271. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67272. }
  67273. /**
  67274. * Define a task used by AssetsManager to load images
  67275. */
  67276. export class ImageAssetTask extends AbstractAssetTask {
  67277. /**
  67278. * Defines the name of the task
  67279. */
  67280. name: string;
  67281. /**
  67282. * Defines the location of the image to load
  67283. */
  67284. url: string;
  67285. /**
  67286. * Gets the loaded images
  67287. */
  67288. image: HTMLImageElement;
  67289. /**
  67290. * Callback called when the task is successful
  67291. */
  67292. onSuccess: (task: ImageAssetTask) => void;
  67293. /**
  67294. * Callback called when the task is successful
  67295. */
  67296. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  67297. /**
  67298. * Creates a new ImageAssetTask
  67299. * @param name defines the name of the task
  67300. * @param url defines the location of the image to load
  67301. */
  67302. constructor(
  67303. /**
  67304. * Defines the name of the task
  67305. */
  67306. name: string,
  67307. /**
  67308. * Defines the location of the image to load
  67309. */
  67310. url: string);
  67311. /**
  67312. * Execute the current task
  67313. * @param scene defines the scene where you want your assets to be loaded
  67314. * @param onSuccess is a callback called when the task is successfully executed
  67315. * @param onError is a callback called if an error occurs
  67316. */
  67317. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67318. }
  67319. /**
  67320. * Defines the interface used by texture loading tasks
  67321. */
  67322. export interface ITextureAssetTask<TEX extends BaseTexture> {
  67323. /**
  67324. * Gets the loaded texture
  67325. */
  67326. texture: TEX;
  67327. }
  67328. /**
  67329. * Define a task used by AssetsManager to load 2D textures
  67330. */
  67331. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  67332. /**
  67333. * Defines the name of the task
  67334. */
  67335. name: string;
  67336. /**
  67337. * Defines the location of the file to load
  67338. */
  67339. url: string;
  67340. /**
  67341. * Defines if mipmap should not be generated (default is false)
  67342. */
  67343. noMipmap?: boolean | undefined;
  67344. /**
  67345. * Defines if texture must be inverted on Y axis (default is false)
  67346. */
  67347. invertY?: boolean | undefined;
  67348. /**
  67349. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67350. */
  67351. samplingMode: number;
  67352. /**
  67353. * Gets the loaded texture
  67354. */
  67355. texture: Texture;
  67356. /**
  67357. * Callback called when the task is successful
  67358. */
  67359. onSuccess: (task: TextureAssetTask) => void;
  67360. /**
  67361. * Callback called when the task is successful
  67362. */
  67363. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  67364. /**
  67365. * Creates a new TextureAssetTask object
  67366. * @param name defines the name of the task
  67367. * @param url defines the location of the file to load
  67368. * @param noMipmap defines if mipmap should not be generated (default is false)
  67369. * @param invertY defines if texture must be inverted on Y axis (default is false)
  67370. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67371. */
  67372. constructor(
  67373. /**
  67374. * Defines the name of the task
  67375. */
  67376. name: string,
  67377. /**
  67378. * Defines the location of the file to load
  67379. */
  67380. url: string,
  67381. /**
  67382. * Defines if mipmap should not be generated (default is false)
  67383. */
  67384. noMipmap?: boolean | undefined,
  67385. /**
  67386. * Defines if texture must be inverted on Y axis (default is false)
  67387. */
  67388. invertY?: boolean | undefined,
  67389. /**
  67390. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  67391. */
  67392. samplingMode?: number);
  67393. /**
  67394. * Execute the current task
  67395. * @param scene defines the scene where you want your assets to be loaded
  67396. * @param onSuccess is a callback called when the task is successfully executed
  67397. * @param onError is a callback called if an error occurs
  67398. */
  67399. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67400. }
  67401. /**
  67402. * Define a task used by AssetsManager to load cube textures
  67403. */
  67404. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  67405. /**
  67406. * Defines the name of the task
  67407. */
  67408. name: string;
  67409. /**
  67410. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67411. */
  67412. url: string;
  67413. /**
  67414. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67415. */
  67416. extensions?: string[] | undefined;
  67417. /**
  67418. * Defines if mipmaps should not be generated (default is false)
  67419. */
  67420. noMipmap?: boolean | undefined;
  67421. /**
  67422. * Defines the explicit list of files (undefined by default)
  67423. */
  67424. files?: string[] | undefined;
  67425. /**
  67426. * Gets the loaded texture
  67427. */
  67428. texture: CubeTexture;
  67429. /**
  67430. * Callback called when the task is successful
  67431. */
  67432. onSuccess: (task: CubeTextureAssetTask) => void;
  67433. /**
  67434. * Callback called when the task is successful
  67435. */
  67436. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  67437. /**
  67438. * Creates a new CubeTextureAssetTask
  67439. * @param name defines the name of the task
  67440. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67441. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67442. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67443. * @param files defines the explicit list of files (undefined by default)
  67444. */
  67445. constructor(
  67446. /**
  67447. * Defines the name of the task
  67448. */
  67449. name: string,
  67450. /**
  67451. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  67452. */
  67453. url: string,
  67454. /**
  67455. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  67456. */
  67457. extensions?: string[] | undefined,
  67458. /**
  67459. * Defines if mipmaps should not be generated (default is false)
  67460. */
  67461. noMipmap?: boolean | undefined,
  67462. /**
  67463. * Defines the explicit list of files (undefined by default)
  67464. */
  67465. files?: string[] | undefined);
  67466. /**
  67467. * Execute the current task
  67468. * @param scene defines the scene where you want your assets to be loaded
  67469. * @param onSuccess is a callback called when the task is successfully executed
  67470. * @param onError is a callback called if an error occurs
  67471. */
  67472. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67473. }
  67474. /**
  67475. * Define a task used by AssetsManager to load HDR cube textures
  67476. */
  67477. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  67478. /**
  67479. * Defines the name of the task
  67480. */
  67481. name: string;
  67482. /**
  67483. * Defines the location of the file to load
  67484. */
  67485. url: string;
  67486. /**
  67487. * Defines the desired size (the more it increases the longer the generation will be)
  67488. */
  67489. size: number;
  67490. /**
  67491. * Defines if mipmaps should not be generated (default is false)
  67492. */
  67493. noMipmap: boolean;
  67494. /**
  67495. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67496. */
  67497. generateHarmonics: boolean;
  67498. /**
  67499. * 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)
  67500. */
  67501. gammaSpace: boolean;
  67502. /**
  67503. * Internal Use Only
  67504. */
  67505. reserved: boolean;
  67506. /**
  67507. * Gets the loaded texture
  67508. */
  67509. texture: HDRCubeTexture;
  67510. /**
  67511. * Callback called when the task is successful
  67512. */
  67513. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  67514. /**
  67515. * Callback called when the task is successful
  67516. */
  67517. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  67518. /**
  67519. * Creates a new HDRCubeTextureAssetTask object
  67520. * @param name defines the name of the task
  67521. * @param url defines the location of the file to load
  67522. * @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.
  67523. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67524. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67525. * @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)
  67526. * @param reserved Internal use only
  67527. */
  67528. constructor(
  67529. /**
  67530. * Defines the name of the task
  67531. */
  67532. name: string,
  67533. /**
  67534. * Defines the location of the file to load
  67535. */
  67536. url: string,
  67537. /**
  67538. * Defines the desired size (the more it increases the longer the generation will be)
  67539. */
  67540. size: number,
  67541. /**
  67542. * Defines if mipmaps should not be generated (default is false)
  67543. */
  67544. noMipmap?: boolean,
  67545. /**
  67546. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  67547. */
  67548. generateHarmonics?: boolean,
  67549. /**
  67550. * 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)
  67551. */
  67552. gammaSpace?: boolean,
  67553. /**
  67554. * Internal Use Only
  67555. */
  67556. reserved?: boolean);
  67557. /**
  67558. * Execute the current task
  67559. * @param scene defines the scene where you want your assets to be loaded
  67560. * @param onSuccess is a callback called when the task is successfully executed
  67561. * @param onError is a callback called if an error occurs
  67562. */
  67563. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67564. }
  67565. /**
  67566. * Define a task used by AssetsManager to load Equirectangular cube textures
  67567. */
  67568. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  67569. /**
  67570. * Defines the name of the task
  67571. */
  67572. name: string;
  67573. /**
  67574. * Defines the location of the file to load
  67575. */
  67576. url: string;
  67577. /**
  67578. * Defines the desired size (the more it increases the longer the generation will be)
  67579. */
  67580. size: number;
  67581. /**
  67582. * Defines if mipmaps should not be generated (default is false)
  67583. */
  67584. noMipmap: boolean;
  67585. /**
  67586. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  67587. * but the standard material would require them in Gamma space) (default is true)
  67588. */
  67589. gammaSpace: boolean;
  67590. /**
  67591. * Gets the loaded texture
  67592. */
  67593. texture: EquiRectangularCubeTexture;
  67594. /**
  67595. * Callback called when the task is successful
  67596. */
  67597. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  67598. /**
  67599. * Callback called when the task is successful
  67600. */
  67601. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  67602. /**
  67603. * Creates a new EquiRectangularCubeTextureAssetTask object
  67604. * @param name defines the name of the task
  67605. * @param url defines the location of the file to load
  67606. * @param size defines the desired size (the more it increases the longer the generation will be)
  67607. * If the size is omitted this implies you are using a preprocessed cubemap.
  67608. * @param noMipmap defines if mipmaps should not be generated (default is false)
  67609. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  67610. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  67611. * (default is true)
  67612. */
  67613. constructor(
  67614. /**
  67615. * Defines the name of the task
  67616. */
  67617. name: string,
  67618. /**
  67619. * Defines the location of the file to load
  67620. */
  67621. url: string,
  67622. /**
  67623. * Defines the desired size (the more it increases the longer the generation will be)
  67624. */
  67625. size: number,
  67626. /**
  67627. * Defines if mipmaps should not be generated (default is false)
  67628. */
  67629. noMipmap?: boolean,
  67630. /**
  67631. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  67632. * but the standard material would require them in Gamma space) (default is true)
  67633. */
  67634. gammaSpace?: boolean);
  67635. /**
  67636. * Execute the current task
  67637. * @param scene defines the scene where you want your assets to be loaded
  67638. * @param onSuccess is a callback called when the task is successfully executed
  67639. * @param onError is a callback called if an error occurs
  67640. */
  67641. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  67642. }
  67643. /**
  67644. * This class can be used to easily import assets into a scene
  67645. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  67646. */
  67647. export class AssetsManager {
  67648. private _scene;
  67649. private _isLoading;
  67650. protected _tasks: AbstractAssetTask[];
  67651. protected _waitingTasksCount: number;
  67652. protected _totalTasksCount: number;
  67653. /**
  67654. * Callback called when all tasks are processed
  67655. */
  67656. onFinish: (tasks: AbstractAssetTask[]) => void;
  67657. /**
  67658. * Callback called when a task is successful
  67659. */
  67660. onTaskSuccess: (task: AbstractAssetTask) => void;
  67661. /**
  67662. * Callback called when a task had an error
  67663. */
  67664. onTaskError: (task: AbstractAssetTask) => void;
  67665. /**
  67666. * Callback called when a task is done (whatever the result is)
  67667. */
  67668. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  67669. /**
  67670. * Observable called when all tasks are processed
  67671. */
  67672. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  67673. /**
  67674. * Observable called when a task had an error
  67675. */
  67676. onTaskErrorObservable: Observable<AbstractAssetTask>;
  67677. /**
  67678. * Observable called when all tasks were executed
  67679. */
  67680. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  67681. /**
  67682. * Observable called when a task is done (whatever the result is)
  67683. */
  67684. onProgressObservable: Observable<IAssetsProgressEvent>;
  67685. /**
  67686. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  67687. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  67688. */
  67689. useDefaultLoadingScreen: boolean;
  67690. /**
  67691. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  67692. * when all assets have been downloaded.
  67693. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  67694. */
  67695. autoHideLoadingUI: boolean;
  67696. /**
  67697. * Creates a new AssetsManager
  67698. * @param scene defines the scene to work on
  67699. */
  67700. constructor(scene: Scene);
  67701. /**
  67702. * Add a MeshAssetTask to the list of active tasks
  67703. * @param taskName defines the name of the new task
  67704. * @param meshesNames defines the name of meshes to load
  67705. * @param rootUrl defines the root url to use to locate files
  67706. * @param sceneFilename defines the filename of the scene file
  67707. * @returns a new MeshAssetTask object
  67708. */
  67709. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  67710. /**
  67711. * Add a TextFileAssetTask to the list of active tasks
  67712. * @param taskName defines the name of the new task
  67713. * @param url defines the url of the file to load
  67714. * @returns a new TextFileAssetTask object
  67715. */
  67716. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  67717. /**
  67718. * Add a BinaryFileAssetTask to the list of active tasks
  67719. * @param taskName defines the name of the new task
  67720. * @param url defines the url of the file to load
  67721. * @returns a new BinaryFileAssetTask object
  67722. */
  67723. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  67724. /**
  67725. * Add a ImageAssetTask to the list of active tasks
  67726. * @param taskName defines the name of the new task
  67727. * @param url defines the url of the file to load
  67728. * @returns a new ImageAssetTask object
  67729. */
  67730. addImageTask(taskName: string, url: string): ImageAssetTask;
  67731. /**
  67732. * Add a TextureAssetTask to the list of active tasks
  67733. * @param taskName defines the name of the new task
  67734. * @param url defines the url of the file to load
  67735. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67736. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  67737. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  67738. * @returns a new TextureAssetTask object
  67739. */
  67740. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  67741. /**
  67742. * Add a CubeTextureAssetTask to the list of active tasks
  67743. * @param taskName defines the name of the new task
  67744. * @param url defines the url of the file to load
  67745. * @param extensions defines the extension to use to load the cube map (can be null)
  67746. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67747. * @param files defines the list of files to load (can be null)
  67748. * @returns a new CubeTextureAssetTask object
  67749. */
  67750. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  67751. /**
  67752. *
  67753. * Add a HDRCubeTextureAssetTask to the list of active tasks
  67754. * @param taskName defines the name of the new task
  67755. * @param url defines the url of the file to load
  67756. * @param size defines the size you want for the cubemap (can be null)
  67757. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67758. * @param generateHarmonics defines if you want to automatically generate (true by default)
  67759. * @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)
  67760. * @param reserved Internal use only
  67761. * @returns a new HDRCubeTextureAssetTask object
  67762. */
  67763. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  67764. /**
  67765. *
  67766. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  67767. * @param taskName defines the name of the new task
  67768. * @param url defines the url of the file to load
  67769. * @param size defines the size you want for the cubemap (can be null)
  67770. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  67771. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  67772. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  67773. * @returns a new EquiRectangularCubeTextureAssetTask object
  67774. */
  67775. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  67776. /**
  67777. * Remove a task from the assets manager.
  67778. * @param task the task to remove
  67779. */
  67780. removeTask(task: AbstractAssetTask): void;
  67781. private _decreaseWaitingTasksCount;
  67782. private _runTask;
  67783. /**
  67784. * Reset the AssetsManager and remove all tasks
  67785. * @return the current instance of the AssetsManager
  67786. */
  67787. reset(): AssetsManager;
  67788. /**
  67789. * Start the loading process
  67790. * @return the current instance of the AssetsManager
  67791. */
  67792. load(): AssetsManager;
  67793. /**
  67794. * Start the loading process as an async operation
  67795. * @return a promise returning the list of failed tasks
  67796. */
  67797. loadAsync(): Promise<void>;
  67798. }
  67799. }
  67800. declare module BABYLON {
  67801. /**
  67802. * Wrapper class for promise with external resolve and reject.
  67803. */
  67804. export class Deferred<T> {
  67805. /**
  67806. * The promise associated with this deferred object.
  67807. */
  67808. readonly promise: Promise<T>;
  67809. private _resolve;
  67810. private _reject;
  67811. /**
  67812. * The resolve method of the promise associated with this deferred object.
  67813. */
  67814. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  67815. /**
  67816. * The reject method of the promise associated with this deferred object.
  67817. */
  67818. get reject(): (reason?: any) => void;
  67819. /**
  67820. * Constructor for this deferred object.
  67821. */
  67822. constructor();
  67823. }
  67824. }
  67825. declare module BABYLON {
  67826. /**
  67827. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  67828. */
  67829. export class MeshExploder {
  67830. private _centerMesh;
  67831. private _meshes;
  67832. private _meshesOrigins;
  67833. private _toCenterVectors;
  67834. private _scaledDirection;
  67835. private _newPosition;
  67836. private _centerPosition;
  67837. /**
  67838. * Explodes meshes from a center mesh.
  67839. * @param meshes The meshes to explode.
  67840. * @param centerMesh The mesh to be center of explosion.
  67841. */
  67842. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  67843. private _setCenterMesh;
  67844. /**
  67845. * Get class name
  67846. * @returns "MeshExploder"
  67847. */
  67848. getClassName(): string;
  67849. /**
  67850. * "Exploded meshes"
  67851. * @returns Array of meshes with the centerMesh at index 0.
  67852. */
  67853. getMeshes(): Array<Mesh>;
  67854. /**
  67855. * Explodes meshes giving a specific direction
  67856. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  67857. */
  67858. explode(direction?: number): void;
  67859. }
  67860. }
  67861. declare module BABYLON {
  67862. /**
  67863. * Class used to help managing file picking and drag'n'drop
  67864. */
  67865. export class FilesInput {
  67866. /**
  67867. * List of files ready to be loaded
  67868. */
  67869. static get FilesToLoad(): {
  67870. [key: string]: File;
  67871. };
  67872. /**
  67873. * Callback called when a file is processed
  67874. */
  67875. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  67876. private _engine;
  67877. private _currentScene;
  67878. private _sceneLoadedCallback;
  67879. private _progressCallback;
  67880. private _additionalRenderLoopLogicCallback;
  67881. private _textureLoadingCallback;
  67882. private _startingProcessingFilesCallback;
  67883. private _onReloadCallback;
  67884. private _errorCallback;
  67885. private _elementToMonitor;
  67886. private _sceneFileToLoad;
  67887. private _filesToLoad;
  67888. /**
  67889. * Creates a new FilesInput
  67890. * @param engine defines the rendering engine
  67891. * @param scene defines the hosting scene
  67892. * @param sceneLoadedCallback callback called when scene is loaded
  67893. * @param progressCallback callback called to track progress
  67894. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  67895. * @param textureLoadingCallback callback called when a texture is loading
  67896. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  67897. * @param onReloadCallback callback called when a reload is requested
  67898. * @param errorCallback callback call if an error occurs
  67899. */
  67900. 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);
  67901. private _dragEnterHandler;
  67902. private _dragOverHandler;
  67903. private _dropHandler;
  67904. /**
  67905. * Calls this function to listen to drag'n'drop events on a specific DOM element
  67906. * @param elementToMonitor defines the DOM element to track
  67907. */
  67908. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  67909. /**
  67910. * Release all associated resources
  67911. */
  67912. dispose(): void;
  67913. private renderFunction;
  67914. private drag;
  67915. private drop;
  67916. private _traverseFolder;
  67917. private _processFiles;
  67918. /**
  67919. * Load files from a drop event
  67920. * @param event defines the drop event to use as source
  67921. */
  67922. loadFiles(event: any): void;
  67923. private _processReload;
  67924. /**
  67925. * Reload the current scene from the loaded files
  67926. */
  67927. reload(): void;
  67928. }
  67929. }
  67930. declare module BABYLON {
  67931. /**
  67932. * Defines the root class used to create scene optimization to use with SceneOptimizer
  67933. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67934. */
  67935. export class SceneOptimization {
  67936. /**
  67937. * Defines the priority of this optimization (0 by default which means first in the list)
  67938. */
  67939. priority: number;
  67940. /**
  67941. * Gets a string describing the action executed by the current optimization
  67942. * @returns description string
  67943. */
  67944. getDescription(): string;
  67945. /**
  67946. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  67947. * @param scene defines the current scene where to apply this optimization
  67948. * @param optimizer defines the current optimizer
  67949. * @returns true if everything that can be done was applied
  67950. */
  67951. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  67952. /**
  67953. * Creates the SceneOptimization object
  67954. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67955. * @param desc defines the description associated with the optimization
  67956. */
  67957. constructor(
  67958. /**
  67959. * Defines the priority of this optimization (0 by default which means first in the list)
  67960. */
  67961. priority?: number);
  67962. }
  67963. /**
  67964. * Defines an optimization used to reduce the size of render target textures
  67965. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  67966. */
  67967. export class TextureOptimization 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 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
  67974. */
  67975. maximumSize: number;
  67976. /**
  67977. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  67978. */
  67979. step: number;
  67980. /**
  67981. * Gets a string describing the action executed by the current optimization
  67982. * @returns description string
  67983. */
  67984. getDescription(): string;
  67985. /**
  67986. * Creates the TextureOptimization object
  67987. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  67988. * @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
  67989. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  67990. */
  67991. constructor(
  67992. /**
  67993. * Defines the priority of this optimization (0 by default which means first in the list)
  67994. */
  67995. priority?: number,
  67996. /**
  67997. * 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
  67998. */
  67999. maximumSize?: number,
  68000. /**
  68001. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  68002. */
  68003. step?: number);
  68004. /**
  68005. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68006. * @param scene defines the current scene where to apply this optimization
  68007. * @param optimizer defines the current optimizer
  68008. * @returns true if everything that can be done was applied
  68009. */
  68010. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68011. }
  68012. /**
  68013. * Defines an optimization used to increase or decrease the rendering resolution
  68014. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68015. */
  68016. export class HardwareScalingOptimization extends SceneOptimization {
  68017. /**
  68018. * Defines the priority of this optimization (0 by default which means first in the list)
  68019. */
  68020. priority: number;
  68021. /**
  68022. * Defines the maximum scale to use (2 by default)
  68023. */
  68024. maximumScale: number;
  68025. /**
  68026. * Defines the step to use between two passes (0.5 by default)
  68027. */
  68028. step: number;
  68029. private _currentScale;
  68030. private _directionOffset;
  68031. /**
  68032. * Gets a string describing the action executed by the current optimization
  68033. * @return description string
  68034. */
  68035. getDescription(): string;
  68036. /**
  68037. * Creates the HardwareScalingOptimization object
  68038. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68039. * @param maximumScale defines the maximum scale to use (2 by default)
  68040. * @param step defines the step to use between two passes (0.5 by default)
  68041. */
  68042. constructor(
  68043. /**
  68044. * Defines the priority of this optimization (0 by default which means first in the list)
  68045. */
  68046. priority?: number,
  68047. /**
  68048. * Defines the maximum scale to use (2 by default)
  68049. */
  68050. maximumScale?: number,
  68051. /**
  68052. * Defines the step to use between two passes (0.5 by default)
  68053. */
  68054. step?: number);
  68055. /**
  68056. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68057. * @param scene defines the current scene where to apply this optimization
  68058. * @param optimizer defines the current optimizer
  68059. * @returns true if everything that can be done was applied
  68060. */
  68061. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68062. }
  68063. /**
  68064. * Defines an optimization used to remove shadows
  68065. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68066. */
  68067. export class ShadowsOptimization extends SceneOptimization {
  68068. /**
  68069. * Gets a string describing the action executed by the current optimization
  68070. * @return description string
  68071. */
  68072. getDescription(): string;
  68073. /**
  68074. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68075. * @param scene defines the current scene where to apply this optimization
  68076. * @param optimizer defines the current optimizer
  68077. * @returns true if everything that can be done was applied
  68078. */
  68079. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68080. }
  68081. /**
  68082. * Defines an optimization used to turn post-processes off
  68083. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68084. */
  68085. export class PostProcessesOptimization extends SceneOptimization {
  68086. /**
  68087. * Gets a string describing the action executed by the current optimization
  68088. * @return description string
  68089. */
  68090. getDescription(): string;
  68091. /**
  68092. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68093. * @param scene defines the current scene where to apply this optimization
  68094. * @param optimizer defines the current optimizer
  68095. * @returns true if everything that can be done was applied
  68096. */
  68097. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68098. }
  68099. /**
  68100. * Defines an optimization used to turn lens flares off
  68101. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68102. */
  68103. export class LensFlaresOptimization extends SceneOptimization {
  68104. /**
  68105. * Gets a string describing the action executed by the current optimization
  68106. * @return description string
  68107. */
  68108. getDescription(): string;
  68109. /**
  68110. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68111. * @param scene defines the current scene where to apply this optimization
  68112. * @param optimizer defines the current optimizer
  68113. * @returns true if everything that can be done was applied
  68114. */
  68115. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68116. }
  68117. /**
  68118. * Defines an optimization based on user defined callback.
  68119. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68120. */
  68121. export class CustomOptimization extends SceneOptimization {
  68122. /**
  68123. * Callback called to apply the custom optimization.
  68124. */
  68125. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  68126. /**
  68127. * Callback called to get custom description
  68128. */
  68129. onGetDescription: () => string;
  68130. /**
  68131. * Gets a string describing the action executed by the current optimization
  68132. * @returns description string
  68133. */
  68134. getDescription(): string;
  68135. /**
  68136. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68137. * @param scene defines the current scene where to apply this optimization
  68138. * @param optimizer defines the current optimizer
  68139. * @returns true if everything that can be done was applied
  68140. */
  68141. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68142. }
  68143. /**
  68144. * Defines an optimization used to turn particles off
  68145. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68146. */
  68147. export class ParticlesOptimization extends SceneOptimization {
  68148. /**
  68149. * Gets a string describing the action executed by the current optimization
  68150. * @return description string
  68151. */
  68152. getDescription(): string;
  68153. /**
  68154. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68155. * @param scene defines the current scene where to apply this optimization
  68156. * @param optimizer defines the current optimizer
  68157. * @returns true if everything that can be done was applied
  68158. */
  68159. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68160. }
  68161. /**
  68162. * Defines an optimization used to turn render targets off
  68163. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68164. */
  68165. export class RenderTargetsOptimization extends SceneOptimization {
  68166. /**
  68167. * Gets a string describing the action executed by the current optimization
  68168. * @return description string
  68169. */
  68170. getDescription(): string;
  68171. /**
  68172. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68173. * @param scene defines the current scene where to apply this optimization
  68174. * @param optimizer defines the current optimizer
  68175. * @returns true if everything that can be done was applied
  68176. */
  68177. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  68178. }
  68179. /**
  68180. * Defines an optimization used to merge meshes with compatible materials
  68181. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68182. */
  68183. export class MergeMeshesOptimization extends SceneOptimization {
  68184. private static _UpdateSelectionTree;
  68185. /**
  68186. * Gets or sets a boolean which defines if optimization octree has to be updated
  68187. */
  68188. static get UpdateSelectionTree(): boolean;
  68189. /**
  68190. * Gets or sets a boolean which defines if optimization octree has to be updated
  68191. */
  68192. static set UpdateSelectionTree(value: boolean);
  68193. /**
  68194. * Gets a string describing the action executed by the current optimization
  68195. * @return description string
  68196. */
  68197. getDescription(): string;
  68198. private _canBeMerged;
  68199. /**
  68200. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  68201. * @param scene defines the current scene where to apply this optimization
  68202. * @param optimizer defines the current optimizer
  68203. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  68204. * @returns true if everything that can be done was applied
  68205. */
  68206. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  68207. }
  68208. /**
  68209. * Defines a list of options used by SceneOptimizer
  68210. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68211. */
  68212. export class SceneOptimizerOptions {
  68213. /**
  68214. * Defines the target frame rate to reach (60 by default)
  68215. */
  68216. targetFrameRate: number;
  68217. /**
  68218. * Defines the interval between two checkes (2000ms by default)
  68219. */
  68220. trackerDuration: number;
  68221. /**
  68222. * Gets the list of optimizations to apply
  68223. */
  68224. optimizations: SceneOptimization[];
  68225. /**
  68226. * Creates a new list of options used by SceneOptimizer
  68227. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  68228. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  68229. */
  68230. constructor(
  68231. /**
  68232. * Defines the target frame rate to reach (60 by default)
  68233. */
  68234. targetFrameRate?: number,
  68235. /**
  68236. * Defines the interval between two checkes (2000ms by default)
  68237. */
  68238. trackerDuration?: number);
  68239. /**
  68240. * Add a new optimization
  68241. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  68242. * @returns the current SceneOptimizerOptions
  68243. */
  68244. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  68245. /**
  68246. * Add a new custom optimization
  68247. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  68248. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  68249. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  68250. * @returns the current SceneOptimizerOptions
  68251. */
  68252. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  68253. /**
  68254. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  68255. * @param targetFrameRate defines the target frame rate (60 by default)
  68256. * @returns a SceneOptimizerOptions object
  68257. */
  68258. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68259. /**
  68260. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  68261. * @param targetFrameRate defines the target frame rate (60 by default)
  68262. * @returns a SceneOptimizerOptions object
  68263. */
  68264. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68265. /**
  68266. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  68267. * @param targetFrameRate defines the target frame rate (60 by default)
  68268. * @returns a SceneOptimizerOptions object
  68269. */
  68270. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  68271. }
  68272. /**
  68273. * Class used to run optimizations in order to reach a target frame rate
  68274. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  68275. */
  68276. export class SceneOptimizer implements IDisposable {
  68277. private _isRunning;
  68278. private _options;
  68279. private _scene;
  68280. private _currentPriorityLevel;
  68281. private _targetFrameRate;
  68282. private _trackerDuration;
  68283. private _currentFrameRate;
  68284. private _sceneDisposeObserver;
  68285. private _improvementMode;
  68286. /**
  68287. * Defines an observable called when the optimizer reaches the target frame rate
  68288. */
  68289. onSuccessObservable: Observable<SceneOptimizer>;
  68290. /**
  68291. * Defines an observable called when the optimizer enables an optimization
  68292. */
  68293. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  68294. /**
  68295. * Defines an observable called when the optimizer is not able to reach the target frame rate
  68296. */
  68297. onFailureObservable: Observable<SceneOptimizer>;
  68298. /**
  68299. * Gets a boolean indicating if the optimizer is in improvement mode
  68300. */
  68301. get isInImprovementMode(): boolean;
  68302. /**
  68303. * Gets the current priority level (0 at start)
  68304. */
  68305. get currentPriorityLevel(): number;
  68306. /**
  68307. * Gets the current frame rate checked by the SceneOptimizer
  68308. */
  68309. get currentFrameRate(): number;
  68310. /**
  68311. * Gets or sets the current target frame rate (60 by default)
  68312. */
  68313. get targetFrameRate(): number;
  68314. /**
  68315. * Gets or sets the current target frame rate (60 by default)
  68316. */
  68317. set targetFrameRate(value: number);
  68318. /**
  68319. * Gets or sets the current interval between two checks (every 2000ms by default)
  68320. */
  68321. get trackerDuration(): number;
  68322. /**
  68323. * Gets or sets the current interval between two checks (every 2000ms by default)
  68324. */
  68325. set trackerDuration(value: number);
  68326. /**
  68327. * Gets the list of active optimizations
  68328. */
  68329. get optimizations(): SceneOptimization[];
  68330. /**
  68331. * Creates a new SceneOptimizer
  68332. * @param scene defines the scene to work on
  68333. * @param options defines the options to use with the SceneOptimizer
  68334. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  68335. * @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)
  68336. */
  68337. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  68338. /**
  68339. * Stops the current optimizer
  68340. */
  68341. stop(): void;
  68342. /**
  68343. * Reset the optimizer to initial step (current priority level = 0)
  68344. */
  68345. reset(): void;
  68346. /**
  68347. * Start the optimizer. By default it will try to reach a specific framerate
  68348. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  68349. */
  68350. start(): void;
  68351. private _checkCurrentState;
  68352. /**
  68353. * Release all resources
  68354. */
  68355. dispose(): void;
  68356. /**
  68357. * Helper function to create a SceneOptimizer with one single line of code
  68358. * @param scene defines the scene to work on
  68359. * @param options defines the options to use with the SceneOptimizer
  68360. * @param onSuccess defines a callback to call on success
  68361. * @param onFailure defines a callback to call on failure
  68362. * @returns the new SceneOptimizer object
  68363. */
  68364. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  68365. }
  68366. }
  68367. declare module BABYLON {
  68368. /**
  68369. * Class used to serialize a scene into a string
  68370. */
  68371. export class SceneSerializer {
  68372. /**
  68373. * Clear cache used by a previous serialization
  68374. */
  68375. static ClearCache(): void;
  68376. /**
  68377. * Serialize a scene into a JSON compatible object
  68378. * @param scene defines the scene to serialize
  68379. * @returns a JSON compatible object
  68380. */
  68381. static Serialize(scene: Scene): any;
  68382. /**
  68383. * Serialize a mesh into a JSON compatible object
  68384. * @param toSerialize defines the mesh to serialize
  68385. * @param withParents defines if parents must be serialized as well
  68386. * @param withChildren defines if children must be serialized as well
  68387. * @returns a JSON compatible object
  68388. */
  68389. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  68390. }
  68391. }
  68392. declare module BABYLON {
  68393. /**
  68394. * Class used to host texture specific utilities
  68395. */
  68396. export class TextureTools {
  68397. /**
  68398. * Uses the GPU to create a copy texture rescaled at a given size
  68399. * @param texture Texture to copy from
  68400. * @param width defines the desired width
  68401. * @param height defines the desired height
  68402. * @param useBilinearMode defines if bilinear mode has to be used
  68403. * @return the generated texture
  68404. */
  68405. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  68406. }
  68407. }
  68408. declare module BABYLON {
  68409. /**
  68410. * This represents the different options available for the video capture.
  68411. */
  68412. export interface VideoRecorderOptions {
  68413. /** Defines the mime type of the video. */
  68414. mimeType: string;
  68415. /** Defines the FPS the video should be recorded at. */
  68416. fps: number;
  68417. /** Defines the chunk size for the recording data. */
  68418. recordChunckSize: number;
  68419. /** The audio tracks to attach to the recording. */
  68420. audioTracks?: MediaStreamTrack[];
  68421. }
  68422. /**
  68423. * This can help with recording videos from BabylonJS.
  68424. * This is based on the available WebRTC functionalities of the browser.
  68425. *
  68426. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  68427. */
  68428. export class VideoRecorder {
  68429. private static readonly _defaultOptions;
  68430. /**
  68431. * Returns whether or not the VideoRecorder is available in your browser.
  68432. * @param engine Defines the Babylon Engine.
  68433. * @returns true if supported otherwise false.
  68434. */
  68435. static IsSupported(engine: Engine): boolean;
  68436. private readonly _options;
  68437. private _canvas;
  68438. private _mediaRecorder;
  68439. private _recordedChunks;
  68440. private _fileName;
  68441. private _resolve;
  68442. private _reject;
  68443. /**
  68444. * True when a recording is already in progress.
  68445. */
  68446. get isRecording(): boolean;
  68447. /**
  68448. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  68449. * @param engine Defines the BabylonJS Engine you wish to record.
  68450. * @param options Defines options that can be used to customize the capture.
  68451. */
  68452. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  68453. /**
  68454. * Stops the current recording before the default capture timeout passed in the startRecording function.
  68455. */
  68456. stopRecording(): void;
  68457. /**
  68458. * Starts recording the canvas for a max duration specified in parameters.
  68459. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  68460. * If null no automatic download will start and you can rely on the promise to get the data back.
  68461. * @param maxDuration Defines the maximum recording time in seconds.
  68462. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  68463. * @return A promise callback at the end of the recording with the video data in Blob.
  68464. */
  68465. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  68466. /**
  68467. * Releases internal resources used during the recording.
  68468. */
  68469. dispose(): void;
  68470. private _handleDataAvailable;
  68471. private _handleError;
  68472. private _handleStop;
  68473. }
  68474. }
  68475. declare module BABYLON {
  68476. /**
  68477. * Class containing a set of static utilities functions for screenshots
  68478. */
  68479. export class ScreenshotTools {
  68480. /**
  68481. * Captures a screenshot of the current rendering
  68482. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68483. * @param engine defines the rendering engine
  68484. * @param camera defines the source camera
  68485. * @param size This parameter can be set to a single number or to an object with the
  68486. * following (optional) properties: precision, width, height. If a single number is passed,
  68487. * it will be used for both width and height. If an object is passed, the screenshot size
  68488. * will be derived from the parameters. The precision property is a multiplier allowing
  68489. * rendering at a higher or lower resolution
  68490. * @param successCallback defines the callback receives a single parameter which contains the
  68491. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  68492. * src parameter of an <img> to display it
  68493. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  68494. * Check your browser for supported MIME types
  68495. */
  68496. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  68497. /**
  68498. * Captures a screenshot of the current rendering
  68499. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68500. * @param engine defines the rendering engine
  68501. * @param camera defines the source camera
  68502. * @param size This parameter can be set to a single number or to an object with the
  68503. * following (optional) properties: precision, width, height. If a single number is passed,
  68504. * it will be used for both width and height. If an object is passed, the screenshot size
  68505. * will be derived from the parameters. The precision property is a multiplier allowing
  68506. * rendering at a higher or lower resolution
  68507. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  68508. * Check your browser for supported MIME types
  68509. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  68510. * to the src parameter of an <img> to display it
  68511. */
  68512. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  68513. /**
  68514. * Generates an image screenshot from the specified camera.
  68515. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68516. * @param engine The engine to use for rendering
  68517. * @param camera The camera to use for rendering
  68518. * @param size This parameter can be set to a single number or to an object with the
  68519. * following (optional) properties: precision, width, height. If a single number is passed,
  68520. * it will be used for both width and height. If an object is passed, the screenshot size
  68521. * will be derived from the parameters. The precision property is a multiplier allowing
  68522. * rendering at a higher or lower resolution
  68523. * @param successCallback The callback receives a single parameter which contains the
  68524. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  68525. * src parameter of an <img> to display it
  68526. * @param mimeType The MIME type of the screenshot image (default: image/png).
  68527. * Check your browser for supported MIME types
  68528. * @param samples Texture samples (default: 1)
  68529. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  68530. * @param fileName A name for for the downloaded file.
  68531. */
  68532. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  68533. /**
  68534. * Generates an image screenshot from the specified camera.
  68535. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  68536. * @param engine The engine to use for rendering
  68537. * @param camera The camera to use for rendering
  68538. * @param size This parameter can be set to a single number or to an object with the
  68539. * following (optional) properties: precision, width, height. If a single number is passed,
  68540. * it will be used for both width and height. If an object is passed, the screenshot size
  68541. * will be derived from the parameters. The precision property is a multiplier allowing
  68542. * rendering at a higher or lower resolution
  68543. * @param mimeType The MIME type of the screenshot image (default: image/png).
  68544. * Check your browser for supported MIME types
  68545. * @param samples Texture samples (default: 1)
  68546. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  68547. * @param fileName A name for for the downloaded file.
  68548. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  68549. * to the src parameter of an <img> to display it
  68550. */
  68551. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  68552. /**
  68553. * Gets height and width for screenshot size
  68554. * @private
  68555. */
  68556. private static _getScreenshotSize;
  68557. }
  68558. }
  68559. declare module BABYLON {
  68560. /**
  68561. * Interface for a data buffer
  68562. */
  68563. export interface IDataBuffer {
  68564. /**
  68565. * Reads bytes from the data buffer.
  68566. * @param byteOffset The byte offset to read
  68567. * @param byteLength The byte length to read
  68568. * @returns A promise that resolves when the bytes are read
  68569. */
  68570. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  68571. /**
  68572. * The byte length of the buffer.
  68573. */
  68574. readonly byteLength: number;
  68575. }
  68576. /**
  68577. * Utility class for reading from a data buffer
  68578. */
  68579. export class DataReader {
  68580. /**
  68581. * The data buffer associated with this data reader.
  68582. */
  68583. readonly buffer: IDataBuffer;
  68584. /**
  68585. * The current byte offset from the beginning of the data buffer.
  68586. */
  68587. byteOffset: number;
  68588. private _dataView;
  68589. private _dataByteOffset;
  68590. /**
  68591. * Constructor
  68592. * @param buffer The buffer to read
  68593. */
  68594. constructor(buffer: IDataBuffer);
  68595. /**
  68596. * Loads the given byte length.
  68597. * @param byteLength The byte length to load
  68598. * @returns A promise that resolves when the load is complete
  68599. */
  68600. loadAsync(byteLength: number): Promise<void>;
  68601. /**
  68602. * Read a unsigned 32-bit integer from the currently loaded data range.
  68603. * @returns The 32-bit integer read
  68604. */
  68605. readUint32(): number;
  68606. /**
  68607. * Read a byte array from the currently loaded data range.
  68608. * @param byteLength The byte length to read
  68609. * @returns The byte array read
  68610. */
  68611. readUint8Array(byteLength: number): Uint8Array;
  68612. /**
  68613. * Read a string from the currently loaded data range.
  68614. * @param byteLength The byte length to read
  68615. * @returns The string read
  68616. */
  68617. readString(byteLength: number): string;
  68618. /**
  68619. * Skips the given byte length the currently loaded data range.
  68620. * @param byteLength The byte length to skip
  68621. */
  68622. skipBytes(byteLength: number): void;
  68623. }
  68624. }
  68625. declare module BABYLON {
  68626. /**
  68627. * Options used for hit testing
  68628. */
  68629. export interface IWebXRHitTestOptions {
  68630. /**
  68631. * Only test when user interacted with the scene. Default - hit test every frame
  68632. */
  68633. testOnPointerDownOnly?: boolean;
  68634. /**
  68635. * The node to use to transform the local results to world coordinates
  68636. */
  68637. worldParentNode?: TransformNode;
  68638. }
  68639. /**
  68640. * Interface defining the babylon result of raycasting/hit-test
  68641. */
  68642. export interface IWebXRHitResult {
  68643. /**
  68644. * The native hit test result
  68645. */
  68646. xrHitResult: XRHitResult;
  68647. /**
  68648. * Transformation matrix that can be applied to a node that will put it in the hit point location
  68649. */
  68650. transformationMatrix: Matrix;
  68651. }
  68652. /**
  68653. * The currently-working hit-test module.
  68654. * Hit test (or raycasting) is used to interact with the real world.
  68655. * For further information read here - https://github.com/immersive-web/hit-test
  68656. */
  68657. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  68658. /**
  68659. * options to use when constructing this feature
  68660. */
  68661. readonly options: IWebXRHitTestOptions;
  68662. /**
  68663. * The module's name
  68664. */
  68665. static readonly Name: string;
  68666. /**
  68667. * The (Babylon) version of this module.
  68668. * This is an integer representing the implementation version.
  68669. * This number does not correspond to the webxr specs version
  68670. */
  68671. static readonly Version: number;
  68672. /**
  68673. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  68674. * @param event the (select) event to use to select with
  68675. * @param referenceSpace the reference space to use for this hit test
  68676. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  68677. */
  68678. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  68679. /**
  68680. * execute a hit test with an XR Ray
  68681. *
  68682. * @param xrSession a native xrSession that will execute this hit test
  68683. * @param xrRay the ray (position and direction) to use for raycasting
  68684. * @param referenceSpace native XR reference space to use for the hit-test
  68685. * @param filter filter function that will filter the results
  68686. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  68687. */
  68688. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  68689. /**
  68690. * Triggered when new babylon (transformed) hit test results are available
  68691. */
  68692. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  68693. private _onSelectEnabled;
  68694. /**
  68695. * Creates a new instance of the (legacy version) hit test feature
  68696. * @param _xrSessionManager an instance of WebXRSessionManager
  68697. * @param options options to use when constructing this feature
  68698. */
  68699. constructor(_xrSessionManager: WebXRSessionManager,
  68700. /**
  68701. * options to use when constructing this feature
  68702. */
  68703. options?: IWebXRHitTestOptions);
  68704. /**
  68705. * Populated with the last native XR Hit Results
  68706. */
  68707. lastNativeXRHitResults: XRHitResult[];
  68708. /**
  68709. * attach this feature
  68710. * Will usually be called by the features manager
  68711. *
  68712. * @returns true if successful.
  68713. */
  68714. attach(): boolean;
  68715. /**
  68716. * detach this feature.
  68717. * Will usually be called by the features manager
  68718. *
  68719. * @returns true if successful.
  68720. */
  68721. detach(): boolean;
  68722. private _onHitTestResults;
  68723. private _origin;
  68724. private _direction;
  68725. private _mat;
  68726. protected _onXRFrame(frame: XRFrame): void;
  68727. private _onSelect;
  68728. /**
  68729. * Dispose this feature and all of the resources attached
  68730. */
  68731. dispose(): void;
  68732. }
  68733. }
  68734. declare module BABYLON {
  68735. /**
  68736. * Options used in the plane detector module
  68737. */
  68738. export interface IWebXRPlaneDetectorOptions {
  68739. /**
  68740. * The node to use to transform the local results to world coordinates
  68741. */
  68742. worldParentNode?: TransformNode;
  68743. }
  68744. /**
  68745. * A babylon interface for a webxr plane.
  68746. * A Plane is actually a polygon, built from N points in space
  68747. *
  68748. * Supported in chrome 79, not supported in canary 81 ATM
  68749. */
  68750. export interface IWebXRPlane {
  68751. /**
  68752. * a babylon-assigned ID for this polygon
  68753. */
  68754. id: number;
  68755. /**
  68756. * the native xr-plane object
  68757. */
  68758. xrPlane: XRPlane;
  68759. /**
  68760. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  68761. */
  68762. polygonDefinition: Array<Vector3>;
  68763. /**
  68764. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  68765. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  68766. */
  68767. transformationMatrix: Matrix;
  68768. }
  68769. /**
  68770. * The plane detector is used to detect planes in the real world when in AR
  68771. * For more information see https://github.com/immersive-web/real-world-geometry/
  68772. */
  68773. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  68774. private _options;
  68775. /**
  68776. * The module's name
  68777. */
  68778. static readonly Name: string;
  68779. /**
  68780. * The (Babylon) version of this module.
  68781. * This is an integer representing the implementation version.
  68782. * This number does not correspond to the webxr specs version
  68783. */
  68784. static readonly Version: number;
  68785. /**
  68786. * Observers registered here will be executed when a new plane was added to the session
  68787. */
  68788. onPlaneAddedObservable: Observable<IWebXRPlane>;
  68789. /**
  68790. * Observers registered here will be executed when a plane is no longer detected in the session
  68791. */
  68792. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  68793. /**
  68794. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  68795. * This can execute N times every frame
  68796. */
  68797. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  68798. private _enabled;
  68799. private _detectedPlanes;
  68800. private _lastFrameDetected;
  68801. /**
  68802. * construct a new Plane Detector
  68803. * @param _xrSessionManager an instance of xr Session manager
  68804. * @param _options configuration to use when constructing this feature
  68805. */
  68806. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  68807. private _init;
  68808. protected _onXRFrame(frame: XRFrame): void;
  68809. /**
  68810. * Dispose this feature and all of the resources attached
  68811. */
  68812. dispose(): void;
  68813. private _updatePlaneWithXRPlane;
  68814. /**
  68815. * avoiding using Array.find for global support.
  68816. * @param xrPlane the plane to find in the array
  68817. */
  68818. private findIndexInPlaneArray;
  68819. }
  68820. }
  68821. declare module BABYLON {
  68822. /**
  68823. * Configuration options of the anchor system
  68824. */
  68825. export interface IWebXRAnchorSystemOptions {
  68826. /**
  68827. * a node that will be used to convert local to world coordinates
  68828. */
  68829. worldParentNode?: TransformNode;
  68830. /**
  68831. * should the anchor system use plane detection.
  68832. * If set to true, the plane-detection feature should be set using setPlaneDetector
  68833. */
  68834. usePlaneDetection?: boolean;
  68835. /**
  68836. * Should a new anchor be added every time a select event is triggered
  68837. */
  68838. addAnchorOnSelect?: boolean;
  68839. }
  68840. /**
  68841. * A babylon container for an XR Anchor
  68842. */
  68843. export interface IWebXRAnchor {
  68844. /**
  68845. * A babylon-assigned ID for this anchor
  68846. */
  68847. id: number;
  68848. /**
  68849. * The native anchor object
  68850. */
  68851. xrAnchor: XRAnchor;
  68852. /**
  68853. * Transformation matrix to apply to an object attached to this anchor
  68854. */
  68855. transformationMatrix: Matrix;
  68856. }
  68857. /**
  68858. * An implementation of the anchor system of WebXR.
  68859. * Note that the current documented implementation is not available in any browser. Future implementations
  68860. * will use the frame to create an anchor and not the session or a detected plane
  68861. * For further information see https://github.com/immersive-web/anchors/
  68862. */
  68863. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  68864. private _options;
  68865. /**
  68866. * The module's name
  68867. */
  68868. static readonly Name: string;
  68869. /**
  68870. * The (Babylon) version of this module.
  68871. * This is an integer representing the implementation version.
  68872. * This number does not correspond to the webxr specs version
  68873. */
  68874. static readonly Version: number;
  68875. /**
  68876. * Observers registered here will be executed when a new anchor was added to the session
  68877. */
  68878. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  68879. /**
  68880. * Observers registered here will be executed when an existing anchor updates
  68881. * This can execute N times every frame
  68882. */
  68883. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  68884. /**
  68885. * Observers registered here will be executed when an anchor was removed from the session
  68886. */
  68887. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  68888. private _planeDetector;
  68889. private _hitTestModule;
  68890. private _enabled;
  68891. private _trackedAnchors;
  68892. private _lastFrameDetected;
  68893. /**
  68894. * constructs a new anchor system
  68895. * @param _xrSessionManager an instance of WebXRSessionManager
  68896. * @param _options configuration object for this feature
  68897. */
  68898. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  68899. /**
  68900. * set the plane detector to use in order to create anchors from frames
  68901. * @param planeDetector the plane-detector module to use
  68902. * @param enable enable plane-anchors. default is true
  68903. */
  68904. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  68905. /**
  68906. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  68907. * @param hitTestModule the hit-test module to use.
  68908. */
  68909. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  68910. /**
  68911. * attach this feature
  68912. * Will usually be called by the features manager
  68913. *
  68914. * @returns true if successful.
  68915. */
  68916. attach(): boolean;
  68917. /**
  68918. * detach this feature.
  68919. * Will usually be called by the features manager
  68920. *
  68921. * @returns true if successful.
  68922. */
  68923. detach(): boolean;
  68924. /**
  68925. * Dispose this feature and all of the resources attached
  68926. */
  68927. dispose(): void;
  68928. protected _onXRFrame(frame: XRFrame): void;
  68929. private _onSelect;
  68930. /**
  68931. * Add anchor at a specific XR point.
  68932. *
  68933. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  68934. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  68935. * @returns a promise the fulfills when the anchor was created
  68936. */
  68937. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  68938. private _updateAnchorWithXRFrame;
  68939. /**
  68940. * avoiding using Array.find for global support.
  68941. * @param xrAnchor the plane to find in the array
  68942. */
  68943. private _findIndexInAnchorArray;
  68944. }
  68945. }
  68946. declare module BABYLON {
  68947. /**
  68948. * Options interface for the background remover plugin
  68949. */
  68950. export interface IWebXRBackgroundRemoverOptions {
  68951. /**
  68952. * don't disable the environment helper
  68953. */
  68954. ignoreEnvironmentHelper?: boolean;
  68955. /**
  68956. * flags to configure the removal of the environment helper.
  68957. * If not set, the entire background will be removed. If set, flags should be set as well.
  68958. */
  68959. environmentHelperRemovalFlags?: {
  68960. /**
  68961. * Should the skybox be removed (default false)
  68962. */
  68963. skyBox?: boolean;
  68964. /**
  68965. * Should the ground be removed (default false)
  68966. */
  68967. ground?: boolean;
  68968. };
  68969. /**
  68970. * Further background meshes to disable when entering AR
  68971. */
  68972. backgroundMeshes?: AbstractMesh[];
  68973. }
  68974. /**
  68975. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  68976. */
  68977. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  68978. /**
  68979. * read-only options to be used in this module
  68980. */
  68981. readonly options: IWebXRBackgroundRemoverOptions;
  68982. /**
  68983. * The module's name
  68984. */
  68985. static readonly Name: string;
  68986. /**
  68987. * The (Babylon) version of this module.
  68988. * This is an integer representing the implementation version.
  68989. * This number does not correspond to the webxr specs version
  68990. */
  68991. static readonly Version: number;
  68992. /**
  68993. * registered observers will be triggered when the background state changes
  68994. */
  68995. onBackgroundStateChangedObservable: Observable<boolean>;
  68996. /**
  68997. * constructs a new background remover module
  68998. * @param _xrSessionManager the session manager for this module
  68999. * @param options read-only options to be used in this module
  69000. */
  69001. constructor(_xrSessionManager: WebXRSessionManager,
  69002. /**
  69003. * read-only options to be used in this module
  69004. */
  69005. options?: IWebXRBackgroundRemoverOptions);
  69006. /**
  69007. * attach this feature
  69008. * Will usually be called by the features manager
  69009. *
  69010. * @returns true if successful.
  69011. */
  69012. attach(): boolean;
  69013. /**
  69014. * detach this feature.
  69015. * Will usually be called by the features manager
  69016. *
  69017. * @returns true if successful.
  69018. */
  69019. detach(): boolean;
  69020. private _setBackgroundState;
  69021. /**
  69022. * Dispose this feature and all of the resources attached
  69023. */
  69024. dispose(): void;
  69025. protected _onXRFrame(_xrFrame: XRFrame): void;
  69026. }
  69027. }
  69028. declare module BABYLON {
  69029. /**
  69030. * Options for the controller physics feature
  69031. */
  69032. export class IWebXRControllerPhysicsOptions {
  69033. /**
  69034. * the xr input to use with this pointer selection
  69035. */
  69036. xrInput: WebXRInput;
  69037. /**
  69038. * The physics properties of the future impostors
  69039. */
  69040. physicsProperties?: {
  69041. /**
  69042. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  69043. * Note that this requires a physics engine that supports mesh impostors!
  69044. */
  69045. useControllerMesh?: boolean;
  69046. /**
  69047. * The type of impostor to create. Default is sphere
  69048. */
  69049. impostorType?: number;
  69050. /**
  69051. * the size of the impostor. Defaults to 10cm
  69052. */
  69053. impostorSize?: number | {
  69054. width: number;
  69055. height: number;
  69056. depth: number;
  69057. };
  69058. /**
  69059. * Friction definitions
  69060. */
  69061. friction?: number;
  69062. /**
  69063. * Restitution
  69064. */
  69065. restitution?: number;
  69066. };
  69067. }
  69068. /**
  69069. * Add physics impostor to your webxr controllers,
  69070. * including naive calculation of their linear and angular velocity
  69071. */
  69072. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  69073. private readonly _options;
  69074. /**
  69075. * The module's name
  69076. */
  69077. static readonly Name: string;
  69078. /**
  69079. * The (Babylon) version of this module.
  69080. * This is an integer representing the implementation version.
  69081. * This number does not correspond to the webxr specs version
  69082. */
  69083. static readonly Version: number;
  69084. private _lastTimestamp;
  69085. private _delta;
  69086. private _controllers;
  69087. private _tmpVector;
  69088. private _tmpQuaternion;
  69089. /**
  69090. * Construct a new Controller Physics Feature
  69091. * @param _xrSessionManager the corresponding xr session manager
  69092. * @param _options options to create this feature with
  69093. */
  69094. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  69095. /**
  69096. * Update the physics properties provided in the constructor
  69097. * @param newProperties the new properties object
  69098. */
  69099. setPhysicsProperties(newProperties: {
  69100. impostorType?: number;
  69101. impostorSize?: number | {
  69102. width: number;
  69103. height: number;
  69104. depth: number;
  69105. };
  69106. friction?: number;
  69107. restitution?: number;
  69108. }): void;
  69109. /**
  69110. * attach this feature
  69111. * Will usually be called by the features manager
  69112. *
  69113. * @returns true if successful.
  69114. */
  69115. attach(): boolean;
  69116. /**
  69117. * detach this feature.
  69118. * Will usually be called by the features manager
  69119. *
  69120. * @returns true if successful.
  69121. */
  69122. detach(): boolean;
  69123. /**
  69124. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  69125. * @param xrController the controller to add
  69126. */
  69127. addController(xrController: WebXRInputSource): void;
  69128. private _debugMode;
  69129. /**
  69130. * @hidden
  69131. * enable debugging - will show console outputs and the impostor mesh
  69132. */
  69133. _enablePhysicsDebug(): void;
  69134. private _attachController;
  69135. private _detachController;
  69136. protected _onXRFrame(_xrFrame: any): void;
  69137. }
  69138. }
  69139. declare module BABYLON {
  69140. /**
  69141. * The motion controller class for all microsoft mixed reality controllers
  69142. */
  69143. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  69144. /**
  69145. * The base url used to load the left and right controller models
  69146. */
  69147. static MODEL_BASE_URL: string;
  69148. /**
  69149. * The name of the left controller model file
  69150. */
  69151. static MODEL_LEFT_FILENAME: string;
  69152. /**
  69153. * The name of the right controller model file
  69154. */
  69155. static MODEL_RIGHT_FILENAME: string;
  69156. profileId: string;
  69157. protected readonly _mapping: {
  69158. defaultButton: {
  69159. "valueNodeName": string;
  69160. "unpressedNodeName": string;
  69161. "pressedNodeName": string;
  69162. };
  69163. defaultAxis: {
  69164. "valueNodeName": string;
  69165. "minNodeName": string;
  69166. "maxNodeName": string;
  69167. };
  69168. buttons: {
  69169. "xr-standard-trigger": {
  69170. "rootNodeName": string;
  69171. "componentProperty": string;
  69172. "states": string[];
  69173. };
  69174. "xr-standard-squeeze": {
  69175. "rootNodeName": string;
  69176. "componentProperty": string;
  69177. "states": string[];
  69178. };
  69179. "xr-standard-touchpad": {
  69180. "rootNodeName": string;
  69181. "labelAnchorNodeName": string;
  69182. "touchPointNodeName": string;
  69183. };
  69184. "xr-standard-thumbstick": {
  69185. "rootNodeName": string;
  69186. "componentProperty": string;
  69187. "states": string[];
  69188. };
  69189. };
  69190. axes: {
  69191. "xr-standard-touchpad": {
  69192. "x-axis": {
  69193. "rootNodeName": string;
  69194. };
  69195. "y-axis": {
  69196. "rootNodeName": string;
  69197. };
  69198. };
  69199. "xr-standard-thumbstick": {
  69200. "x-axis": {
  69201. "rootNodeName": string;
  69202. };
  69203. "y-axis": {
  69204. "rootNodeName": string;
  69205. };
  69206. };
  69207. };
  69208. };
  69209. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  69210. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  69211. protected _getFilenameAndPath(): {
  69212. filename: string;
  69213. path: string;
  69214. };
  69215. protected _updateModel(): void;
  69216. protected _getModelLoadingConstraints(): boolean;
  69217. protected _setRootMesh(meshes: AbstractMesh[]): void;
  69218. }
  69219. }
  69220. declare module BABYLON {
  69221. /**
  69222. * The motion controller class for oculus touch (quest, rift).
  69223. * This class supports legacy mapping as well the standard xr mapping
  69224. */
  69225. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  69226. private _forceLegacyControllers;
  69227. /**
  69228. * The base url used to load the left and right controller models
  69229. */
  69230. static MODEL_BASE_URL: string;
  69231. /**
  69232. * The name of the left controller model file
  69233. */
  69234. static MODEL_LEFT_FILENAME: string;
  69235. /**
  69236. * The name of the right controller model file
  69237. */
  69238. static MODEL_RIGHT_FILENAME: string;
  69239. /**
  69240. * Base Url for the Quest controller model.
  69241. */
  69242. static QUEST_MODEL_BASE_URL: string;
  69243. profileId: string;
  69244. private _modelRootNode;
  69245. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  69246. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  69247. protected _getFilenameAndPath(): {
  69248. filename: string;
  69249. path: string;
  69250. };
  69251. /**
  69252. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  69253. * between the touch and touch 2.
  69254. */
  69255. private _isQuest;
  69256. protected _updateModel(): void;
  69257. protected _getModelLoadingConstraints(): boolean;
  69258. protected _setRootMesh(meshes: AbstractMesh[]): void;
  69259. }
  69260. }
  69261. declare module BABYLON {
  69262. /**
  69263. * The motion controller class for the standard HTC-Vive controllers
  69264. */
  69265. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  69266. /**
  69267. * The base url used to load the left and right controller models
  69268. */
  69269. static MODEL_BASE_URL: string;
  69270. /**
  69271. * File name for the controller model.
  69272. */
  69273. static MODEL_FILENAME: string;
  69274. profileId: string;
  69275. private _modelRootNode;
  69276. /**
  69277. * Create a new Vive motion controller object
  69278. * @param scene the scene to use to create this controller
  69279. * @param gamepadObject the corresponding gamepad object
  69280. * @param handness the handness of the controller
  69281. */
  69282. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  69283. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  69284. protected _getFilenameAndPath(): {
  69285. filename: string;
  69286. path: string;
  69287. };
  69288. protected _updateModel(): void;
  69289. protected _getModelLoadingConstraints(): boolean;
  69290. protected _setRootMesh(meshes: AbstractMesh[]): void;
  69291. }
  69292. }
  69293. declare module BABYLON {
  69294. /**
  69295. * A cursor which tracks a point on a path
  69296. */
  69297. export class PathCursor {
  69298. private path;
  69299. /**
  69300. * Stores path cursor callbacks for when an onchange event is triggered
  69301. */
  69302. private _onchange;
  69303. /**
  69304. * The value of the path cursor
  69305. */
  69306. value: number;
  69307. /**
  69308. * The animation array of the path cursor
  69309. */
  69310. animations: Animation[];
  69311. /**
  69312. * Initializes the path cursor
  69313. * @param path The path to track
  69314. */
  69315. constructor(path: Path2);
  69316. /**
  69317. * Gets the cursor point on the path
  69318. * @returns A point on the path cursor at the cursor location
  69319. */
  69320. getPoint(): Vector3;
  69321. /**
  69322. * Moves the cursor ahead by the step amount
  69323. * @param step The amount to move the cursor forward
  69324. * @returns This path cursor
  69325. */
  69326. moveAhead(step?: number): PathCursor;
  69327. /**
  69328. * Moves the cursor behind by the step amount
  69329. * @param step The amount to move the cursor back
  69330. * @returns This path cursor
  69331. */
  69332. moveBack(step?: number): PathCursor;
  69333. /**
  69334. * Moves the cursor by the step amount
  69335. * If the step amount is greater than one, an exception is thrown
  69336. * @param step The amount to move the cursor
  69337. * @returns This path cursor
  69338. */
  69339. move(step: number): PathCursor;
  69340. /**
  69341. * Ensures that the value is limited between zero and one
  69342. * @returns This path cursor
  69343. */
  69344. private ensureLimits;
  69345. /**
  69346. * Runs onchange callbacks on change (used by the animation engine)
  69347. * @returns This path cursor
  69348. */
  69349. private raiseOnChange;
  69350. /**
  69351. * Executes a function on change
  69352. * @param f A path cursor onchange callback
  69353. * @returns This path cursor
  69354. */
  69355. onchange(f: (cursor: PathCursor) => void): PathCursor;
  69356. }
  69357. }
  69358. declare module BABYLON {
  69359. /** @hidden */
  69360. export var blurPixelShader: {
  69361. name: string;
  69362. shader: string;
  69363. };
  69364. }
  69365. declare module BABYLON {
  69366. /** @hidden */
  69367. export var pointCloudVertexDeclaration: {
  69368. name: string;
  69369. shader: string;
  69370. };
  69371. }
  69372. // Mixins
  69373. interface Window {
  69374. mozIndexedDB: IDBFactory;
  69375. webkitIndexedDB: IDBFactory;
  69376. msIndexedDB: IDBFactory;
  69377. webkitURL: typeof URL;
  69378. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  69379. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  69380. WebGLRenderingContext: WebGLRenderingContext;
  69381. MSGesture: MSGesture;
  69382. CANNON: any;
  69383. AudioContext: AudioContext;
  69384. webkitAudioContext: AudioContext;
  69385. PointerEvent: any;
  69386. Math: Math;
  69387. Uint8Array: Uint8ArrayConstructor;
  69388. Float32Array: Float32ArrayConstructor;
  69389. mozURL: typeof URL;
  69390. msURL: typeof URL;
  69391. VRFrameData: any; // WebVR, from specs 1.1
  69392. DracoDecoderModule: any;
  69393. setImmediate(handler: (...args: any[]) => void): number;
  69394. }
  69395. interface HTMLCanvasElement {
  69396. requestPointerLock(): void;
  69397. msRequestPointerLock?(): void;
  69398. mozRequestPointerLock?(): void;
  69399. webkitRequestPointerLock?(): void;
  69400. /** Track wether a record is in progress */
  69401. isRecording: boolean;
  69402. /** Capture Stream method defined by some browsers */
  69403. captureStream(fps?: number): MediaStream;
  69404. }
  69405. interface CanvasRenderingContext2D {
  69406. msImageSmoothingEnabled: boolean;
  69407. }
  69408. interface MouseEvent {
  69409. mozMovementX: number;
  69410. mozMovementY: number;
  69411. webkitMovementX: number;
  69412. webkitMovementY: number;
  69413. msMovementX: number;
  69414. msMovementY: number;
  69415. }
  69416. interface Navigator {
  69417. mozGetVRDevices: (any: any) => any;
  69418. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  69419. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  69420. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  69421. webkitGetGamepads(): Gamepad[];
  69422. msGetGamepads(): Gamepad[];
  69423. webkitGamepads(): Gamepad[];
  69424. }
  69425. interface HTMLVideoElement {
  69426. mozSrcObject: any;
  69427. }
  69428. interface Math {
  69429. fround(x: number): number;
  69430. imul(a: number, b: number): number;
  69431. }
  69432. interface WebGLRenderingContext {
  69433. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  69434. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  69435. vertexAttribDivisor(index: number, divisor: number): void;
  69436. createVertexArray(): any;
  69437. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  69438. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  69439. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  69440. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  69441. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  69442. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  69443. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  69444. // Queries
  69445. createQuery(): WebGLQuery;
  69446. deleteQuery(query: WebGLQuery): void;
  69447. beginQuery(target: number, query: WebGLQuery): void;
  69448. endQuery(target: number): void;
  69449. getQueryParameter(query: WebGLQuery, pname: number): any;
  69450. getQuery(target: number, pname: number): any;
  69451. MAX_SAMPLES: number;
  69452. RGBA8: number;
  69453. READ_FRAMEBUFFER: number;
  69454. DRAW_FRAMEBUFFER: number;
  69455. UNIFORM_BUFFER: number;
  69456. HALF_FLOAT_OES: number;
  69457. RGBA16F: number;
  69458. RGBA32F: number;
  69459. R32F: number;
  69460. RG32F: number;
  69461. RGB32F: number;
  69462. R16F: number;
  69463. RG16F: number;
  69464. RGB16F: number;
  69465. RED: number;
  69466. RG: number;
  69467. R8: number;
  69468. RG8: number;
  69469. UNSIGNED_INT_24_8: number;
  69470. DEPTH24_STENCIL8: number;
  69471. MIN: number;
  69472. MAX: number;
  69473. /* Multiple Render Targets */
  69474. drawBuffers(buffers: number[]): void;
  69475. readBuffer(src: number): void;
  69476. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  69477. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  69478. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  69479. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  69480. // Occlusion Query
  69481. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  69482. ANY_SAMPLES_PASSED: number;
  69483. QUERY_RESULT_AVAILABLE: number;
  69484. QUERY_RESULT: number;
  69485. }
  69486. interface WebGLProgram {
  69487. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  69488. }
  69489. interface EXT_disjoint_timer_query {
  69490. QUERY_COUNTER_BITS_EXT: number;
  69491. TIME_ELAPSED_EXT: number;
  69492. TIMESTAMP_EXT: number;
  69493. GPU_DISJOINT_EXT: number;
  69494. QUERY_RESULT_EXT: number;
  69495. QUERY_RESULT_AVAILABLE_EXT: number;
  69496. queryCounterEXT(query: WebGLQuery, target: number): void;
  69497. createQueryEXT(): WebGLQuery;
  69498. beginQueryEXT(target: number, query: WebGLQuery): void;
  69499. endQueryEXT(target: number): void;
  69500. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  69501. deleteQueryEXT(query: WebGLQuery): void;
  69502. }
  69503. interface WebGLUniformLocation {
  69504. _currentState: any;
  69505. }
  69506. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  69507. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  69508. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  69509. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  69510. interface WebGLRenderingContext {
  69511. readonly RASTERIZER_DISCARD: number;
  69512. readonly DEPTH_COMPONENT24: number;
  69513. readonly TEXTURE_3D: number;
  69514. readonly TEXTURE_2D_ARRAY: number;
  69515. readonly TEXTURE_COMPARE_FUNC: number;
  69516. readonly TEXTURE_COMPARE_MODE: number;
  69517. readonly COMPARE_REF_TO_TEXTURE: number;
  69518. readonly TEXTURE_WRAP_R: number;
  69519. readonly HALF_FLOAT: number;
  69520. readonly RGB8: number;
  69521. readonly RED_INTEGER: number;
  69522. readonly RG_INTEGER: number;
  69523. readonly RGB_INTEGER: number;
  69524. readonly RGBA_INTEGER: number;
  69525. readonly R8_SNORM: number;
  69526. readonly RG8_SNORM: number;
  69527. readonly RGB8_SNORM: number;
  69528. readonly RGBA8_SNORM: number;
  69529. readonly R8I: number;
  69530. readonly RG8I: number;
  69531. readonly RGB8I: number;
  69532. readonly RGBA8I: number;
  69533. readonly R8UI: number;
  69534. readonly RG8UI: number;
  69535. readonly RGB8UI: number;
  69536. readonly RGBA8UI: number;
  69537. readonly R16I: number;
  69538. readonly RG16I: number;
  69539. readonly RGB16I: number;
  69540. readonly RGBA16I: number;
  69541. readonly R16UI: number;
  69542. readonly RG16UI: number;
  69543. readonly RGB16UI: number;
  69544. readonly RGBA16UI: number;
  69545. readonly R32I: number;
  69546. readonly RG32I: number;
  69547. readonly RGB32I: number;
  69548. readonly RGBA32I: number;
  69549. readonly R32UI: number;
  69550. readonly RG32UI: number;
  69551. readonly RGB32UI: number;
  69552. readonly RGBA32UI: number;
  69553. readonly RGB10_A2UI: number;
  69554. readonly R11F_G11F_B10F: number;
  69555. readonly RGB9_E5: number;
  69556. readonly RGB10_A2: number;
  69557. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  69558. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  69559. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  69560. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  69561. readonly DEPTH_COMPONENT32F: number;
  69562. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  69563. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  69564. 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;
  69565. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  69566. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  69567. readonly TRANSFORM_FEEDBACK: number;
  69568. readonly INTERLEAVED_ATTRIBS: number;
  69569. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  69570. createTransformFeedback(): WebGLTransformFeedback;
  69571. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  69572. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  69573. beginTransformFeedback(primitiveMode: number): void;
  69574. endTransformFeedback(): void;
  69575. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  69576. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  69577. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  69578. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  69579. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  69580. }
  69581. interface ImageBitmap {
  69582. readonly width: number;
  69583. readonly height: number;
  69584. close(): void;
  69585. }
  69586. interface WebGLQuery extends WebGLObject {
  69587. }
  69588. declare var WebGLQuery: {
  69589. prototype: WebGLQuery;
  69590. new(): WebGLQuery;
  69591. };
  69592. interface WebGLSampler extends WebGLObject {
  69593. }
  69594. declare var WebGLSampler: {
  69595. prototype: WebGLSampler;
  69596. new(): WebGLSampler;
  69597. };
  69598. interface WebGLSync extends WebGLObject {
  69599. }
  69600. declare var WebGLSync: {
  69601. prototype: WebGLSync;
  69602. new(): WebGLSync;
  69603. };
  69604. interface WebGLTransformFeedback extends WebGLObject {
  69605. }
  69606. declare var WebGLTransformFeedback: {
  69607. prototype: WebGLTransformFeedback;
  69608. new(): WebGLTransformFeedback;
  69609. };
  69610. interface WebGLVertexArrayObject extends WebGLObject {
  69611. }
  69612. declare var WebGLVertexArrayObject: {
  69613. prototype: WebGLVertexArrayObject;
  69614. new(): WebGLVertexArrayObject;
  69615. };
  69616. // Type definitions for WebVR API
  69617. // Project: https://w3c.github.io/webvr/
  69618. // Definitions by: six a <https://github.com/lostfictions>
  69619. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  69620. interface VRDisplay extends EventTarget {
  69621. /**
  69622. * Dictionary of capabilities describing the VRDisplay.
  69623. */
  69624. readonly capabilities: VRDisplayCapabilities;
  69625. /**
  69626. * z-depth defining the far plane of the eye view frustum
  69627. * enables mapping of values in the render target depth
  69628. * attachment to scene coordinates. Initially set to 10000.0.
  69629. */
  69630. depthFar: number;
  69631. /**
  69632. * z-depth defining the near plane of the eye view frustum
  69633. * enables mapping of values in the render target depth
  69634. * attachment to scene coordinates. Initially set to 0.01.
  69635. */
  69636. depthNear: number;
  69637. /**
  69638. * An identifier for this distinct VRDisplay. Used as an
  69639. * association point in the Gamepad API.
  69640. */
  69641. readonly displayId: number;
  69642. /**
  69643. * A display name, a user-readable name identifying it.
  69644. */
  69645. readonly displayName: string;
  69646. readonly isConnected: boolean;
  69647. readonly isPresenting: boolean;
  69648. /**
  69649. * If this VRDisplay supports room-scale experiences, the optional
  69650. * stage attribute contains details on the room-scale parameters.
  69651. */
  69652. readonly stageParameters: VRStageParameters | null;
  69653. /**
  69654. * Passing the value returned by `requestAnimationFrame` to
  69655. * `cancelAnimationFrame` will unregister the callback.
  69656. * @param handle Define the hanle of the request to cancel
  69657. */
  69658. cancelAnimationFrame(handle: number): void;
  69659. /**
  69660. * Stops presenting to the VRDisplay.
  69661. * @returns a promise to know when it stopped
  69662. */
  69663. exitPresent(): Promise<void>;
  69664. /**
  69665. * Return the current VREyeParameters for the given eye.
  69666. * @param whichEye Define the eye we want the parameter for
  69667. * @returns the eye parameters
  69668. */
  69669. getEyeParameters(whichEye: string): VREyeParameters;
  69670. /**
  69671. * Populates the passed VRFrameData with the information required to render
  69672. * the current frame.
  69673. * @param frameData Define the data structure to populate
  69674. * @returns true if ok otherwise false
  69675. */
  69676. getFrameData(frameData: VRFrameData): boolean;
  69677. /**
  69678. * Get the layers currently being presented.
  69679. * @returns the list of VR layers
  69680. */
  69681. getLayers(): VRLayer[];
  69682. /**
  69683. * Return a VRPose containing the future predicted pose of the VRDisplay
  69684. * when the current frame will be presented. The value returned will not
  69685. * change until JavaScript has returned control to the browser.
  69686. *
  69687. * The VRPose will contain the position, orientation, velocity,
  69688. * and acceleration of each of these properties.
  69689. * @returns the pose object
  69690. */
  69691. getPose(): VRPose;
  69692. /**
  69693. * Return the current instantaneous pose of the VRDisplay, with no
  69694. * prediction applied.
  69695. * @returns the current instantaneous pose
  69696. */
  69697. getImmediatePose(): VRPose;
  69698. /**
  69699. * The callback passed to `requestAnimationFrame` will be called
  69700. * any time a new frame should be rendered. When the VRDisplay is
  69701. * presenting the callback will be called at the native refresh
  69702. * rate of the HMD. When not presenting this function acts
  69703. * identically to how window.requestAnimationFrame acts. Content should
  69704. * make no assumptions of frame rate or vsync behavior as the HMD runs
  69705. * asynchronously from other displays and at differing refresh rates.
  69706. * @param callback Define the eaction to run next frame
  69707. * @returns the request handle it
  69708. */
  69709. requestAnimationFrame(callback: FrameRequestCallback): number;
  69710. /**
  69711. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  69712. * Repeat calls while already presenting will update the VRLayers being displayed.
  69713. * @param layers Define the list of layer to present
  69714. * @returns a promise to know when the request has been fulfilled
  69715. */
  69716. requestPresent(layers: VRLayer[]): Promise<void>;
  69717. /**
  69718. * Reset the pose for this display, treating its current position and
  69719. * orientation as the "origin/zero" values. VRPose.position,
  69720. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  69721. * updated when calling resetPose(). This should be called in only
  69722. * sitting-space experiences.
  69723. */
  69724. resetPose(): void;
  69725. /**
  69726. * The VRLayer provided to the VRDisplay will be captured and presented
  69727. * in the HMD. Calling this function has the same effect on the source
  69728. * canvas as any other operation that uses its source image, and canvases
  69729. * created without preserveDrawingBuffer set to true will be cleared.
  69730. * @param pose Define the pose to submit
  69731. */
  69732. submitFrame(pose?: VRPose): void;
  69733. }
  69734. declare var VRDisplay: {
  69735. prototype: VRDisplay;
  69736. new(): VRDisplay;
  69737. };
  69738. interface VRLayer {
  69739. leftBounds?: number[] | Float32Array | null;
  69740. rightBounds?: number[] | Float32Array | null;
  69741. source?: HTMLCanvasElement | null;
  69742. }
  69743. interface VRDisplayCapabilities {
  69744. readonly canPresent: boolean;
  69745. readonly hasExternalDisplay: boolean;
  69746. readonly hasOrientation: boolean;
  69747. readonly hasPosition: boolean;
  69748. readonly maxLayers: number;
  69749. }
  69750. interface VREyeParameters {
  69751. /** @deprecated */
  69752. readonly fieldOfView: VRFieldOfView;
  69753. readonly offset: Float32Array;
  69754. readonly renderHeight: number;
  69755. readonly renderWidth: number;
  69756. }
  69757. interface VRFieldOfView {
  69758. readonly downDegrees: number;
  69759. readonly leftDegrees: number;
  69760. readonly rightDegrees: number;
  69761. readonly upDegrees: number;
  69762. }
  69763. interface VRFrameData {
  69764. readonly leftProjectionMatrix: Float32Array;
  69765. readonly leftViewMatrix: Float32Array;
  69766. readonly pose: VRPose;
  69767. readonly rightProjectionMatrix: Float32Array;
  69768. readonly rightViewMatrix: Float32Array;
  69769. readonly timestamp: number;
  69770. }
  69771. interface VRPose {
  69772. readonly angularAcceleration: Float32Array | null;
  69773. readonly angularVelocity: Float32Array | null;
  69774. readonly linearAcceleration: Float32Array | null;
  69775. readonly linearVelocity: Float32Array | null;
  69776. readonly orientation: Float32Array | null;
  69777. readonly position: Float32Array | null;
  69778. readonly timestamp: number;
  69779. }
  69780. interface VRStageParameters {
  69781. sittingToStandingTransform?: Float32Array;
  69782. sizeX?: number;
  69783. sizeY?: number;
  69784. }
  69785. interface Navigator {
  69786. getVRDisplays(): Promise<VRDisplay[]>;
  69787. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  69788. }
  69789. interface Window {
  69790. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  69791. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  69792. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  69793. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  69794. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  69795. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  69796. }
  69797. interface Gamepad {
  69798. readonly displayId: number;
  69799. }
  69800. type XRSessionMode =
  69801. | "inline"
  69802. | "immersive-vr"
  69803. | "immersive-ar";
  69804. type XRReferenceSpaceType =
  69805. | "viewer"
  69806. | "local"
  69807. | "local-floor"
  69808. | "bounded-floor"
  69809. | "unbounded";
  69810. type XREnvironmentBlendMode =
  69811. | "opaque"
  69812. | "additive"
  69813. | "alpha-blend";
  69814. type XRVisibilityState =
  69815. | "visible"
  69816. | "visible-blurred"
  69817. | "hidden";
  69818. type XRHandedness =
  69819. | "none"
  69820. | "left"
  69821. | "right";
  69822. type XRTargetRayMode =
  69823. | "gaze"
  69824. | "tracked-pointer"
  69825. | "screen";
  69826. type XREye =
  69827. | "none"
  69828. | "left"
  69829. | "right";
  69830. interface XRSpace extends EventTarget {
  69831. }
  69832. interface XRRenderState {
  69833. depthNear?: number;
  69834. depthFar?: number;
  69835. inlineVerticalFieldOfView?: number;
  69836. baseLayer?: XRWebGLLayer;
  69837. }
  69838. interface XRInputSource {
  69839. handedness: XRHandedness;
  69840. targetRayMode: XRTargetRayMode;
  69841. targetRaySpace: XRSpace;
  69842. gripSpace: XRSpace | undefined;
  69843. gamepad: Gamepad | undefined;
  69844. profiles: Array<string>;
  69845. }
  69846. interface XRSessionInit {
  69847. optionalFeatures?: XRReferenceSpaceType[];
  69848. requiredFeatures?: XRReferenceSpaceType[];
  69849. }
  69850. interface XRSession extends XRAnchorCreator {
  69851. addEventListener: Function;
  69852. removeEventListener: Function;
  69853. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  69854. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  69855. requestAnimationFrame: Function;
  69856. end(): Promise<void>;
  69857. renderState: XRRenderState;
  69858. inputSources: Array<XRInputSource>;
  69859. // AR hit test
  69860. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  69861. updateWorldTrackingState(options: {
  69862. planeDetectionState?: { enabled: boolean; }
  69863. }): void;
  69864. }
  69865. interface XRReferenceSpace extends XRSpace {
  69866. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  69867. onreset: any;
  69868. }
  69869. type XRPlaneSet = Set<XRPlane>;
  69870. type XRAnchorSet = Set<XRAnchor>;
  69871. interface XRFrame {
  69872. session: XRSession;
  69873. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  69874. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  69875. // Anchors
  69876. trackedAnchors?: XRAnchorSet;
  69877. // Planes
  69878. worldInformation: {
  69879. detectedPlanes?: XRPlaneSet;
  69880. };
  69881. }
  69882. interface XRViewerPose extends XRPose {
  69883. views: Array<XRView>;
  69884. }
  69885. interface XRPose {
  69886. transform: XRRigidTransform;
  69887. emulatedPosition: boolean;
  69888. }
  69889. interface XRWebGLLayerOptions {
  69890. antialias?: boolean;
  69891. depth?: boolean;
  69892. stencil?: boolean;
  69893. alpha?: boolean;
  69894. multiview?: boolean;
  69895. framebufferScaleFactor?: number;
  69896. }
  69897. declare var XRWebGLLayer: {
  69898. prototype: XRWebGLLayer;
  69899. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  69900. };
  69901. interface XRWebGLLayer {
  69902. framebuffer: WebGLFramebuffer;
  69903. framebufferWidth: number;
  69904. framebufferHeight: number;
  69905. getViewport: Function;
  69906. }
  69907. declare class XRRigidTransform {
  69908. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  69909. position: DOMPointReadOnly;
  69910. orientation: DOMPointReadOnly;
  69911. matrix: Float32Array;
  69912. inverse: XRRigidTransform;
  69913. }
  69914. interface XRView {
  69915. eye: XREye;
  69916. projectionMatrix: Float32Array;
  69917. transform: XRRigidTransform;
  69918. }
  69919. interface XRInputSourceChangeEvent {
  69920. session: XRSession;
  69921. removed: Array<XRInputSource>;
  69922. added: Array<XRInputSource>;
  69923. }
  69924. interface XRInputSourceEvent extends Event {
  69925. readonly frame: XRFrame;
  69926. readonly inputSource: XRInputSource;
  69927. }
  69928. // Experimental(er) features
  69929. declare class XRRay {
  69930. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  69931. origin: DOMPointReadOnly;
  69932. direction: DOMPointReadOnly;
  69933. matrix: Float32Array;
  69934. }
  69935. interface XRHitResult {
  69936. hitMatrix: Float32Array;
  69937. }
  69938. interface XRAnchor {
  69939. // remove?
  69940. id?: string;
  69941. anchorSpace: XRSpace;
  69942. lastChangedTime: number;
  69943. detach(): void;
  69944. }
  69945. interface XRPlane extends XRAnchorCreator {
  69946. orientation: "Horizontal" | "Vertical";
  69947. planeSpace: XRSpace;
  69948. polygon: Array<DOMPointReadOnly>;
  69949. lastChangedTime: number;
  69950. }
  69951. interface XRAnchorCreator {
  69952. // AR Anchors
  69953. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  69954. }
  69955. /**
  69956. * @ignore
  69957. */
  69958. declare module BABYLON.GLTF2.Exporter {
  69959. }
  69960. /**
  69961. * @ignore
  69962. */
  69963. declare module BABYLON.GLTF1 {
  69964. }
  69965. declare module BABYLON.GUI {
  69966. /**
  69967. * Class used to specific a value and its associated unit
  69968. */
  69969. export class ValueAndUnit {
  69970. /** defines the unit to store */
  69971. unit: number;
  69972. /** defines a boolean indicating if the value can be negative */
  69973. negativeValueAllowed: boolean;
  69974. private _value;
  69975. private _originalUnit;
  69976. /**
  69977. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  69978. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  69979. */
  69980. ignoreAdaptiveScaling: boolean;
  69981. /**
  69982. * Creates a new ValueAndUnit
  69983. * @param value defines the value to store
  69984. * @param unit defines the unit to store
  69985. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  69986. */
  69987. constructor(value: number,
  69988. /** defines the unit to store */
  69989. unit?: number,
  69990. /** defines a boolean indicating if the value can be negative */
  69991. negativeValueAllowed?: boolean);
  69992. /** Gets a boolean indicating if the value is a percentage */
  69993. get isPercentage(): boolean;
  69994. /** Gets a boolean indicating if the value is store as pixel */
  69995. get isPixel(): boolean;
  69996. /** Gets direct internal value */
  69997. get internalValue(): number;
  69998. /**
  69999. * Gets value as pixel
  70000. * @param host defines the root host
  70001. * @param refValue defines the reference value for percentages
  70002. * @returns the value as pixel
  70003. */
  70004. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  70005. /**
  70006. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  70007. * @param value defines the value to store
  70008. * @param unit defines the unit to store
  70009. * @returns the current ValueAndUnit
  70010. */
  70011. updateInPlace(value: number, unit?: number): ValueAndUnit;
  70012. /**
  70013. * Gets the value accordingly to its unit
  70014. * @param host defines the root host
  70015. * @returns the value
  70016. */
  70017. getValue(host: AdvancedDynamicTexture): number;
  70018. /**
  70019. * Gets a string representation of the value
  70020. * @param host defines the root host
  70021. * @param decimals defines an optional number of decimals to display
  70022. * @returns a string
  70023. */
  70024. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  70025. /**
  70026. * Store a value parsed from a string
  70027. * @param source defines the source string
  70028. * @returns true if the value was successfully parsed
  70029. */
  70030. fromString(source: string | number): boolean;
  70031. private static _Regex;
  70032. private static _UNITMODE_PERCENTAGE;
  70033. private static _UNITMODE_PIXEL;
  70034. /** UNITMODE_PERCENTAGE */
  70035. static get UNITMODE_PERCENTAGE(): number;
  70036. /** UNITMODE_PIXEL */
  70037. static get UNITMODE_PIXEL(): number;
  70038. }
  70039. }
  70040. declare module BABYLON.GUI {
  70041. /**
  70042. * Define a style used by control to automatically setup properties based on a template.
  70043. * Only support font related properties so far
  70044. */
  70045. export class Style implements BABYLON.IDisposable {
  70046. private _fontFamily;
  70047. private _fontStyle;
  70048. private _fontWeight;
  70049. /** @hidden */
  70050. _host: AdvancedDynamicTexture;
  70051. /** @hidden */
  70052. _fontSize: ValueAndUnit;
  70053. /**
  70054. * BABYLON.Observable raised when the style values are changed
  70055. */
  70056. onChangedObservable: BABYLON.Observable<Style>;
  70057. /**
  70058. * Creates a new style object
  70059. * @param host defines the AdvancedDynamicTexture which hosts this style
  70060. */
  70061. constructor(host: AdvancedDynamicTexture);
  70062. /**
  70063. * Gets or sets the font size
  70064. */
  70065. get fontSize(): string | number;
  70066. set fontSize(value: string | number);
  70067. /**
  70068. * Gets or sets the font family
  70069. */
  70070. get fontFamily(): string;
  70071. set fontFamily(value: string);
  70072. /**
  70073. * Gets or sets the font style
  70074. */
  70075. get fontStyle(): string;
  70076. set fontStyle(value: string);
  70077. /** Gets or sets font weight */
  70078. get fontWeight(): string;
  70079. set fontWeight(value: string);
  70080. /** Dispose all associated resources */
  70081. dispose(): void;
  70082. }
  70083. }
  70084. declare module BABYLON.GUI {
  70085. /**
  70086. * Class used to transport BABYLON.Vector2 information for pointer events
  70087. */
  70088. export class Vector2WithInfo extends BABYLON.Vector2 {
  70089. /** defines the current mouse button index */
  70090. buttonIndex: number;
  70091. /**
  70092. * Creates a new Vector2WithInfo
  70093. * @param source defines the vector2 data to transport
  70094. * @param buttonIndex defines the current mouse button index
  70095. */
  70096. constructor(source: BABYLON.Vector2,
  70097. /** defines the current mouse button index */
  70098. buttonIndex?: number);
  70099. }
  70100. /** Class used to provide 2D matrix features */
  70101. export class Matrix2D {
  70102. /** Gets the internal array of 6 floats used to store matrix data */
  70103. m: Float32Array;
  70104. /**
  70105. * Creates a new matrix
  70106. * @param m00 defines value for (0, 0)
  70107. * @param m01 defines value for (0, 1)
  70108. * @param m10 defines value for (1, 0)
  70109. * @param m11 defines value for (1, 1)
  70110. * @param m20 defines value for (2, 0)
  70111. * @param m21 defines value for (2, 1)
  70112. */
  70113. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  70114. /**
  70115. * Fills the matrix from direct values
  70116. * @param m00 defines value for (0, 0)
  70117. * @param m01 defines value for (0, 1)
  70118. * @param m10 defines value for (1, 0)
  70119. * @param m11 defines value for (1, 1)
  70120. * @param m20 defines value for (2, 0)
  70121. * @param m21 defines value for (2, 1)
  70122. * @returns the current modified matrix
  70123. */
  70124. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  70125. /**
  70126. * Gets matrix determinant
  70127. * @returns the determinant
  70128. */
  70129. determinant(): number;
  70130. /**
  70131. * Inverses the matrix and stores it in a target matrix
  70132. * @param result defines the target matrix
  70133. * @returns the current matrix
  70134. */
  70135. invertToRef(result: Matrix2D): Matrix2D;
  70136. /**
  70137. * Multiplies the current matrix with another one
  70138. * @param other defines the second operand
  70139. * @param result defines the target matrix
  70140. * @returns the current matrix
  70141. */
  70142. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  70143. /**
  70144. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  70145. * @param x defines the x coordinate to transform
  70146. * @param y defines the x coordinate to transform
  70147. * @param result defines the target vector2
  70148. * @returns the current matrix
  70149. */
  70150. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  70151. /**
  70152. * Creates an identity matrix
  70153. * @returns a new matrix
  70154. */
  70155. static Identity(): Matrix2D;
  70156. /**
  70157. * Creates a translation matrix and stores it in a target matrix
  70158. * @param x defines the x coordinate of the translation
  70159. * @param y defines the y coordinate of the translation
  70160. * @param result defines the target matrix
  70161. */
  70162. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  70163. /**
  70164. * Creates a scaling matrix and stores it in a target matrix
  70165. * @param x defines the x coordinate of the scaling
  70166. * @param y defines the y coordinate of the scaling
  70167. * @param result defines the target matrix
  70168. */
  70169. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  70170. /**
  70171. * Creates a rotation matrix and stores it in a target matrix
  70172. * @param angle defines the rotation angle
  70173. * @param result defines the target matrix
  70174. */
  70175. static RotationToRef(angle: number, result: Matrix2D): void;
  70176. private static _TempPreTranslationMatrix;
  70177. private static _TempPostTranslationMatrix;
  70178. private static _TempRotationMatrix;
  70179. private static _TempScalingMatrix;
  70180. private static _TempCompose0;
  70181. private static _TempCompose1;
  70182. private static _TempCompose2;
  70183. /**
  70184. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  70185. * @param tx defines the x coordinate of the translation
  70186. * @param ty defines the y coordinate of the translation
  70187. * @param angle defines the rotation angle
  70188. * @param scaleX defines the x coordinate of the scaling
  70189. * @param scaleY defines the y coordinate of the scaling
  70190. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  70191. * @param result defines the target matrix
  70192. */
  70193. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  70194. }
  70195. }
  70196. declare module BABYLON.GUI {
  70197. /**
  70198. * Class used to store 2D control sizes
  70199. */
  70200. export class Measure {
  70201. /** defines left coordinate */
  70202. left: number;
  70203. /** defines top coordinate */
  70204. top: number;
  70205. /** defines width dimension */
  70206. width: number;
  70207. /** defines height dimension */
  70208. height: number;
  70209. /**
  70210. * Creates a new measure
  70211. * @param left defines left coordinate
  70212. * @param top defines top coordinate
  70213. * @param width defines width dimension
  70214. * @param height defines height dimension
  70215. */
  70216. constructor(
  70217. /** defines left coordinate */
  70218. left: number,
  70219. /** defines top coordinate */
  70220. top: number,
  70221. /** defines width dimension */
  70222. width: number,
  70223. /** defines height dimension */
  70224. height: number);
  70225. /**
  70226. * Copy from another measure
  70227. * @param other defines the other measure to copy from
  70228. */
  70229. copyFrom(other: Measure): void;
  70230. /**
  70231. * Copy from a group of 4 floats
  70232. * @param left defines left coordinate
  70233. * @param top defines top coordinate
  70234. * @param width defines width dimension
  70235. * @param height defines height dimension
  70236. */
  70237. copyFromFloats(left: number, top: number, width: number, height: number): void;
  70238. /**
  70239. * Computes the axis aligned bounding box measure for two given measures
  70240. * @param a Input measure
  70241. * @param b Input measure
  70242. * @param result the resulting bounding measure
  70243. */
  70244. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  70245. /**
  70246. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  70247. * @param transform the matrix to transform the measure before computing the AABB
  70248. * @param result the resulting AABB
  70249. */
  70250. transformToRef(transform: Matrix2D, result: Measure): void;
  70251. /**
  70252. * Check equality between this measure and another one
  70253. * @param other defines the other measures
  70254. * @returns true if both measures are equals
  70255. */
  70256. isEqualsTo(other: Measure): boolean;
  70257. /**
  70258. * Creates an empty measure
  70259. * @returns a new measure
  70260. */
  70261. static Empty(): Measure;
  70262. }
  70263. }
  70264. declare module BABYLON.GUI {
  70265. /**
  70266. * Interface used to define a control that can receive focus
  70267. */
  70268. export interface IFocusableControl {
  70269. /**
  70270. * Function called when the control receives the focus
  70271. */
  70272. onFocus(): void;
  70273. /**
  70274. * Function called when the control loses the focus
  70275. */
  70276. onBlur(): void;
  70277. /**
  70278. * Function called to let the control handle keyboard events
  70279. * @param evt defines the current keyboard event
  70280. */
  70281. processKeyboard(evt: KeyboardEvent): void;
  70282. /**
  70283. * Function called to get the list of controls that should not steal the focus from this control
  70284. * @returns an array of controls
  70285. */
  70286. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  70287. }
  70288. /**
  70289. * Class used to create texture to support 2D GUI elements
  70290. * @see http://doc.babylonjs.com/how_to/gui
  70291. */
  70292. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  70293. private _isDirty;
  70294. private _renderObserver;
  70295. private _resizeObserver;
  70296. private _preKeyboardObserver;
  70297. private _pointerMoveObserver;
  70298. private _pointerObserver;
  70299. private _canvasPointerOutObserver;
  70300. private _background;
  70301. /** @hidden */
  70302. _rootContainer: Container;
  70303. /** @hidden */
  70304. _lastPickedControl: Control;
  70305. /** @hidden */
  70306. _lastControlOver: {
  70307. [pointerId: number]: Control;
  70308. };
  70309. /** @hidden */
  70310. _lastControlDown: {
  70311. [pointerId: number]: Control;
  70312. };
  70313. /** @hidden */
  70314. _capturingControl: {
  70315. [pointerId: number]: Control;
  70316. };
  70317. /** @hidden */
  70318. _shouldBlockPointer: boolean;
  70319. /** @hidden */
  70320. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  70321. /** @hidden */
  70322. _linkedControls: Control[];
  70323. private _isFullscreen;
  70324. private _fullscreenViewport;
  70325. private _idealWidth;
  70326. private _idealHeight;
  70327. private _useSmallestIdeal;
  70328. private _renderAtIdealSize;
  70329. private _focusedControl;
  70330. private _blockNextFocusCheck;
  70331. private _renderScale;
  70332. private _rootElement;
  70333. private _cursorChanged;
  70334. /** @hidden */
  70335. _numLayoutCalls: number;
  70336. /** Gets the number of layout calls made the last time the ADT has been rendered */
  70337. get numLayoutCalls(): number;
  70338. /** @hidden */
  70339. _numRenderCalls: number;
  70340. /** Gets the number of render calls made the last time the ADT has been rendered */
  70341. get numRenderCalls(): number;
  70342. /**
  70343. * Define type to string to ensure compatibility across browsers
  70344. * Safari doesn't support DataTransfer constructor
  70345. */
  70346. private _clipboardData;
  70347. /**
  70348. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  70349. */
  70350. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  70351. /**
  70352. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  70353. */
  70354. onControlPickedObservable: BABYLON.Observable<Control>;
  70355. /**
  70356. * BABYLON.Observable event triggered before layout is evaluated
  70357. */
  70358. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  70359. /**
  70360. * BABYLON.Observable event triggered after the layout was evaluated
  70361. */
  70362. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  70363. /**
  70364. * BABYLON.Observable event triggered before the texture is rendered
  70365. */
  70366. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  70367. /**
  70368. * BABYLON.Observable event triggered after the texture was rendered
  70369. */
  70370. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  70371. /**
  70372. * Gets or sets a boolean defining if alpha is stored as premultiplied
  70373. */
  70374. premulAlpha: boolean;
  70375. /**
  70376. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  70377. * Useful when you want more antialiasing
  70378. */
  70379. get renderScale(): number;
  70380. set renderScale(value: number);
  70381. /** Gets or sets the background color */
  70382. get background(): string;
  70383. set background(value: string);
  70384. /**
  70385. * Gets or sets the ideal width used to design controls.
  70386. * The GUI will then rescale everything accordingly
  70387. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70388. */
  70389. get idealWidth(): number;
  70390. set idealWidth(value: number);
  70391. /**
  70392. * Gets or sets the ideal height used to design controls.
  70393. * The GUI will then rescale everything accordingly
  70394. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70395. */
  70396. get idealHeight(): number;
  70397. set idealHeight(value: number);
  70398. /**
  70399. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  70400. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70401. */
  70402. get useSmallestIdeal(): boolean;
  70403. set useSmallestIdeal(value: boolean);
  70404. /**
  70405. * Gets or sets a boolean indicating if adaptive scaling must be used
  70406. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70407. */
  70408. get renderAtIdealSize(): boolean;
  70409. set renderAtIdealSize(value: boolean);
  70410. /**
  70411. * Gets the ratio used when in "ideal mode"
  70412. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  70413. * */
  70414. get idealRatio(): number;
  70415. /**
  70416. * Gets the underlying layer used to render the texture when in fullscreen mode
  70417. */
  70418. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  70419. /**
  70420. * Gets the root container control
  70421. */
  70422. get rootContainer(): Container;
  70423. /**
  70424. * Returns an array containing the root container.
  70425. * This is mostly used to let the Inspector introspects the ADT
  70426. * @returns an array containing the rootContainer
  70427. */
  70428. getChildren(): Array<Container>;
  70429. /**
  70430. * Will return all controls that are inside this texture
  70431. * @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
  70432. * @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
  70433. * @return all child controls
  70434. */
  70435. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  70436. /**
  70437. * Gets or sets the current focused control
  70438. */
  70439. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  70440. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  70441. /**
  70442. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  70443. */
  70444. get isForeground(): boolean;
  70445. set isForeground(value: boolean);
  70446. /**
  70447. * Gets or set information about clipboardData
  70448. */
  70449. get clipboardData(): string;
  70450. set clipboardData(value: string);
  70451. /**
  70452. * Creates a new AdvancedDynamicTexture
  70453. * @param name defines the name of the texture
  70454. * @param width defines the width of the texture
  70455. * @param height defines the height of the texture
  70456. * @param scene defines the hosting scene
  70457. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  70458. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  70459. */
  70460. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  70461. /**
  70462. * Get the current class name of the texture useful for serialization or dynamic coding.
  70463. * @returns "AdvancedDynamicTexture"
  70464. */
  70465. getClassName(): string;
  70466. /**
  70467. * Function used to execute a function on all controls
  70468. * @param func defines the function to execute
  70469. * @param container defines the container where controls belong. If null the root container will be used
  70470. */
  70471. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  70472. private _useInvalidateRectOptimization;
  70473. /**
  70474. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  70475. */
  70476. get useInvalidateRectOptimization(): boolean;
  70477. set useInvalidateRectOptimization(value: boolean);
  70478. private _invalidatedRectangle;
  70479. /**
  70480. * Invalidates a rectangle area on the gui texture
  70481. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  70482. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  70483. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  70484. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  70485. */
  70486. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  70487. /**
  70488. * Marks the texture as dirty forcing a complete update
  70489. */
  70490. markAsDirty(): void;
  70491. /**
  70492. * Helper function used to create a new style
  70493. * @returns a new style
  70494. * @see http://doc.babylonjs.com/how_to/gui#styles
  70495. */
  70496. createStyle(): Style;
  70497. /**
  70498. * Adds a new control to the root container
  70499. * @param control defines the control to add
  70500. * @returns the current texture
  70501. */
  70502. addControl(control: Control): AdvancedDynamicTexture;
  70503. /**
  70504. * Removes a control from the root container
  70505. * @param control defines the control to remove
  70506. * @returns the current texture
  70507. */
  70508. removeControl(control: Control): AdvancedDynamicTexture;
  70509. /**
  70510. * Release all resources
  70511. */
  70512. dispose(): void;
  70513. private _onResize;
  70514. /** @hidden */
  70515. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  70516. /**
  70517. * Get screen coordinates for a vector3
  70518. * @param position defines the position to project
  70519. * @param worldMatrix defines the world matrix to use
  70520. * @returns the projected position
  70521. */
  70522. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  70523. private _checkUpdate;
  70524. private _clearMeasure;
  70525. private _render;
  70526. /** @hidden */
  70527. _changeCursor(cursor: string): void;
  70528. /** @hidden */
  70529. _registerLastControlDown(control: Control, pointerId: number): void;
  70530. private _doPicking;
  70531. /** @hidden */
  70532. _cleanControlAfterRemovalFromList(list: {
  70533. [pointerId: number]: Control;
  70534. }, control: Control): void;
  70535. /** @hidden */
  70536. _cleanControlAfterRemoval(control: Control): void;
  70537. /** Attach to all scene events required to support pointer events */
  70538. attach(): void;
  70539. /** @hidden */
  70540. private onClipboardCopy;
  70541. /** @hidden */
  70542. private onClipboardCut;
  70543. /** @hidden */
  70544. private onClipboardPaste;
  70545. /**
  70546. * Register the clipboard Events onto the canvas
  70547. */
  70548. registerClipboardEvents(): void;
  70549. /**
  70550. * Unregister the clipboard Events from the canvas
  70551. */
  70552. unRegisterClipboardEvents(): void;
  70553. /**
  70554. * Connect the texture to a hosting mesh to enable interactions
  70555. * @param mesh defines the mesh to attach to
  70556. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  70557. */
  70558. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  70559. /**
  70560. * Move the focus to a specific control
  70561. * @param control defines the control which will receive the focus
  70562. */
  70563. moveFocusToControl(control: IFocusableControl): void;
  70564. private _manageFocus;
  70565. private _attachToOnPointerOut;
  70566. /**
  70567. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  70568. * @param mesh defines the mesh which will receive the texture
  70569. * @param width defines the texture width (1024 by default)
  70570. * @param height defines the texture height (1024 by default)
  70571. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  70572. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  70573. * @returns a new AdvancedDynamicTexture
  70574. */
  70575. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  70576. /**
  70577. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  70578. * In this mode the texture will rely on a layer for its rendering.
  70579. * This allows it to be treated like any other layer.
  70580. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  70581. * LayerMask is set through advancedTexture.layer.layerMask
  70582. * @param name defines name for the texture
  70583. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  70584. * @param scene defines the hsoting scene
  70585. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  70586. * @returns a new AdvancedDynamicTexture
  70587. */
  70588. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  70589. }
  70590. }
  70591. declare module BABYLON.GUI {
  70592. /**
  70593. * Root class used for all 2D controls
  70594. * @see http://doc.babylonjs.com/how_to/gui#controls
  70595. */
  70596. export class Control {
  70597. /** defines the name of the control */
  70598. name?: string | undefined;
  70599. /**
  70600. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  70601. */
  70602. static AllowAlphaInheritance: boolean;
  70603. private _alpha;
  70604. private _alphaSet;
  70605. private _zIndex;
  70606. /** @hidden */
  70607. _host: AdvancedDynamicTexture;
  70608. /** Gets or sets the control parent */
  70609. parent: BABYLON.Nullable<Container>;
  70610. /** @hidden */
  70611. _currentMeasure: Measure;
  70612. private _fontFamily;
  70613. private _fontStyle;
  70614. private _fontWeight;
  70615. private _fontSize;
  70616. private _font;
  70617. /** @hidden */
  70618. _width: ValueAndUnit;
  70619. /** @hidden */
  70620. _height: ValueAndUnit;
  70621. /** @hidden */
  70622. protected _fontOffset: {
  70623. ascent: number;
  70624. height: number;
  70625. descent: number;
  70626. };
  70627. private _color;
  70628. private _style;
  70629. private _styleObserver;
  70630. /** @hidden */
  70631. protected _horizontalAlignment: number;
  70632. /** @hidden */
  70633. protected _verticalAlignment: number;
  70634. /** @hidden */
  70635. protected _isDirty: boolean;
  70636. /** @hidden */
  70637. protected _wasDirty: boolean;
  70638. /** @hidden */
  70639. _tempParentMeasure: Measure;
  70640. /** @hidden */
  70641. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  70642. /** @hidden */
  70643. protected _cachedParentMeasure: Measure;
  70644. private _paddingLeft;
  70645. private _paddingRight;
  70646. private _paddingTop;
  70647. private _paddingBottom;
  70648. /** @hidden */
  70649. _left: ValueAndUnit;
  70650. /** @hidden */
  70651. _top: ValueAndUnit;
  70652. private _scaleX;
  70653. private _scaleY;
  70654. private _rotation;
  70655. private _transformCenterX;
  70656. private _transformCenterY;
  70657. /** @hidden */
  70658. _transformMatrix: Matrix2D;
  70659. /** @hidden */
  70660. protected _invertTransformMatrix: Matrix2D;
  70661. /** @hidden */
  70662. protected _transformedPosition: BABYLON.Vector2;
  70663. private _isMatrixDirty;
  70664. private _cachedOffsetX;
  70665. private _cachedOffsetY;
  70666. private _isVisible;
  70667. private _isHighlighted;
  70668. /** @hidden */
  70669. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  70670. private _fontSet;
  70671. private _dummyVector2;
  70672. private _downCount;
  70673. private _enterCount;
  70674. private _doNotRender;
  70675. private _downPointerIds;
  70676. protected _isEnabled: boolean;
  70677. protected _disabledColor: string;
  70678. /** @hidden */
  70679. protected _rebuildLayout: boolean;
  70680. /** @hidden */
  70681. _customData: any;
  70682. /** @hidden */
  70683. _isClipped: boolean;
  70684. /** @hidden */
  70685. _automaticSize: boolean;
  70686. /** @hidden */
  70687. _tag: any;
  70688. /**
  70689. * 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
  70690. */
  70691. uniqueId: number;
  70692. /**
  70693. * Gets or sets an object used to store user defined information for the node
  70694. */
  70695. metadata: any;
  70696. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  70697. isHitTestVisible: boolean;
  70698. /** Gets or sets a boolean indicating if the control can block pointer events */
  70699. isPointerBlocker: boolean;
  70700. /** Gets or sets a boolean indicating if the control can be focusable */
  70701. isFocusInvisible: boolean;
  70702. /**
  70703. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  70704. * 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
  70705. */
  70706. clipChildren: boolean;
  70707. /**
  70708. * Gets or sets a boolean indicating that control content must be clipped
  70709. * 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
  70710. */
  70711. clipContent: boolean;
  70712. /**
  70713. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  70714. */
  70715. useBitmapCache: boolean;
  70716. private _cacheData;
  70717. private _shadowOffsetX;
  70718. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  70719. get shadowOffsetX(): number;
  70720. set shadowOffsetX(value: number);
  70721. private _shadowOffsetY;
  70722. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  70723. get shadowOffsetY(): number;
  70724. set shadowOffsetY(value: number);
  70725. private _shadowBlur;
  70726. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  70727. get shadowBlur(): number;
  70728. set shadowBlur(value: number);
  70729. private _shadowColor;
  70730. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  70731. get shadowColor(): string;
  70732. set shadowColor(value: string);
  70733. /** Gets or sets the cursor to use when the control is hovered */
  70734. hoverCursor: string;
  70735. /** @hidden */
  70736. protected _linkOffsetX: ValueAndUnit;
  70737. /** @hidden */
  70738. protected _linkOffsetY: ValueAndUnit;
  70739. /** Gets the control type name */
  70740. get typeName(): string;
  70741. /**
  70742. * Get the current class name of the control.
  70743. * @returns current class name
  70744. */
  70745. getClassName(): string;
  70746. /**
  70747. * An event triggered when the pointer move over the control.
  70748. */
  70749. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  70750. /**
  70751. * An event triggered when the pointer move out of the control.
  70752. */
  70753. onPointerOutObservable: BABYLON.Observable<Control>;
  70754. /**
  70755. * An event triggered when the pointer taps the control
  70756. */
  70757. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  70758. /**
  70759. * An event triggered when pointer up
  70760. */
  70761. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  70762. /**
  70763. * An event triggered when a control is clicked on
  70764. */
  70765. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  70766. /**
  70767. * An event triggered when pointer enters the control
  70768. */
  70769. onPointerEnterObservable: BABYLON.Observable<Control>;
  70770. /**
  70771. * An event triggered when the control is marked as dirty
  70772. */
  70773. onDirtyObservable: BABYLON.Observable<Control>;
  70774. /**
  70775. * An event triggered before drawing the control
  70776. */
  70777. onBeforeDrawObservable: BABYLON.Observable<Control>;
  70778. /**
  70779. * An event triggered after the control was drawn
  70780. */
  70781. onAfterDrawObservable: BABYLON.Observable<Control>;
  70782. /**
  70783. * Get the hosting AdvancedDynamicTexture
  70784. */
  70785. get host(): AdvancedDynamicTexture;
  70786. /** Gets or set information about font offsets (used to render and align text) */
  70787. get fontOffset(): {
  70788. ascent: number;
  70789. height: number;
  70790. descent: number;
  70791. };
  70792. set fontOffset(offset: {
  70793. ascent: number;
  70794. height: number;
  70795. descent: number;
  70796. });
  70797. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  70798. get alpha(): number;
  70799. set alpha(value: number);
  70800. /**
  70801. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  70802. */
  70803. get isHighlighted(): boolean;
  70804. set isHighlighted(value: boolean);
  70805. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  70806. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70807. */
  70808. get scaleX(): number;
  70809. set scaleX(value: number);
  70810. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  70811. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70812. */
  70813. get scaleY(): number;
  70814. set scaleY(value: number);
  70815. /** Gets or sets the rotation angle (0 by default)
  70816. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70817. */
  70818. get rotation(): number;
  70819. set rotation(value: number);
  70820. /** Gets or sets the transformation center on Y axis (0 by default)
  70821. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70822. */
  70823. get transformCenterY(): number;
  70824. set transformCenterY(value: number);
  70825. /** Gets or sets the transformation center on X axis (0 by default)
  70826. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  70827. */
  70828. get transformCenterX(): number;
  70829. set transformCenterX(value: number);
  70830. /**
  70831. * Gets or sets the horizontal alignment
  70832. * @see http://doc.babylonjs.com/how_to/gui#alignments
  70833. */
  70834. get horizontalAlignment(): number;
  70835. set horizontalAlignment(value: number);
  70836. /**
  70837. * Gets or sets the vertical alignment
  70838. * @see http://doc.babylonjs.com/how_to/gui#alignments
  70839. */
  70840. get verticalAlignment(): number;
  70841. set verticalAlignment(value: number);
  70842. /**
  70843. * Gets or sets control width
  70844. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70845. */
  70846. get width(): string | number;
  70847. set width(value: string | number);
  70848. /**
  70849. * Gets or sets the control width in pixel
  70850. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70851. */
  70852. get widthInPixels(): number;
  70853. set widthInPixels(value: number);
  70854. /**
  70855. * Gets or sets control height
  70856. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70857. */
  70858. get height(): string | number;
  70859. set height(value: string | number);
  70860. /**
  70861. * Gets or sets control height in pixel
  70862. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70863. */
  70864. get heightInPixels(): number;
  70865. set heightInPixels(value: number);
  70866. /** Gets or set font family */
  70867. get fontFamily(): string;
  70868. set fontFamily(value: string);
  70869. /** Gets or sets font style */
  70870. get fontStyle(): string;
  70871. set fontStyle(value: string);
  70872. /** Gets or sets font weight */
  70873. get fontWeight(): string;
  70874. set fontWeight(value: string);
  70875. /**
  70876. * Gets or sets style
  70877. * @see http://doc.babylonjs.com/how_to/gui#styles
  70878. */
  70879. get style(): BABYLON.Nullable<Style>;
  70880. set style(value: BABYLON.Nullable<Style>);
  70881. /** @hidden */
  70882. get _isFontSizeInPercentage(): boolean;
  70883. /** Gets or sets font size in pixels */
  70884. get fontSizeInPixels(): number;
  70885. set fontSizeInPixels(value: number);
  70886. /** Gets or sets font size */
  70887. get fontSize(): string | number;
  70888. set fontSize(value: string | number);
  70889. /** Gets or sets foreground color */
  70890. get color(): string;
  70891. set color(value: string);
  70892. /** Gets or sets z index which is used to reorder controls on the z axis */
  70893. get zIndex(): number;
  70894. set zIndex(value: number);
  70895. /** Gets or sets a boolean indicating if the control can be rendered */
  70896. get notRenderable(): boolean;
  70897. set notRenderable(value: boolean);
  70898. /** Gets or sets a boolean indicating if the control is visible */
  70899. get isVisible(): boolean;
  70900. set isVisible(value: boolean);
  70901. /** Gets a boolean indicating that the control needs to update its rendering */
  70902. get isDirty(): boolean;
  70903. /**
  70904. * Gets the current linked mesh (or null if none)
  70905. */
  70906. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  70907. /**
  70908. * Gets or sets a value indicating the padding to use on the left of the control
  70909. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70910. */
  70911. get paddingLeft(): string | number;
  70912. set paddingLeft(value: string | number);
  70913. /**
  70914. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  70915. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70916. */
  70917. get paddingLeftInPixels(): number;
  70918. set paddingLeftInPixels(value: number);
  70919. /**
  70920. * Gets or sets a value indicating the padding to use on the right of the control
  70921. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70922. */
  70923. get paddingRight(): string | number;
  70924. set paddingRight(value: string | number);
  70925. /**
  70926. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  70927. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70928. */
  70929. get paddingRightInPixels(): number;
  70930. set paddingRightInPixels(value: number);
  70931. /**
  70932. * Gets or sets a value indicating the padding to use on the top of the control
  70933. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70934. */
  70935. get paddingTop(): string | number;
  70936. set paddingTop(value: string | number);
  70937. /**
  70938. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  70939. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70940. */
  70941. get paddingTopInPixels(): number;
  70942. set paddingTopInPixels(value: number);
  70943. /**
  70944. * Gets or sets a value indicating the padding to use on the bottom of the control
  70945. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70946. */
  70947. get paddingBottom(): string | number;
  70948. set paddingBottom(value: string | number);
  70949. /**
  70950. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  70951. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70952. */
  70953. get paddingBottomInPixels(): number;
  70954. set paddingBottomInPixels(value: number);
  70955. /**
  70956. * Gets or sets a value indicating the left coordinate of the control
  70957. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70958. */
  70959. get left(): string | number;
  70960. set left(value: string | number);
  70961. /**
  70962. * Gets or sets a value indicating the left coordinate in pixels of the control
  70963. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70964. */
  70965. get leftInPixels(): number;
  70966. set leftInPixels(value: number);
  70967. /**
  70968. * Gets or sets a value indicating the top coordinate of the control
  70969. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70970. */
  70971. get top(): string | number;
  70972. set top(value: string | number);
  70973. /**
  70974. * Gets or sets a value indicating the top coordinate in pixels of the control
  70975. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  70976. */
  70977. get topInPixels(): number;
  70978. set topInPixels(value: number);
  70979. /**
  70980. * Gets or sets a value indicating the offset on X axis to the linked mesh
  70981. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  70982. */
  70983. get linkOffsetX(): string | number;
  70984. set linkOffsetX(value: string | number);
  70985. /**
  70986. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  70987. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  70988. */
  70989. get linkOffsetXInPixels(): number;
  70990. set linkOffsetXInPixels(value: number);
  70991. /**
  70992. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  70993. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  70994. */
  70995. get linkOffsetY(): string | number;
  70996. set linkOffsetY(value: string | number);
  70997. /**
  70998. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  70999. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71000. */
  71001. get linkOffsetYInPixels(): number;
  71002. set linkOffsetYInPixels(value: number);
  71003. /** Gets the center coordinate on X axis */
  71004. get centerX(): number;
  71005. /** Gets the center coordinate on Y axis */
  71006. get centerY(): number;
  71007. /** Gets or sets if control is Enabled*/
  71008. get isEnabled(): boolean;
  71009. set isEnabled(value: boolean);
  71010. /** Gets or sets background color of control if it's disabled*/
  71011. get disabledColor(): string;
  71012. set disabledColor(value: string);
  71013. /**
  71014. * Creates a new control
  71015. * @param name defines the name of the control
  71016. */
  71017. constructor(
  71018. /** defines the name of the control */
  71019. name?: string | undefined);
  71020. /** @hidden */
  71021. protected _getTypeName(): string;
  71022. /**
  71023. * Gets the first ascendant in the hierarchy of the given type
  71024. * @param className defines the required type
  71025. * @returns the ascendant or null if not found
  71026. */
  71027. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  71028. /** @hidden */
  71029. _resetFontCache(): void;
  71030. /**
  71031. * Determines if a container is an ascendant of the current control
  71032. * @param container defines the container to look for
  71033. * @returns true if the container is one of the ascendant of the control
  71034. */
  71035. isAscendant(container: Control): boolean;
  71036. /**
  71037. * Gets coordinates in local control space
  71038. * @param globalCoordinates defines the coordinates to transform
  71039. * @returns the new coordinates in local space
  71040. */
  71041. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  71042. /**
  71043. * Gets coordinates in local control space
  71044. * @param globalCoordinates defines the coordinates to transform
  71045. * @param result defines the target vector2 where to store the result
  71046. * @returns the current control
  71047. */
  71048. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  71049. /**
  71050. * Gets coordinates in parent local control space
  71051. * @param globalCoordinates defines the coordinates to transform
  71052. * @returns the new coordinates in parent local space
  71053. */
  71054. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  71055. /**
  71056. * Move the current control to a vector3 position projected onto the screen.
  71057. * @param position defines the target position
  71058. * @param scene defines the hosting scene
  71059. */
  71060. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  71061. /**
  71062. * Will store all controls that have this control as ascendant in a given array
  71063. * @param results defines the array where to store the descendants
  71064. * @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
  71065. * @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
  71066. */
  71067. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  71068. /**
  71069. * Will return all controls that have this control as ascendant
  71070. * @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
  71071. * @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
  71072. * @return all child controls
  71073. */
  71074. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  71075. /**
  71076. * Link current control with a target mesh
  71077. * @param mesh defines the mesh to link with
  71078. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  71079. */
  71080. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  71081. /** @hidden */
  71082. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  71083. /** @hidden */
  71084. _offsetLeft(offset: number): void;
  71085. /** @hidden */
  71086. _offsetTop(offset: number): void;
  71087. /** @hidden */
  71088. _markMatrixAsDirty(): void;
  71089. /** @hidden */
  71090. _flagDescendantsAsMatrixDirty(): void;
  71091. /** @hidden */
  71092. _intersectsRect(rect: Measure): boolean;
  71093. /** @hidden */
  71094. protected invalidateRect(): void;
  71095. /** @hidden */
  71096. _markAsDirty(force?: boolean): void;
  71097. /** @hidden */
  71098. _markAllAsDirty(): void;
  71099. /** @hidden */
  71100. _link(host: AdvancedDynamicTexture): void;
  71101. /** @hidden */
  71102. protected _transform(context?: CanvasRenderingContext2D): void;
  71103. /** @hidden */
  71104. _renderHighlight(context: CanvasRenderingContext2D): void;
  71105. /** @hidden */
  71106. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  71107. /** @hidden */
  71108. protected _applyStates(context: CanvasRenderingContext2D): void;
  71109. /** @hidden */
  71110. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  71111. /** @hidden */
  71112. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71113. protected _evaluateClippingState(parentMeasure: Measure): void;
  71114. /** @hidden */
  71115. _measure(): void;
  71116. /** @hidden */
  71117. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71118. /** @hidden */
  71119. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71120. /** @hidden */
  71121. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71122. /** @hidden */
  71123. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  71124. private static _ClipMeasure;
  71125. private _tmpMeasureA;
  71126. private _clip;
  71127. /** @hidden */
  71128. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  71129. /** @hidden */
  71130. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  71131. /**
  71132. * Tests if a given coordinates belong to the current control
  71133. * @param x defines x coordinate to test
  71134. * @param y defines y coordinate to test
  71135. * @returns true if the coordinates are inside the control
  71136. */
  71137. contains(x: number, y: number): boolean;
  71138. /** @hidden */
  71139. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  71140. /** @hidden */
  71141. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  71142. /** @hidden */
  71143. _onPointerEnter(target: Control): boolean;
  71144. /** @hidden */
  71145. _onPointerOut(target: Control, force?: boolean): void;
  71146. /** @hidden */
  71147. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  71148. /** @hidden */
  71149. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  71150. /** @hidden */
  71151. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  71152. /** @hidden */
  71153. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  71154. private _prepareFont;
  71155. /** Releases associated resources */
  71156. dispose(): void;
  71157. private static _HORIZONTAL_ALIGNMENT_LEFT;
  71158. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  71159. private static _HORIZONTAL_ALIGNMENT_CENTER;
  71160. private static _VERTICAL_ALIGNMENT_TOP;
  71161. private static _VERTICAL_ALIGNMENT_BOTTOM;
  71162. private static _VERTICAL_ALIGNMENT_CENTER;
  71163. /** HORIZONTAL_ALIGNMENT_LEFT */
  71164. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  71165. /** HORIZONTAL_ALIGNMENT_RIGHT */
  71166. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  71167. /** HORIZONTAL_ALIGNMENT_CENTER */
  71168. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  71169. /** VERTICAL_ALIGNMENT_TOP */
  71170. static get VERTICAL_ALIGNMENT_TOP(): number;
  71171. /** VERTICAL_ALIGNMENT_BOTTOM */
  71172. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  71173. /** VERTICAL_ALIGNMENT_CENTER */
  71174. static get VERTICAL_ALIGNMENT_CENTER(): number;
  71175. private static _FontHeightSizes;
  71176. /** @hidden */
  71177. static _GetFontOffset(font: string): {
  71178. ascent: number;
  71179. height: number;
  71180. descent: number;
  71181. };
  71182. /**
  71183. * Creates a stack panel that can be used to render headers
  71184. * @param control defines the control to associate with the header
  71185. * @param text defines the text of the header
  71186. * @param size defines the size of the header
  71187. * @param options defines options used to configure the header
  71188. * @returns a new StackPanel
  71189. * @ignore
  71190. * @hidden
  71191. */
  71192. static AddHeader: (control: Control, text: string, size: string | number, options: {
  71193. isHorizontal: boolean;
  71194. controlFirst: boolean;
  71195. }) => any;
  71196. /** @hidden */
  71197. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  71198. }
  71199. }
  71200. declare module BABYLON.GUI {
  71201. /**
  71202. * Root class for 2D containers
  71203. * @see http://doc.babylonjs.com/how_to/gui#containers
  71204. */
  71205. export class Container extends Control {
  71206. name?: string | undefined;
  71207. /** @hidden */
  71208. _children: Control[];
  71209. /** @hidden */
  71210. protected _measureForChildren: Measure;
  71211. /** @hidden */
  71212. protected _background: string;
  71213. /** @hidden */
  71214. protected _adaptWidthToChildren: boolean;
  71215. /** @hidden */
  71216. protected _adaptHeightToChildren: boolean;
  71217. /**
  71218. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  71219. */
  71220. logLayoutCycleErrors: boolean;
  71221. /**
  71222. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  71223. */
  71224. maxLayoutCycle: number;
  71225. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  71226. get adaptHeightToChildren(): boolean;
  71227. set adaptHeightToChildren(value: boolean);
  71228. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  71229. get adaptWidthToChildren(): boolean;
  71230. set adaptWidthToChildren(value: boolean);
  71231. /** Gets or sets background color */
  71232. get background(): string;
  71233. set background(value: string);
  71234. /** Gets the list of children */
  71235. get children(): Control[];
  71236. /**
  71237. * Creates a new Container
  71238. * @param name defines the name of the container
  71239. */
  71240. constructor(name?: string | undefined);
  71241. protected _getTypeName(): string;
  71242. _flagDescendantsAsMatrixDirty(): void;
  71243. /**
  71244. * Gets a child using its name
  71245. * @param name defines the child name to look for
  71246. * @returns the child control if found
  71247. */
  71248. getChildByName(name: string): BABYLON.Nullable<Control>;
  71249. /**
  71250. * Gets a child using its type and its name
  71251. * @param name defines the child name to look for
  71252. * @param type defines the child type to look for
  71253. * @returns the child control if found
  71254. */
  71255. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  71256. /**
  71257. * Search for a specific control in children
  71258. * @param control defines the control to look for
  71259. * @returns true if the control is in child list
  71260. */
  71261. containsControl(control: Control): boolean;
  71262. /**
  71263. * Adds a new control to the current container
  71264. * @param control defines the control to add
  71265. * @returns the current container
  71266. */
  71267. addControl(control: BABYLON.Nullable<Control>): Container;
  71268. /**
  71269. * Removes all controls from the current container
  71270. * @returns the current container
  71271. */
  71272. clearControls(): Container;
  71273. /**
  71274. * Removes a control from the current container
  71275. * @param control defines the control to remove
  71276. * @returns the current container
  71277. */
  71278. removeControl(control: Control): Container;
  71279. /** @hidden */
  71280. _reOrderControl(control: Control): void;
  71281. /** @hidden */
  71282. _offsetLeft(offset: number): void;
  71283. /** @hidden */
  71284. _offsetTop(offset: number): void;
  71285. /** @hidden */
  71286. _markAllAsDirty(): void;
  71287. /** @hidden */
  71288. protected _localDraw(context: CanvasRenderingContext2D): void;
  71289. /** @hidden */
  71290. _link(host: AdvancedDynamicTexture): void;
  71291. /** @hidden */
  71292. protected _beforeLayout(): void;
  71293. /** @hidden */
  71294. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71295. /** @hidden */
  71296. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  71297. protected _postMeasure(): void;
  71298. /** @hidden */
  71299. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  71300. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  71301. /** @hidden */
  71302. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  71303. /** @hidden */
  71304. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71305. /** Releases associated resources */
  71306. dispose(): void;
  71307. }
  71308. }
  71309. declare module BABYLON.GUI {
  71310. /** Class used to create rectangle container */
  71311. export class Rectangle extends Container {
  71312. name?: string | undefined;
  71313. private _thickness;
  71314. private _cornerRadius;
  71315. /** Gets or sets border thickness */
  71316. get thickness(): number;
  71317. set thickness(value: number);
  71318. /** Gets or sets the corner radius angle */
  71319. get cornerRadius(): number;
  71320. set cornerRadius(value: number);
  71321. /**
  71322. * Creates a new Rectangle
  71323. * @param name defines the control name
  71324. */
  71325. constructor(name?: string | undefined);
  71326. protected _getTypeName(): string;
  71327. protected _localDraw(context: CanvasRenderingContext2D): void;
  71328. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71329. private _drawRoundedRect;
  71330. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  71331. }
  71332. }
  71333. declare module BABYLON.GUI {
  71334. /**
  71335. * Enum that determines the text-wrapping mode to use.
  71336. */
  71337. export enum TextWrapping {
  71338. /**
  71339. * Clip the text when it's larger than Control.width; this is the default mode.
  71340. */
  71341. Clip = 0,
  71342. /**
  71343. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  71344. */
  71345. WordWrap = 1,
  71346. /**
  71347. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  71348. */
  71349. Ellipsis = 2
  71350. }
  71351. /**
  71352. * Class used to create text block control
  71353. */
  71354. export class TextBlock extends Control {
  71355. /**
  71356. * Defines the name of the control
  71357. */
  71358. name?: string | undefined;
  71359. private _text;
  71360. private _textWrapping;
  71361. private _textHorizontalAlignment;
  71362. private _textVerticalAlignment;
  71363. private _lines;
  71364. private _resizeToFit;
  71365. private _lineSpacing;
  71366. private _outlineWidth;
  71367. private _outlineColor;
  71368. /**
  71369. * An event triggered after the text is changed
  71370. */
  71371. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  71372. /**
  71373. * An event triggered after the text was broken up into lines
  71374. */
  71375. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  71376. /**
  71377. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  71378. */
  71379. get lines(): any[];
  71380. /**
  71381. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  71382. */
  71383. get resizeToFit(): boolean;
  71384. /**
  71385. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  71386. */
  71387. set resizeToFit(value: boolean);
  71388. /**
  71389. * Gets or sets a boolean indicating if text must be wrapped
  71390. */
  71391. get textWrapping(): TextWrapping | boolean;
  71392. /**
  71393. * Gets or sets a boolean indicating if text must be wrapped
  71394. */
  71395. set textWrapping(value: TextWrapping | boolean);
  71396. /**
  71397. * Gets or sets text to display
  71398. */
  71399. get text(): string;
  71400. /**
  71401. * Gets or sets text to display
  71402. */
  71403. set text(value: string);
  71404. /**
  71405. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  71406. */
  71407. get textHorizontalAlignment(): number;
  71408. /**
  71409. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  71410. */
  71411. set textHorizontalAlignment(value: number);
  71412. /**
  71413. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  71414. */
  71415. get textVerticalAlignment(): number;
  71416. /**
  71417. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  71418. */
  71419. set textVerticalAlignment(value: number);
  71420. /**
  71421. * Gets or sets line spacing value
  71422. */
  71423. set lineSpacing(value: string | number);
  71424. /**
  71425. * Gets or sets line spacing value
  71426. */
  71427. get lineSpacing(): string | number;
  71428. /**
  71429. * Gets or sets outlineWidth of the text to display
  71430. */
  71431. get outlineWidth(): number;
  71432. /**
  71433. * Gets or sets outlineWidth of the text to display
  71434. */
  71435. set outlineWidth(value: number);
  71436. /**
  71437. * Gets or sets outlineColor of the text to display
  71438. */
  71439. get outlineColor(): string;
  71440. /**
  71441. * Gets or sets outlineColor of the text to display
  71442. */
  71443. set outlineColor(value: string);
  71444. /**
  71445. * Creates a new TextBlock object
  71446. * @param name defines the name of the control
  71447. * @param text defines the text to display (emptry string by default)
  71448. */
  71449. constructor(
  71450. /**
  71451. * Defines the name of the control
  71452. */
  71453. name?: string | undefined, text?: string);
  71454. protected _getTypeName(): string;
  71455. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71456. private _drawText;
  71457. /** @hidden */
  71458. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  71459. protected _applyStates(context: CanvasRenderingContext2D): void;
  71460. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  71461. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  71462. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  71463. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  71464. protected _renderLines(context: CanvasRenderingContext2D): void;
  71465. /**
  71466. * Given a width constraint applied on the text block, find the expected height
  71467. * @returns expected height
  71468. */
  71469. computeExpectedHeight(): number;
  71470. dispose(): void;
  71471. }
  71472. }
  71473. declare module BABYLON.GUI {
  71474. /**
  71475. * Class used to create 2D images
  71476. */
  71477. export class Image extends Control {
  71478. name?: string | undefined;
  71479. private _workingCanvas;
  71480. private _domImage;
  71481. private _imageWidth;
  71482. private _imageHeight;
  71483. private _loaded;
  71484. private _stretch;
  71485. private _source;
  71486. private _autoScale;
  71487. private _sourceLeft;
  71488. private _sourceTop;
  71489. private _sourceWidth;
  71490. private _sourceHeight;
  71491. private _svgAttributesComputationCompleted;
  71492. private _isSVG;
  71493. private _cellWidth;
  71494. private _cellHeight;
  71495. private _cellId;
  71496. private _populateNinePatchSlicesFromImage;
  71497. private _sliceLeft;
  71498. private _sliceRight;
  71499. private _sliceTop;
  71500. private _sliceBottom;
  71501. private _detectPointerOnOpaqueOnly;
  71502. /**
  71503. * BABYLON.Observable notified when the content is loaded
  71504. */
  71505. onImageLoadedObservable: BABYLON.Observable<Image>;
  71506. /**
  71507. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  71508. */
  71509. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  71510. /**
  71511. * Gets a boolean indicating that the content is loaded
  71512. */
  71513. get isLoaded(): boolean;
  71514. /**
  71515. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  71516. */
  71517. get populateNinePatchSlicesFromImage(): boolean;
  71518. set populateNinePatchSlicesFromImage(value: boolean);
  71519. /**
  71520. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  71521. * Beware using this as this will comsume more memory as the image has to be stored twice
  71522. */
  71523. get detectPointerOnOpaqueOnly(): boolean;
  71524. set detectPointerOnOpaqueOnly(value: boolean);
  71525. /**
  71526. * Gets or sets the left value for slicing (9-patch)
  71527. */
  71528. get sliceLeft(): number;
  71529. set sliceLeft(value: number);
  71530. /**
  71531. * Gets or sets the right value for slicing (9-patch)
  71532. */
  71533. get sliceRight(): number;
  71534. set sliceRight(value: number);
  71535. /**
  71536. * Gets or sets the top value for slicing (9-patch)
  71537. */
  71538. get sliceTop(): number;
  71539. set sliceTop(value: number);
  71540. /**
  71541. * Gets or sets the bottom value for slicing (9-patch)
  71542. */
  71543. get sliceBottom(): number;
  71544. set sliceBottom(value: number);
  71545. /**
  71546. * Gets or sets the left coordinate in the source image
  71547. */
  71548. get sourceLeft(): number;
  71549. set sourceLeft(value: number);
  71550. /**
  71551. * Gets or sets the top coordinate in the source image
  71552. */
  71553. get sourceTop(): number;
  71554. set sourceTop(value: number);
  71555. /**
  71556. * Gets or sets the width to capture in the source image
  71557. */
  71558. get sourceWidth(): number;
  71559. set sourceWidth(value: number);
  71560. /**
  71561. * Gets or sets the height to capture in the source image
  71562. */
  71563. get sourceHeight(): number;
  71564. set sourceHeight(value: number);
  71565. /** Indicates if the format of the image is SVG */
  71566. get isSVG(): boolean;
  71567. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  71568. get svgAttributesComputationCompleted(): boolean;
  71569. /**
  71570. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  71571. * @see http://doc.babylonjs.com/how_to/gui#image
  71572. */
  71573. get autoScale(): boolean;
  71574. set autoScale(value: boolean);
  71575. /** Gets or sets the streching mode used by the image */
  71576. get stretch(): number;
  71577. set stretch(value: number);
  71578. /** @hidden */
  71579. _rotate90(n: number, preserveProperties?: boolean): Image;
  71580. private _handleRotationForSVGImage;
  71581. private _rotate90SourceProperties;
  71582. /**
  71583. * Gets or sets the internal DOM image used to render the control
  71584. */
  71585. set domImage(value: HTMLImageElement);
  71586. get domImage(): HTMLImageElement;
  71587. private _onImageLoaded;
  71588. private _extractNinePatchSliceDataFromImage;
  71589. /**
  71590. * Gets or sets image source url
  71591. */
  71592. set source(value: BABYLON.Nullable<string>);
  71593. /**
  71594. * Checks for svg document with icon id present
  71595. */
  71596. private _svgCheck;
  71597. /**
  71598. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  71599. * given external svg file and icon id
  71600. */
  71601. private _getSVGAttribs;
  71602. /**
  71603. * Gets or sets the cell width to use when animation sheet is enabled
  71604. * @see http://doc.babylonjs.com/how_to/gui#image
  71605. */
  71606. get cellWidth(): number;
  71607. set cellWidth(value: number);
  71608. /**
  71609. * Gets or sets the cell height to use when animation sheet is enabled
  71610. * @see http://doc.babylonjs.com/how_to/gui#image
  71611. */
  71612. get cellHeight(): number;
  71613. set cellHeight(value: number);
  71614. /**
  71615. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  71616. * @see http://doc.babylonjs.com/how_to/gui#image
  71617. */
  71618. get cellId(): number;
  71619. set cellId(value: number);
  71620. /**
  71621. * Creates a new Image
  71622. * @param name defines the control name
  71623. * @param url defines the image url
  71624. */
  71625. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  71626. /**
  71627. * Tests if a given coordinates belong to the current control
  71628. * @param x defines x coordinate to test
  71629. * @param y defines y coordinate to test
  71630. * @returns true if the coordinates are inside the control
  71631. */
  71632. contains(x: number, y: number): boolean;
  71633. protected _getTypeName(): string;
  71634. /** Force the control to synchronize with its content */
  71635. synchronizeSizeWithContent(): void;
  71636. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71637. private _prepareWorkingCanvasForOpaqueDetection;
  71638. private _drawImage;
  71639. _draw(context: CanvasRenderingContext2D): void;
  71640. private _renderCornerPatch;
  71641. private _renderNinePatch;
  71642. dispose(): void;
  71643. /** STRETCH_NONE */
  71644. static readonly STRETCH_NONE: number;
  71645. /** STRETCH_FILL */
  71646. static readonly STRETCH_FILL: number;
  71647. /** STRETCH_UNIFORM */
  71648. static readonly STRETCH_UNIFORM: number;
  71649. /** STRETCH_EXTEND */
  71650. static readonly STRETCH_EXTEND: number;
  71651. /** NINE_PATCH */
  71652. static readonly STRETCH_NINE_PATCH: number;
  71653. }
  71654. }
  71655. declare module BABYLON.GUI {
  71656. /**
  71657. * Class used to create 2D buttons
  71658. */
  71659. export class Button extends Rectangle {
  71660. name?: string | undefined;
  71661. /**
  71662. * Function called to generate a pointer enter animation
  71663. */
  71664. pointerEnterAnimation: () => void;
  71665. /**
  71666. * Function called to generate a pointer out animation
  71667. */
  71668. pointerOutAnimation: () => void;
  71669. /**
  71670. * Function called to generate a pointer down animation
  71671. */
  71672. pointerDownAnimation: () => void;
  71673. /**
  71674. * Function called to generate a pointer up animation
  71675. */
  71676. pointerUpAnimation: () => void;
  71677. /**
  71678. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  71679. */
  71680. delegatePickingToChildren: boolean;
  71681. private _image;
  71682. /**
  71683. * Returns the image part of the button (if any)
  71684. */
  71685. get image(): BABYLON.Nullable<Image>;
  71686. private _textBlock;
  71687. /**
  71688. * Returns the image part of the button (if any)
  71689. */
  71690. get textBlock(): BABYLON.Nullable<TextBlock>;
  71691. /**
  71692. * Creates a new Button
  71693. * @param name defines the name of the button
  71694. */
  71695. constructor(name?: string | undefined);
  71696. protected _getTypeName(): string;
  71697. /** @hidden */
  71698. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  71699. /** @hidden */
  71700. _onPointerEnter(target: Control): boolean;
  71701. /** @hidden */
  71702. _onPointerOut(target: Control, force?: boolean): void;
  71703. /** @hidden */
  71704. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  71705. /** @hidden */
  71706. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  71707. /**
  71708. * Creates a new button made with an image and a text
  71709. * @param name defines the name of the button
  71710. * @param text defines the text of the button
  71711. * @param imageUrl defines the url of the image
  71712. * @returns a new Button
  71713. */
  71714. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  71715. /**
  71716. * Creates a new button made with an image
  71717. * @param name defines the name of the button
  71718. * @param imageUrl defines the url of the image
  71719. * @returns a new Button
  71720. */
  71721. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  71722. /**
  71723. * Creates a new button made with a text
  71724. * @param name defines the name of the button
  71725. * @param text defines the text of the button
  71726. * @returns a new Button
  71727. */
  71728. static CreateSimpleButton(name: string, text: string): Button;
  71729. /**
  71730. * Creates a new button made with an image and a centered text
  71731. * @param name defines the name of the button
  71732. * @param text defines the text of the button
  71733. * @param imageUrl defines the url of the image
  71734. * @returns a new Button
  71735. */
  71736. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  71737. }
  71738. }
  71739. declare module BABYLON.GUI {
  71740. /**
  71741. * Class used to create a 2D stack panel container
  71742. */
  71743. export class StackPanel extends Container {
  71744. name?: string | undefined;
  71745. private _isVertical;
  71746. private _manualWidth;
  71747. private _manualHeight;
  71748. private _doNotTrackManualChanges;
  71749. /**
  71750. * Gets or sets a boolean indicating that layou warnings should be ignored
  71751. */
  71752. ignoreLayoutWarnings: boolean;
  71753. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  71754. get isVertical(): boolean;
  71755. set isVertical(value: boolean);
  71756. /**
  71757. * Gets or sets panel width.
  71758. * This value should not be set when in horizontal mode as it will be computed automatically
  71759. */
  71760. set width(value: string | number);
  71761. get width(): string | number;
  71762. /**
  71763. * Gets or sets panel height.
  71764. * This value should not be set when in vertical mode as it will be computed automatically
  71765. */
  71766. set height(value: string | number);
  71767. get height(): string | number;
  71768. /**
  71769. * Creates a new StackPanel
  71770. * @param name defines control name
  71771. */
  71772. constructor(name?: string | undefined);
  71773. protected _getTypeName(): string;
  71774. /** @hidden */
  71775. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71776. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  71777. protected _postMeasure(): void;
  71778. }
  71779. }
  71780. declare module BABYLON.GUI {
  71781. /**
  71782. * Class used to represent a 2D checkbox
  71783. */
  71784. export class Checkbox extends Control {
  71785. name?: string | undefined;
  71786. private _isChecked;
  71787. private _background;
  71788. private _checkSizeRatio;
  71789. private _thickness;
  71790. /** Gets or sets border thickness */
  71791. get thickness(): number;
  71792. set thickness(value: number);
  71793. /**
  71794. * BABYLON.Observable raised when isChecked property changes
  71795. */
  71796. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  71797. /** Gets or sets a value indicating the ratio between overall size and check size */
  71798. get checkSizeRatio(): number;
  71799. set checkSizeRatio(value: number);
  71800. /** Gets or sets background color */
  71801. get background(): string;
  71802. set background(value: string);
  71803. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  71804. get isChecked(): boolean;
  71805. set isChecked(value: boolean);
  71806. /**
  71807. * Creates a new CheckBox
  71808. * @param name defines the control name
  71809. */
  71810. constructor(name?: string | undefined);
  71811. protected _getTypeName(): string;
  71812. /** @hidden */
  71813. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  71814. /** @hidden */
  71815. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  71816. /**
  71817. * Utility function to easily create a checkbox with a header
  71818. * @param title defines the label to use for the header
  71819. * @param onValueChanged defines the callback to call when value changes
  71820. * @returns a StackPanel containing the checkbox and a textBlock
  71821. */
  71822. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  71823. }
  71824. }
  71825. declare module BABYLON.GUI {
  71826. /**
  71827. * Class used to store key control properties
  71828. */
  71829. export class KeyPropertySet {
  71830. /** Width */
  71831. width?: string;
  71832. /** Height */
  71833. height?: string;
  71834. /** Left padding */
  71835. paddingLeft?: string;
  71836. /** Right padding */
  71837. paddingRight?: string;
  71838. /** Top padding */
  71839. paddingTop?: string;
  71840. /** Bottom padding */
  71841. paddingBottom?: string;
  71842. /** Foreground color */
  71843. color?: string;
  71844. /** Background color */
  71845. background?: string;
  71846. }
  71847. /**
  71848. * Class used to create virtual keyboard
  71849. */
  71850. export class VirtualKeyboard extends StackPanel {
  71851. /** BABYLON.Observable raised when a key is pressed */
  71852. onKeyPressObservable: BABYLON.Observable<string>;
  71853. /** Gets or sets default key button width */
  71854. defaultButtonWidth: string;
  71855. /** Gets or sets default key button height */
  71856. defaultButtonHeight: string;
  71857. /** Gets or sets default key button left padding */
  71858. defaultButtonPaddingLeft: string;
  71859. /** Gets or sets default key button right padding */
  71860. defaultButtonPaddingRight: string;
  71861. /** Gets or sets default key button top padding */
  71862. defaultButtonPaddingTop: string;
  71863. /** Gets or sets default key button bottom padding */
  71864. defaultButtonPaddingBottom: string;
  71865. /** Gets or sets default key button foreground color */
  71866. defaultButtonColor: string;
  71867. /** Gets or sets default key button background color */
  71868. defaultButtonBackground: string;
  71869. /** Gets or sets shift button foreground color */
  71870. shiftButtonColor: string;
  71871. /** Gets or sets shift button thickness*/
  71872. selectedShiftThickness: number;
  71873. /** Gets shift key state */
  71874. shiftState: number;
  71875. protected _getTypeName(): string;
  71876. private _createKey;
  71877. /**
  71878. * Adds a new row of keys
  71879. * @param keys defines the list of keys to add
  71880. * @param propertySets defines the associated property sets
  71881. */
  71882. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  71883. /**
  71884. * Set the shift key to a specific state
  71885. * @param shiftState defines the new shift state
  71886. */
  71887. applyShiftState(shiftState: number): void;
  71888. private _currentlyConnectedInputText;
  71889. private _connectedInputTexts;
  71890. private _onKeyPressObserver;
  71891. /** Gets the input text control currently attached to the keyboard */
  71892. get connectedInputText(): BABYLON.Nullable<InputText>;
  71893. /**
  71894. * Connects the keyboard with an input text control
  71895. *
  71896. * @param input defines the target control
  71897. */
  71898. connect(input: InputText): void;
  71899. /**
  71900. * Disconnects the keyboard from connected InputText controls
  71901. *
  71902. * @param input optionally defines a target control, otherwise all are disconnected
  71903. */
  71904. disconnect(input?: InputText): void;
  71905. private _removeConnectedInputObservables;
  71906. /**
  71907. * Release all resources
  71908. */
  71909. dispose(): void;
  71910. /**
  71911. * Creates a new keyboard using a default layout
  71912. *
  71913. * @param name defines control name
  71914. * @returns a new VirtualKeyboard
  71915. */
  71916. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  71917. }
  71918. }
  71919. declare module BABYLON.GUI {
  71920. /**
  71921. * Class used to create input text control
  71922. */
  71923. export class InputText extends Control implements IFocusableControl {
  71924. name?: string | undefined;
  71925. private _text;
  71926. private _placeholderText;
  71927. private _background;
  71928. private _focusedBackground;
  71929. private _focusedColor;
  71930. private _placeholderColor;
  71931. private _thickness;
  71932. private _margin;
  71933. private _autoStretchWidth;
  71934. private _maxWidth;
  71935. private _isFocused;
  71936. private _blinkTimeout;
  71937. private _blinkIsEven;
  71938. private _cursorOffset;
  71939. private _scrollLeft;
  71940. private _textWidth;
  71941. private _clickedCoordinate;
  71942. private _deadKey;
  71943. private _addKey;
  71944. private _currentKey;
  71945. private _isTextHighlightOn;
  71946. private _textHighlightColor;
  71947. private _highligherOpacity;
  71948. private _highlightedText;
  71949. private _startHighlightIndex;
  71950. private _endHighlightIndex;
  71951. private _cursorIndex;
  71952. private _onFocusSelectAll;
  71953. private _isPointerDown;
  71954. private _onClipboardObserver;
  71955. private _onPointerDblTapObserver;
  71956. /** @hidden */
  71957. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  71958. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  71959. promptMessage: string;
  71960. /** Force disable prompt on mobile device */
  71961. disableMobilePrompt: boolean;
  71962. /** BABYLON.Observable raised when the text changes */
  71963. onTextChangedObservable: BABYLON.Observable<InputText>;
  71964. /** BABYLON.Observable raised just before an entered character is to be added */
  71965. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  71966. /** BABYLON.Observable raised when the control gets the focus */
  71967. onFocusObservable: BABYLON.Observable<InputText>;
  71968. /** BABYLON.Observable raised when the control loses the focus */
  71969. onBlurObservable: BABYLON.Observable<InputText>;
  71970. /**Observable raised when the text is highlighted */
  71971. onTextHighlightObservable: BABYLON.Observable<InputText>;
  71972. /**Observable raised when copy event is triggered */
  71973. onTextCopyObservable: BABYLON.Observable<InputText>;
  71974. /** BABYLON.Observable raised when cut event is triggered */
  71975. onTextCutObservable: BABYLON.Observable<InputText>;
  71976. /** BABYLON.Observable raised when paste event is triggered */
  71977. onTextPasteObservable: BABYLON.Observable<InputText>;
  71978. /** BABYLON.Observable raised when a key event was processed */
  71979. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  71980. /** Gets or sets the maximum width allowed by the control */
  71981. get maxWidth(): string | number;
  71982. /** Gets the maximum width allowed by the control in pixels */
  71983. get maxWidthInPixels(): number;
  71984. set maxWidth(value: string | number);
  71985. /** Gets or sets the text highlighter transparency; default: 0.4 */
  71986. get highligherOpacity(): number;
  71987. set highligherOpacity(value: number);
  71988. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  71989. get onFocusSelectAll(): boolean;
  71990. set onFocusSelectAll(value: boolean);
  71991. /** Gets or sets the text hightlight color */
  71992. get textHighlightColor(): string;
  71993. set textHighlightColor(value: string);
  71994. /** Gets or sets control margin */
  71995. get margin(): string;
  71996. /** Gets control margin in pixels */
  71997. get marginInPixels(): number;
  71998. set margin(value: string);
  71999. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  72000. get autoStretchWidth(): boolean;
  72001. set autoStretchWidth(value: boolean);
  72002. /** Gets or sets border thickness */
  72003. get thickness(): number;
  72004. set thickness(value: number);
  72005. /** Gets or sets the background color when focused */
  72006. get focusedBackground(): string;
  72007. set focusedBackground(value: string);
  72008. /** Gets or sets the background color when focused */
  72009. get focusedColor(): string;
  72010. set focusedColor(value: string);
  72011. /** Gets or sets the background color */
  72012. get background(): string;
  72013. set background(value: string);
  72014. /** Gets or sets the placeholder color */
  72015. get placeholderColor(): string;
  72016. set placeholderColor(value: string);
  72017. /** Gets or sets the text displayed when the control is empty */
  72018. get placeholderText(): string;
  72019. set placeholderText(value: string);
  72020. /** Gets or sets the dead key flag */
  72021. get deadKey(): boolean;
  72022. set deadKey(flag: boolean);
  72023. /** Gets or sets the highlight text */
  72024. get highlightedText(): string;
  72025. set highlightedText(text: string);
  72026. /** Gets or sets if the current key should be added */
  72027. get addKey(): boolean;
  72028. set addKey(flag: boolean);
  72029. /** Gets or sets the value of the current key being entered */
  72030. get currentKey(): string;
  72031. set currentKey(key: string);
  72032. /** Gets or sets the text displayed in the control */
  72033. get text(): string;
  72034. set text(value: string);
  72035. /** Gets or sets control width */
  72036. get width(): string | number;
  72037. set width(value: string | number);
  72038. /**
  72039. * Creates a new InputText
  72040. * @param name defines the control name
  72041. * @param text defines the text of the control
  72042. */
  72043. constructor(name?: string | undefined, text?: string);
  72044. /** @hidden */
  72045. onBlur(): void;
  72046. /** @hidden */
  72047. onFocus(): void;
  72048. protected _getTypeName(): string;
  72049. /**
  72050. * Function called to get the list of controls that should not steal the focus from this control
  72051. * @returns an array of controls
  72052. */
  72053. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  72054. /** @hidden */
  72055. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  72056. /** @hidden */
  72057. private _updateValueFromCursorIndex;
  72058. /** @hidden */
  72059. private _processDblClick;
  72060. /** @hidden */
  72061. private _selectAllText;
  72062. /**
  72063. * Handles the keyboard event
  72064. * @param evt Defines the KeyboardEvent
  72065. */
  72066. processKeyboard(evt: KeyboardEvent): void;
  72067. /** @hidden */
  72068. private _onCopyText;
  72069. /** @hidden */
  72070. private _onCutText;
  72071. /** @hidden */
  72072. private _onPasteText;
  72073. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72074. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72075. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  72076. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72077. protected _beforeRenderText(text: string): string;
  72078. dispose(): void;
  72079. }
  72080. }
  72081. declare module BABYLON.GUI {
  72082. /**
  72083. * Class used to create a 2D grid container
  72084. */
  72085. export class Grid extends Container {
  72086. name?: string | undefined;
  72087. private _rowDefinitions;
  72088. private _columnDefinitions;
  72089. private _cells;
  72090. private _childControls;
  72091. /**
  72092. * Gets the number of columns
  72093. */
  72094. get columnCount(): number;
  72095. /**
  72096. * Gets the number of rows
  72097. */
  72098. get rowCount(): number;
  72099. /** Gets the list of children */
  72100. get children(): Control[];
  72101. /** Gets the list of cells (e.g. the containers) */
  72102. get cells(): {
  72103. [key: string]: Container;
  72104. };
  72105. /**
  72106. * Gets the definition of a specific row
  72107. * @param index defines the index of the row
  72108. * @returns the row definition
  72109. */
  72110. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  72111. /**
  72112. * Gets the definition of a specific column
  72113. * @param index defines the index of the column
  72114. * @returns the column definition
  72115. */
  72116. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  72117. /**
  72118. * Adds a new row to the grid
  72119. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  72120. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  72121. * @returns the current grid
  72122. */
  72123. addRowDefinition(height: number, isPixel?: boolean): Grid;
  72124. /**
  72125. * Adds a new column to the grid
  72126. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  72127. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  72128. * @returns the current grid
  72129. */
  72130. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  72131. /**
  72132. * Update a row definition
  72133. * @param index defines the index of the row to update
  72134. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  72135. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  72136. * @returns the current grid
  72137. */
  72138. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  72139. /**
  72140. * Update a column definition
  72141. * @param index defines the index of the column to update
  72142. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  72143. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  72144. * @returns the current grid
  72145. */
  72146. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  72147. /**
  72148. * Gets the list of children stored in a specific cell
  72149. * @param row defines the row to check
  72150. * @param column defines the column to check
  72151. * @returns the list of controls
  72152. */
  72153. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  72154. /**
  72155. * Gets a string representing the child cell info (row x column)
  72156. * @param child defines the control to get info from
  72157. * @returns a string containing the child cell info (row x column)
  72158. */
  72159. getChildCellInfo(child: Control): string;
  72160. private _removeCell;
  72161. private _offsetCell;
  72162. /**
  72163. * Remove a column definition at specified index
  72164. * @param index defines the index of the column to remove
  72165. * @returns the current grid
  72166. */
  72167. removeColumnDefinition(index: number): Grid;
  72168. /**
  72169. * Remove a row definition at specified index
  72170. * @param index defines the index of the row to remove
  72171. * @returns the current grid
  72172. */
  72173. removeRowDefinition(index: number): Grid;
  72174. /**
  72175. * Adds a new control to the current grid
  72176. * @param control defines the control to add
  72177. * @param row defines the row where to add the control (0 by default)
  72178. * @param column defines the column where to add the control (0 by default)
  72179. * @returns the current grid
  72180. */
  72181. addControl(control: Control, row?: number, column?: number): Grid;
  72182. /**
  72183. * Removes a control from the current container
  72184. * @param control defines the control to remove
  72185. * @returns the current container
  72186. */
  72187. removeControl(control: Control): Container;
  72188. /**
  72189. * Creates a new Grid
  72190. * @param name defines control name
  72191. */
  72192. constructor(name?: string | undefined);
  72193. protected _getTypeName(): string;
  72194. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  72195. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72196. _flagDescendantsAsMatrixDirty(): void;
  72197. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  72198. /** Releases associated resources */
  72199. dispose(): void;
  72200. }
  72201. }
  72202. declare module BABYLON.GUI {
  72203. /** Class used to create color pickers */
  72204. export class ColorPicker extends Control {
  72205. name?: string | undefined;
  72206. private static _Epsilon;
  72207. private _colorWheelCanvas;
  72208. private _value;
  72209. private _tmpColor;
  72210. private _pointerStartedOnSquare;
  72211. private _pointerStartedOnWheel;
  72212. private _squareLeft;
  72213. private _squareTop;
  72214. private _squareSize;
  72215. private _h;
  72216. private _s;
  72217. private _v;
  72218. private _lastPointerDownID;
  72219. /**
  72220. * BABYLON.Observable raised when the value changes
  72221. */
  72222. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  72223. /** Gets or sets the color of the color picker */
  72224. get value(): BABYLON.Color3;
  72225. set value(value: BABYLON.Color3);
  72226. /**
  72227. * Gets or sets control width
  72228. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72229. */
  72230. get width(): string | number;
  72231. set width(value: string | number);
  72232. /**
  72233. * Gets or sets control height
  72234. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  72235. */
  72236. get height(): string | number;
  72237. /** Gets or sets control height */
  72238. set height(value: string | number);
  72239. /** Gets or sets control size */
  72240. get size(): string | number;
  72241. set size(value: string | number);
  72242. /**
  72243. * Creates a new ColorPicker
  72244. * @param name defines the control name
  72245. */
  72246. constructor(name?: string | undefined);
  72247. protected _getTypeName(): string;
  72248. /** @hidden */
  72249. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72250. private _updateSquareProps;
  72251. private _drawGradientSquare;
  72252. private _drawCircle;
  72253. private _createColorWheelCanvas;
  72254. /** @hidden */
  72255. _draw(context: CanvasRenderingContext2D): void;
  72256. private _pointerIsDown;
  72257. private _updateValueFromPointer;
  72258. private _isPointOnSquare;
  72259. private _isPointOnWheel;
  72260. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72261. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  72262. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72263. /**
  72264. * This function expands the color picker by creating a color picker dialog with manual
  72265. * color value input and the ability to save colors into an array to be used later in
  72266. * subsequent launches of the dialogue.
  72267. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  72268. * @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.
  72269. * @returns picked color as a hex string and the saved colors array as hex strings.
  72270. */
  72271. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  72272. pickerWidth?: string;
  72273. pickerHeight?: string;
  72274. headerHeight?: string;
  72275. lastColor?: string;
  72276. swatchLimit?: number;
  72277. numSwatchesPerLine?: number;
  72278. savedColors?: Array<string>;
  72279. }): Promise<{
  72280. savedColors?: string[];
  72281. pickedColor: string;
  72282. }>;
  72283. }
  72284. }
  72285. declare module BABYLON.GUI {
  72286. /** Class used to create 2D ellipse containers */
  72287. export class Ellipse extends Container {
  72288. name?: string | undefined;
  72289. private _thickness;
  72290. /** Gets or sets border thickness */
  72291. get thickness(): number;
  72292. set thickness(value: number);
  72293. /**
  72294. * Creates a new Ellipse
  72295. * @param name defines the control name
  72296. */
  72297. constructor(name?: string | undefined);
  72298. protected _getTypeName(): string;
  72299. protected _localDraw(context: CanvasRenderingContext2D): void;
  72300. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72301. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  72302. }
  72303. }
  72304. declare module BABYLON.GUI {
  72305. /**
  72306. * Class used to create a password control
  72307. */
  72308. export class InputPassword extends InputText {
  72309. protected _beforeRenderText(text: string): string;
  72310. }
  72311. }
  72312. declare module BABYLON.GUI {
  72313. /** Class used to render 2D lines */
  72314. export class Line extends Control {
  72315. name?: string | undefined;
  72316. private _lineWidth;
  72317. private _x1;
  72318. private _y1;
  72319. private _x2;
  72320. private _y2;
  72321. private _dash;
  72322. private _connectedControl;
  72323. private _connectedControlDirtyObserver;
  72324. /** Gets or sets the dash pattern */
  72325. get dash(): Array<number>;
  72326. set dash(value: Array<number>);
  72327. /** Gets or sets the control connected with the line end */
  72328. get connectedControl(): Control;
  72329. set connectedControl(value: Control);
  72330. /** Gets or sets start coordinates on X axis */
  72331. get x1(): string | number;
  72332. set x1(value: string | number);
  72333. /** Gets or sets start coordinates on Y axis */
  72334. get y1(): string | number;
  72335. set y1(value: string | number);
  72336. /** Gets or sets end coordinates on X axis */
  72337. get x2(): string | number;
  72338. set x2(value: string | number);
  72339. /** Gets or sets end coordinates on Y axis */
  72340. get y2(): string | number;
  72341. set y2(value: string | number);
  72342. /** Gets or sets line width */
  72343. get lineWidth(): number;
  72344. set lineWidth(value: number);
  72345. /** Gets or sets horizontal alignment */
  72346. set horizontalAlignment(value: number);
  72347. /** Gets or sets vertical alignment */
  72348. set verticalAlignment(value: number);
  72349. private get _effectiveX2();
  72350. private get _effectiveY2();
  72351. /**
  72352. * Creates a new Line
  72353. * @param name defines the control name
  72354. */
  72355. constructor(name?: string | undefined);
  72356. protected _getTypeName(): string;
  72357. _draw(context: CanvasRenderingContext2D): void;
  72358. _measure(): void;
  72359. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72360. /**
  72361. * Move one end of the line given 3D cartesian coordinates.
  72362. * @param position Targeted world position
  72363. * @param scene BABYLON.Scene
  72364. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  72365. */
  72366. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  72367. /**
  72368. * Move one end of the line to a position in screen absolute space.
  72369. * @param projectedPosition Position in screen absolute space (X, Y)
  72370. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  72371. */
  72372. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  72373. }
  72374. }
  72375. declare module BABYLON.GUI {
  72376. /**
  72377. * Class used to store a point for a MultiLine object.
  72378. * The point can be pure 2D coordinates, a mesh or a control
  72379. */
  72380. export class MultiLinePoint {
  72381. private _multiLine;
  72382. private _x;
  72383. private _y;
  72384. private _control;
  72385. private _mesh;
  72386. private _controlObserver;
  72387. private _meshObserver;
  72388. /** @hidden */
  72389. _point: BABYLON.Vector2;
  72390. /**
  72391. * Creates a new MultiLinePoint
  72392. * @param multiLine defines the source MultiLine object
  72393. */
  72394. constructor(multiLine: MultiLine);
  72395. /** Gets or sets x coordinate */
  72396. get x(): string | number;
  72397. set x(value: string | number);
  72398. /** Gets or sets y coordinate */
  72399. get y(): string | number;
  72400. set y(value: string | number);
  72401. /** Gets or sets the control associated with this point */
  72402. get control(): BABYLON.Nullable<Control>;
  72403. set control(value: BABYLON.Nullable<Control>);
  72404. /** Gets or sets the mesh associated with this point */
  72405. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  72406. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  72407. /** Resets links */
  72408. resetLinks(): void;
  72409. /**
  72410. * Gets a translation vector
  72411. * @returns the translation vector
  72412. */
  72413. translate(): BABYLON.Vector2;
  72414. private _translatePoint;
  72415. /** Release associated resources */
  72416. dispose(): void;
  72417. }
  72418. }
  72419. declare module BABYLON.GUI {
  72420. /**
  72421. * Class used to create multi line control
  72422. */
  72423. export class MultiLine extends Control {
  72424. name?: string | undefined;
  72425. private _lineWidth;
  72426. private _dash;
  72427. private _points;
  72428. private _minX;
  72429. private _minY;
  72430. private _maxX;
  72431. private _maxY;
  72432. /**
  72433. * Creates a new MultiLine
  72434. * @param name defines the control name
  72435. */
  72436. constructor(name?: string | undefined);
  72437. /** Gets or sets dash pattern */
  72438. get dash(): Array<number>;
  72439. set dash(value: Array<number>);
  72440. /**
  72441. * Gets point stored at specified index
  72442. * @param index defines the index to look for
  72443. * @returns the requested point if found
  72444. */
  72445. getAt(index: number): MultiLinePoint;
  72446. /** Function called when a point is updated */
  72447. onPointUpdate: () => void;
  72448. /**
  72449. * Adds new points to the point collection
  72450. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  72451. * @returns the list of created MultiLinePoint
  72452. */
  72453. add(...items: (AbstractMesh | Control | {
  72454. x: string | number;
  72455. y: string | number;
  72456. })[]): MultiLinePoint[];
  72457. /**
  72458. * Adds a new point to the point collection
  72459. * @param item defines the item (mesh, control or 2d coordiantes) to add
  72460. * @returns the created MultiLinePoint
  72461. */
  72462. push(item?: (AbstractMesh | Control | {
  72463. x: string | number;
  72464. y: string | number;
  72465. })): MultiLinePoint;
  72466. /**
  72467. * Remove a specific value or point from the active point collection
  72468. * @param value defines the value or point to remove
  72469. */
  72470. remove(value: number | MultiLinePoint): void;
  72471. /**
  72472. * Resets this object to initial state (no point)
  72473. */
  72474. reset(): void;
  72475. /**
  72476. * Resets all links
  72477. */
  72478. resetLinks(): void;
  72479. /** Gets or sets line width */
  72480. get lineWidth(): number;
  72481. set lineWidth(value: number);
  72482. set horizontalAlignment(value: number);
  72483. set verticalAlignment(value: number);
  72484. protected _getTypeName(): string;
  72485. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72486. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72487. _measure(): void;
  72488. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72489. dispose(): void;
  72490. }
  72491. }
  72492. declare module BABYLON.GUI {
  72493. /**
  72494. * Class used to create radio button controls
  72495. */
  72496. export class RadioButton extends Control {
  72497. name?: string | undefined;
  72498. private _isChecked;
  72499. private _background;
  72500. private _checkSizeRatio;
  72501. private _thickness;
  72502. /** Gets or sets border thickness */
  72503. get thickness(): number;
  72504. set thickness(value: number);
  72505. /** Gets or sets group name */
  72506. group: string;
  72507. /** BABYLON.Observable raised when isChecked is changed */
  72508. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  72509. /** Gets or sets a value indicating the ratio between overall size and check size */
  72510. get checkSizeRatio(): number;
  72511. set checkSizeRatio(value: number);
  72512. /** Gets or sets background color */
  72513. get background(): string;
  72514. set background(value: string);
  72515. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  72516. get isChecked(): boolean;
  72517. set isChecked(value: boolean);
  72518. /**
  72519. * Creates a new RadioButton
  72520. * @param name defines the control name
  72521. */
  72522. constructor(name?: string | undefined);
  72523. protected _getTypeName(): string;
  72524. _draw(context: CanvasRenderingContext2D): void;
  72525. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72526. /**
  72527. * Utility function to easily create a radio button with a header
  72528. * @param title defines the label to use for the header
  72529. * @param group defines the group to use for the radio button
  72530. * @param isChecked defines the initial state of the radio button
  72531. * @param onValueChanged defines the callback to call when value changes
  72532. * @returns a StackPanel containing the radio button and a textBlock
  72533. */
  72534. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  72535. }
  72536. }
  72537. declare module BABYLON.GUI {
  72538. /**
  72539. * Class used to create slider controls
  72540. */
  72541. export class BaseSlider extends Control {
  72542. name?: string | undefined;
  72543. protected _thumbWidth: ValueAndUnit;
  72544. private _minimum;
  72545. private _maximum;
  72546. private _value;
  72547. private _isVertical;
  72548. protected _barOffset: ValueAndUnit;
  72549. private _isThumbClamped;
  72550. protected _displayThumb: boolean;
  72551. private _step;
  72552. private _lastPointerDownID;
  72553. protected _effectiveBarOffset: number;
  72554. protected _renderLeft: number;
  72555. protected _renderTop: number;
  72556. protected _renderWidth: number;
  72557. protected _renderHeight: number;
  72558. protected _backgroundBoxLength: number;
  72559. protected _backgroundBoxThickness: number;
  72560. protected _effectiveThumbThickness: number;
  72561. /** BABYLON.Observable raised when the sldier value changes */
  72562. onValueChangedObservable: BABYLON.Observable<number>;
  72563. /** Gets or sets a boolean indicating if the thumb must be rendered */
  72564. get displayThumb(): boolean;
  72565. set displayThumb(value: boolean);
  72566. /** Gets or sets a step to apply to values (0 by default) */
  72567. get step(): number;
  72568. set step(value: number);
  72569. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  72570. get barOffset(): string | number;
  72571. /** Gets main bar offset in pixels*/
  72572. get barOffsetInPixels(): number;
  72573. set barOffset(value: string | number);
  72574. /** Gets or sets thumb width */
  72575. get thumbWidth(): string | number;
  72576. /** Gets thumb width in pixels */
  72577. get thumbWidthInPixels(): number;
  72578. set thumbWidth(value: string | number);
  72579. /** Gets or sets minimum value */
  72580. get minimum(): number;
  72581. set minimum(value: number);
  72582. /** Gets or sets maximum value */
  72583. get maximum(): number;
  72584. set maximum(value: number);
  72585. /** Gets or sets current value */
  72586. get value(): number;
  72587. set value(value: number);
  72588. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  72589. get isVertical(): boolean;
  72590. set isVertical(value: boolean);
  72591. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  72592. get isThumbClamped(): boolean;
  72593. set isThumbClamped(value: boolean);
  72594. /**
  72595. * Creates a new BaseSlider
  72596. * @param name defines the control name
  72597. */
  72598. constructor(name?: string | undefined);
  72599. protected _getTypeName(): string;
  72600. protected _getThumbPosition(): number;
  72601. protected _getThumbThickness(type: string): number;
  72602. protected _prepareRenderingData(type: string): void;
  72603. private _pointerIsDown;
  72604. /** @hidden */
  72605. protected _updateValueFromPointer(x: number, y: number): void;
  72606. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72607. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  72608. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  72609. }
  72610. }
  72611. declare module BABYLON.GUI {
  72612. /**
  72613. * Class used to create slider controls
  72614. */
  72615. export class Slider extends BaseSlider {
  72616. name?: string | undefined;
  72617. private _background;
  72618. private _borderColor;
  72619. private _isThumbCircle;
  72620. protected _displayValueBar: boolean;
  72621. /** Gets or sets a boolean indicating if the value bar must be rendered */
  72622. get displayValueBar(): boolean;
  72623. set displayValueBar(value: boolean);
  72624. /** Gets or sets border color */
  72625. get borderColor(): string;
  72626. set borderColor(value: string);
  72627. /** Gets or sets background color */
  72628. get background(): string;
  72629. set background(value: string);
  72630. /** Gets or sets a boolean indicating if the thumb should be round or square */
  72631. get isThumbCircle(): boolean;
  72632. set isThumbCircle(value: boolean);
  72633. /**
  72634. * Creates a new Slider
  72635. * @param name defines the control name
  72636. */
  72637. constructor(name?: string | undefined);
  72638. protected _getTypeName(): string;
  72639. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  72640. }
  72641. }
  72642. declare module BABYLON.GUI {
  72643. /** Class used to create a RadioGroup
  72644. * which contains groups of radio buttons
  72645. */
  72646. export class SelectorGroup {
  72647. /** name of SelectorGroup */
  72648. name: string;
  72649. private _groupPanel;
  72650. private _selectors;
  72651. private _groupHeader;
  72652. /**
  72653. * Creates a new SelectorGroup
  72654. * @param name of group, used as a group heading
  72655. */
  72656. constructor(
  72657. /** name of SelectorGroup */
  72658. name: string);
  72659. /** Gets the groupPanel of the SelectorGroup */
  72660. get groupPanel(): StackPanel;
  72661. /** Gets the selectors array */
  72662. get selectors(): StackPanel[];
  72663. /** Gets and sets the group header */
  72664. get header(): string;
  72665. set header(label: string);
  72666. /** @hidden */
  72667. private _addGroupHeader;
  72668. /** @hidden*/
  72669. _getSelector(selectorNb: number): StackPanel | undefined;
  72670. /** Removes the selector at the given position
  72671. * @param selectorNb the position of the selector within the group
  72672. */
  72673. removeSelector(selectorNb: number): void;
  72674. }
  72675. /** Class used to create a CheckboxGroup
  72676. * which contains groups of checkbox buttons
  72677. */
  72678. export class CheckboxGroup extends SelectorGroup {
  72679. /** Adds a checkbox as a control
  72680. * @param text is the label for the selector
  72681. * @param func is the function called when the Selector is checked
  72682. * @param checked is true when Selector is checked
  72683. */
  72684. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  72685. /** @hidden */
  72686. _setSelectorLabel(selectorNb: number, label: string): void;
  72687. /** @hidden */
  72688. _setSelectorLabelColor(selectorNb: number, color: string): void;
  72689. /** @hidden */
  72690. _setSelectorButtonColor(selectorNb: number, color: string): void;
  72691. /** @hidden */
  72692. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  72693. }
  72694. /** Class used to create a RadioGroup
  72695. * which contains groups of radio buttons
  72696. */
  72697. export class RadioGroup extends SelectorGroup {
  72698. private _selectNb;
  72699. /** Adds a radio button as a control
  72700. * @param label is the label for the selector
  72701. * @param func is the function called when the Selector is checked
  72702. * @param checked is true when Selector is checked
  72703. */
  72704. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  72705. /** @hidden */
  72706. _setSelectorLabel(selectorNb: number, label: string): void;
  72707. /** @hidden */
  72708. _setSelectorLabelColor(selectorNb: number, color: string): void;
  72709. /** @hidden */
  72710. _setSelectorButtonColor(selectorNb: number, color: string): void;
  72711. /** @hidden */
  72712. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  72713. }
  72714. /** Class used to create a SliderGroup
  72715. * which contains groups of slider buttons
  72716. */
  72717. export class SliderGroup extends SelectorGroup {
  72718. /**
  72719. * Adds a slider to the SelectorGroup
  72720. * @param label is the label for the SliderBar
  72721. * @param func is the function called when the Slider moves
  72722. * @param unit is a string describing the units used, eg degrees or metres
  72723. * @param min is the minimum value for the Slider
  72724. * @param max is the maximum value for the Slider
  72725. * @param value is the start value for the Slider between min and max
  72726. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  72727. */
  72728. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  72729. /** @hidden */
  72730. _setSelectorLabel(selectorNb: number, label: string): void;
  72731. /** @hidden */
  72732. _setSelectorLabelColor(selectorNb: number, color: string): void;
  72733. /** @hidden */
  72734. _setSelectorButtonColor(selectorNb: number, color: string): void;
  72735. /** @hidden */
  72736. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  72737. }
  72738. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  72739. * @see http://doc.babylonjs.com/how_to/selector
  72740. */
  72741. export class SelectionPanel extends Rectangle {
  72742. /** name of SelectionPanel */
  72743. name: string;
  72744. /** an array of SelectionGroups */
  72745. groups: SelectorGroup[];
  72746. private _panel;
  72747. private _buttonColor;
  72748. private _buttonBackground;
  72749. private _headerColor;
  72750. private _barColor;
  72751. private _barHeight;
  72752. private _spacerHeight;
  72753. private _labelColor;
  72754. private _groups;
  72755. private _bars;
  72756. /**
  72757. * Creates a new SelectionPanel
  72758. * @param name of SelectionPanel
  72759. * @param groups is an array of SelectionGroups
  72760. */
  72761. constructor(
  72762. /** name of SelectionPanel */
  72763. name: string,
  72764. /** an array of SelectionGroups */
  72765. groups?: SelectorGroup[]);
  72766. protected _getTypeName(): string;
  72767. /** Gets or sets the headerColor */
  72768. get headerColor(): string;
  72769. set headerColor(color: string);
  72770. private _setHeaderColor;
  72771. /** Gets or sets the button color */
  72772. get buttonColor(): string;
  72773. set buttonColor(color: string);
  72774. private _setbuttonColor;
  72775. /** Gets or sets the label color */
  72776. get labelColor(): string;
  72777. set labelColor(color: string);
  72778. private _setLabelColor;
  72779. /** Gets or sets the button background */
  72780. get buttonBackground(): string;
  72781. set buttonBackground(color: string);
  72782. private _setButtonBackground;
  72783. /** Gets or sets the color of separator bar */
  72784. get barColor(): string;
  72785. set barColor(color: string);
  72786. private _setBarColor;
  72787. /** Gets or sets the height of separator bar */
  72788. get barHeight(): string;
  72789. set barHeight(value: string);
  72790. private _setBarHeight;
  72791. /** Gets or sets the height of spacers*/
  72792. get spacerHeight(): string;
  72793. set spacerHeight(value: string);
  72794. private _setSpacerHeight;
  72795. /** Adds a bar between groups */
  72796. private _addSpacer;
  72797. /** Add a group to the selection panel
  72798. * @param group is the selector group to add
  72799. */
  72800. addGroup(group: SelectorGroup): void;
  72801. /** Remove the group from the given position
  72802. * @param groupNb is the position of the group in the list
  72803. */
  72804. removeGroup(groupNb: number): void;
  72805. /** Change a group header label
  72806. * @param label is the new group header label
  72807. * @param groupNb is the number of the group to relabel
  72808. * */
  72809. setHeaderName(label: string, groupNb: number): void;
  72810. /** Change selector label to the one given
  72811. * @param label is the new selector label
  72812. * @param groupNb is the number of the groupcontaining the selector
  72813. * @param selectorNb is the number of the selector within a group to relabel
  72814. * */
  72815. relabel(label: string, groupNb: number, selectorNb: number): void;
  72816. /** For a given group position remove the selector at the given position
  72817. * @param groupNb is the number of the group to remove the selector from
  72818. * @param selectorNb is the number of the selector within the group
  72819. */
  72820. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  72821. /** For a given group position of correct type add a checkbox button
  72822. * @param groupNb is the number of the group to remove the selector from
  72823. * @param label is the label for the selector
  72824. * @param func is the function called when the Selector is checked
  72825. * @param checked is true when Selector is checked
  72826. */
  72827. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  72828. /** For a given group position of correct type add a radio button
  72829. * @param groupNb is the number of the group to remove the selector from
  72830. * @param label is the label for the selector
  72831. * @param func is the function called when the Selector is checked
  72832. * @param checked is true when Selector is checked
  72833. */
  72834. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  72835. /**
  72836. * For a given slider group add a slider
  72837. * @param groupNb is the number of the group to add the slider to
  72838. * @param label is the label for the Slider
  72839. * @param func is the function called when the Slider moves
  72840. * @param unit is a string describing the units used, eg degrees or metres
  72841. * @param min is the minimum value for the Slider
  72842. * @param max is the maximum value for the Slider
  72843. * @param value is the start value for the Slider between min and max
  72844. * @param onVal is the function used to format the value displayed, eg radians to degrees
  72845. */
  72846. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  72847. }
  72848. }
  72849. declare module BABYLON.GUI {
  72850. /**
  72851. * Class used to hold a the container for ScrollViewer
  72852. * @hidden
  72853. */
  72854. export class _ScrollViewerWindow extends Container {
  72855. parentClientWidth: number;
  72856. parentClientHeight: number;
  72857. private _freezeControls;
  72858. private _parentMeasure;
  72859. private _oldLeft;
  72860. private _oldTop;
  72861. get freezeControls(): boolean;
  72862. set freezeControls(value: boolean);
  72863. private _bucketWidth;
  72864. private _bucketHeight;
  72865. private _buckets;
  72866. private _bucketLen;
  72867. get bucketWidth(): number;
  72868. get bucketHeight(): number;
  72869. setBucketSizes(width: number, height: number): void;
  72870. private _useBuckets;
  72871. private _makeBuckets;
  72872. private _dispatchInBuckets;
  72873. private _updateMeasures;
  72874. private _updateChildrenMeasures;
  72875. /**
  72876. * Creates a new ScrollViewerWindow
  72877. * @param name of ScrollViewerWindow
  72878. */
  72879. constructor(name?: string);
  72880. protected _getTypeName(): string;
  72881. /** @hidden */
  72882. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  72883. /** @hidden */
  72884. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  72885. private _scrollChildren;
  72886. private _scrollChildrenWithBuckets;
  72887. /** @hidden */
  72888. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  72889. protected _postMeasure(): void;
  72890. }
  72891. }
  72892. declare module BABYLON.GUI {
  72893. /**
  72894. * Class used to create slider controls
  72895. */
  72896. export class ScrollBar extends BaseSlider {
  72897. name?: string | undefined;
  72898. private _background;
  72899. private _borderColor;
  72900. private _tempMeasure;
  72901. /** Gets or sets border color */
  72902. get borderColor(): string;
  72903. set borderColor(value: string);
  72904. /** Gets or sets background color */
  72905. get background(): string;
  72906. set background(value: string);
  72907. /**
  72908. * Creates a new Slider
  72909. * @param name defines the control name
  72910. */
  72911. constructor(name?: string | undefined);
  72912. protected _getTypeName(): string;
  72913. protected _getThumbThickness(): number;
  72914. _draw(context: CanvasRenderingContext2D): void;
  72915. private _first;
  72916. private _originX;
  72917. private _originY;
  72918. /** @hidden */
  72919. protected _updateValueFromPointer(x: number, y: number): void;
  72920. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72921. }
  72922. }
  72923. declare module BABYLON.GUI {
  72924. /**
  72925. * Class used to create slider controls
  72926. */
  72927. export class ImageScrollBar extends BaseSlider {
  72928. name?: string | undefined;
  72929. private _backgroundBaseImage;
  72930. private _backgroundImage;
  72931. private _thumbImage;
  72932. private _thumbBaseImage;
  72933. private _thumbLength;
  72934. private _thumbHeight;
  72935. private _barImageHeight;
  72936. private _tempMeasure;
  72937. /** Number of 90° rotation to apply on the images when in vertical mode */
  72938. num90RotationInVerticalMode: number;
  72939. /**
  72940. * Gets or sets the image used to render the background for horizontal bar
  72941. */
  72942. get backgroundImage(): Image;
  72943. set backgroundImage(value: Image);
  72944. /**
  72945. * Gets or sets the image used to render the thumb
  72946. */
  72947. get thumbImage(): Image;
  72948. set thumbImage(value: Image);
  72949. /**
  72950. * Gets or sets the length of the thumb
  72951. */
  72952. get thumbLength(): number;
  72953. set thumbLength(value: number);
  72954. /**
  72955. * Gets or sets the height of the thumb
  72956. */
  72957. get thumbHeight(): number;
  72958. set thumbHeight(value: number);
  72959. /**
  72960. * Gets or sets the height of the bar image
  72961. */
  72962. get barImageHeight(): number;
  72963. set barImageHeight(value: number);
  72964. /**
  72965. * Creates a new ImageScrollBar
  72966. * @param name defines the control name
  72967. */
  72968. constructor(name?: string | undefined);
  72969. protected _getTypeName(): string;
  72970. protected _getThumbThickness(): number;
  72971. _draw(context: CanvasRenderingContext2D): void;
  72972. private _first;
  72973. private _originX;
  72974. private _originY;
  72975. /** @hidden */
  72976. protected _updateValueFromPointer(x: number, y: number): void;
  72977. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  72978. }
  72979. }
  72980. declare module BABYLON.GUI {
  72981. /**
  72982. * Class used to hold a viewer window and sliders in a grid
  72983. */
  72984. export class ScrollViewer extends Rectangle {
  72985. private _grid;
  72986. private _horizontalBarSpace;
  72987. private _verticalBarSpace;
  72988. private _dragSpace;
  72989. private _horizontalBar;
  72990. private _verticalBar;
  72991. private _barColor;
  72992. private _barBackground;
  72993. private _barImage;
  72994. private _horizontalBarImage;
  72995. private _verticalBarImage;
  72996. private _barBackgroundImage;
  72997. private _horizontalBarBackgroundImage;
  72998. private _verticalBarBackgroundImage;
  72999. private _barSize;
  73000. private _window;
  73001. private _pointerIsOver;
  73002. private _wheelPrecision;
  73003. private _onPointerObserver;
  73004. private _clientWidth;
  73005. private _clientHeight;
  73006. private _useImageBar;
  73007. private _thumbLength;
  73008. private _thumbHeight;
  73009. private _barImageHeight;
  73010. private _horizontalBarImageHeight;
  73011. private _verticalBarImageHeight;
  73012. /**
  73013. * Gets the horizontal scrollbar
  73014. */
  73015. get horizontalBar(): ScrollBar | ImageScrollBar;
  73016. /**
  73017. * Gets the vertical scrollbar
  73018. */
  73019. get verticalBar(): ScrollBar | ImageScrollBar;
  73020. /**
  73021. * Adds a new control to the current container
  73022. * @param control defines the control to add
  73023. * @returns the current container
  73024. */
  73025. addControl(control: BABYLON.Nullable<Control>): Container;
  73026. /**
  73027. * Removes a control from the current container
  73028. * @param control defines the control to remove
  73029. * @returns the current container
  73030. */
  73031. removeControl(control: Control): Container;
  73032. /** Gets the list of children */
  73033. get children(): Control[];
  73034. _flagDescendantsAsMatrixDirty(): void;
  73035. /**
  73036. * Freezes or unfreezes the controls in the window.
  73037. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  73038. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  73039. */
  73040. get freezeControls(): boolean;
  73041. set freezeControls(value: boolean);
  73042. /** Gets the bucket width */
  73043. get bucketWidth(): number;
  73044. /** Gets the bucket height */
  73045. get bucketHeight(): number;
  73046. /**
  73047. * Sets the bucket sizes.
  73048. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  73049. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  73050. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  73051. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  73052. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  73053. * used), that's why it is not enabled by default.
  73054. * @param width width of the bucket
  73055. * @param height height of the bucket
  73056. */
  73057. setBucketSizes(width: number, height: number): void;
  73058. private _forceHorizontalBar;
  73059. private _forceVerticalBar;
  73060. /**
  73061. * Forces the horizontal scroll bar to be displayed
  73062. */
  73063. get forceHorizontalBar(): boolean;
  73064. set forceHorizontalBar(value: boolean);
  73065. /**
  73066. * Forces the vertical scroll bar to be displayed
  73067. */
  73068. get forceVerticalBar(): boolean;
  73069. set forceVerticalBar(value: boolean);
  73070. /**
  73071. * Creates a new ScrollViewer
  73072. * @param name of ScrollViewer
  73073. */
  73074. constructor(name?: string, isImageBased?: boolean);
  73075. /** Reset the scroll viewer window to initial size */
  73076. resetWindow(): void;
  73077. protected _getTypeName(): string;
  73078. private _buildClientSizes;
  73079. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  73080. protected _postMeasure(): void;
  73081. /**
  73082. * Gets or sets the mouse wheel precision
  73083. * from 0 to 1 with a default value of 0.05
  73084. * */
  73085. get wheelPrecision(): number;
  73086. set wheelPrecision(value: number);
  73087. /** Gets or sets the scroll bar container background color */
  73088. get scrollBackground(): string;
  73089. set scrollBackground(color: string);
  73090. /** Gets or sets the bar color */
  73091. get barColor(): string;
  73092. set barColor(color: string);
  73093. /** Gets or sets the bar image */
  73094. get thumbImage(): Image;
  73095. set thumbImage(value: Image);
  73096. /** Gets or sets the horizontal bar image */
  73097. get horizontalThumbImage(): Image;
  73098. set horizontalThumbImage(value: Image);
  73099. /** Gets or sets the vertical bar image */
  73100. get verticalThumbImage(): Image;
  73101. set verticalThumbImage(value: Image);
  73102. /** Gets or sets the size of the bar */
  73103. get barSize(): number;
  73104. set barSize(value: number);
  73105. /** Gets or sets the length of the thumb */
  73106. get thumbLength(): number;
  73107. set thumbLength(value: number);
  73108. /** Gets or sets the height of the thumb */
  73109. get thumbHeight(): number;
  73110. set thumbHeight(value: number);
  73111. /** Gets or sets the height of the bar image */
  73112. get barImageHeight(): number;
  73113. set barImageHeight(value: number);
  73114. /** Gets or sets the height of the horizontal bar image */
  73115. get horizontalBarImageHeight(): number;
  73116. set horizontalBarImageHeight(value: number);
  73117. /** Gets or sets the height of the vertical bar image */
  73118. get verticalBarImageHeight(): number;
  73119. set verticalBarImageHeight(value: number);
  73120. /** Gets or sets the bar background */
  73121. get barBackground(): string;
  73122. set barBackground(color: string);
  73123. /** Gets or sets the bar background image */
  73124. get barImage(): Image;
  73125. set barImage(value: Image);
  73126. /** Gets or sets the horizontal bar background image */
  73127. get horizontalBarImage(): Image;
  73128. set horizontalBarImage(value: Image);
  73129. /** Gets or sets the vertical bar background image */
  73130. get verticalBarImage(): Image;
  73131. set verticalBarImage(value: Image);
  73132. private _setWindowPosition;
  73133. /** @hidden */
  73134. private _updateScroller;
  73135. _link(host: AdvancedDynamicTexture): void;
  73136. /** @hidden */
  73137. private _addBar;
  73138. /** @hidden */
  73139. private _attachWheel;
  73140. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  73141. /** Releases associated resources */
  73142. dispose(): void;
  73143. }
  73144. }
  73145. declare module BABYLON.GUI {
  73146. /** Class used to render a grid */
  73147. export class DisplayGrid extends Control {
  73148. name?: string | undefined;
  73149. private _cellWidth;
  73150. private _cellHeight;
  73151. private _minorLineTickness;
  73152. private _minorLineColor;
  73153. private _majorLineTickness;
  73154. private _majorLineColor;
  73155. private _majorLineFrequency;
  73156. private _background;
  73157. private _displayMajorLines;
  73158. private _displayMinorLines;
  73159. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  73160. get displayMinorLines(): boolean;
  73161. set displayMinorLines(value: boolean);
  73162. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  73163. get displayMajorLines(): boolean;
  73164. set displayMajorLines(value: boolean);
  73165. /** Gets or sets background color (Black by default) */
  73166. get background(): string;
  73167. set background(value: string);
  73168. /** Gets or sets the width of each cell (20 by default) */
  73169. get cellWidth(): number;
  73170. set cellWidth(value: number);
  73171. /** Gets or sets the height of each cell (20 by default) */
  73172. get cellHeight(): number;
  73173. set cellHeight(value: number);
  73174. /** Gets or sets the tickness of minor lines (1 by default) */
  73175. get minorLineTickness(): number;
  73176. set minorLineTickness(value: number);
  73177. /** Gets or sets the color of minor lines (DarkGray by default) */
  73178. get minorLineColor(): string;
  73179. set minorLineColor(value: string);
  73180. /** Gets or sets the tickness of major lines (2 by default) */
  73181. get majorLineTickness(): number;
  73182. set majorLineTickness(value: number);
  73183. /** Gets or sets the color of major lines (White by default) */
  73184. get majorLineColor(): string;
  73185. set majorLineColor(value: string);
  73186. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  73187. get majorLineFrequency(): number;
  73188. set majorLineFrequency(value: number);
  73189. /**
  73190. * Creates a new GridDisplayRectangle
  73191. * @param name defines the control name
  73192. */
  73193. constructor(name?: string | undefined);
  73194. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73195. protected _getTypeName(): string;
  73196. }
  73197. }
  73198. declare module BABYLON.GUI {
  73199. /**
  73200. * Class used to create slider controls based on images
  73201. */
  73202. export class ImageBasedSlider extends BaseSlider {
  73203. name?: string | undefined;
  73204. private _backgroundImage;
  73205. private _thumbImage;
  73206. private _valueBarImage;
  73207. private _tempMeasure;
  73208. get displayThumb(): boolean;
  73209. set displayThumb(value: boolean);
  73210. /**
  73211. * Gets or sets the image used to render the background
  73212. */
  73213. get backgroundImage(): Image;
  73214. set backgroundImage(value: Image);
  73215. /**
  73216. * Gets or sets the image used to render the value bar
  73217. */
  73218. get valueBarImage(): Image;
  73219. set valueBarImage(value: Image);
  73220. /**
  73221. * Gets or sets the image used to render the thumb
  73222. */
  73223. get thumbImage(): Image;
  73224. set thumbImage(value: Image);
  73225. /**
  73226. * Creates a new ImageBasedSlider
  73227. * @param name defines the control name
  73228. */
  73229. constructor(name?: string | undefined);
  73230. protected _getTypeName(): string;
  73231. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  73232. }
  73233. }
  73234. declare module BABYLON.GUI {
  73235. /**
  73236. * Forcing an export so that this code will execute
  73237. * @hidden
  73238. */
  73239. const name = "Statics";
  73240. }
  73241. declare module BABYLON.GUI {
  73242. /**
  73243. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  73244. */
  73245. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  73246. /**
  73247. * Define the instrumented AdvancedDynamicTexture.
  73248. */
  73249. texture: AdvancedDynamicTexture;
  73250. private _captureRenderTime;
  73251. private _renderTime;
  73252. private _captureLayoutTime;
  73253. private _layoutTime;
  73254. private _onBeginRenderObserver;
  73255. private _onEndRenderObserver;
  73256. private _onBeginLayoutObserver;
  73257. private _onEndLayoutObserver;
  73258. /**
  73259. * Gets the perf counter used to capture render time
  73260. */
  73261. get renderTimeCounter(): BABYLON.PerfCounter;
  73262. /**
  73263. * Gets the perf counter used to capture layout time
  73264. */
  73265. get layoutTimeCounter(): BABYLON.PerfCounter;
  73266. /**
  73267. * Enable or disable the render time capture
  73268. */
  73269. get captureRenderTime(): boolean;
  73270. set captureRenderTime(value: boolean);
  73271. /**
  73272. * Enable or disable the layout time capture
  73273. */
  73274. get captureLayoutTime(): boolean;
  73275. set captureLayoutTime(value: boolean);
  73276. /**
  73277. * Instantiates a new advanced dynamic texture instrumentation.
  73278. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  73279. * @param texture Defines the AdvancedDynamicTexture to instrument
  73280. */
  73281. constructor(
  73282. /**
  73283. * Define the instrumented AdvancedDynamicTexture.
  73284. */
  73285. texture: AdvancedDynamicTexture);
  73286. /**
  73287. * Dispose and release associated resources.
  73288. */
  73289. dispose(): void;
  73290. }
  73291. }
  73292. declare module BABYLON.GUI {
  73293. /**
  73294. * Class used to load GUI via XML.
  73295. */
  73296. export class XmlLoader {
  73297. private _nodes;
  73298. private _nodeTypes;
  73299. private _isLoaded;
  73300. private _objectAttributes;
  73301. private _parentClass;
  73302. /**
  73303. * Create a new xml loader
  73304. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  73305. */
  73306. constructor(parentClass?: null);
  73307. private _getChainElement;
  73308. private _getClassAttribute;
  73309. private _createGuiElement;
  73310. private _parseGrid;
  73311. private _parseElement;
  73312. private _prepareSourceElement;
  73313. private _parseElementsFromSource;
  73314. private _parseXml;
  73315. /**
  73316. * Gets if the loading has finished.
  73317. * @returns whether the loading has finished or not
  73318. */
  73319. isLoaded(): boolean;
  73320. /**
  73321. * Gets a loaded node / control by id.
  73322. * @param id the Controls id set in the xml
  73323. * @returns element of type Control
  73324. */
  73325. getNodeById(id: string): any;
  73326. /**
  73327. * Gets all loaded nodes / controls
  73328. * @returns Array of controls
  73329. */
  73330. getNodes(): any;
  73331. /**
  73332. * Initiates the xml layout loading
  73333. * @param xmlFile defines the xml layout to load
  73334. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  73335. * @param callback defines the callback called on layout load.
  73336. */
  73337. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  73338. }
  73339. }
  73340. declare module BABYLON.GUI {
  73341. /**
  73342. * Class used to create containers for controls
  73343. */
  73344. export class Container3D extends Control3D {
  73345. private _blockLayout;
  73346. /**
  73347. * Gets the list of child controls
  73348. */
  73349. protected _children: Control3D[];
  73350. /**
  73351. * Gets the list of child controls
  73352. */
  73353. get children(): Array<Control3D>;
  73354. /**
  73355. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  73356. * This is helpful to optimize layout operation when adding multiple children in a row
  73357. */
  73358. get blockLayout(): boolean;
  73359. set blockLayout(value: boolean);
  73360. /**
  73361. * Creates a new container
  73362. * @param name defines the container name
  73363. */
  73364. constructor(name?: string);
  73365. /**
  73366. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  73367. * @returns the current container
  73368. */
  73369. updateLayout(): Container3D;
  73370. /**
  73371. * Gets a boolean indicating if the given control is in the children of this control
  73372. * @param control defines the control to check
  73373. * @returns true if the control is in the child list
  73374. */
  73375. containsControl(control: Control3D): boolean;
  73376. /**
  73377. * Adds a control to the children of this control
  73378. * @param control defines the control to add
  73379. * @returns the current container
  73380. */
  73381. addControl(control: Control3D): Container3D;
  73382. /**
  73383. * This function will be called everytime a new control is added
  73384. */
  73385. protected _arrangeChildren(): void;
  73386. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  73387. /**
  73388. * Removes a control from the children of this control
  73389. * @param control defines the control to remove
  73390. * @returns the current container
  73391. */
  73392. removeControl(control: Control3D): Container3D;
  73393. protected _getTypeName(): string;
  73394. /**
  73395. * Releases all associated resources
  73396. */
  73397. dispose(): void;
  73398. /** Control rotation will remain unchanged */
  73399. static readonly UNSET_ORIENTATION: number;
  73400. /** Control will rotate to make it look at sphere central axis */
  73401. static readonly FACEORIGIN_ORIENTATION: number;
  73402. /** Control will rotate to make it look back at sphere central axis */
  73403. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  73404. /** Control will rotate to look at z axis (0, 0, 1) */
  73405. static readonly FACEFORWARD_ORIENTATION: number;
  73406. /** Control will rotate to look at negative z axis (0, 0, -1) */
  73407. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  73408. }
  73409. }
  73410. declare module BABYLON.GUI {
  73411. /**
  73412. * Class used to manage 3D user interface
  73413. * @see http://doc.babylonjs.com/how_to/gui3d
  73414. */
  73415. export class GUI3DManager implements BABYLON.IDisposable {
  73416. private _scene;
  73417. private _sceneDisposeObserver;
  73418. private _utilityLayer;
  73419. private _rootContainer;
  73420. private _pointerObserver;
  73421. private _pointerOutObserver;
  73422. /** @hidden */
  73423. _lastPickedControl: Control3D;
  73424. /** @hidden */
  73425. _lastControlOver: {
  73426. [pointerId: number]: Control3D;
  73427. };
  73428. /** @hidden */
  73429. _lastControlDown: {
  73430. [pointerId: number]: Control3D;
  73431. };
  73432. /**
  73433. * BABYLON.Observable raised when the point picked by the pointer events changed
  73434. */
  73435. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  73436. /** @hidden */
  73437. _sharedMaterials: {
  73438. [key: string]: BABYLON.Material;
  73439. };
  73440. /** Gets the hosting scene */
  73441. get scene(): BABYLON.Scene;
  73442. /** Gets associated utility layer */
  73443. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  73444. /**
  73445. * Creates a new GUI3DManager
  73446. * @param scene
  73447. */
  73448. constructor(scene?: BABYLON.Scene);
  73449. private _handlePointerOut;
  73450. private _doPicking;
  73451. /**
  73452. * Gets the root container
  73453. */
  73454. get rootContainer(): Container3D;
  73455. /**
  73456. * Gets a boolean indicating if the given control is in the root child list
  73457. * @param control defines the control to check
  73458. * @returns true if the control is in the root child list
  73459. */
  73460. containsControl(control: Control3D): boolean;
  73461. /**
  73462. * Adds a control to the root child list
  73463. * @param control defines the control to add
  73464. * @returns the current manager
  73465. */
  73466. addControl(control: Control3D): GUI3DManager;
  73467. /**
  73468. * Removes a control from the root child list
  73469. * @param control defines the control to remove
  73470. * @returns the current container
  73471. */
  73472. removeControl(control: Control3D): GUI3DManager;
  73473. /**
  73474. * Releases all associated resources
  73475. */
  73476. dispose(): void;
  73477. }
  73478. }
  73479. declare module BABYLON.GUI {
  73480. /**
  73481. * Class used to transport BABYLON.Vector3 information for pointer events
  73482. */
  73483. export class Vector3WithInfo extends BABYLON.Vector3 {
  73484. /** defines the current mouse button index */
  73485. buttonIndex: number;
  73486. /**
  73487. * Creates a new Vector3WithInfo
  73488. * @param source defines the vector3 data to transport
  73489. * @param buttonIndex defines the current mouse button index
  73490. */
  73491. constructor(source: BABYLON.Vector3,
  73492. /** defines the current mouse button index */
  73493. buttonIndex?: number);
  73494. }
  73495. }
  73496. declare module BABYLON.GUI {
  73497. /**
  73498. * Class used as base class for controls
  73499. */
  73500. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  73501. /** Defines the control name */
  73502. name?: string | undefined;
  73503. /** @hidden */
  73504. _host: GUI3DManager;
  73505. private _node;
  73506. private _downCount;
  73507. private _enterCount;
  73508. private _downPointerIds;
  73509. private _isVisible;
  73510. /** Gets or sets the control position in world space */
  73511. get position(): BABYLON.Vector3;
  73512. set position(value: BABYLON.Vector3);
  73513. /** Gets or sets the control scaling in world space */
  73514. get scaling(): BABYLON.Vector3;
  73515. set scaling(value: BABYLON.Vector3);
  73516. /** Callback used to start pointer enter animation */
  73517. pointerEnterAnimation: () => void;
  73518. /** Callback used to start pointer out animation */
  73519. pointerOutAnimation: () => void;
  73520. /** Callback used to start pointer down animation */
  73521. pointerDownAnimation: () => void;
  73522. /** Callback used to start pointer up animation */
  73523. pointerUpAnimation: () => void;
  73524. /**
  73525. * An event triggered when the pointer move over the control
  73526. */
  73527. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  73528. /**
  73529. * An event triggered when the pointer move out of the control
  73530. */
  73531. onPointerOutObservable: BABYLON.Observable<Control3D>;
  73532. /**
  73533. * An event triggered when the pointer taps the control
  73534. */
  73535. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  73536. /**
  73537. * An event triggered when pointer is up
  73538. */
  73539. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  73540. /**
  73541. * An event triggered when a control is clicked on (with a mouse)
  73542. */
  73543. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  73544. /**
  73545. * An event triggered when pointer enters the control
  73546. */
  73547. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  73548. /**
  73549. * Gets or sets the parent container
  73550. */
  73551. parent: BABYLON.Nullable<Container3D>;
  73552. private _behaviors;
  73553. /**
  73554. * Gets the list of attached behaviors
  73555. * @see http://doc.babylonjs.com/features/behaviour
  73556. */
  73557. get behaviors(): BABYLON.Behavior<Control3D>[];
  73558. /**
  73559. * Attach a behavior to the control
  73560. * @see http://doc.babylonjs.com/features/behaviour
  73561. * @param behavior defines the behavior to attach
  73562. * @returns the current control
  73563. */
  73564. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  73565. /**
  73566. * Remove an attached behavior
  73567. * @see http://doc.babylonjs.com/features/behaviour
  73568. * @param behavior defines the behavior to attach
  73569. * @returns the current control
  73570. */
  73571. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  73572. /**
  73573. * Gets an attached behavior by name
  73574. * @param name defines the name of the behavior to look for
  73575. * @see http://doc.babylonjs.com/features/behaviour
  73576. * @returns null if behavior was not found else the requested behavior
  73577. */
  73578. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  73579. /** Gets or sets a boolean indicating if the control is visible */
  73580. get isVisible(): boolean;
  73581. set isVisible(value: boolean);
  73582. /**
  73583. * Creates a new control
  73584. * @param name defines the control name
  73585. */
  73586. constructor(
  73587. /** Defines the control name */
  73588. name?: string | undefined);
  73589. /**
  73590. * Gets a string representing the class name
  73591. */
  73592. get typeName(): string;
  73593. /**
  73594. * Get the current class name of the control.
  73595. * @returns current class name
  73596. */
  73597. getClassName(): string;
  73598. protected _getTypeName(): string;
  73599. /**
  73600. * Gets the transform node used by this control
  73601. */
  73602. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  73603. /**
  73604. * Gets the mesh used to render this control
  73605. */
  73606. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  73607. /**
  73608. * Link the control as child of the given node
  73609. * @param node defines the node to link to. Use null to unlink the control
  73610. * @returns the current control
  73611. */
  73612. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  73613. /** @hidden **/
  73614. _prepareNode(scene: BABYLON.Scene): void;
  73615. /**
  73616. * Node creation.
  73617. * Can be overriden by children
  73618. * @param scene defines the scene where the node must be attached
  73619. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  73620. */
  73621. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  73622. /**
  73623. * Affect a material to the given mesh
  73624. * @param mesh defines the mesh which will represent the control
  73625. */
  73626. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  73627. /** @hidden */
  73628. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  73629. /** @hidden */
  73630. _onPointerEnter(target: Control3D): boolean;
  73631. /** @hidden */
  73632. _onPointerOut(target: Control3D): void;
  73633. /** @hidden */
  73634. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  73635. /** @hidden */
  73636. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  73637. /** @hidden */
  73638. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  73639. /** @hidden */
  73640. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  73641. /** @hidden */
  73642. _disposeNode(): void;
  73643. /**
  73644. * Releases all associated resources
  73645. */
  73646. dispose(): void;
  73647. }
  73648. }
  73649. declare module BABYLON.GUI {
  73650. /**
  73651. * Class used as a root to all buttons
  73652. */
  73653. export class AbstractButton3D extends Control3D {
  73654. /**
  73655. * Creates a new button
  73656. * @param name defines the control name
  73657. */
  73658. constructor(name?: string);
  73659. protected _getTypeName(): string;
  73660. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  73661. }
  73662. }
  73663. declare module BABYLON.GUI {
  73664. /**
  73665. * Class used to create a button in 3D
  73666. */
  73667. export class Button3D extends AbstractButton3D {
  73668. /** @hidden */
  73669. protected _currentMaterial: BABYLON.Material;
  73670. private _facadeTexture;
  73671. private _content;
  73672. private _contentResolution;
  73673. private _contentScaleRatio;
  73674. /**
  73675. * Gets or sets the texture resolution used to render content (512 by default)
  73676. */
  73677. get contentResolution(): BABYLON.int;
  73678. set contentResolution(value: BABYLON.int);
  73679. /**
  73680. * Gets or sets the texture scale ratio used to render content (2 by default)
  73681. */
  73682. get contentScaleRatio(): number;
  73683. set contentScaleRatio(value: number);
  73684. protected _disposeFacadeTexture(): void;
  73685. protected _resetContent(): void;
  73686. /**
  73687. * Creates a new button
  73688. * @param name defines the control name
  73689. */
  73690. constructor(name?: string);
  73691. /**
  73692. * Gets or sets the GUI 2D content used to display the button's facade
  73693. */
  73694. get content(): Control;
  73695. set content(value: Control);
  73696. /**
  73697. * Apply the facade texture (created from the content property).
  73698. * This function can be overloaded by child classes
  73699. * @param facadeTexture defines the AdvancedDynamicTexture to use
  73700. */
  73701. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  73702. protected _getTypeName(): string;
  73703. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  73704. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  73705. /**
  73706. * Releases all associated resources
  73707. */
  73708. dispose(): void;
  73709. }
  73710. }
  73711. declare module BABYLON.GUI {
  73712. /**
  73713. * Abstract class used to create a container panel deployed on the surface of a volume
  73714. */
  73715. export abstract class VolumeBasedPanel extends Container3D {
  73716. private _columns;
  73717. private _rows;
  73718. private _rowThenColum;
  73719. private _orientation;
  73720. protected _cellWidth: number;
  73721. protected _cellHeight: number;
  73722. /**
  73723. * Gets or sets the distance between elements
  73724. */
  73725. margin: number;
  73726. /**
  73727. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  73728. * | Value | Type | Description |
  73729. * | ----- | ----------------------------------- | ----------- |
  73730. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  73731. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  73732. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  73733. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  73734. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  73735. */
  73736. get orientation(): number;
  73737. set orientation(value: number);
  73738. /**
  73739. * Gets or sets the number of columns requested (10 by default).
  73740. * The panel will automatically compute the number of rows based on number of child controls.
  73741. */
  73742. get columns(): BABYLON.int;
  73743. set columns(value: BABYLON.int);
  73744. /**
  73745. * Gets or sets a the number of rows requested.
  73746. * The panel will automatically compute the number of columns based on number of child controls.
  73747. */
  73748. get rows(): BABYLON.int;
  73749. set rows(value: BABYLON.int);
  73750. /**
  73751. * Creates new VolumeBasedPanel
  73752. */
  73753. constructor();
  73754. protected _arrangeChildren(): void;
  73755. /** Child classes must implement this function to provide correct control positioning */
  73756. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  73757. /** Child classes can implement this function to provide additional processing */
  73758. protected _finalProcessing(): void;
  73759. }
  73760. }
  73761. declare module BABYLON.GUI {
  73762. /**
  73763. * Class used to create a container panel deployed on the surface of a cylinder
  73764. */
  73765. export class CylinderPanel extends VolumeBasedPanel {
  73766. private _radius;
  73767. /**
  73768. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  73769. */
  73770. get radius(): BABYLON.float;
  73771. set radius(value: BABYLON.float);
  73772. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  73773. private _cylindricalMapping;
  73774. }
  73775. }
  73776. declare module BABYLON.GUI {
  73777. /** @hidden */
  73778. export var fluentVertexShader: {
  73779. name: string;
  73780. shader: string;
  73781. };
  73782. }
  73783. declare module BABYLON.GUI {
  73784. /** @hidden */
  73785. export var fluentPixelShader: {
  73786. name: string;
  73787. shader: string;
  73788. };
  73789. }
  73790. declare module BABYLON.GUI {
  73791. /** @hidden */
  73792. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  73793. INNERGLOW: boolean;
  73794. BORDER: boolean;
  73795. HOVERLIGHT: boolean;
  73796. TEXTURE: boolean;
  73797. constructor();
  73798. }
  73799. /**
  73800. * Class used to render controls with fluent desgin
  73801. */
  73802. export class FluentMaterial extends BABYLON.PushMaterial {
  73803. /**
  73804. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  73805. */
  73806. innerGlowColorIntensity: number;
  73807. /**
  73808. * Gets or sets the inner glow color (white by default)
  73809. */
  73810. innerGlowColor: BABYLON.Color3;
  73811. /**
  73812. * Gets or sets alpha value (default is 1.0)
  73813. */
  73814. alpha: number;
  73815. /**
  73816. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  73817. */
  73818. albedoColor: BABYLON.Color3;
  73819. /**
  73820. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  73821. */
  73822. renderBorders: boolean;
  73823. /**
  73824. * Gets or sets border width (default is 0.5)
  73825. */
  73826. borderWidth: number;
  73827. /**
  73828. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  73829. */
  73830. edgeSmoothingValue: number;
  73831. /**
  73832. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  73833. */
  73834. borderMinValue: number;
  73835. /**
  73836. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  73837. */
  73838. renderHoverLight: boolean;
  73839. /**
  73840. * Gets or sets the radius used to render the hover light (default is 1.0)
  73841. */
  73842. hoverRadius: number;
  73843. /**
  73844. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  73845. */
  73846. hoverColor: BABYLON.Color4;
  73847. /**
  73848. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  73849. */
  73850. hoverPosition: BABYLON.Vector3;
  73851. private _albedoTexture;
  73852. /** Gets or sets the texture to use for albedo color */
  73853. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  73854. /**
  73855. * Creates a new Fluent material
  73856. * @param name defines the name of the material
  73857. * @param scene defines the hosting scene
  73858. */
  73859. constructor(name: string, scene: BABYLON.Scene);
  73860. needAlphaBlending(): boolean;
  73861. needAlphaTesting(): boolean;
  73862. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  73863. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  73864. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  73865. getActiveTextures(): BABYLON.BaseTexture[];
  73866. hasTexture(texture: BABYLON.BaseTexture): boolean;
  73867. dispose(forceDisposeEffect?: boolean): void;
  73868. clone(name: string): FluentMaterial;
  73869. serialize(): any;
  73870. getClassName(): string;
  73871. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  73872. }
  73873. }
  73874. declare module BABYLON.GUI {
  73875. /**
  73876. * Class used to create a holographic button in 3D
  73877. */
  73878. export class HolographicButton extends Button3D {
  73879. private _backPlate;
  73880. private _textPlate;
  73881. private _frontPlate;
  73882. private _text;
  73883. private _imageUrl;
  73884. private _shareMaterials;
  73885. private _frontMaterial;
  73886. private _backMaterial;
  73887. private _plateMaterial;
  73888. private _pickedPointObserver;
  73889. private _tooltipFade;
  73890. private _tooltipTextBlock;
  73891. private _tooltipTexture;
  73892. private _tooltipMesh;
  73893. private _tooltipHoverObserver;
  73894. private _tooltipOutObserver;
  73895. private _disposeTooltip;
  73896. /**
  73897. * Rendering ground id of all the mesh in the button
  73898. */
  73899. set renderingGroupId(id: number);
  73900. get renderingGroupId(): number;
  73901. /**
  73902. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  73903. */
  73904. set tooltipText(text: BABYLON.Nullable<string>);
  73905. get tooltipText(): BABYLON.Nullable<string>;
  73906. /**
  73907. * Gets or sets text for the button
  73908. */
  73909. get text(): string;
  73910. set text(value: string);
  73911. /**
  73912. * Gets or sets the image url for the button
  73913. */
  73914. get imageUrl(): string;
  73915. set imageUrl(value: string);
  73916. /**
  73917. * Gets the back material used by this button
  73918. */
  73919. get backMaterial(): FluentMaterial;
  73920. /**
  73921. * Gets the front material used by this button
  73922. */
  73923. get frontMaterial(): FluentMaterial;
  73924. /**
  73925. * Gets the plate material used by this button
  73926. */
  73927. get plateMaterial(): BABYLON.StandardMaterial;
  73928. /**
  73929. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  73930. */
  73931. get shareMaterials(): boolean;
  73932. /**
  73933. * Creates a new button
  73934. * @param name defines the control name
  73935. */
  73936. constructor(name?: string, shareMaterials?: boolean);
  73937. protected _getTypeName(): string;
  73938. private _rebuildContent;
  73939. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  73940. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  73941. private _createBackMaterial;
  73942. private _createFrontMaterial;
  73943. private _createPlateMaterial;
  73944. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  73945. /**
  73946. * Releases all associated resources
  73947. */
  73948. dispose(): void;
  73949. }
  73950. }
  73951. declare module BABYLON.GUI {
  73952. /**
  73953. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  73954. */
  73955. export class MeshButton3D extends Button3D {
  73956. /** @hidden */
  73957. protected _currentMesh: BABYLON.Mesh;
  73958. /**
  73959. * Creates a new 3D button based on a mesh
  73960. * @param mesh mesh to become a 3D button
  73961. * @param name defines the control name
  73962. */
  73963. constructor(mesh: BABYLON.Mesh, name?: string);
  73964. protected _getTypeName(): string;
  73965. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  73966. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  73967. }
  73968. }
  73969. declare module BABYLON.GUI {
  73970. /**
  73971. * Class used to create a container panel deployed on the surface of a plane
  73972. */
  73973. export class PlanePanel extends VolumeBasedPanel {
  73974. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  73975. }
  73976. }
  73977. declare module BABYLON.GUI {
  73978. /**
  73979. * Class used to create a container panel where items get randomized planar mapping
  73980. */
  73981. export class ScatterPanel extends VolumeBasedPanel {
  73982. private _iteration;
  73983. /**
  73984. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  73985. */
  73986. get iteration(): BABYLON.float;
  73987. set iteration(value: BABYLON.float);
  73988. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  73989. private _scatterMapping;
  73990. protected _finalProcessing(): void;
  73991. }
  73992. }
  73993. declare module BABYLON.GUI {
  73994. /**
  73995. * Class used to create a container panel deployed on the surface of a sphere
  73996. */
  73997. export class SpherePanel extends VolumeBasedPanel {
  73998. private _radius;
  73999. /**
  74000. * Gets or sets the radius of the sphere where to project controls (5 by default)
  74001. */
  74002. get radius(): BABYLON.float;
  74003. set radius(value: BABYLON.float);
  74004. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  74005. private _sphericalMapping;
  74006. }
  74007. }
  74008. declare module BABYLON.GUI {
  74009. /**
  74010. * Class used to create a stack panel in 3D on XY plane
  74011. */
  74012. export class StackPanel3D extends Container3D {
  74013. private _isVertical;
  74014. /**
  74015. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  74016. */
  74017. get isVertical(): boolean;
  74018. set isVertical(value: boolean);
  74019. /**
  74020. * Gets or sets the distance between elements
  74021. */
  74022. margin: number;
  74023. /**
  74024. * Creates new StackPanel
  74025. * @param isVertical
  74026. */
  74027. constructor(isVertical?: boolean);
  74028. protected _arrangeChildren(): void;
  74029. }
  74030. }
  74031. declare module BABYLON {
  74032. /**
  74033. * Configuration for glTF validation
  74034. */
  74035. export interface IGLTFValidationConfiguration {
  74036. /**
  74037. * The url of the glTF validator.
  74038. */
  74039. url: string;
  74040. }
  74041. /**
  74042. * glTF validation
  74043. */
  74044. export class GLTFValidation {
  74045. /**
  74046. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  74047. */
  74048. static Configuration: IGLTFValidationConfiguration;
  74049. private static _LoadScriptPromise;
  74050. /**
  74051. * Validate a glTF asset using the glTF-Validator.
  74052. * @param data The JSON of a glTF or the array buffer of a binary glTF
  74053. * @param rootUrl The root url for the glTF
  74054. * @param fileName The file name for the glTF
  74055. * @param getExternalResource The callback to get external resources for the glTF validator
  74056. * @returns A promise that resolves with the glTF validation results once complete
  74057. */
  74058. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  74059. }
  74060. }
  74061. declare module BABYLON {
  74062. /**
  74063. * Mode that determines the coordinate system to use.
  74064. */
  74065. export enum GLTFLoaderCoordinateSystemMode {
  74066. /**
  74067. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  74068. */
  74069. AUTO = 0,
  74070. /**
  74071. * Sets the useRightHandedSystem flag on the scene.
  74072. */
  74073. FORCE_RIGHT_HANDED = 1
  74074. }
  74075. /**
  74076. * Mode that determines what animations will start.
  74077. */
  74078. export enum GLTFLoaderAnimationStartMode {
  74079. /**
  74080. * No animation will start.
  74081. */
  74082. NONE = 0,
  74083. /**
  74084. * The first animation will start.
  74085. */
  74086. FIRST = 1,
  74087. /**
  74088. * All animations will start.
  74089. */
  74090. ALL = 2
  74091. }
  74092. /**
  74093. * Interface that contains the data for the glTF asset.
  74094. */
  74095. export interface IGLTFLoaderData {
  74096. /**
  74097. * The object that represents the glTF JSON.
  74098. */
  74099. json: Object;
  74100. /**
  74101. * The BIN chunk of a binary glTF.
  74102. */
  74103. bin: Nullable<IDataBuffer>;
  74104. }
  74105. /**
  74106. * Interface for extending the loader.
  74107. */
  74108. export interface IGLTFLoaderExtension {
  74109. /**
  74110. * The name of this extension.
  74111. */
  74112. readonly name: string;
  74113. /**
  74114. * Defines whether this extension is enabled.
  74115. */
  74116. enabled: boolean;
  74117. /**
  74118. * Defines the order of this extension.
  74119. * The loader sorts the extensions using these values when loading.
  74120. */
  74121. order?: number;
  74122. }
  74123. /**
  74124. * Loader state.
  74125. */
  74126. export enum GLTFLoaderState {
  74127. /**
  74128. * The asset is loading.
  74129. */
  74130. LOADING = 0,
  74131. /**
  74132. * The asset is ready for rendering.
  74133. */
  74134. READY = 1,
  74135. /**
  74136. * The asset is completely loaded.
  74137. */
  74138. COMPLETE = 2
  74139. }
  74140. /** @hidden */
  74141. export interface IGLTFLoader extends IDisposable {
  74142. readonly state: Nullable<GLTFLoaderState>;
  74143. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  74144. meshes: AbstractMesh[];
  74145. particleSystems: IParticleSystem[];
  74146. skeletons: Skeleton[];
  74147. animationGroups: AnimationGroup[];
  74148. }>;
  74149. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  74150. }
  74151. /**
  74152. * File loader for loading glTF files into a scene.
  74153. */
  74154. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  74155. /** @hidden */
  74156. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  74157. /** @hidden */
  74158. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  74159. /**
  74160. * Raised when the asset has been parsed
  74161. */
  74162. onParsedObservable: Observable<IGLTFLoaderData>;
  74163. private _onParsedObserver;
  74164. /**
  74165. * Raised when the asset has been parsed
  74166. */
  74167. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  74168. /**
  74169. * 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.
  74170. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  74171. * Defaults to true.
  74172. * @hidden
  74173. */
  74174. static IncrementalLoading: boolean;
  74175. /**
  74176. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  74177. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  74178. * @hidden
  74179. */
  74180. static HomogeneousCoordinates: boolean;
  74181. /**
  74182. * The coordinate system mode. Defaults to AUTO.
  74183. */
  74184. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  74185. /**
  74186. * The animation start mode. Defaults to FIRST.
  74187. */
  74188. animationStartMode: GLTFLoaderAnimationStartMode;
  74189. /**
  74190. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  74191. */
  74192. compileMaterials: boolean;
  74193. /**
  74194. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  74195. */
  74196. useClipPlane: boolean;
  74197. /**
  74198. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  74199. */
  74200. compileShadowGenerators: boolean;
  74201. /**
  74202. * Defines if the Alpha blended materials are only applied as coverage.
  74203. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  74204. * If true, no extra effects are applied to transparent pixels.
  74205. */
  74206. transparencyAsCoverage: boolean;
  74207. /**
  74208. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  74209. * Enabling will disable offline support and glTF validator.
  74210. * Defaults to false.
  74211. */
  74212. useRangeRequests: boolean;
  74213. /**
  74214. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  74215. */
  74216. createInstances: boolean;
  74217. /**
  74218. * Function called before loading a url referenced by the asset.
  74219. */
  74220. preprocessUrlAsync: (url: string) => Promise<string>;
  74221. /**
  74222. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  74223. */
  74224. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  74225. private _onMeshLoadedObserver;
  74226. /**
  74227. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  74228. */
  74229. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  74230. /**
  74231. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  74232. */
  74233. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  74234. private _onTextureLoadedObserver;
  74235. /**
  74236. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  74237. */
  74238. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  74239. /**
  74240. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  74241. */
  74242. readonly onMaterialLoadedObservable: Observable<Material>;
  74243. private _onMaterialLoadedObserver;
  74244. /**
  74245. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  74246. */
  74247. set onMaterialLoaded(callback: (material: Material) => void);
  74248. /**
  74249. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  74250. */
  74251. readonly onCameraLoadedObservable: Observable<Camera>;
  74252. private _onCameraLoadedObserver;
  74253. /**
  74254. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  74255. */
  74256. set onCameraLoaded(callback: (camera: Camera) => void);
  74257. /**
  74258. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  74259. * For assets with LODs, raised when all of the LODs are complete.
  74260. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  74261. */
  74262. readonly onCompleteObservable: Observable<void>;
  74263. private _onCompleteObserver;
  74264. /**
  74265. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  74266. * For assets with LODs, raised when all of the LODs are complete.
  74267. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  74268. */
  74269. set onComplete(callback: () => void);
  74270. /**
  74271. * Observable raised when an error occurs.
  74272. */
  74273. readonly onErrorObservable: Observable<any>;
  74274. private _onErrorObserver;
  74275. /**
  74276. * Callback raised when an error occurs.
  74277. */
  74278. set onError(callback: (reason: any) => void);
  74279. /**
  74280. * Observable raised after the loader is disposed.
  74281. */
  74282. readonly onDisposeObservable: Observable<void>;
  74283. private _onDisposeObserver;
  74284. /**
  74285. * Callback raised after the loader is disposed.
  74286. */
  74287. set onDispose(callback: () => void);
  74288. /**
  74289. * Observable raised after a loader extension is created.
  74290. * Set additional options for a loader extension in this event.
  74291. */
  74292. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  74293. private _onExtensionLoadedObserver;
  74294. /**
  74295. * Callback raised after a loader extension is created.
  74296. */
  74297. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  74298. /**
  74299. * Defines if the loader logging is enabled.
  74300. */
  74301. get loggingEnabled(): boolean;
  74302. set loggingEnabled(value: boolean);
  74303. /**
  74304. * Defines if the loader should capture performance counters.
  74305. */
  74306. get capturePerformanceCounters(): boolean;
  74307. set capturePerformanceCounters(value: boolean);
  74308. /**
  74309. * Defines if the loader should validate the asset.
  74310. */
  74311. validate: boolean;
  74312. /**
  74313. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  74314. */
  74315. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  74316. private _onValidatedObserver;
  74317. /**
  74318. * Callback raised after a loader extension is created.
  74319. */
  74320. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  74321. private _loader;
  74322. /**
  74323. * Name of the loader ("gltf")
  74324. */
  74325. name: string;
  74326. /** @hidden */
  74327. extensions: ISceneLoaderPluginExtensions;
  74328. /**
  74329. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  74330. */
  74331. dispose(): void;
  74332. /** @hidden */
  74333. _clear(): void;
  74334. /** @hidden */
  74335. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  74336. /** @hidden */
  74337. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  74338. /** @hidden */
  74339. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  74340. meshes: AbstractMesh[];
  74341. particleSystems: IParticleSystem[];
  74342. skeletons: Skeleton[];
  74343. animationGroups: AnimationGroup[];
  74344. }>;
  74345. /** @hidden */
  74346. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  74347. /** @hidden */
  74348. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  74349. /** @hidden */
  74350. canDirectLoad(data: string): boolean;
  74351. /** @hidden */
  74352. directLoad(scene: Scene, data: string): any;
  74353. /**
  74354. * The callback that allows custom handling of the root url based on the response url.
  74355. * @param rootUrl the original root url
  74356. * @param responseURL the response url if available
  74357. * @returns the new root url
  74358. */
  74359. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  74360. /** @hidden */
  74361. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  74362. /**
  74363. * The loader state or null if the loader is not active.
  74364. */
  74365. get loaderState(): Nullable<GLTFLoaderState>;
  74366. /**
  74367. * Returns a promise that resolves when the asset is completely loaded.
  74368. * @returns a promise that resolves when the asset is completely loaded.
  74369. */
  74370. whenCompleteAsync(): Promise<void>;
  74371. private _validate;
  74372. private _getLoader;
  74373. private _parseJson;
  74374. private _unpackBinaryAsync;
  74375. private _unpackBinaryV1Async;
  74376. private _unpackBinaryV2Async;
  74377. private static _parseVersion;
  74378. private static _compareVersion;
  74379. private static readonly _logSpaces;
  74380. private _logIndentLevel;
  74381. private _loggingEnabled;
  74382. /** @hidden */
  74383. _log: (message: string) => void;
  74384. /** @hidden */
  74385. _logOpen(message: string): void;
  74386. /** @hidden */
  74387. _logClose(): void;
  74388. private _logEnabled;
  74389. private _logDisabled;
  74390. private _capturePerformanceCounters;
  74391. /** @hidden */
  74392. _startPerformanceCounter: (counterName: string) => void;
  74393. /** @hidden */
  74394. _endPerformanceCounter: (counterName: string) => void;
  74395. private _startPerformanceCounterEnabled;
  74396. private _startPerformanceCounterDisabled;
  74397. private _endPerformanceCounterEnabled;
  74398. private _endPerformanceCounterDisabled;
  74399. }
  74400. }
  74401. declare module BABYLON.GLTF1 {
  74402. /**
  74403. * Enums
  74404. * @hidden
  74405. */
  74406. export enum EComponentType {
  74407. BYTE = 5120,
  74408. UNSIGNED_BYTE = 5121,
  74409. SHORT = 5122,
  74410. UNSIGNED_SHORT = 5123,
  74411. FLOAT = 5126
  74412. }
  74413. /** @hidden */
  74414. export enum EShaderType {
  74415. FRAGMENT = 35632,
  74416. VERTEX = 35633
  74417. }
  74418. /** @hidden */
  74419. export enum EParameterType {
  74420. BYTE = 5120,
  74421. UNSIGNED_BYTE = 5121,
  74422. SHORT = 5122,
  74423. UNSIGNED_SHORT = 5123,
  74424. INT = 5124,
  74425. UNSIGNED_INT = 5125,
  74426. FLOAT = 5126,
  74427. FLOAT_VEC2 = 35664,
  74428. FLOAT_VEC3 = 35665,
  74429. FLOAT_VEC4 = 35666,
  74430. INT_VEC2 = 35667,
  74431. INT_VEC3 = 35668,
  74432. INT_VEC4 = 35669,
  74433. BOOL = 35670,
  74434. BOOL_VEC2 = 35671,
  74435. BOOL_VEC3 = 35672,
  74436. BOOL_VEC4 = 35673,
  74437. FLOAT_MAT2 = 35674,
  74438. FLOAT_MAT3 = 35675,
  74439. FLOAT_MAT4 = 35676,
  74440. SAMPLER_2D = 35678
  74441. }
  74442. /** @hidden */
  74443. export enum ETextureWrapMode {
  74444. CLAMP_TO_EDGE = 33071,
  74445. MIRRORED_REPEAT = 33648,
  74446. REPEAT = 10497
  74447. }
  74448. /** @hidden */
  74449. export enum ETextureFilterType {
  74450. NEAREST = 9728,
  74451. LINEAR = 9728,
  74452. NEAREST_MIPMAP_NEAREST = 9984,
  74453. LINEAR_MIPMAP_NEAREST = 9985,
  74454. NEAREST_MIPMAP_LINEAR = 9986,
  74455. LINEAR_MIPMAP_LINEAR = 9987
  74456. }
  74457. /** @hidden */
  74458. export enum ETextureFormat {
  74459. ALPHA = 6406,
  74460. RGB = 6407,
  74461. RGBA = 6408,
  74462. LUMINANCE = 6409,
  74463. LUMINANCE_ALPHA = 6410
  74464. }
  74465. /** @hidden */
  74466. export enum ECullingType {
  74467. FRONT = 1028,
  74468. BACK = 1029,
  74469. FRONT_AND_BACK = 1032
  74470. }
  74471. /** @hidden */
  74472. export enum EBlendingFunction {
  74473. ZERO = 0,
  74474. ONE = 1,
  74475. SRC_COLOR = 768,
  74476. ONE_MINUS_SRC_COLOR = 769,
  74477. DST_COLOR = 774,
  74478. ONE_MINUS_DST_COLOR = 775,
  74479. SRC_ALPHA = 770,
  74480. ONE_MINUS_SRC_ALPHA = 771,
  74481. DST_ALPHA = 772,
  74482. ONE_MINUS_DST_ALPHA = 773,
  74483. CONSTANT_COLOR = 32769,
  74484. ONE_MINUS_CONSTANT_COLOR = 32770,
  74485. CONSTANT_ALPHA = 32771,
  74486. ONE_MINUS_CONSTANT_ALPHA = 32772,
  74487. SRC_ALPHA_SATURATE = 776
  74488. }
  74489. /** @hidden */
  74490. export interface IGLTFProperty {
  74491. extensions?: {
  74492. [key: string]: any;
  74493. };
  74494. extras?: Object;
  74495. }
  74496. /** @hidden */
  74497. export interface IGLTFChildRootProperty extends IGLTFProperty {
  74498. name?: string;
  74499. }
  74500. /** @hidden */
  74501. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  74502. bufferView: string;
  74503. byteOffset: number;
  74504. byteStride: number;
  74505. count: number;
  74506. type: string;
  74507. componentType: EComponentType;
  74508. max?: number[];
  74509. min?: number[];
  74510. name?: string;
  74511. }
  74512. /** @hidden */
  74513. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  74514. buffer: string;
  74515. byteOffset: number;
  74516. byteLength: number;
  74517. byteStride: number;
  74518. target?: number;
  74519. }
  74520. /** @hidden */
  74521. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  74522. uri: string;
  74523. byteLength?: number;
  74524. type?: string;
  74525. }
  74526. /** @hidden */
  74527. export interface IGLTFShader extends IGLTFChildRootProperty {
  74528. uri: string;
  74529. type: EShaderType;
  74530. }
  74531. /** @hidden */
  74532. export interface IGLTFProgram extends IGLTFChildRootProperty {
  74533. attributes: string[];
  74534. fragmentShader: string;
  74535. vertexShader: string;
  74536. }
  74537. /** @hidden */
  74538. export interface IGLTFTechniqueParameter {
  74539. type: number;
  74540. count?: number;
  74541. semantic?: string;
  74542. node?: string;
  74543. value?: number | boolean | string | Array<any>;
  74544. source?: string;
  74545. babylonValue?: any;
  74546. }
  74547. /** @hidden */
  74548. export interface IGLTFTechniqueCommonProfile {
  74549. lightingModel: string;
  74550. texcoordBindings: Object;
  74551. parameters?: Array<any>;
  74552. }
  74553. /** @hidden */
  74554. export interface IGLTFTechniqueStatesFunctions {
  74555. blendColor?: number[];
  74556. blendEquationSeparate?: number[];
  74557. blendFuncSeparate?: number[];
  74558. colorMask: boolean[];
  74559. cullFace: number[];
  74560. }
  74561. /** @hidden */
  74562. export interface IGLTFTechniqueStates {
  74563. enable: number[];
  74564. functions: IGLTFTechniqueStatesFunctions;
  74565. }
  74566. /** @hidden */
  74567. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  74568. parameters: {
  74569. [key: string]: IGLTFTechniqueParameter;
  74570. };
  74571. program: string;
  74572. attributes: {
  74573. [key: string]: string;
  74574. };
  74575. uniforms: {
  74576. [key: string]: string;
  74577. };
  74578. states: IGLTFTechniqueStates;
  74579. }
  74580. /** @hidden */
  74581. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  74582. technique?: string;
  74583. values: string[];
  74584. }
  74585. /** @hidden */
  74586. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  74587. attributes: {
  74588. [key: string]: string;
  74589. };
  74590. indices: string;
  74591. material: string;
  74592. mode?: number;
  74593. }
  74594. /** @hidden */
  74595. export interface IGLTFMesh extends IGLTFChildRootProperty {
  74596. primitives: IGLTFMeshPrimitive[];
  74597. }
  74598. /** @hidden */
  74599. export interface IGLTFImage extends IGLTFChildRootProperty {
  74600. uri: string;
  74601. }
  74602. /** @hidden */
  74603. export interface IGLTFSampler extends IGLTFChildRootProperty {
  74604. magFilter?: number;
  74605. minFilter?: number;
  74606. wrapS?: number;
  74607. wrapT?: number;
  74608. }
  74609. /** @hidden */
  74610. export interface IGLTFTexture extends IGLTFChildRootProperty {
  74611. sampler: string;
  74612. source: string;
  74613. format?: ETextureFormat;
  74614. internalFormat?: ETextureFormat;
  74615. target?: number;
  74616. type?: number;
  74617. babylonTexture?: Texture;
  74618. }
  74619. /** @hidden */
  74620. export interface IGLTFAmbienLight {
  74621. color?: number[];
  74622. }
  74623. /** @hidden */
  74624. export interface IGLTFDirectionalLight {
  74625. color?: number[];
  74626. }
  74627. /** @hidden */
  74628. export interface IGLTFPointLight {
  74629. color?: number[];
  74630. constantAttenuation?: number;
  74631. linearAttenuation?: number;
  74632. quadraticAttenuation?: number;
  74633. }
  74634. /** @hidden */
  74635. export interface IGLTFSpotLight {
  74636. color?: number[];
  74637. constantAttenuation?: number;
  74638. fallOfAngle?: number;
  74639. fallOffExponent?: number;
  74640. linearAttenuation?: number;
  74641. quadraticAttenuation?: number;
  74642. }
  74643. /** @hidden */
  74644. export interface IGLTFLight extends IGLTFChildRootProperty {
  74645. type: string;
  74646. }
  74647. /** @hidden */
  74648. export interface IGLTFCameraOrthographic {
  74649. xmag: number;
  74650. ymag: number;
  74651. zfar: number;
  74652. znear: number;
  74653. }
  74654. /** @hidden */
  74655. export interface IGLTFCameraPerspective {
  74656. aspectRatio: number;
  74657. yfov: number;
  74658. zfar: number;
  74659. znear: number;
  74660. }
  74661. /** @hidden */
  74662. export interface IGLTFCamera extends IGLTFChildRootProperty {
  74663. type: string;
  74664. }
  74665. /** @hidden */
  74666. export interface IGLTFAnimationChannelTarget {
  74667. id: string;
  74668. path: string;
  74669. }
  74670. /** @hidden */
  74671. export interface IGLTFAnimationChannel {
  74672. sampler: string;
  74673. target: IGLTFAnimationChannelTarget;
  74674. }
  74675. /** @hidden */
  74676. export interface IGLTFAnimationSampler {
  74677. input: string;
  74678. output: string;
  74679. interpolation?: string;
  74680. }
  74681. /** @hidden */
  74682. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  74683. channels?: IGLTFAnimationChannel[];
  74684. parameters?: {
  74685. [key: string]: string;
  74686. };
  74687. samplers?: {
  74688. [key: string]: IGLTFAnimationSampler;
  74689. };
  74690. }
  74691. /** @hidden */
  74692. export interface IGLTFNodeInstanceSkin {
  74693. skeletons: string[];
  74694. skin: string;
  74695. meshes: string[];
  74696. }
  74697. /** @hidden */
  74698. export interface IGLTFSkins extends IGLTFChildRootProperty {
  74699. bindShapeMatrix: number[];
  74700. inverseBindMatrices: string;
  74701. jointNames: string[];
  74702. babylonSkeleton?: Skeleton;
  74703. }
  74704. /** @hidden */
  74705. export interface IGLTFNode extends IGLTFChildRootProperty {
  74706. camera?: string;
  74707. children: string[];
  74708. skin?: string;
  74709. jointName?: string;
  74710. light?: string;
  74711. matrix: number[];
  74712. mesh?: string;
  74713. meshes?: string[];
  74714. rotation?: number[];
  74715. scale?: number[];
  74716. translation?: number[];
  74717. babylonNode?: Node;
  74718. }
  74719. /** @hidden */
  74720. export interface IGLTFScene extends IGLTFChildRootProperty {
  74721. nodes: string[];
  74722. }
  74723. /** @hidden */
  74724. export interface IGLTFRuntime {
  74725. extensions: {
  74726. [key: string]: any;
  74727. };
  74728. accessors: {
  74729. [key: string]: IGLTFAccessor;
  74730. };
  74731. buffers: {
  74732. [key: string]: IGLTFBuffer;
  74733. };
  74734. bufferViews: {
  74735. [key: string]: IGLTFBufferView;
  74736. };
  74737. meshes: {
  74738. [key: string]: IGLTFMesh;
  74739. };
  74740. lights: {
  74741. [key: string]: IGLTFLight;
  74742. };
  74743. cameras: {
  74744. [key: string]: IGLTFCamera;
  74745. };
  74746. nodes: {
  74747. [key: string]: IGLTFNode;
  74748. };
  74749. images: {
  74750. [key: string]: IGLTFImage;
  74751. };
  74752. textures: {
  74753. [key: string]: IGLTFTexture;
  74754. };
  74755. shaders: {
  74756. [key: string]: IGLTFShader;
  74757. };
  74758. programs: {
  74759. [key: string]: IGLTFProgram;
  74760. };
  74761. samplers: {
  74762. [key: string]: IGLTFSampler;
  74763. };
  74764. techniques: {
  74765. [key: string]: IGLTFTechnique;
  74766. };
  74767. materials: {
  74768. [key: string]: IGLTFMaterial;
  74769. };
  74770. animations: {
  74771. [key: string]: IGLTFAnimation;
  74772. };
  74773. skins: {
  74774. [key: string]: IGLTFSkins;
  74775. };
  74776. currentScene?: Object;
  74777. scenes: {
  74778. [key: string]: IGLTFScene;
  74779. };
  74780. extensionsUsed: string[];
  74781. extensionsRequired?: string[];
  74782. buffersCount: number;
  74783. shaderscount: number;
  74784. scene: Scene;
  74785. rootUrl: string;
  74786. loadedBufferCount: number;
  74787. loadedBufferViews: {
  74788. [name: string]: ArrayBufferView;
  74789. };
  74790. loadedShaderCount: number;
  74791. importOnlyMeshes: boolean;
  74792. importMeshesNames?: string[];
  74793. dummyNodes: Node[];
  74794. }
  74795. /** @hidden */
  74796. export interface INodeToRoot {
  74797. bone: Bone;
  74798. node: IGLTFNode;
  74799. id: string;
  74800. }
  74801. /** @hidden */
  74802. export interface IJointNode {
  74803. node: IGLTFNode;
  74804. id: string;
  74805. }
  74806. }
  74807. declare module BABYLON.GLTF1 {
  74808. /**
  74809. * Utils functions for GLTF
  74810. * @hidden
  74811. */
  74812. export class GLTFUtils {
  74813. /**
  74814. * Sets the given "parameter" matrix
  74815. * @param scene: the Scene object
  74816. * @param source: the source node where to pick the matrix
  74817. * @param parameter: the GLTF technique parameter
  74818. * @param uniformName: the name of the shader's uniform
  74819. * @param shaderMaterial: the shader material
  74820. */
  74821. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  74822. /**
  74823. * Sets the given "parameter" matrix
  74824. * @param shaderMaterial: the shader material
  74825. * @param uniform: the name of the shader's uniform
  74826. * @param value: the value of the uniform
  74827. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  74828. */
  74829. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  74830. /**
  74831. * Returns the wrap mode of the texture
  74832. * @param mode: the mode value
  74833. */
  74834. static GetWrapMode(mode: number): number;
  74835. /**
  74836. * Returns the byte stride giving an accessor
  74837. * @param accessor: the GLTF accessor objet
  74838. */
  74839. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  74840. /**
  74841. * Returns the texture filter mode giving a mode value
  74842. * @param mode: the filter mode value
  74843. */
  74844. static GetTextureFilterMode(mode: number): ETextureFilterType;
  74845. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  74846. /**
  74847. * Returns a buffer from its accessor
  74848. * @param gltfRuntime: the GLTF runtime
  74849. * @param accessor: the GLTF accessor
  74850. */
  74851. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  74852. /**
  74853. * Decodes a buffer view into a string
  74854. * @param view: the buffer view
  74855. */
  74856. static DecodeBufferToText(view: ArrayBufferView): string;
  74857. /**
  74858. * Returns the default material of gltf. Related to
  74859. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  74860. * @param scene: the Babylon.js scene
  74861. */
  74862. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  74863. private static _DefaultMaterial;
  74864. }
  74865. }
  74866. declare module BABYLON.GLTF1 {
  74867. /**
  74868. * Implementation of the base glTF spec
  74869. * @hidden
  74870. */
  74871. export class GLTFLoaderBase {
  74872. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  74873. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  74874. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  74875. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  74876. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  74877. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  74878. }
  74879. /**
  74880. * glTF V1 Loader
  74881. * @hidden
  74882. */
  74883. export class GLTFLoader implements IGLTFLoader {
  74884. static Extensions: {
  74885. [name: string]: GLTFLoaderExtension;
  74886. };
  74887. static RegisterExtension(extension: GLTFLoaderExtension): void;
  74888. state: Nullable<GLTFLoaderState>;
  74889. dispose(): void;
  74890. private _importMeshAsync;
  74891. /**
  74892. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  74893. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  74894. * @param scene the scene the meshes should be added to
  74895. * @param data gltf data containing information of the meshes in a loaded file
  74896. * @param rootUrl root url to load from
  74897. * @param onProgress event that fires when loading progress has occured
  74898. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  74899. */
  74900. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  74901. meshes: AbstractMesh[];
  74902. particleSystems: IParticleSystem[];
  74903. skeletons: Skeleton[];
  74904. animationGroups: AnimationGroup[];
  74905. }>;
  74906. private _loadAsync;
  74907. /**
  74908. * Imports all objects from a loaded gltf file and adds them to the scene
  74909. * @param scene the scene the objects should be added to
  74910. * @param data gltf data containing information of the meshes in a loaded file
  74911. * @param rootUrl root url to load from
  74912. * @param onProgress event that fires when loading progress has occured
  74913. * @returns a promise which completes when objects have been loaded to the scene
  74914. */
  74915. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  74916. private _loadShadersAsync;
  74917. private _loadBuffersAsync;
  74918. private _createNodes;
  74919. }
  74920. /** @hidden */
  74921. export abstract class GLTFLoaderExtension {
  74922. private _name;
  74923. constructor(name: string);
  74924. get name(): string;
  74925. /**
  74926. * Defines an override for loading the runtime
  74927. * Return true to stop further extensions from loading the runtime
  74928. */
  74929. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  74930. /**
  74931. * Defines an onverride for creating gltf runtime
  74932. * Return true to stop further extensions from creating the runtime
  74933. */
  74934. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  74935. /**
  74936. * Defines an override for loading buffers
  74937. * Return true to stop further extensions from loading this buffer
  74938. */
  74939. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  74940. /**
  74941. * Defines an override for loading texture buffers
  74942. * Return true to stop further extensions from loading this texture data
  74943. */
  74944. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  74945. /**
  74946. * Defines an override for creating textures
  74947. * Return true to stop further extensions from loading this texture
  74948. */
  74949. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  74950. /**
  74951. * Defines an override for loading shader strings
  74952. * Return true to stop further extensions from loading this shader data
  74953. */
  74954. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  74955. /**
  74956. * Defines an override for loading materials
  74957. * Return true to stop further extensions from loading this material
  74958. */
  74959. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  74960. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  74961. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  74962. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  74963. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  74964. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  74965. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  74966. private static LoadTextureBufferAsync;
  74967. private static CreateTextureAsync;
  74968. private static ApplyExtensions;
  74969. }
  74970. }
  74971. declare module BABYLON.GLTF1 {
  74972. /** @hidden */
  74973. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  74974. private _bin;
  74975. constructor();
  74976. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  74977. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  74978. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  74979. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  74980. }
  74981. }
  74982. declare module BABYLON.GLTF1 {
  74983. /** @hidden */
  74984. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  74985. constructor();
  74986. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  74987. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  74988. private _loadTexture;
  74989. }
  74990. }
  74991. declare module BABYLON.GLTF2.Loader {
  74992. /**
  74993. * Loader interface with an index field.
  74994. */
  74995. export interface IArrayItem {
  74996. /**
  74997. * The index of this item in the array.
  74998. */
  74999. index: number;
  75000. }
  75001. /**
  75002. * Loader interface with additional members.
  75003. */
  75004. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  75005. /** @hidden */
  75006. _data?: Promise<ArrayBufferView>;
  75007. /** @hidden */
  75008. _babylonVertexBuffer?: Promise<VertexBuffer>;
  75009. }
  75010. /**
  75011. * Loader interface with additional members.
  75012. */
  75013. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  75014. }
  75015. /** @hidden */
  75016. export interface _IAnimationSamplerData {
  75017. input: Float32Array;
  75018. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  75019. output: Float32Array;
  75020. }
  75021. /**
  75022. * Loader interface with additional members.
  75023. */
  75024. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  75025. /** @hidden */
  75026. _data?: Promise<_IAnimationSamplerData>;
  75027. }
  75028. /**
  75029. * Loader interface with additional members.
  75030. */
  75031. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  75032. channels: IAnimationChannel[];
  75033. samplers: IAnimationSampler[];
  75034. /** @hidden */
  75035. _babylonAnimationGroup?: AnimationGroup;
  75036. }
  75037. /**
  75038. * Loader interface with additional members.
  75039. */
  75040. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  75041. /** @hidden */
  75042. _data?: Promise<ArrayBufferView>;
  75043. }
  75044. /**
  75045. * Loader interface with additional members.
  75046. */
  75047. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  75048. /** @hidden */
  75049. _data?: Promise<ArrayBufferView>;
  75050. /** @hidden */
  75051. _babylonBuffer?: Promise<Buffer>;
  75052. }
  75053. /**
  75054. * Loader interface with additional members.
  75055. */
  75056. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  75057. }
  75058. /**
  75059. * Loader interface with additional members.
  75060. */
  75061. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  75062. /** @hidden */
  75063. _data?: Promise<ArrayBufferView>;
  75064. }
  75065. /**
  75066. * Loader interface with additional members.
  75067. */
  75068. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  75069. }
  75070. /**
  75071. * Loader interface with additional members.
  75072. */
  75073. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  75074. }
  75075. /**
  75076. * Loader interface with additional members.
  75077. */
  75078. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  75079. baseColorTexture?: ITextureInfo;
  75080. metallicRoughnessTexture?: ITextureInfo;
  75081. }
  75082. /**
  75083. * Loader interface with additional members.
  75084. */
  75085. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  75086. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  75087. normalTexture?: IMaterialNormalTextureInfo;
  75088. occlusionTexture?: IMaterialOcclusionTextureInfo;
  75089. emissiveTexture?: ITextureInfo;
  75090. /** @hidden */
  75091. _data?: {
  75092. [babylonDrawMode: number]: {
  75093. babylonMaterial: Material;
  75094. babylonMeshes: AbstractMesh[];
  75095. promise: Promise<void>;
  75096. };
  75097. };
  75098. }
  75099. /**
  75100. * Loader interface with additional members.
  75101. */
  75102. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  75103. primitives: IMeshPrimitive[];
  75104. }
  75105. /**
  75106. * Loader interface with additional members.
  75107. */
  75108. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  75109. /** @hidden */
  75110. _instanceData?: {
  75111. babylonSourceMesh: Mesh;
  75112. promise: Promise<any>;
  75113. };
  75114. }
  75115. /**
  75116. * Loader interface with additional members.
  75117. */
  75118. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  75119. /**
  75120. * The parent glTF node.
  75121. */
  75122. parent?: INode;
  75123. /** @hidden */
  75124. _babylonTransformNode?: TransformNode;
  75125. /** @hidden */
  75126. _primitiveBabylonMeshes?: AbstractMesh[];
  75127. /** @hidden */
  75128. _babylonBones?: Bone[];
  75129. /** @hidden */
  75130. _numMorphTargets?: number;
  75131. }
  75132. /** @hidden */
  75133. export interface _ISamplerData {
  75134. noMipMaps: boolean;
  75135. samplingMode: number;
  75136. wrapU: number;
  75137. wrapV: number;
  75138. }
  75139. /**
  75140. * Loader interface with additional members.
  75141. */
  75142. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  75143. /** @hidden */
  75144. _data?: _ISamplerData;
  75145. }
  75146. /**
  75147. * Loader interface with additional members.
  75148. */
  75149. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  75150. }
  75151. /**
  75152. * Loader interface with additional members.
  75153. */
  75154. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  75155. /** @hidden */
  75156. _data?: {
  75157. babylonSkeleton: Skeleton;
  75158. promise: Promise<void>;
  75159. };
  75160. }
  75161. /**
  75162. * Loader interface with additional members.
  75163. */
  75164. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  75165. }
  75166. /**
  75167. * Loader interface with additional members.
  75168. */
  75169. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  75170. }
  75171. /**
  75172. * Loader interface with additional members.
  75173. */
  75174. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  75175. accessors?: IAccessor[];
  75176. animations?: IAnimation[];
  75177. buffers?: IBuffer[];
  75178. bufferViews?: IBufferView[];
  75179. cameras?: ICamera[];
  75180. images?: IImage[];
  75181. materials?: IMaterial[];
  75182. meshes?: IMesh[];
  75183. nodes?: INode[];
  75184. samplers?: ISampler[];
  75185. scenes?: IScene[];
  75186. skins?: ISkin[];
  75187. textures?: ITexture[];
  75188. }
  75189. }
  75190. declare module BABYLON.GLTF2 {
  75191. /**
  75192. * Interface for a glTF loader extension.
  75193. */
  75194. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  75195. /**
  75196. * Called after the loader state changes to LOADING.
  75197. */
  75198. onLoading?(): void;
  75199. /**
  75200. * Called after the loader state changes to READY.
  75201. */
  75202. onReady?(): void;
  75203. /**
  75204. * Define this method to modify the default behavior when loading scenes.
  75205. * @param context The context when loading the asset
  75206. * @param scene The glTF scene property
  75207. * @returns A promise that resolves when the load is complete or null if not handled
  75208. */
  75209. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  75210. /**
  75211. * Define this method to modify the default behavior when loading nodes.
  75212. * @param context The context when loading the asset
  75213. * @param node The glTF node property
  75214. * @param assign A function called synchronously after parsing the glTF properties
  75215. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  75216. */
  75217. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  75218. /**
  75219. * Define this method to modify the default behavior when loading cameras.
  75220. * @param context The context when loading the asset
  75221. * @param camera The glTF camera property
  75222. * @param assign A function called synchronously after parsing the glTF properties
  75223. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  75224. */
  75225. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  75226. /**
  75227. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  75228. * @param context The context when loading the asset
  75229. * @param primitive The glTF mesh primitive property
  75230. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  75231. */
  75232. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  75233. /**
  75234. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  75235. * @param context The context when loading the asset
  75236. * @param name The mesh name when loading the asset
  75237. * @param node The glTF node when loading the asset
  75238. * @param mesh The glTF mesh when loading the asset
  75239. * @param primitive The glTF mesh primitive property
  75240. * @param assign A function called synchronously after parsing the glTF properties
  75241. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  75242. */
  75243. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  75244. /**
  75245. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  75246. * @param context The context when loading the asset
  75247. * @param material The glTF material property
  75248. * @param assign A function called synchronously after parsing the glTF properties
  75249. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  75250. */
  75251. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  75252. /**
  75253. * Define this method to modify the default behavior when creating materials.
  75254. * @param context The context when loading the asset
  75255. * @param material The glTF material property
  75256. * @param babylonDrawMode The draw mode for the Babylon material
  75257. * @returns The Babylon material or null if not handled
  75258. */
  75259. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  75260. /**
  75261. * Define this method to modify the default behavior when loading material properties.
  75262. * @param context The context when loading the asset
  75263. * @param material The glTF material property
  75264. * @param babylonMaterial The Babylon material
  75265. * @returns A promise that resolves when the load is complete or null if not handled
  75266. */
  75267. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75268. /**
  75269. * Define this method to modify the default behavior when loading texture infos.
  75270. * @param context The context when loading the asset
  75271. * @param textureInfo The glTF texture info property
  75272. * @param assign A function called synchronously after parsing the glTF properties
  75273. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  75274. */
  75275. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  75276. /**
  75277. * Define this method to modify the default behavior when loading animations.
  75278. * @param context The context when loading the asset
  75279. * @param animation The glTF animation property
  75280. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  75281. */
  75282. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  75283. /**
  75284. * @hidden Define this method to modify the default behavior when loading skins.
  75285. * @param context The context when loading the asset
  75286. * @param node The glTF node property
  75287. * @param skin The glTF skin property
  75288. * @returns A promise that resolves when the load is complete or null if not handled
  75289. */
  75290. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  75291. /**
  75292. * @hidden Define this method to modify the default behavior when loading uris.
  75293. * @param context The context when loading the asset
  75294. * @param property The glTF property associated with the uri
  75295. * @param uri The uri to load
  75296. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  75297. */
  75298. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  75299. /**
  75300. * Define this method to modify the default behavior when loading buffer views.
  75301. * @param context The context when loading the asset
  75302. * @param bufferView The glTF buffer view property
  75303. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  75304. */
  75305. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  75306. /**
  75307. * Define this method to modify the default behavior when loading buffers.
  75308. * @param context The context when loading the asset
  75309. * @param buffer The glTF buffer property
  75310. * @param byteOffset The byte offset to load
  75311. * @param byteLength The byte length to load
  75312. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  75313. */
  75314. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  75315. }
  75316. }
  75317. declare module BABYLON.GLTF2 {
  75318. /**
  75319. * Helper class for working with arrays when loading the glTF asset
  75320. */
  75321. export class ArrayItem {
  75322. /**
  75323. * Gets an item from the given array.
  75324. * @param context The context when loading the asset
  75325. * @param array The array to get the item from
  75326. * @param index The index to the array
  75327. * @returns The array item
  75328. */
  75329. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  75330. /**
  75331. * Assign an `index` field to each item of the given array.
  75332. * @param array The array of items
  75333. */
  75334. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  75335. }
  75336. /**
  75337. * The glTF 2.0 loader
  75338. */
  75339. export class GLTFLoader implements IGLTFLoader {
  75340. /** @hidden */
  75341. _completePromises: Promise<any>[];
  75342. private _disposed;
  75343. private _parent;
  75344. private _state;
  75345. private _extensions;
  75346. private _rootUrl;
  75347. private _fileName;
  75348. private _uniqueRootUrl;
  75349. private _gltf;
  75350. private _bin;
  75351. private _babylonScene;
  75352. private _rootBabylonMesh;
  75353. private _defaultBabylonMaterialData;
  75354. private _progressCallback?;
  75355. private _requests;
  75356. private static readonly _DefaultSampler;
  75357. private static _RegisteredExtensions;
  75358. /**
  75359. * Registers a loader extension.
  75360. * @param name The name of the loader extension.
  75361. * @param factory The factory function that creates the loader extension.
  75362. */
  75363. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  75364. /**
  75365. * Unregisters a loader extension.
  75366. * @param name The name of the loader extension.
  75367. * @returns A boolean indicating whether the extension has been unregistered
  75368. */
  75369. static UnregisterExtension(name: string): boolean;
  75370. /**
  75371. * Gets the loader state.
  75372. */
  75373. get state(): Nullable<GLTFLoaderState>;
  75374. /**
  75375. * The object that represents the glTF JSON.
  75376. */
  75377. get gltf(): IGLTF;
  75378. /**
  75379. * The BIN chunk of a binary glTF.
  75380. */
  75381. get bin(): Nullable<IDataBuffer>;
  75382. /**
  75383. * The parent file loader.
  75384. */
  75385. get parent(): GLTFFileLoader;
  75386. /**
  75387. * The Babylon scene when loading the asset.
  75388. */
  75389. get babylonScene(): Scene;
  75390. /**
  75391. * The root Babylon mesh when loading the asset.
  75392. */
  75393. get rootBabylonMesh(): Mesh;
  75394. /** @hidden */
  75395. constructor(parent: GLTFFileLoader);
  75396. /** @hidden */
  75397. dispose(): void;
  75398. /** @hidden */
  75399. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  75400. meshes: AbstractMesh[];
  75401. particleSystems: IParticleSystem[];
  75402. skeletons: Skeleton[];
  75403. animationGroups: AnimationGroup[];
  75404. }>;
  75405. /** @hidden */
  75406. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  75407. private _loadAsync;
  75408. private _loadData;
  75409. private _setupData;
  75410. private _loadExtensions;
  75411. private _checkExtensions;
  75412. private _setState;
  75413. private _createRootNode;
  75414. /**
  75415. * Loads a glTF scene.
  75416. * @param context The context when loading the asset
  75417. * @param scene The glTF scene property
  75418. * @returns A promise that resolves when the load is complete
  75419. */
  75420. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  75421. private _forEachPrimitive;
  75422. private _getMeshes;
  75423. private _getSkeletons;
  75424. private _getAnimationGroups;
  75425. private _startAnimations;
  75426. /**
  75427. * Loads a glTF node.
  75428. * @param context The context when loading the asset
  75429. * @param node The glTF node property
  75430. * @param assign A function called synchronously after parsing the glTF properties
  75431. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  75432. */
  75433. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  75434. private _loadMeshAsync;
  75435. /**
  75436. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  75437. * @param context The context when loading the asset
  75438. * @param name The mesh name when loading the asset
  75439. * @param node The glTF node when loading the asset
  75440. * @param mesh The glTF mesh when loading the asset
  75441. * @param primitive The glTF mesh primitive property
  75442. * @param assign A function called synchronously after parsing the glTF properties
  75443. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  75444. */
  75445. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  75446. private _loadVertexDataAsync;
  75447. private _createMorphTargets;
  75448. private _loadMorphTargetsAsync;
  75449. private _loadMorphTargetVertexDataAsync;
  75450. private static _LoadTransform;
  75451. private _loadSkinAsync;
  75452. private _loadBones;
  75453. private _loadBone;
  75454. private _loadSkinInverseBindMatricesDataAsync;
  75455. private _updateBoneMatrices;
  75456. private _getNodeMatrix;
  75457. /**
  75458. * Loads a glTF camera.
  75459. * @param context The context when loading the asset
  75460. * @param camera The glTF camera property
  75461. * @param assign A function called synchronously after parsing the glTF properties
  75462. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  75463. */
  75464. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  75465. private _loadAnimationsAsync;
  75466. /**
  75467. * Loads a glTF animation.
  75468. * @param context The context when loading the asset
  75469. * @param animation The glTF animation property
  75470. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  75471. */
  75472. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  75473. /**
  75474. * @hidden Loads a glTF animation channel.
  75475. * @param context The context when loading the asset
  75476. * @param animationContext The context of the animation when loading the asset
  75477. * @param animation The glTF animation property
  75478. * @param channel The glTF animation channel property
  75479. * @param babylonAnimationGroup The babylon animation group property
  75480. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  75481. * @returns A void promise when the channel load is complete
  75482. */
  75483. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  75484. private _loadAnimationSamplerAsync;
  75485. private _loadBufferAsync;
  75486. /**
  75487. * Loads a glTF buffer view.
  75488. * @param context The context when loading the asset
  75489. * @param bufferView The glTF buffer view property
  75490. * @returns A promise that resolves with the loaded data when the load is complete
  75491. */
  75492. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  75493. private _loadAccessorAsync;
  75494. private _loadFloatAccessorAsync;
  75495. private _loadIndicesAccessorAsync;
  75496. private _loadVertexBufferViewAsync;
  75497. private _loadVertexAccessorAsync;
  75498. private _loadMaterialMetallicRoughnessPropertiesAsync;
  75499. /** @hidden */
  75500. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  75501. private _createDefaultMaterial;
  75502. /**
  75503. * Creates a Babylon material from a glTF material.
  75504. * @param context The context when loading the asset
  75505. * @param material The glTF material property
  75506. * @param babylonDrawMode The draw mode for the Babylon material
  75507. * @returns The Babylon material
  75508. */
  75509. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  75510. /**
  75511. * Loads properties from a glTF material into a Babylon material.
  75512. * @param context The context when loading the asset
  75513. * @param material The glTF material property
  75514. * @param babylonMaterial The Babylon material
  75515. * @returns A promise that resolves when the load is complete
  75516. */
  75517. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  75518. /**
  75519. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  75520. * @param context The context when loading the asset
  75521. * @param material The glTF material property
  75522. * @param babylonMaterial The Babylon material
  75523. * @returns A promise that resolves when the load is complete
  75524. */
  75525. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  75526. /**
  75527. * Loads the alpha properties from a glTF material into a Babylon material.
  75528. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  75529. * @param context The context when loading the asset
  75530. * @param material The glTF material property
  75531. * @param babylonMaterial The Babylon material
  75532. */
  75533. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  75534. /**
  75535. * Loads a glTF texture info.
  75536. * @param context The context when loading the asset
  75537. * @param textureInfo The glTF texture info property
  75538. * @param assign A function called synchronously after parsing the glTF properties
  75539. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  75540. */
  75541. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  75542. private _loadTextureAsync;
  75543. private _loadSampler;
  75544. /**
  75545. * Loads a glTF image.
  75546. * @param context The context when loading the asset
  75547. * @param image The glTF image property
  75548. * @returns A promise that resolves with the loaded data when the load is complete
  75549. */
  75550. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  75551. /**
  75552. * Loads a glTF uri.
  75553. * @param context The context when loading the asset
  75554. * @param property The glTF property associated with the uri
  75555. * @param uri The base64 or relative uri
  75556. * @returns A promise that resolves with the loaded data when the load is complete
  75557. */
  75558. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  75559. private _onProgress;
  75560. /**
  75561. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  75562. * @param babylonObject the Babylon object with metadata
  75563. * @param pointer the JSON pointer
  75564. */
  75565. static AddPointerMetadata(babylonObject: {
  75566. metadata: any;
  75567. }, pointer: string): void;
  75568. private static _GetTextureWrapMode;
  75569. private static _GetTextureSamplingMode;
  75570. private static _GetTypedArrayConstructor;
  75571. private static _GetTypedArray;
  75572. private static _GetNumComponents;
  75573. private static _ValidateUri;
  75574. private static _GetDrawMode;
  75575. private _compileMaterialsAsync;
  75576. private _compileShadowGeneratorsAsync;
  75577. private _forEachExtensions;
  75578. private _applyExtensions;
  75579. private _extensionsOnLoading;
  75580. private _extensionsOnReady;
  75581. private _extensionsLoadSceneAsync;
  75582. private _extensionsLoadNodeAsync;
  75583. private _extensionsLoadCameraAsync;
  75584. private _extensionsLoadVertexDataAsync;
  75585. private _extensionsLoadMeshPrimitiveAsync;
  75586. private _extensionsLoadMaterialAsync;
  75587. private _extensionsCreateMaterial;
  75588. private _extensionsLoadMaterialPropertiesAsync;
  75589. private _extensionsLoadTextureInfoAsync;
  75590. private _extensionsLoadAnimationAsync;
  75591. private _extensionsLoadSkinAsync;
  75592. private _extensionsLoadUriAsync;
  75593. private _extensionsLoadBufferViewAsync;
  75594. private _extensionsLoadBufferAsync;
  75595. /**
  75596. * Helper method called by a loader extension to load an glTF extension.
  75597. * @param context The context when loading the asset
  75598. * @param property The glTF property to load the extension from
  75599. * @param extensionName The name of the extension to load
  75600. * @param actionAsync The action to run
  75601. * @returns The promise returned by actionAsync or null if the extension does not exist
  75602. */
  75603. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  75604. /**
  75605. * Helper method called by a loader extension to load a glTF extra.
  75606. * @param context The context when loading the asset
  75607. * @param property The glTF property to load the extra from
  75608. * @param extensionName The name of the extension to load
  75609. * @param actionAsync The action to run
  75610. * @returns The promise returned by actionAsync or null if the extra does not exist
  75611. */
  75612. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  75613. /**
  75614. * Checks for presence of an extension.
  75615. * @param name The name of the extension to check
  75616. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  75617. */
  75618. isExtensionUsed(name: string): boolean;
  75619. /**
  75620. * Increments the indentation level and logs a message.
  75621. * @param message The message to log
  75622. */
  75623. logOpen(message: string): void;
  75624. /**
  75625. * Decrements the indentation level.
  75626. */
  75627. logClose(): void;
  75628. /**
  75629. * Logs a message
  75630. * @param message The message to log
  75631. */
  75632. log(message: string): void;
  75633. /**
  75634. * Starts a performance counter.
  75635. * @param counterName The name of the performance counter
  75636. */
  75637. startPerformanceCounter(counterName: string): void;
  75638. /**
  75639. * Ends a performance counter.
  75640. * @param counterName The name of the performance counter
  75641. */
  75642. endPerformanceCounter(counterName: string): void;
  75643. }
  75644. }
  75645. declare module BABYLON.GLTF2.Loader.Extensions {
  75646. /**
  75647. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  75648. */
  75649. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  75650. /**
  75651. * The name of this extension.
  75652. */
  75653. readonly name: string;
  75654. /**
  75655. * Defines whether this extension is enabled.
  75656. */
  75657. enabled: boolean;
  75658. private _loader;
  75659. private _lights?;
  75660. /** @hidden */
  75661. constructor(loader: GLTFLoader);
  75662. /** @hidden */
  75663. dispose(): void;
  75664. /** @hidden */
  75665. onLoading(): void;
  75666. /** @hidden */
  75667. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  75668. private _loadLightAsync;
  75669. }
  75670. }
  75671. declare module BABYLON.GLTF2.Loader.Extensions {
  75672. /**
  75673. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  75674. */
  75675. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  75676. /**
  75677. * The name of this extension.
  75678. */
  75679. readonly name: string;
  75680. /**
  75681. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  75682. */
  75683. dracoCompression?: DracoCompression;
  75684. /**
  75685. * Defines whether this extension is enabled.
  75686. */
  75687. enabled: boolean;
  75688. private _loader;
  75689. /** @hidden */
  75690. constructor(loader: GLTFLoader);
  75691. /** @hidden */
  75692. dispose(): void;
  75693. /** @hidden */
  75694. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  75695. }
  75696. }
  75697. declare module BABYLON.GLTF2.Loader.Extensions {
  75698. /**
  75699. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  75700. */
  75701. export class KHR_lights implements IGLTFLoaderExtension {
  75702. /**
  75703. * The name of this extension.
  75704. */
  75705. readonly name: string;
  75706. /**
  75707. * Defines whether this extension is enabled.
  75708. */
  75709. enabled: boolean;
  75710. private _loader;
  75711. private _lights?;
  75712. /** @hidden */
  75713. constructor(loader: GLTFLoader);
  75714. /** @hidden */
  75715. dispose(): void;
  75716. /** @hidden */
  75717. onLoading(): void;
  75718. /** @hidden */
  75719. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  75720. }
  75721. }
  75722. declare module BABYLON.GLTF2.Loader.Extensions {
  75723. /**
  75724. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  75725. */
  75726. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  75727. /**
  75728. * The name of this extension.
  75729. */
  75730. readonly name: string;
  75731. /**
  75732. * Defines whether this extension is enabled.
  75733. */
  75734. enabled: boolean;
  75735. /**
  75736. * Defines a number that determines the order the extensions are applied.
  75737. */
  75738. order: number;
  75739. private _loader;
  75740. /** @hidden */
  75741. constructor(loader: GLTFLoader);
  75742. /** @hidden */
  75743. dispose(): void;
  75744. /** @hidden */
  75745. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75746. private _loadSpecularGlossinessPropertiesAsync;
  75747. }
  75748. }
  75749. declare module BABYLON.GLTF2.Loader.Extensions {
  75750. /**
  75751. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  75752. */
  75753. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  75754. /**
  75755. * The name of this extension.
  75756. */
  75757. readonly name: string;
  75758. /**
  75759. * Defines whether this extension is enabled.
  75760. */
  75761. enabled: boolean;
  75762. /**
  75763. * Defines a number that determines the order the extensions are applied.
  75764. */
  75765. order: number;
  75766. private _loader;
  75767. /** @hidden */
  75768. constructor(loader: GLTFLoader);
  75769. /** @hidden */
  75770. dispose(): void;
  75771. /** @hidden */
  75772. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75773. private _loadUnlitPropertiesAsync;
  75774. }
  75775. }
  75776. declare module BABYLON.GLTF2.Loader.Extensions {
  75777. /**
  75778. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  75779. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  75780. * !!! Experimental Extension Subject to Changes !!!
  75781. */
  75782. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  75783. /**
  75784. * The name of this extension.
  75785. */
  75786. readonly name: string;
  75787. /**
  75788. * Defines whether this extension is enabled.
  75789. */
  75790. enabled: boolean;
  75791. /**
  75792. * Defines a number that determines the order the extensions are applied.
  75793. */
  75794. order: number;
  75795. private _loader;
  75796. /** @hidden */
  75797. constructor(loader: GLTFLoader);
  75798. /** @hidden */
  75799. dispose(): void;
  75800. /** @hidden */
  75801. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75802. private _loadClearCoatPropertiesAsync;
  75803. }
  75804. }
  75805. declare module BABYLON.GLTF2.Loader.Extensions {
  75806. /**
  75807. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  75808. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  75809. * !!! Experimental Extension Subject to Changes !!!
  75810. */
  75811. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  75812. /**
  75813. * The name of this extension.
  75814. */
  75815. readonly name: string;
  75816. /**
  75817. * Defines whether this extension is enabled.
  75818. */
  75819. enabled: boolean;
  75820. /**
  75821. * Defines a number that determines the order the extensions are applied.
  75822. */
  75823. order: number;
  75824. private _loader;
  75825. /** @hidden */
  75826. constructor(loader: GLTFLoader);
  75827. /** @hidden */
  75828. dispose(): void;
  75829. /** @hidden */
  75830. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75831. private _loadSheenPropertiesAsync;
  75832. }
  75833. }
  75834. declare module BABYLON.GLTF2.Loader.Extensions {
  75835. /**
  75836. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  75837. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  75838. * !!! Experimental Extension Subject to Changes !!!
  75839. */
  75840. export class KHR_materials_specular implements IGLTFLoaderExtension {
  75841. /**
  75842. * The name of this extension.
  75843. */
  75844. readonly name: string;
  75845. /**
  75846. * Defines whether this extension is enabled.
  75847. */
  75848. enabled: boolean;
  75849. /**
  75850. * Defines a number that determines the order the extensions are applied.
  75851. */
  75852. order: number;
  75853. private _loader;
  75854. /** @hidden */
  75855. constructor(loader: GLTFLoader);
  75856. /** @hidden */
  75857. dispose(): void;
  75858. /** @hidden */
  75859. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  75860. private _loadSpecularPropertiesAsync;
  75861. }
  75862. }
  75863. declare module BABYLON.GLTF2.Loader.Extensions {
  75864. /**
  75865. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  75866. */
  75867. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  75868. /**
  75869. * The name of this extension.
  75870. */
  75871. readonly name: string;
  75872. /**
  75873. * Defines whether this extension is enabled.
  75874. */
  75875. enabled: boolean;
  75876. /** @hidden */
  75877. constructor(loader: GLTFLoader);
  75878. /** @hidden */
  75879. dispose(): void;
  75880. }
  75881. }
  75882. declare module BABYLON.GLTF2.Loader.Extensions {
  75883. /**
  75884. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  75885. */
  75886. export class KHR_texture_transform implements IGLTFLoaderExtension {
  75887. /**
  75888. * The name of this extension.
  75889. */
  75890. readonly name: string;
  75891. /**
  75892. * Defines whether this extension is enabled.
  75893. */
  75894. enabled: boolean;
  75895. private _loader;
  75896. /** @hidden */
  75897. constructor(loader: GLTFLoader);
  75898. /** @hidden */
  75899. dispose(): void;
  75900. /** @hidden */
  75901. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  75902. }
  75903. }
  75904. declare module BABYLON.GLTF2.Loader.Extensions {
  75905. /**
  75906. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  75907. */
  75908. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  75909. /**
  75910. * The name of this extension.
  75911. */
  75912. readonly name: string;
  75913. /**
  75914. * Defines whether this extension is enabled.
  75915. */
  75916. enabled: boolean;
  75917. private _loader;
  75918. private _clips;
  75919. private _emitters;
  75920. /** @hidden */
  75921. constructor(loader: GLTFLoader);
  75922. /** @hidden */
  75923. dispose(): void;
  75924. /** @hidden */
  75925. onLoading(): void;
  75926. /** @hidden */
  75927. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  75928. /** @hidden */
  75929. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  75930. /** @hidden */
  75931. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  75932. private _loadClipAsync;
  75933. private _loadEmitterAsync;
  75934. private _getEventAction;
  75935. private _loadAnimationEventAsync;
  75936. }
  75937. }
  75938. declare module BABYLON.GLTF2.Loader.Extensions {
  75939. /**
  75940. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  75941. */
  75942. export class MSFT_lod implements IGLTFLoaderExtension {
  75943. /**
  75944. * The name of this extension.
  75945. */
  75946. readonly name: string;
  75947. /**
  75948. * Defines whether this extension is enabled.
  75949. */
  75950. enabled: boolean;
  75951. /**
  75952. * Defines a number that determines the order the extensions are applied.
  75953. */
  75954. order: number;
  75955. /**
  75956. * Maximum number of LODs to load, starting from the lowest LOD.
  75957. */
  75958. maxLODsToLoad: number;
  75959. /**
  75960. * Observable raised when all node LODs of one level are loaded.
  75961. * The event data is the index of the loaded LOD starting from zero.
  75962. * Dispose the loader to cancel the loading of the next level of LODs.
  75963. */
  75964. onNodeLODsLoadedObservable: Observable<number>;
  75965. /**
  75966. * Observable raised when all material LODs of one level are loaded.
  75967. * The event data is the index of the loaded LOD starting from zero.
  75968. * Dispose the loader to cancel the loading of the next level of LODs.
  75969. */
  75970. onMaterialLODsLoadedObservable: Observable<number>;
  75971. private _loader;
  75972. private _nodeIndexLOD;
  75973. private _nodeSignalLODs;
  75974. private _nodePromiseLODs;
  75975. private _materialIndexLOD;
  75976. private _materialSignalLODs;
  75977. private _materialPromiseLODs;
  75978. private _indexLOD;
  75979. private _bufferLODs;
  75980. /** @hidden */
  75981. constructor(loader: GLTFLoader);
  75982. /** @hidden */
  75983. dispose(): void;
  75984. /** @hidden */
  75985. onReady(): void;
  75986. /** @hidden */
  75987. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  75988. /** @hidden */
  75989. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  75990. /** @hidden */
  75991. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  75992. /** @hidden */
  75993. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  75994. /** @hidden */
  75995. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  75996. private _loadBufferLOD;
  75997. /**
  75998. * Gets an array of LOD properties from lowest to highest.
  75999. */
  76000. private _getLODs;
  76001. private _disposeUnusedMaterials;
  76002. }
  76003. }
  76004. declare module BABYLON.GLTF2.Loader.Extensions {
  76005. /** @hidden */
  76006. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  76007. readonly name: string;
  76008. enabled: boolean;
  76009. private _loader;
  76010. constructor(loader: GLTFLoader);
  76011. dispose(): void;
  76012. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76013. }
  76014. }
  76015. declare module BABYLON.GLTF2.Loader.Extensions {
  76016. /** @hidden */
  76017. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  76018. readonly name: string;
  76019. enabled: boolean;
  76020. private _loader;
  76021. constructor(loader: GLTFLoader);
  76022. dispose(): void;
  76023. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  76024. }
  76025. }
  76026. declare module BABYLON.GLTF2.Loader.Extensions {
  76027. /**
  76028. * Store glTF extras (if present) in BJS objects' metadata
  76029. */
  76030. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  76031. /**
  76032. * The name of this extension.
  76033. */
  76034. readonly name: string;
  76035. /**
  76036. * Defines whether this extension is enabled.
  76037. */
  76038. enabled: boolean;
  76039. private _loader;
  76040. private _assignExtras;
  76041. /** @hidden */
  76042. constructor(loader: GLTFLoader);
  76043. /** @hidden */
  76044. dispose(): void;
  76045. /** @hidden */
  76046. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  76047. /** @hidden */
  76048. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  76049. /** @hidden */
  76050. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  76051. }
  76052. }
  76053. declare module BABYLON {
  76054. /**
  76055. * Class reading and parsing the MTL file bundled with the obj file.
  76056. */
  76057. export class MTLFileLoader {
  76058. /**
  76059. * Invert Y-Axis of referenced textures on load
  76060. */
  76061. static INVERT_TEXTURE_Y: boolean;
  76062. /**
  76063. * All material loaded from the mtl will be set here
  76064. */
  76065. materials: StandardMaterial[];
  76066. /**
  76067. * This function will read the mtl file and create each material described inside
  76068. * This function could be improve by adding :
  76069. * -some component missing (Ni, Tf...)
  76070. * -including the specific options available
  76071. *
  76072. * @param scene defines the scene the material will be created in
  76073. * @param data defines the mtl data to parse
  76074. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  76075. */
  76076. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  76077. /**
  76078. * Gets the texture for the material.
  76079. *
  76080. * If the material is imported from input file,
  76081. * We sanitize the url to ensure it takes the textre from aside the material.
  76082. *
  76083. * @param rootUrl The root url to load from
  76084. * @param value The value stored in the mtl
  76085. * @return The Texture
  76086. */
  76087. private static _getTexture;
  76088. }
  76089. }
  76090. declare module BABYLON {
  76091. /**
  76092. * Options for loading OBJ/MTL files
  76093. */
  76094. type MeshLoadOptions = {
  76095. /**
  76096. * Defines if UVs are optimized by default during load.
  76097. */
  76098. OptimizeWithUV: boolean;
  76099. /**
  76100. * Defines custom scaling of UV coordinates of loaded meshes.
  76101. */
  76102. UVScaling: Vector2;
  76103. /**
  76104. * Invert model on y-axis (does a model scaling inversion)
  76105. */
  76106. InvertY: boolean;
  76107. /**
  76108. * Invert Y-Axis of referenced textures on load
  76109. */
  76110. InvertTextureY: boolean;
  76111. /**
  76112. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  76113. */
  76114. ImportVertexColors: boolean;
  76115. /**
  76116. * Compute the normals for the model, even if normals are present in the file.
  76117. */
  76118. ComputeNormals: boolean;
  76119. /**
  76120. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  76121. */
  76122. SkipMaterials: boolean;
  76123. /**
  76124. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  76125. */
  76126. MaterialLoadingFailsSilently: boolean;
  76127. };
  76128. /**
  76129. * OBJ file type loader.
  76130. * This is a babylon scene loader plugin.
  76131. */
  76132. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  76133. /**
  76134. * Defines if UVs are optimized by default during load.
  76135. */
  76136. static OPTIMIZE_WITH_UV: boolean;
  76137. /**
  76138. * Invert model on y-axis (does a model scaling inversion)
  76139. */
  76140. static INVERT_Y: boolean;
  76141. /**
  76142. * Invert Y-Axis of referenced textures on load
  76143. */
  76144. static get INVERT_TEXTURE_Y(): boolean;
  76145. static set INVERT_TEXTURE_Y(value: boolean);
  76146. /**
  76147. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  76148. */
  76149. static IMPORT_VERTEX_COLORS: boolean;
  76150. /**
  76151. * Compute the normals for the model, even if normals are present in the file.
  76152. */
  76153. static COMPUTE_NORMALS: boolean;
  76154. /**
  76155. * Defines custom scaling of UV coordinates of loaded meshes.
  76156. */
  76157. static UV_SCALING: Vector2;
  76158. /**
  76159. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  76160. */
  76161. static SKIP_MATERIALS: boolean;
  76162. /**
  76163. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  76164. *
  76165. * Defaults to true for backwards compatibility.
  76166. */
  76167. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  76168. /**
  76169. * Defines the name of the plugin.
  76170. */
  76171. name: string;
  76172. /**
  76173. * Defines the extension the plugin is able to load.
  76174. */
  76175. extensions: string;
  76176. /** @hidden */
  76177. obj: RegExp;
  76178. /** @hidden */
  76179. group: RegExp;
  76180. /** @hidden */
  76181. mtllib: RegExp;
  76182. /** @hidden */
  76183. usemtl: RegExp;
  76184. /** @hidden */
  76185. smooth: RegExp;
  76186. /** @hidden */
  76187. vertexPattern: RegExp;
  76188. /** @hidden */
  76189. normalPattern: RegExp;
  76190. /** @hidden */
  76191. uvPattern: RegExp;
  76192. /** @hidden */
  76193. facePattern1: RegExp;
  76194. /** @hidden */
  76195. facePattern2: RegExp;
  76196. /** @hidden */
  76197. facePattern3: RegExp;
  76198. /** @hidden */
  76199. facePattern4: RegExp;
  76200. /** @hidden */
  76201. facePattern5: RegExp;
  76202. private _meshLoadOptions;
  76203. /**
  76204. * Creates loader for .OBJ files
  76205. *
  76206. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  76207. */
  76208. constructor(meshLoadOptions?: MeshLoadOptions);
  76209. private static get currentMeshLoadOptions();
  76210. /**
  76211. * Calls synchronously the MTL file attached to this obj.
  76212. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  76213. * Without this function materials are not displayed in the first frame (but displayed after).
  76214. * In consequence it is impossible to get material information in your HTML file
  76215. *
  76216. * @param url The URL of the MTL file
  76217. * @param rootUrl
  76218. * @param onSuccess Callback function to be called when the MTL file is loaded
  76219. * @private
  76220. */
  76221. private _loadMTL;
  76222. /**
  76223. * Instantiates a OBJ file loader plugin.
  76224. * @returns the created plugin
  76225. */
  76226. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  76227. /**
  76228. * If the data string can be loaded directly.
  76229. *
  76230. * @param data string containing the file data
  76231. * @returns if the data can be loaded directly
  76232. */
  76233. canDirectLoad(data: string): boolean;
  76234. /**
  76235. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  76236. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  76237. * @param scene the scene the meshes should be added to
  76238. * @param data the OBJ data to load
  76239. * @param rootUrl root url to load from
  76240. * @param onProgress event that fires when loading progress has occured
  76241. * @param fileName Defines the name of the file to load
  76242. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  76243. */
  76244. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  76245. meshes: AbstractMesh[];
  76246. particleSystems: IParticleSystem[];
  76247. skeletons: Skeleton[];
  76248. animationGroups: AnimationGroup[];
  76249. }>;
  76250. /**
  76251. * Imports all objects from the loaded OBJ data and adds them to the scene
  76252. * @param scene the scene the objects should be added to
  76253. * @param data the OBJ data to load
  76254. * @param rootUrl root url to load from
  76255. * @param onProgress event that fires when loading progress has occured
  76256. * @param fileName Defines the name of the file to load
  76257. * @returns a promise which completes when objects have been loaded to the scene
  76258. */
  76259. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  76260. /**
  76261. * Load into an asset container.
  76262. * @param scene The scene to load into
  76263. * @param data The data to import
  76264. * @param rootUrl The root url for scene and resources
  76265. * @param onProgress The callback when the load progresses
  76266. * @param fileName Defines the name of the file to load
  76267. * @returns The loaded asset container
  76268. */
  76269. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  76270. /**
  76271. * Read the OBJ file and create an Array of meshes.
  76272. * Each mesh contains all information given by the OBJ and the MTL file.
  76273. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  76274. *
  76275. * @param meshesNames
  76276. * @param scene Scene The scene where are displayed the data
  76277. * @param data String The content of the obj file
  76278. * @param rootUrl String The path to the folder
  76279. * @returns Array<AbstractMesh>
  76280. * @private
  76281. */
  76282. private _parseSolid;
  76283. }
  76284. }
  76285. declare module BABYLON {
  76286. /**
  76287. * STL file type loader.
  76288. * This is a babylon scene loader plugin.
  76289. */
  76290. export class STLFileLoader implements ISceneLoaderPlugin {
  76291. /** @hidden */
  76292. solidPattern: RegExp;
  76293. /** @hidden */
  76294. facetsPattern: RegExp;
  76295. /** @hidden */
  76296. normalPattern: RegExp;
  76297. /** @hidden */
  76298. vertexPattern: RegExp;
  76299. /**
  76300. * Defines the name of the plugin.
  76301. */
  76302. name: string;
  76303. /**
  76304. * Defines the extensions the stl loader is able to load.
  76305. * force data to come in as an ArrayBuffer
  76306. * we'll convert to string if it looks like it's an ASCII .stl
  76307. */
  76308. extensions: ISceneLoaderPluginExtensions;
  76309. /**
  76310. * Import meshes into a scene.
  76311. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  76312. * @param scene The scene to import into
  76313. * @param data The data to import
  76314. * @param rootUrl The root url for scene and resources
  76315. * @param meshes The meshes array to import into
  76316. * @param particleSystems The particle systems array to import into
  76317. * @param skeletons The skeletons array to import into
  76318. * @param onError The callback when import fails
  76319. * @returns True if successful or false otherwise
  76320. */
  76321. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  76322. /**
  76323. * Load into a scene.
  76324. * @param scene The scene to load into
  76325. * @param data The data to import
  76326. * @param rootUrl The root url for scene and resources
  76327. * @param onError The callback when import fails
  76328. * @returns true if successful or false otherwise
  76329. */
  76330. load(scene: Scene, data: any, rootUrl: string): boolean;
  76331. /**
  76332. * Load into an asset container.
  76333. * @param scene The scene to load into
  76334. * @param data The data to import
  76335. * @param rootUrl The root url for scene and resources
  76336. * @param onError The callback when import fails
  76337. * @returns The loaded asset container
  76338. */
  76339. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  76340. private _isBinary;
  76341. private _parseBinary;
  76342. private _parseASCII;
  76343. }
  76344. }
  76345. declare module BABYLON {
  76346. /**
  76347. * Class for generating OBJ data from a Babylon scene.
  76348. */
  76349. export class OBJExport {
  76350. /**
  76351. * Exports the geometry of a Mesh array in .OBJ file format (text)
  76352. * @param mesh defines the list of meshes to serialize
  76353. * @param materials defines if materials should be exported
  76354. * @param matlibname defines the name of the associated mtl file
  76355. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  76356. * @returns the OBJ content
  76357. */
  76358. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  76359. /**
  76360. * Exports the material(s) of a mesh in .MTL file format (text)
  76361. * @param mesh defines the mesh to extract the material from
  76362. * @returns the mtl content
  76363. */
  76364. static MTL(mesh: Mesh): string;
  76365. }
  76366. }
  76367. declare module BABYLON {
  76368. /** @hidden */
  76369. export var __IGLTFExporterExtension: number;
  76370. /**
  76371. * Interface for extending the exporter
  76372. * @hidden
  76373. */
  76374. export interface IGLTFExporterExtension {
  76375. /**
  76376. * The name of this extension
  76377. */
  76378. readonly name: string;
  76379. /**
  76380. * Defines whether this extension is enabled
  76381. */
  76382. enabled: boolean;
  76383. /**
  76384. * Defines whether this extension is required
  76385. */
  76386. required: boolean;
  76387. }
  76388. }
  76389. declare module BABYLON.GLTF2.Exporter {
  76390. /** @hidden */
  76391. export var __IGLTFExporterExtensionV2: number;
  76392. /**
  76393. * Interface for a glTF exporter extension
  76394. * @hidden
  76395. */
  76396. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  76397. /**
  76398. * Define this method to modify the default behavior before exporting a texture
  76399. * @param context The context when loading the asset
  76400. * @param babylonTexture The Babylon.js texture
  76401. * @param mimeType The mime-type of the generated image
  76402. * @returns A promise that resolves with the exported texture
  76403. */
  76404. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  76405. /**
  76406. * Define this method to get notified when a texture info is created
  76407. * @param context The context when loading the asset
  76408. * @param textureInfo The glTF texture info
  76409. * @param babylonTexture The Babylon.js texture
  76410. */
  76411. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  76412. /**
  76413. * Define this method to modify the default behavior when exporting texture info
  76414. * @param context The context when loading the asset
  76415. * @param meshPrimitive glTF mesh primitive
  76416. * @param babylonSubMesh Babylon submesh
  76417. * @param binaryWriter glTF serializer binary writer instance
  76418. * @returns nullable IMeshPrimitive promise
  76419. */
  76420. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  76421. /**
  76422. * Define this method to modify the default behavior when exporting a node
  76423. * @param context The context when exporting the node
  76424. * @param node glTF node
  76425. * @param babylonNode BabylonJS node
  76426. * @returns nullable INode promise
  76427. */
  76428. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Promise<INode>;
  76429. /**
  76430. * Define this method to modify the default behavior when exporting a material
  76431. * @param material glTF material
  76432. * @param babylonMaterial BabylonJS material
  76433. * @returns nullable IMaterial promise
  76434. */
  76435. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  76436. /**
  76437. * Define this method to return additional textures to export from a material
  76438. * @param material glTF material
  76439. * @param babylonMaterial BabylonJS material
  76440. * @returns List of textures
  76441. */
  76442. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  76443. /** Gets a boolean indicating that this extension was used */
  76444. wasUsed: boolean;
  76445. /** Gets a boolean indicating that this extension is required for the file to work */
  76446. required: boolean;
  76447. /**
  76448. * Called after the exporter state changes to EXPORTING
  76449. */
  76450. onExporting?(): void;
  76451. }
  76452. }
  76453. declare module BABYLON.GLTF2.Exporter {
  76454. /**
  76455. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  76456. * @hidden
  76457. */
  76458. export class _GLTFMaterialExporter {
  76459. /**
  76460. * Represents the dielectric specular values for R, G and B
  76461. */
  76462. private static readonly _DielectricSpecular;
  76463. /**
  76464. * Allows the maximum specular power to be defined for material calculations
  76465. */
  76466. private static readonly _MaxSpecularPower;
  76467. /**
  76468. * Mapping to store textures
  76469. */
  76470. private _textureMap;
  76471. /**
  76472. * Numeric tolerance value
  76473. */
  76474. private static readonly _Epsilon;
  76475. /**
  76476. * Reference to the glTF Exporter
  76477. */
  76478. private _exporter;
  76479. constructor(exporter: _Exporter);
  76480. /**
  76481. * Specifies if two colors are approximately equal in value
  76482. * @param color1 first color to compare to
  76483. * @param color2 second color to compare to
  76484. * @param epsilon threshold value
  76485. */
  76486. private static FuzzyEquals;
  76487. /**
  76488. * Gets the materials from a Babylon scene and converts them to glTF materials
  76489. * @param scene babylonjs scene
  76490. * @param mimeType texture mime type
  76491. * @param images array of images
  76492. * @param textures array of textures
  76493. * @param materials array of materials
  76494. * @param imageData mapping of texture names to base64 textures
  76495. * @param hasTextureCoords specifies if texture coordinates are present on the material
  76496. */
  76497. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  76498. /**
  76499. * Makes a copy of the glTF material without the texture parameters
  76500. * @param originalMaterial original glTF material
  76501. * @returns glTF material without texture parameters
  76502. */
  76503. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  76504. /**
  76505. * Specifies if the material has any texture parameters present
  76506. * @param material glTF Material
  76507. * @returns boolean specifying if texture parameters are present
  76508. */
  76509. _hasTexturesPresent(material: IMaterial): boolean;
  76510. /**
  76511. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  76512. * @param babylonStandardMaterial
  76513. * @returns glTF Metallic Roughness Material representation
  76514. */
  76515. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  76516. /**
  76517. * Computes the metallic factor
  76518. * @param diffuse diffused value
  76519. * @param specular specular value
  76520. * @param oneMinusSpecularStrength one minus the specular strength
  76521. * @returns metallic value
  76522. */
  76523. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  76524. /**
  76525. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  76526. * @param glTFMaterial glTF material
  76527. * @param babylonMaterial Babylon material
  76528. */
  76529. private static _SetAlphaMode;
  76530. /**
  76531. * Converts a Babylon Standard Material to a glTF Material
  76532. * @param babylonStandardMaterial BJS Standard Material
  76533. * @param mimeType mime type to use for the textures
  76534. * @param images array of glTF image interfaces
  76535. * @param textures array of glTF texture interfaces
  76536. * @param materials array of glTF material interfaces
  76537. * @param imageData map of image file name to data
  76538. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  76539. */
  76540. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  76541. private _finishMaterial;
  76542. /**
  76543. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  76544. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  76545. * @param mimeType mime type to use for the textures
  76546. * @param images array of glTF image interfaces
  76547. * @param textures array of glTF texture interfaces
  76548. * @param materials array of glTF material interfaces
  76549. * @param imageData map of image file name to data
  76550. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  76551. */
  76552. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  76553. /**
  76554. * Converts an image typed array buffer to a base64 image
  76555. * @param buffer typed array buffer
  76556. * @param width width of the image
  76557. * @param height height of the image
  76558. * @param mimeType mimetype of the image
  76559. * @returns base64 image string
  76560. */
  76561. private _createBase64FromCanvasAsync;
  76562. /**
  76563. * Generates a white texture based on the specified width and height
  76564. * @param width width of the texture in pixels
  76565. * @param height height of the texture in pixels
  76566. * @param scene babylonjs scene
  76567. * @returns white texture
  76568. */
  76569. private _createWhiteTexture;
  76570. /**
  76571. * 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
  76572. * @param texture1 first texture to resize
  76573. * @param texture2 second texture to resize
  76574. * @param scene babylonjs scene
  76575. * @returns resized textures or null
  76576. */
  76577. private _resizeTexturesToSameDimensions;
  76578. /**
  76579. * Converts an array of pixels to a Float32Array
  76580. * Throws an error if the pixel format is not supported
  76581. * @param pixels - array buffer containing pixel values
  76582. * @returns Float32 of pixels
  76583. */
  76584. private _convertPixelArrayToFloat32;
  76585. /**
  76586. * Convert Specular Glossiness Textures to Metallic Roughness
  76587. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  76588. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  76589. * @param diffuseTexture texture used to store diffuse information
  76590. * @param specularGlossinessTexture texture used to store specular and glossiness information
  76591. * @param factors specular glossiness material factors
  76592. * @param mimeType the mime type to use for the texture
  76593. * @returns pbr metallic roughness interface or null
  76594. */
  76595. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  76596. /**
  76597. * Converts specular glossiness material properties to metallic roughness
  76598. * @param specularGlossiness interface with specular glossiness material properties
  76599. * @returns interface with metallic roughness material properties
  76600. */
  76601. private _convertSpecularGlossinessToMetallicRoughness;
  76602. /**
  76603. * Calculates the surface reflectance, independent of lighting conditions
  76604. * @param color Color source to calculate brightness from
  76605. * @returns number representing the perceived brightness, or zero if color is undefined
  76606. */
  76607. private _getPerceivedBrightness;
  76608. /**
  76609. * Returns the maximum color component value
  76610. * @param color
  76611. * @returns maximum color component value, or zero if color is null or undefined
  76612. */
  76613. private _getMaxComponent;
  76614. /**
  76615. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  76616. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  76617. * @param mimeType mime type to use for the textures
  76618. * @param images array of glTF image interfaces
  76619. * @param textures array of glTF texture interfaces
  76620. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  76621. * @param imageData map of image file name to data
  76622. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  76623. * @returns glTF PBR Metallic Roughness factors
  76624. */
  76625. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  76626. private _getGLTFTextureSampler;
  76627. private _getGLTFTextureWrapMode;
  76628. private _getGLTFTextureWrapModesSampler;
  76629. /**
  76630. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  76631. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  76632. * @param mimeType mime type to use for the textures
  76633. * @param images array of glTF image interfaces
  76634. * @param textures array of glTF texture interfaces
  76635. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  76636. * @param imageData map of image file name to data
  76637. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  76638. * @returns glTF PBR Metallic Roughness factors
  76639. */
  76640. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  76641. /**
  76642. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  76643. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  76644. * @param mimeType mime type to use for the textures
  76645. * @param images array of glTF image interfaces
  76646. * @param textures array of glTF texture interfaces
  76647. * @param materials array of glTF material interfaces
  76648. * @param imageData map of image file name to data
  76649. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  76650. */
  76651. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  76652. private setMetallicRoughnessPbrMaterial;
  76653. private getPixelsFromTexture;
  76654. /**
  76655. * Extracts a texture from a Babylon texture into file data and glTF data
  76656. * @param babylonTexture Babylon texture to extract
  76657. * @param mimeType Mime Type of the babylonTexture
  76658. * @return glTF texture info, or null if the texture format is not supported
  76659. */
  76660. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  76661. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  76662. /**
  76663. * Builds a texture from base64 string
  76664. * @param base64Texture base64 texture string
  76665. * @param baseTextureName Name to use for the texture
  76666. * @param mimeType image mime type for the texture
  76667. * @param images array of images
  76668. * @param textures array of textures
  76669. * @param imageData map of image data
  76670. * @returns glTF texture info, or null if the texture format is not supported
  76671. */
  76672. private _getTextureInfoFromBase64;
  76673. }
  76674. }
  76675. declare module BABYLON {
  76676. /**
  76677. * Class for holding and downloading glTF file data
  76678. */
  76679. export class GLTFData {
  76680. /**
  76681. * Object which contains the file name as the key and its data as the value
  76682. */
  76683. glTFFiles: {
  76684. [fileName: string]: string | Blob;
  76685. };
  76686. /**
  76687. * Initializes the glTF file object
  76688. */
  76689. constructor();
  76690. /**
  76691. * Downloads the glTF data as files based on their names and data
  76692. */
  76693. downloadFiles(): void;
  76694. }
  76695. }
  76696. declare module BABYLON {
  76697. /**
  76698. * Holds a collection of exporter options and parameters
  76699. */
  76700. export interface IExportOptions {
  76701. /**
  76702. * Function which indicates whether a babylon node should be exported or not
  76703. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  76704. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  76705. */
  76706. shouldExportNode?(node: Node): boolean;
  76707. /**
  76708. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  76709. * @param metadata source metadata to read from
  76710. * @returns the data to store to glTF node extras
  76711. */
  76712. metadataSelector?(metadata: any): any;
  76713. /**
  76714. * The sample rate to bake animation curves
  76715. */
  76716. animationSampleRate?: number;
  76717. /**
  76718. * Begin serialization without waiting for the scene to be ready
  76719. */
  76720. exportWithoutWaitingForScene?: boolean;
  76721. }
  76722. /**
  76723. * Class for generating glTF data from a Babylon scene.
  76724. */
  76725. export class GLTF2Export {
  76726. /**
  76727. * Exports the geometry of the scene to .gltf file format asynchronously
  76728. * @param scene Babylon scene with scene hierarchy information
  76729. * @param filePrefix File prefix to use when generating the glTF file
  76730. * @param options Exporter options
  76731. * @returns Returns an object with a .gltf file and associates texture names
  76732. * as keys and their data and paths as values
  76733. */
  76734. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  76735. private static _PreExportAsync;
  76736. private static _PostExportAsync;
  76737. /**
  76738. * Exports the geometry of the scene to .glb file format asychronously
  76739. * @param scene Babylon scene with scene hierarchy information
  76740. * @param filePrefix File prefix to use when generating glb file
  76741. * @param options Exporter options
  76742. * @returns Returns an object with a .glb filename as key and data as value
  76743. */
  76744. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  76745. }
  76746. }
  76747. declare module BABYLON.GLTF2.Exporter {
  76748. /**
  76749. * @hidden
  76750. */
  76751. export class _GLTFUtilities {
  76752. /**
  76753. * Creates a buffer view based on the supplied arguments
  76754. * @param bufferIndex index value of the specified buffer
  76755. * @param byteOffset byte offset value
  76756. * @param byteLength byte length of the bufferView
  76757. * @param byteStride byte distance between conequential elements
  76758. * @param name name of the buffer view
  76759. * @returns bufferView for glTF
  76760. */
  76761. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  76762. /**
  76763. * Creates an accessor based on the supplied arguments
  76764. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  76765. * @param name The name of the accessor
  76766. * @param type The type of the accessor
  76767. * @param componentType The datatype of components in the attribute
  76768. * @param count The number of attributes referenced by this accessor
  76769. * @param byteOffset The offset relative to the start of the bufferView in bytes
  76770. * @param min Minimum value of each component in this attribute
  76771. * @param max Maximum value of each component in this attribute
  76772. * @returns accessor for glTF
  76773. */
  76774. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  76775. /**
  76776. * Calculates the minimum and maximum values of an array of position floats
  76777. * @param positions Positions array of a mesh
  76778. * @param vertexStart Starting vertex offset to calculate min and max values
  76779. * @param vertexCount Number of vertices to check for min and max values
  76780. * @returns min number array and max number array
  76781. */
  76782. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  76783. min: number[];
  76784. max: number[];
  76785. };
  76786. /**
  76787. * Converts a new right-handed Vector3
  76788. * @param vector vector3 array
  76789. * @returns right-handed Vector3
  76790. */
  76791. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  76792. /**
  76793. * Converts a Vector3 to right-handed
  76794. * @param vector Vector3 to convert to right-handed
  76795. */
  76796. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  76797. /**
  76798. * Converts a three element number array to right-handed
  76799. * @param vector number array to convert to right-handed
  76800. */
  76801. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  76802. /**
  76803. * Converts a new right-handed Vector3
  76804. * @param vector vector3 array
  76805. * @returns right-handed Vector3
  76806. */
  76807. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  76808. /**
  76809. * Converts a Vector3 to right-handed
  76810. * @param vector Vector3 to convert to right-handed
  76811. */
  76812. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  76813. /**
  76814. * Converts a three element number array to right-handed
  76815. * @param vector number array to convert to right-handed
  76816. */
  76817. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  76818. /**
  76819. * Converts a Vector4 to right-handed
  76820. * @param vector Vector4 to convert to right-handed
  76821. */
  76822. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  76823. /**
  76824. * Converts a Vector4 to right-handed
  76825. * @param vector Vector4 to convert to right-handed
  76826. */
  76827. static _GetRightHandedArray4FromRef(vector: number[]): void;
  76828. /**
  76829. * Converts a Quaternion to right-handed
  76830. * @param quaternion Source quaternion to convert to right-handed
  76831. */
  76832. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  76833. /**
  76834. * Converts a Quaternion to right-handed
  76835. * @param quaternion Source quaternion to convert to right-handed
  76836. */
  76837. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  76838. static _NormalizeTangentFromRef(tangent: Vector4): void;
  76839. }
  76840. }
  76841. declare module BABYLON.GLTF2.Exporter {
  76842. /**
  76843. * Converts Babylon Scene into glTF 2.0.
  76844. * @hidden
  76845. */
  76846. export class _Exporter {
  76847. /**
  76848. * Stores the glTF to export
  76849. */
  76850. _glTF: IGLTF;
  76851. /**
  76852. * Stores all generated buffer views, which represents views into the main glTF buffer data
  76853. */
  76854. _bufferViews: IBufferView[];
  76855. /**
  76856. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  76857. */
  76858. _accessors: IAccessor[];
  76859. /**
  76860. * Stores all the generated nodes, which contains transform and/or mesh information per node
  76861. */
  76862. private _nodes;
  76863. /**
  76864. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  76865. */
  76866. private _scenes;
  76867. /**
  76868. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  76869. */
  76870. private _meshes;
  76871. /**
  76872. * Stores all the generated material information, which represents the appearance of each primitive
  76873. */
  76874. _materials: IMaterial[];
  76875. _materialMap: {
  76876. [materialID: number]: number;
  76877. };
  76878. /**
  76879. * Stores all the generated texture information, which is referenced by glTF materials
  76880. */
  76881. _textures: ITexture[];
  76882. /**
  76883. * Stores all the generated image information, which is referenced by glTF textures
  76884. */
  76885. _images: IImage[];
  76886. /**
  76887. * Stores all the texture samplers
  76888. */
  76889. _samplers: ISampler[];
  76890. /**
  76891. * Stores all the generated animation samplers, which is referenced by glTF animations
  76892. */
  76893. /**
  76894. * Stores the animations for glTF models
  76895. */
  76896. private _animations;
  76897. /**
  76898. * Stores the total amount of bytes stored in the glTF buffer
  76899. */
  76900. private _totalByteLength;
  76901. /**
  76902. * Stores a reference to the Babylon scene containing the source geometry and material information
  76903. */
  76904. _babylonScene: Scene;
  76905. /**
  76906. * Stores a map of the image data, where the key is the file name and the value
  76907. * is the image data
  76908. */
  76909. _imageData: {
  76910. [fileName: string]: {
  76911. data: Uint8Array;
  76912. mimeType: ImageMimeType;
  76913. };
  76914. };
  76915. /**
  76916. * Stores a map of the unique id of a node to its index in the node array
  76917. */
  76918. private _nodeMap;
  76919. /**
  76920. * Specifies if the Babylon scene should be converted to right-handed on export
  76921. */
  76922. _convertToRightHandedSystem: boolean;
  76923. /**
  76924. * Baked animation sample rate
  76925. */
  76926. private _animationSampleRate;
  76927. private _options;
  76928. private _localEngine;
  76929. _glTFMaterialExporter: _GLTFMaterialExporter;
  76930. private _extensions;
  76931. private static _ExtensionNames;
  76932. private static _ExtensionFactories;
  76933. private _applyExtension;
  76934. private _applyExtensions;
  76935. _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  76936. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  76937. _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Promise<Nullable<INode>>;
  76938. _extensionsPostExportMaterialAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  76939. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  76940. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  76941. private _forEachExtensions;
  76942. private _extensionsOnExporting;
  76943. /**
  76944. * Load glTF serializer extensions
  76945. */
  76946. private _loadExtensions;
  76947. /**
  76948. * Creates a glTF Exporter instance, which can accept optional exporter options
  76949. * @param babylonScene Babylon scene object
  76950. * @param options Options to modify the behavior of the exporter
  76951. */
  76952. constructor(babylonScene: Scene, options?: IExportOptions);
  76953. dispose(): void;
  76954. /**
  76955. * Registers a glTF exporter extension
  76956. * @param name Name of the extension to export
  76957. * @param factory The factory function that creates the exporter extension
  76958. */
  76959. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  76960. /**
  76961. * Un-registers an exporter extension
  76962. * @param name The name fo the exporter extension
  76963. * @returns A boolean indicating whether the extension has been un-registered
  76964. */
  76965. static UnregisterExtension(name: string): boolean;
  76966. /**
  76967. * Lazy load a local engine
  76968. */
  76969. _getLocalEngine(): Engine;
  76970. private reorderIndicesBasedOnPrimitiveMode;
  76971. /**
  76972. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  76973. * clock-wise during export to glTF
  76974. * @param submesh BabylonJS submesh
  76975. * @param primitiveMode Primitive mode of the mesh
  76976. * @param sideOrientation the winding order of the submesh
  76977. * @param vertexBufferKind The type of vertex attribute
  76978. * @param meshAttributeArray The vertex attribute data
  76979. * @param byteOffset The offset to the binary data
  76980. * @param binaryWriter The binary data for the glTF file
  76981. */
  76982. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  76983. /**
  76984. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  76985. * clock-wise during export to glTF
  76986. * @param submesh BabylonJS submesh
  76987. * @param primitiveMode Primitive mode of the mesh
  76988. * @param sideOrientation the winding order of the submesh
  76989. * @param vertexBufferKind The type of vertex attribute
  76990. * @param meshAttributeArray The vertex attribute data
  76991. * @param byteOffset The offset to the binary data
  76992. * @param binaryWriter The binary data for the glTF file
  76993. */
  76994. private reorderTriangleFillMode;
  76995. /**
  76996. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  76997. * clock-wise during export to glTF
  76998. * @param submesh BabylonJS submesh
  76999. * @param primitiveMode Primitive mode of the mesh
  77000. * @param sideOrientation the winding order of the submesh
  77001. * @param vertexBufferKind The type of vertex attribute
  77002. * @param meshAttributeArray The vertex attribute data
  77003. * @param byteOffset The offset to the binary data
  77004. * @param binaryWriter The binary data for the glTF file
  77005. */
  77006. private reorderTriangleStripDrawMode;
  77007. /**
  77008. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  77009. * clock-wise during export to glTF
  77010. * @param submesh BabylonJS submesh
  77011. * @param primitiveMode Primitive mode of the mesh
  77012. * @param sideOrientation the winding order of the submesh
  77013. * @param vertexBufferKind The type of vertex attribute
  77014. * @param meshAttributeArray The vertex attribute data
  77015. * @param byteOffset The offset to the binary data
  77016. * @param binaryWriter The binary data for the glTF file
  77017. */
  77018. private reorderTriangleFanMode;
  77019. /**
  77020. * Writes the vertex attribute data to binary
  77021. * @param vertices The vertices to write to the binary writer
  77022. * @param byteOffset The offset into the binary writer to overwrite binary data
  77023. * @param vertexAttributeKind The vertex attribute type
  77024. * @param meshAttributeArray The vertex attribute data
  77025. * @param binaryWriter The writer containing the binary data
  77026. */
  77027. private writeVertexAttributeData;
  77028. /**
  77029. * Writes mesh attribute data to a data buffer
  77030. * Returns the bytelength of the data
  77031. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  77032. * @param meshAttributeArray Array containing the attribute data
  77033. * @param binaryWriter The buffer to write the binary data to
  77034. * @param indices Used to specify the order of the vertex data
  77035. */
  77036. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  77037. /**
  77038. * Generates glTF json data
  77039. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  77040. * @param glTFPrefix Text to use when prefixing a glTF file
  77041. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  77042. * @returns json data as string
  77043. */
  77044. private generateJSON;
  77045. /**
  77046. * Generates data for .gltf and .bin files based on the glTF prefix string
  77047. * @param glTFPrefix Text to use when prefixing a glTF file
  77048. * @param dispose Dispose the exporter
  77049. * @returns GLTFData with glTF file data
  77050. */
  77051. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  77052. /**
  77053. * Creates a binary buffer for glTF
  77054. * @returns array buffer for binary data
  77055. */
  77056. private _generateBinaryAsync;
  77057. /**
  77058. * Pads the number to a multiple of 4
  77059. * @param num number to pad
  77060. * @returns padded number
  77061. */
  77062. private _getPadding;
  77063. /**
  77064. * @hidden
  77065. */
  77066. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  77067. /**
  77068. * Sets the TRS for each node
  77069. * @param node glTF Node for storing the transformation data
  77070. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  77071. */
  77072. private setNodeTransformation;
  77073. private getVertexBufferFromMesh;
  77074. /**
  77075. * Creates a bufferview based on the vertices type for the Babylon mesh
  77076. * @param kind Indicates the type of vertices data
  77077. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  77078. * @param binaryWriter The buffer to write the bufferview data to
  77079. */
  77080. private createBufferViewKind;
  77081. /**
  77082. * The primitive mode of the Babylon mesh
  77083. * @param babylonMesh The BabylonJS mesh
  77084. */
  77085. private getMeshPrimitiveMode;
  77086. /**
  77087. * Sets the primitive mode of the glTF mesh primitive
  77088. * @param meshPrimitive glTF mesh primitive
  77089. * @param primitiveMode The primitive mode
  77090. */
  77091. private setPrimitiveMode;
  77092. /**
  77093. * Sets the vertex attribute accessor based of the glTF mesh primitive
  77094. * @param meshPrimitive glTF mesh primitive
  77095. * @param attributeKind vertex attribute
  77096. * @returns boolean specifying if uv coordinates are present
  77097. */
  77098. private setAttributeKind;
  77099. /**
  77100. * Sets data for the primitive attributes of each submesh
  77101. * @param mesh glTF Mesh object to store the primitive attribute information
  77102. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  77103. * @param binaryWriter Buffer to write the attribute data to
  77104. */
  77105. private setPrimitiveAttributesAsync;
  77106. /**
  77107. * Creates a glTF scene based on the array of meshes
  77108. * Returns the the total byte offset
  77109. * @param babylonScene Babylon scene to get the mesh data from
  77110. * @param binaryWriter Buffer to write binary data to
  77111. */
  77112. private createSceneAsync;
  77113. /**
  77114. * Creates a mapping of Node unique id to node index and handles animations
  77115. * @param babylonScene Babylon Scene
  77116. * @param nodes Babylon transform nodes
  77117. * @param binaryWriter Buffer to write binary data to
  77118. * @returns Node mapping of unique id to index
  77119. */
  77120. private createNodeMapAndAnimationsAsync;
  77121. /**
  77122. * Creates a glTF node from a Babylon mesh
  77123. * @param babylonMesh Source Babylon mesh
  77124. * @param binaryWriter Buffer for storing geometry data
  77125. * @returns glTF node
  77126. */
  77127. private createNodeAsync;
  77128. }
  77129. /**
  77130. * @hidden
  77131. *
  77132. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  77133. */
  77134. export class _BinaryWriter {
  77135. /**
  77136. * Array buffer which stores all binary data
  77137. */
  77138. private _arrayBuffer;
  77139. /**
  77140. * View of the array buffer
  77141. */
  77142. private _dataView;
  77143. /**
  77144. * byte offset of data in array buffer
  77145. */
  77146. private _byteOffset;
  77147. /**
  77148. * Initialize binary writer with an initial byte length
  77149. * @param byteLength Initial byte length of the array buffer
  77150. */
  77151. constructor(byteLength: number);
  77152. /**
  77153. * Resize the array buffer to the specified byte length
  77154. * @param byteLength
  77155. */
  77156. private resizeBuffer;
  77157. /**
  77158. * Get an array buffer with the length of the byte offset
  77159. * @returns ArrayBuffer resized to the byte offset
  77160. */
  77161. getArrayBuffer(): ArrayBuffer;
  77162. /**
  77163. * Get the byte offset of the array buffer
  77164. * @returns byte offset
  77165. */
  77166. getByteOffset(): number;
  77167. /**
  77168. * Stores an UInt8 in the array buffer
  77169. * @param entry
  77170. * @param byteOffset If defined, specifies where to set the value as an offset.
  77171. */
  77172. setUInt8(entry: number, byteOffset?: number): void;
  77173. /**
  77174. * Gets an UInt32 in the array buffer
  77175. * @param entry
  77176. * @param byteOffset If defined, specifies where to set the value as an offset.
  77177. */
  77178. getUInt32(byteOffset: number): number;
  77179. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  77180. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  77181. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  77182. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  77183. /**
  77184. * Stores a Float32 in the array buffer
  77185. * @param entry
  77186. */
  77187. setFloat32(entry: number, byteOffset?: number): void;
  77188. /**
  77189. * Stores an UInt32 in the array buffer
  77190. * @param entry
  77191. * @param byteOffset If defined, specifies where to set the value as an offset.
  77192. */
  77193. setUInt32(entry: number, byteOffset?: number): void;
  77194. }
  77195. }
  77196. declare module BABYLON.GLTF2.Exporter {
  77197. /**
  77198. * @hidden
  77199. * Interface to store animation data.
  77200. */
  77201. export interface _IAnimationData {
  77202. /**
  77203. * Keyframe data.
  77204. */
  77205. inputs: number[];
  77206. /**
  77207. * Value data.
  77208. */
  77209. outputs: number[][];
  77210. /**
  77211. * Animation interpolation data.
  77212. */
  77213. samplerInterpolation: AnimationSamplerInterpolation;
  77214. /**
  77215. * Minimum keyframe value.
  77216. */
  77217. inputsMin: number;
  77218. /**
  77219. * Maximum keyframe value.
  77220. */
  77221. inputsMax: number;
  77222. }
  77223. /**
  77224. * @hidden
  77225. */
  77226. export interface _IAnimationInfo {
  77227. /**
  77228. * The target channel for the animation
  77229. */
  77230. animationChannelTargetPath: AnimationChannelTargetPath;
  77231. /**
  77232. * The glTF accessor type for the data.
  77233. */
  77234. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  77235. /**
  77236. * Specifies if quaternions should be used.
  77237. */
  77238. useQuaternion: boolean;
  77239. }
  77240. /**
  77241. * @hidden
  77242. * Utility class for generating glTF animation data from BabylonJS.
  77243. */
  77244. export class _GLTFAnimation {
  77245. /**
  77246. * @ignore
  77247. *
  77248. * Creates glTF channel animation from BabylonJS animation.
  77249. * @param babylonTransformNode - BabylonJS mesh.
  77250. * @param animation - animation.
  77251. * @param animationChannelTargetPath - The target animation channel.
  77252. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  77253. * @param useQuaternion - Specifies if quaternions are used.
  77254. * @returns nullable IAnimationData
  77255. */
  77256. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  77257. private static _DeduceAnimationInfo;
  77258. /**
  77259. * @ignore
  77260. * Create node animations from the transform node animations
  77261. * @param babylonNode
  77262. * @param runtimeGLTFAnimation
  77263. * @param idleGLTFAnimations
  77264. * @param nodeMap
  77265. * @param nodes
  77266. * @param binaryWriter
  77267. * @param bufferViews
  77268. * @param accessors
  77269. * @param convertToRightHandedSystem
  77270. */
  77271. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  77272. [key: number]: number;
  77273. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  77274. /**
  77275. * @ignore
  77276. * Create node animations from the animation groups
  77277. * @param babylonScene
  77278. * @param glTFAnimations
  77279. * @param nodeMap
  77280. * @param nodes
  77281. * @param binaryWriter
  77282. * @param bufferViews
  77283. * @param accessors
  77284. * @param convertToRightHandedSystem
  77285. */
  77286. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  77287. [key: number]: number;
  77288. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  77289. private static AddAnimation;
  77290. /**
  77291. * Create a baked animation
  77292. * @param babylonTransformNode BabylonJS mesh
  77293. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  77294. * @param animationChannelTargetPath animation target channel
  77295. * @param minFrame minimum animation frame
  77296. * @param maxFrame maximum animation frame
  77297. * @param fps frames per second of the animation
  77298. * @param inputs input key frames of the animation
  77299. * @param outputs output key frame data of the animation
  77300. * @param convertToRightHandedSystem converts the values to right-handed
  77301. * @param useQuaternion specifies if quaternions should be used
  77302. */
  77303. private static _CreateBakedAnimation;
  77304. private static _ConvertFactorToVector3OrQuaternion;
  77305. private static _SetInterpolatedValue;
  77306. /**
  77307. * Creates linear animation from the animation key frames
  77308. * @param babylonTransformNode BabylonJS mesh
  77309. * @param animation BabylonJS animation
  77310. * @param animationChannelTargetPath The target animation channel
  77311. * @param frameDelta The difference between the last and first frame of the animation
  77312. * @param inputs Array to store the key frame times
  77313. * @param outputs Array to store the key frame data
  77314. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  77315. * @param useQuaternion Specifies if quaternions are used in the animation
  77316. */
  77317. private static _CreateLinearOrStepAnimation;
  77318. /**
  77319. * Creates cubic spline animation from the animation key frames
  77320. * @param babylonTransformNode BabylonJS mesh
  77321. * @param animation BabylonJS animation
  77322. * @param animationChannelTargetPath The target animation channel
  77323. * @param frameDelta The difference between the last and first frame of the animation
  77324. * @param inputs Array to store the key frame times
  77325. * @param outputs Array to store the key frame data
  77326. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  77327. * @param useQuaternion Specifies if quaternions are used in the animation
  77328. */
  77329. private static _CreateCubicSplineAnimation;
  77330. private static _GetBasePositionRotationOrScale;
  77331. /**
  77332. * Adds a key frame value
  77333. * @param keyFrame
  77334. * @param animation
  77335. * @param outputs
  77336. * @param animationChannelTargetPath
  77337. * @param basePositionRotationOrScale
  77338. * @param convertToRightHandedSystem
  77339. * @param useQuaternion
  77340. */
  77341. private static _AddKeyframeValue;
  77342. /**
  77343. * Determine the interpolation based on the key frames
  77344. * @param keyFrames
  77345. * @param animationChannelTargetPath
  77346. * @param useQuaternion
  77347. */
  77348. private static _DeduceInterpolation;
  77349. /**
  77350. * Adds an input tangent or output tangent to the output data
  77351. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  77352. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  77353. * @param outputs The animation data by keyframe
  77354. * @param animationChannelTargetPath The target animation channel
  77355. * @param interpolation The interpolation type
  77356. * @param keyFrame The key frame with the animation data
  77357. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  77358. * @param useQuaternion Specifies if quaternions are used
  77359. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  77360. */
  77361. private static AddSplineTangent;
  77362. /**
  77363. * Get the minimum and maximum key frames' frame values
  77364. * @param keyFrames animation key frames
  77365. * @returns the minimum and maximum key frame value
  77366. */
  77367. private static calculateMinMaxKeyFrames;
  77368. }
  77369. }
  77370. declare module BABYLON.GLTF2.Exporter {
  77371. /** @hidden */
  77372. export var textureTransformPixelShader: {
  77373. name: string;
  77374. shader: string;
  77375. };
  77376. }
  77377. declare module BABYLON.GLTF2.Exporter.Extensions {
  77378. /**
  77379. * @hidden
  77380. */
  77381. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  77382. private _recordedTextures;
  77383. /** Name of this extension */
  77384. readonly name: string;
  77385. /** Defines whether this extension is enabled */
  77386. enabled: boolean;
  77387. /** Defines whether this extension is required */
  77388. required: boolean;
  77389. /** Reference to the glTF exporter */
  77390. private _wasUsed;
  77391. constructor(exporter: _Exporter);
  77392. dispose(): void;
  77393. /** @hidden */
  77394. get wasUsed(): boolean;
  77395. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  77396. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  77397. /**
  77398. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  77399. * @param babylonTexture
  77400. * @param offset
  77401. * @param rotation
  77402. * @param scale
  77403. * @param scene
  77404. */
  77405. private _textureTransformTextureAsync;
  77406. }
  77407. }
  77408. declare module BABYLON.GLTF2.Exporter.Extensions {
  77409. /**
  77410. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  77411. */
  77412. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  77413. /** The name of this extension. */
  77414. readonly name: string;
  77415. /** Defines whether this extension is enabled. */
  77416. enabled: boolean;
  77417. /** Defines whether this extension is required */
  77418. required: boolean;
  77419. /** Reference to the glTF exporter */
  77420. private _exporter;
  77421. private _lights;
  77422. /** @hidden */
  77423. constructor(exporter: _Exporter);
  77424. /** @hidden */
  77425. dispose(): void;
  77426. /** @hidden */
  77427. get wasUsed(): boolean;
  77428. /** @hidden */
  77429. onExporting(): void;
  77430. /**
  77431. * Define this method to modify the default behavior when exporting a node
  77432. * @param context The context when exporting the node
  77433. * @param node glTF node
  77434. * @param babylonNode BabylonJS node
  77435. * @returns nullable INode promise
  77436. */
  77437. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Promise<INode>;
  77438. }
  77439. }
  77440. declare module BABYLON.GLTF2.Exporter.Extensions {
  77441. /**
  77442. * @hidden
  77443. */
  77444. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  77445. /** Name of this extension */
  77446. readonly name: string;
  77447. /** Defines whether this extension is enabled */
  77448. enabled: boolean;
  77449. /** Defines whether this extension is required */
  77450. required: boolean;
  77451. /** Reference to the glTF exporter */
  77452. private _textureInfos;
  77453. private _exportedTextures;
  77454. private _wasUsed;
  77455. constructor(exporter: _Exporter);
  77456. dispose(): void;
  77457. /** @hidden */
  77458. get wasUsed(): boolean;
  77459. private _getTextureIndex;
  77460. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  77461. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  77462. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  77463. }
  77464. }
  77465. declare module BABYLON {
  77466. /**
  77467. * Class for generating STL data from a Babylon scene.
  77468. */
  77469. export class STLExport {
  77470. /**
  77471. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  77472. * @param meshes list defines the mesh to serialize
  77473. * @param download triggers the automatic download of the file.
  77474. * @param fileName changes the downloads fileName.
  77475. * @param binary changes the STL to a binary type.
  77476. * @param isLittleEndian toggle for binary type exporter.
  77477. * @returns the STL as UTF8 string
  77478. */
  77479. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  77480. }
  77481. }
  77482. declare module "babylonjs-gltf2interface" {
  77483. export = BABYLON.GLTF2;
  77484. }
  77485. /**
  77486. * Module for glTF 2.0 Interface
  77487. */
  77488. declare module BABYLON.GLTF2 {
  77489. /**
  77490. * The datatype of the components in the attribute
  77491. */
  77492. const enum AccessorComponentType {
  77493. /**
  77494. * Byte
  77495. */
  77496. BYTE = 5120,
  77497. /**
  77498. * Unsigned Byte
  77499. */
  77500. UNSIGNED_BYTE = 5121,
  77501. /**
  77502. * Short
  77503. */
  77504. SHORT = 5122,
  77505. /**
  77506. * Unsigned Short
  77507. */
  77508. UNSIGNED_SHORT = 5123,
  77509. /**
  77510. * Unsigned Int
  77511. */
  77512. UNSIGNED_INT = 5125,
  77513. /**
  77514. * Float
  77515. */
  77516. FLOAT = 5126,
  77517. }
  77518. /**
  77519. * Specifies if the attirbute is a scalar, vector, or matrix
  77520. */
  77521. const enum AccessorType {
  77522. /**
  77523. * Scalar
  77524. */
  77525. SCALAR = "SCALAR",
  77526. /**
  77527. * Vector2
  77528. */
  77529. VEC2 = "VEC2",
  77530. /**
  77531. * Vector3
  77532. */
  77533. VEC3 = "VEC3",
  77534. /**
  77535. * Vector4
  77536. */
  77537. VEC4 = "VEC4",
  77538. /**
  77539. * Matrix2x2
  77540. */
  77541. MAT2 = "MAT2",
  77542. /**
  77543. * Matrix3x3
  77544. */
  77545. MAT3 = "MAT3",
  77546. /**
  77547. * Matrix4x4
  77548. */
  77549. MAT4 = "MAT4",
  77550. }
  77551. /**
  77552. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  77553. */
  77554. const enum AnimationChannelTargetPath {
  77555. /**
  77556. * Translation
  77557. */
  77558. TRANSLATION = "translation",
  77559. /**
  77560. * Rotation
  77561. */
  77562. ROTATION = "rotation",
  77563. /**
  77564. * Scale
  77565. */
  77566. SCALE = "scale",
  77567. /**
  77568. * Weights
  77569. */
  77570. WEIGHTS = "weights",
  77571. }
  77572. /**
  77573. * Interpolation algorithm
  77574. */
  77575. const enum AnimationSamplerInterpolation {
  77576. /**
  77577. * The animated values are linearly interpolated between keyframes
  77578. */
  77579. LINEAR = "LINEAR",
  77580. /**
  77581. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  77582. */
  77583. STEP = "STEP",
  77584. /**
  77585. * The animation's interpolation is computed using a cubic spline with specified tangents
  77586. */
  77587. CUBICSPLINE = "CUBICSPLINE",
  77588. }
  77589. /**
  77590. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  77591. */
  77592. const enum CameraType {
  77593. /**
  77594. * A perspective camera containing properties to create a perspective projection matrix
  77595. */
  77596. PERSPECTIVE = "perspective",
  77597. /**
  77598. * An orthographic camera containing properties to create an orthographic projection matrix
  77599. */
  77600. ORTHOGRAPHIC = "orthographic",
  77601. }
  77602. /**
  77603. * The mime-type of the image
  77604. */
  77605. const enum ImageMimeType {
  77606. /**
  77607. * JPEG Mime-type
  77608. */
  77609. JPEG = "image/jpeg",
  77610. /**
  77611. * PNG Mime-type
  77612. */
  77613. PNG = "image/png",
  77614. }
  77615. /**
  77616. * The alpha rendering mode of the material
  77617. */
  77618. const enum MaterialAlphaMode {
  77619. /**
  77620. * The alpha value is ignored and the rendered output is fully opaque
  77621. */
  77622. OPAQUE = "OPAQUE",
  77623. /**
  77624. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  77625. */
  77626. MASK = "MASK",
  77627. /**
  77628. * 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)
  77629. */
  77630. BLEND = "BLEND",
  77631. }
  77632. /**
  77633. * The type of the primitives to render
  77634. */
  77635. const enum MeshPrimitiveMode {
  77636. /**
  77637. * Points
  77638. */
  77639. POINTS = 0,
  77640. /**
  77641. * Lines
  77642. */
  77643. LINES = 1,
  77644. /**
  77645. * Line Loop
  77646. */
  77647. LINE_LOOP = 2,
  77648. /**
  77649. * Line Strip
  77650. */
  77651. LINE_STRIP = 3,
  77652. /**
  77653. * Triangles
  77654. */
  77655. TRIANGLES = 4,
  77656. /**
  77657. * Triangle Strip
  77658. */
  77659. TRIANGLE_STRIP = 5,
  77660. /**
  77661. * Triangle Fan
  77662. */
  77663. TRIANGLE_FAN = 6,
  77664. }
  77665. /**
  77666. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  77667. */
  77668. const enum TextureMagFilter {
  77669. /**
  77670. * Nearest
  77671. */
  77672. NEAREST = 9728,
  77673. /**
  77674. * Linear
  77675. */
  77676. LINEAR = 9729,
  77677. }
  77678. /**
  77679. * Minification filter. All valid values correspond to WebGL enums
  77680. */
  77681. const enum TextureMinFilter {
  77682. /**
  77683. * Nearest
  77684. */
  77685. NEAREST = 9728,
  77686. /**
  77687. * Linear
  77688. */
  77689. LINEAR = 9729,
  77690. /**
  77691. * Nearest Mip-Map Nearest
  77692. */
  77693. NEAREST_MIPMAP_NEAREST = 9984,
  77694. /**
  77695. * Linear Mipmap Nearest
  77696. */
  77697. LINEAR_MIPMAP_NEAREST = 9985,
  77698. /**
  77699. * Nearest Mipmap Linear
  77700. */
  77701. NEAREST_MIPMAP_LINEAR = 9986,
  77702. /**
  77703. * Linear Mipmap Linear
  77704. */
  77705. LINEAR_MIPMAP_LINEAR = 9987,
  77706. }
  77707. /**
  77708. * S (U) wrapping mode. All valid values correspond to WebGL enums
  77709. */
  77710. const enum TextureWrapMode {
  77711. /**
  77712. * Clamp to Edge
  77713. */
  77714. CLAMP_TO_EDGE = 33071,
  77715. /**
  77716. * Mirrored Repeat
  77717. */
  77718. MIRRORED_REPEAT = 33648,
  77719. /**
  77720. * Repeat
  77721. */
  77722. REPEAT = 10497,
  77723. }
  77724. /**
  77725. * glTF Property
  77726. */
  77727. interface IProperty {
  77728. /**
  77729. * Dictionary object with extension-specific objects
  77730. */
  77731. extensions?: {
  77732. [key: string]: any;
  77733. };
  77734. /**
  77735. * Application-Specific data
  77736. */
  77737. extras?: any;
  77738. }
  77739. /**
  77740. * glTF Child of Root Property
  77741. */
  77742. interface IChildRootProperty extends IProperty {
  77743. /**
  77744. * The user-defined name of this object
  77745. */
  77746. name?: string;
  77747. }
  77748. /**
  77749. * Indices of those attributes that deviate from their initialization value
  77750. */
  77751. interface IAccessorSparseIndices extends IProperty {
  77752. /**
  77753. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  77754. */
  77755. bufferView: number;
  77756. /**
  77757. * The offset relative to the start of the bufferView in bytes. Must be aligned
  77758. */
  77759. byteOffset?: number;
  77760. /**
  77761. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  77762. */
  77763. componentType: AccessorComponentType;
  77764. }
  77765. /**
  77766. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  77767. */
  77768. interface IAccessorSparseValues extends IProperty {
  77769. /**
  77770. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  77771. */
  77772. bufferView: number;
  77773. /**
  77774. * The offset relative to the start of the bufferView in bytes. Must be aligned
  77775. */
  77776. byteOffset?: number;
  77777. }
  77778. /**
  77779. * Sparse storage of attributes that deviate from their initialization value
  77780. */
  77781. interface IAccessorSparse extends IProperty {
  77782. /**
  77783. * The number of attributes encoded in this sparse accessor
  77784. */
  77785. count: number;
  77786. /**
  77787. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  77788. */
  77789. indices: IAccessorSparseIndices;
  77790. /**
  77791. * 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
  77792. */
  77793. values: IAccessorSparseValues;
  77794. }
  77795. /**
  77796. * 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
  77797. */
  77798. interface IAccessor extends IChildRootProperty {
  77799. /**
  77800. * The index of the bufferview
  77801. */
  77802. bufferView?: number;
  77803. /**
  77804. * The offset relative to the start of the bufferView in bytes
  77805. */
  77806. byteOffset?: number;
  77807. /**
  77808. * The datatype of components in the attribute
  77809. */
  77810. componentType: AccessorComponentType;
  77811. /**
  77812. * Specifies whether integer data values should be normalized
  77813. */
  77814. normalized?: boolean;
  77815. /**
  77816. * The number of attributes referenced by this accessor
  77817. */
  77818. count: number;
  77819. /**
  77820. * Specifies if the attribute is a scalar, vector, or matrix
  77821. */
  77822. type: AccessorType;
  77823. /**
  77824. * Maximum value of each component in this attribute
  77825. */
  77826. max?: number[];
  77827. /**
  77828. * Minimum value of each component in this attribute
  77829. */
  77830. min?: number[];
  77831. /**
  77832. * Sparse storage of attributes that deviate from their initialization value
  77833. */
  77834. sparse?: IAccessorSparse;
  77835. }
  77836. /**
  77837. * Targets an animation's sampler at a node's property
  77838. */
  77839. interface IAnimationChannel extends IProperty {
  77840. /**
  77841. * The index of a sampler in this animation used to compute the value for the target
  77842. */
  77843. sampler: number;
  77844. /**
  77845. * The index of the node and TRS property to target
  77846. */
  77847. target: IAnimationChannelTarget;
  77848. }
  77849. /**
  77850. * The index of the node and TRS property that an animation channel targets
  77851. */
  77852. interface IAnimationChannelTarget extends IProperty {
  77853. /**
  77854. * The index of the node to target
  77855. */
  77856. node: number;
  77857. /**
  77858. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  77859. */
  77860. path: AnimationChannelTargetPath;
  77861. }
  77862. /**
  77863. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  77864. */
  77865. interface IAnimationSampler extends IProperty {
  77866. /**
  77867. * The index of an accessor containing keyframe input values, e.g., time
  77868. */
  77869. input: number;
  77870. /**
  77871. * Interpolation algorithm
  77872. */
  77873. interpolation?: AnimationSamplerInterpolation;
  77874. /**
  77875. * The index of an accessor, containing keyframe output values
  77876. */
  77877. output: number;
  77878. }
  77879. /**
  77880. * A keyframe animation
  77881. */
  77882. interface IAnimation extends IChildRootProperty {
  77883. /**
  77884. * An array of channels, each of which targets an animation's sampler at a node's property
  77885. */
  77886. channels: IAnimationChannel[];
  77887. /**
  77888. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  77889. */
  77890. samplers: IAnimationSampler[];
  77891. }
  77892. /**
  77893. * Metadata about the glTF asset
  77894. */
  77895. interface IAsset extends IChildRootProperty {
  77896. /**
  77897. * A copyright message suitable for display to credit the content creator
  77898. */
  77899. copyright?: string;
  77900. /**
  77901. * Tool that generated this glTF model. Useful for debugging
  77902. */
  77903. generator?: string;
  77904. /**
  77905. * The glTF version that this asset targets
  77906. */
  77907. version: string;
  77908. /**
  77909. * The minimum glTF version that this asset targets
  77910. */
  77911. minVersion?: string;
  77912. }
  77913. /**
  77914. * A buffer points to binary geometry, animation, or skins
  77915. */
  77916. interface IBuffer extends IChildRootProperty {
  77917. /**
  77918. * 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
  77919. */
  77920. uri?: string;
  77921. /**
  77922. * The length of the buffer in bytes
  77923. */
  77924. byteLength: number;
  77925. }
  77926. /**
  77927. * A view into a buffer generally representing a subset of the buffer
  77928. */
  77929. interface IBufferView extends IChildRootProperty {
  77930. /**
  77931. * The index of the buffer
  77932. */
  77933. buffer: number;
  77934. /**
  77935. * The offset into the buffer in bytes
  77936. */
  77937. byteOffset?: number;
  77938. /**
  77939. * The lenth of the bufferView in bytes
  77940. */
  77941. byteLength: number;
  77942. /**
  77943. * The stride, in bytes
  77944. */
  77945. byteStride?: number;
  77946. }
  77947. /**
  77948. * An orthographic camera containing properties to create an orthographic projection matrix
  77949. */
  77950. interface ICameraOrthographic extends IProperty {
  77951. /**
  77952. * The floating-point horizontal magnification of the view. Must not be zero
  77953. */
  77954. xmag: number;
  77955. /**
  77956. * The floating-point vertical magnification of the view. Must not be zero
  77957. */
  77958. ymag: number;
  77959. /**
  77960. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  77961. */
  77962. zfar: number;
  77963. /**
  77964. * The floating-point distance to the near clipping plane
  77965. */
  77966. znear: number;
  77967. }
  77968. /**
  77969. * A perspective camera containing properties to create a perspective projection matrix
  77970. */
  77971. interface ICameraPerspective extends IProperty {
  77972. /**
  77973. * The floating-point aspect ratio of the field of view
  77974. */
  77975. aspectRatio?: number;
  77976. /**
  77977. * The floating-point vertical field of view in radians
  77978. */
  77979. yfov: number;
  77980. /**
  77981. * The floating-point distance to the far clipping plane
  77982. */
  77983. zfar?: number;
  77984. /**
  77985. * The floating-point distance to the near clipping plane
  77986. */
  77987. znear: number;
  77988. }
  77989. /**
  77990. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  77991. */
  77992. interface ICamera extends IChildRootProperty {
  77993. /**
  77994. * An orthographic camera containing properties to create an orthographic projection matrix
  77995. */
  77996. orthographic?: ICameraOrthographic;
  77997. /**
  77998. * A perspective camera containing properties to create a perspective projection matrix
  77999. */
  78000. perspective?: ICameraPerspective;
  78001. /**
  78002. * Specifies if the camera uses a perspective or orthographic projection
  78003. */
  78004. type: CameraType;
  78005. }
  78006. /**
  78007. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  78008. */
  78009. interface IImage extends IChildRootProperty {
  78010. /**
  78011. * 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
  78012. */
  78013. uri?: string;
  78014. /**
  78015. * The image's MIME type
  78016. */
  78017. mimeType?: ImageMimeType;
  78018. /**
  78019. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  78020. */
  78021. bufferView?: number;
  78022. }
  78023. /**
  78024. * Material Normal Texture Info
  78025. */
  78026. interface IMaterialNormalTextureInfo extends ITextureInfo {
  78027. /**
  78028. * The scalar multiplier applied to each normal vector of the normal texture
  78029. */
  78030. scale?: number;
  78031. }
  78032. /**
  78033. * Material Occlusion Texture Info
  78034. */
  78035. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  78036. /**
  78037. * A scalar multiplier controlling the amount of occlusion applied
  78038. */
  78039. strength?: number;
  78040. }
  78041. /**
  78042. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  78043. */
  78044. interface IMaterialPbrMetallicRoughness {
  78045. /**
  78046. * The material's base color factor
  78047. */
  78048. baseColorFactor?: number[];
  78049. /**
  78050. * The base color texture
  78051. */
  78052. baseColorTexture?: ITextureInfo;
  78053. /**
  78054. * The metalness of the material
  78055. */
  78056. metallicFactor?: number;
  78057. /**
  78058. * The roughness of the material
  78059. */
  78060. roughnessFactor?: number;
  78061. /**
  78062. * The metallic-roughness texture
  78063. */
  78064. metallicRoughnessTexture?: ITextureInfo;
  78065. }
  78066. /**
  78067. * The material appearance of a primitive
  78068. */
  78069. interface IMaterial extends IChildRootProperty {
  78070. /**
  78071. * 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
  78072. */
  78073. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  78074. /**
  78075. * The normal map texture
  78076. */
  78077. normalTexture?: IMaterialNormalTextureInfo;
  78078. /**
  78079. * The occlusion map texture
  78080. */
  78081. occlusionTexture?: IMaterialOcclusionTextureInfo;
  78082. /**
  78083. * The emissive map texture
  78084. */
  78085. emissiveTexture?: ITextureInfo;
  78086. /**
  78087. * 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
  78088. */
  78089. emissiveFactor?: number[];
  78090. /**
  78091. * The alpha rendering mode of the material
  78092. */
  78093. alphaMode?: MaterialAlphaMode;
  78094. /**
  78095. * The alpha cutoff value of the material
  78096. */
  78097. alphaCutoff?: number;
  78098. /**
  78099. * Specifies whether the material is double sided
  78100. */
  78101. doubleSided?: boolean;
  78102. }
  78103. /**
  78104. * Geometry to be rendered with the given material
  78105. */
  78106. interface IMeshPrimitive extends IProperty {
  78107. /**
  78108. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  78109. */
  78110. attributes: {
  78111. [name: string]: number;
  78112. };
  78113. /**
  78114. * The index of the accessor that contains the indices
  78115. */
  78116. indices?: number;
  78117. /**
  78118. * The index of the material to apply to this primitive when rendering
  78119. */
  78120. material?: number;
  78121. /**
  78122. * The type of primitives to render. All valid values correspond to WebGL enums
  78123. */
  78124. mode?: MeshPrimitiveMode;
  78125. /**
  78126. * 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
  78127. */
  78128. targets?: {
  78129. [name: string]: number;
  78130. }[];
  78131. }
  78132. /**
  78133. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  78134. */
  78135. interface IMesh extends IChildRootProperty {
  78136. /**
  78137. * An array of primitives, each defining geometry to be rendered with a material
  78138. */
  78139. primitives: IMeshPrimitive[];
  78140. /**
  78141. * Array of weights to be applied to the Morph Targets
  78142. */
  78143. weights?: number[];
  78144. }
  78145. /**
  78146. * A node in the node hierarchy
  78147. */
  78148. interface INode extends IChildRootProperty {
  78149. /**
  78150. * The index of the camera referenced by this node
  78151. */
  78152. camera?: number;
  78153. /**
  78154. * The indices of this node's children
  78155. */
  78156. children?: number[];
  78157. /**
  78158. * The index of the skin referenced by this node
  78159. */
  78160. skin?: number;
  78161. /**
  78162. * A floating-point 4x4 transformation matrix stored in column-major order
  78163. */
  78164. matrix?: number[];
  78165. /**
  78166. * The index of the mesh in this node
  78167. */
  78168. mesh?: number;
  78169. /**
  78170. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  78171. */
  78172. rotation?: number[];
  78173. /**
  78174. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  78175. */
  78176. scale?: number[];
  78177. /**
  78178. * The node's translation along the x, y, and z axes
  78179. */
  78180. translation?: number[];
  78181. /**
  78182. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  78183. */
  78184. weights?: number[];
  78185. }
  78186. /**
  78187. * Texture sampler properties for filtering and wrapping modes
  78188. */
  78189. interface ISampler extends IChildRootProperty {
  78190. /**
  78191. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  78192. */
  78193. magFilter?: TextureMagFilter;
  78194. /**
  78195. * Minification filter. All valid values correspond to WebGL enums
  78196. */
  78197. minFilter?: TextureMinFilter;
  78198. /**
  78199. * S (U) wrapping mode. All valid values correspond to WebGL enums
  78200. */
  78201. wrapS?: TextureWrapMode;
  78202. /**
  78203. * T (V) wrapping mode. All valid values correspond to WebGL enums
  78204. */
  78205. wrapT?: TextureWrapMode;
  78206. }
  78207. /**
  78208. * The root nodes of a scene
  78209. */
  78210. interface IScene extends IChildRootProperty {
  78211. /**
  78212. * The indices of each root node
  78213. */
  78214. nodes: number[];
  78215. }
  78216. /**
  78217. * Joints and matrices defining a skin
  78218. */
  78219. interface ISkin extends IChildRootProperty {
  78220. /**
  78221. * 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
  78222. */
  78223. inverseBindMatrices?: number;
  78224. /**
  78225. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  78226. */
  78227. skeleton?: number;
  78228. /**
  78229. * 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)
  78230. */
  78231. joints: number[];
  78232. }
  78233. /**
  78234. * A texture and its sampler
  78235. */
  78236. interface ITexture extends IChildRootProperty {
  78237. /**
  78238. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  78239. */
  78240. sampler?: number;
  78241. /**
  78242. * The index of the image used by this texture
  78243. */
  78244. source: number;
  78245. }
  78246. /**
  78247. * Reference to a texture
  78248. */
  78249. interface ITextureInfo extends IProperty {
  78250. /**
  78251. * The index of the texture
  78252. */
  78253. index: number;
  78254. /**
  78255. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  78256. */
  78257. texCoord?: number;
  78258. }
  78259. /**
  78260. * The root object for a glTF asset
  78261. */
  78262. interface IGLTF extends IProperty {
  78263. /**
  78264. * An array of accessors. An accessor is a typed view into a bufferView
  78265. */
  78266. accessors?: IAccessor[];
  78267. /**
  78268. * An array of keyframe animations
  78269. */
  78270. animations?: IAnimation[];
  78271. /**
  78272. * Metadata about the glTF asset
  78273. */
  78274. asset: IAsset;
  78275. /**
  78276. * An array of buffers. A buffer points to binary geometry, animation, or skins
  78277. */
  78278. buffers?: IBuffer[];
  78279. /**
  78280. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  78281. */
  78282. bufferViews?: IBufferView[];
  78283. /**
  78284. * An array of cameras
  78285. */
  78286. cameras?: ICamera[];
  78287. /**
  78288. * Names of glTF extensions used somewhere in this asset
  78289. */
  78290. extensionsUsed?: string[];
  78291. /**
  78292. * Names of glTF extensions required to properly load this asset
  78293. */
  78294. extensionsRequired?: string[];
  78295. /**
  78296. * An array of images. An image defines data used to create a texture
  78297. */
  78298. images?: IImage[];
  78299. /**
  78300. * An array of materials. A material defines the appearance of a primitive
  78301. */
  78302. materials?: IMaterial[];
  78303. /**
  78304. * An array of meshes. A mesh is a set of primitives to be rendered
  78305. */
  78306. meshes?: IMesh[];
  78307. /**
  78308. * An array of nodes
  78309. */
  78310. nodes?: INode[];
  78311. /**
  78312. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  78313. */
  78314. samplers?: ISampler[];
  78315. /**
  78316. * The index of the default scene
  78317. */
  78318. scene?: number;
  78319. /**
  78320. * An array of scenes
  78321. */
  78322. scenes?: IScene[];
  78323. /**
  78324. * An array of skins. A skin is defined by joints and matrices
  78325. */
  78326. skins?: ISkin[];
  78327. /**
  78328. * An array of textures
  78329. */
  78330. textures?: ITexture[];
  78331. }
  78332. /**
  78333. * The glTF validation results
  78334. * @ignore
  78335. */
  78336. interface IGLTFValidationResults {
  78337. info: {
  78338. generator: string;
  78339. hasAnimations: boolean;
  78340. hasDefaultScene: boolean;
  78341. hasMaterials: boolean;
  78342. hasMorphTargets: boolean;
  78343. hasSkins: boolean;
  78344. hasTextures: boolean;
  78345. maxAttributesUsed: number;
  78346. primitivesCount: number
  78347. };
  78348. issues: {
  78349. messages: Array<string>;
  78350. numErrors: number;
  78351. numHints: number;
  78352. numInfos: number;
  78353. numWarnings: number;
  78354. truncated: boolean
  78355. };
  78356. mimeType: string;
  78357. uri: string;
  78358. validatedAt: string;
  78359. validatorVersion: string;
  78360. }
  78361. /**
  78362. * The glTF validation options
  78363. */
  78364. interface IGLTFValidationOptions {
  78365. /** Uri to use */
  78366. uri?: string;
  78367. /** Function used to load external resources */
  78368. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  78369. /** Boolean indicating that we need to validate accessor data */
  78370. validateAccessorData?: boolean;
  78371. /** max number of issues allowed */
  78372. maxIssues?: number;
  78373. /** Ignored issues */
  78374. ignoredIssues?: Array<string>;
  78375. /** Value to override severy settings */
  78376. severityOverrides?: Object;
  78377. }
  78378. /**
  78379. * The glTF validator object
  78380. * @ignore
  78381. */
  78382. interface IGLTFValidator {
  78383. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  78384. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  78385. }
  78386. }
  78387. declare module BABYLON {
  78388. /** @hidden */
  78389. export var cellPixelShader: {
  78390. name: string;
  78391. shader: string;
  78392. };
  78393. }
  78394. declare module BABYLON {
  78395. /** @hidden */
  78396. export var cellVertexShader: {
  78397. name: string;
  78398. shader: string;
  78399. };
  78400. }
  78401. declare module BABYLON {
  78402. export class CellMaterial extends BABYLON.PushMaterial {
  78403. private _diffuseTexture;
  78404. diffuseTexture: BABYLON.BaseTexture;
  78405. diffuseColor: BABYLON.Color3;
  78406. _computeHighLevel: boolean;
  78407. computeHighLevel: boolean;
  78408. private _disableLighting;
  78409. disableLighting: boolean;
  78410. private _maxSimultaneousLights;
  78411. maxSimultaneousLights: number;
  78412. private _renderId;
  78413. constructor(name: string, scene: BABYLON.Scene);
  78414. needAlphaBlending(): boolean;
  78415. needAlphaTesting(): boolean;
  78416. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78417. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78418. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78419. getAnimatables(): BABYLON.IAnimatable[];
  78420. getActiveTextures(): BABYLON.BaseTexture[];
  78421. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78422. dispose(forceDisposeEffect?: boolean): void;
  78423. getClassName(): string;
  78424. clone(name: string): CellMaterial;
  78425. serialize(): any;
  78426. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  78427. }
  78428. }
  78429. declare module BABYLON {
  78430. export class CustomShaderStructure {
  78431. FragmentStore: string;
  78432. VertexStore: string;
  78433. constructor();
  78434. }
  78435. export class ShaderSpecialParts {
  78436. constructor();
  78437. Fragment_Begin: string;
  78438. Fragment_Definitions: string;
  78439. Fragment_MainBegin: string;
  78440. Fragment_Custom_Diffuse: string;
  78441. Fragment_Before_Lights: string;
  78442. Fragment_Before_Fog: string;
  78443. Fragment_Custom_Alpha: string;
  78444. Fragment_Before_FragColor: string;
  78445. Vertex_Begin: string;
  78446. Vertex_Definitions: string;
  78447. Vertex_MainBegin: string;
  78448. Vertex_Before_PositionUpdated: string;
  78449. Vertex_Before_NormalUpdated: string;
  78450. Vertex_MainEnd: string;
  78451. }
  78452. export class CustomMaterial extends BABYLON.StandardMaterial {
  78453. static ShaderIndexer: number;
  78454. CustomParts: ShaderSpecialParts;
  78455. _isCreatedShader: boolean;
  78456. _createdShaderName: string;
  78457. _customUniform: string[];
  78458. _newUniforms: string[];
  78459. _newUniformInstances: any[];
  78460. _newSamplerInstances: BABYLON.Texture[];
  78461. FragmentShader: string;
  78462. VertexShader: string;
  78463. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  78464. ReviewUniform(name: string, arr: string[]): string[];
  78465. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  78466. constructor(name: string, scene: BABYLON.Scene);
  78467. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  78468. Fragment_Begin(shaderPart: string): CustomMaterial;
  78469. Fragment_Definitions(shaderPart: string): CustomMaterial;
  78470. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  78471. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  78472. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  78473. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  78474. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  78475. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  78476. Vertex_Begin(shaderPart: string): CustomMaterial;
  78477. Vertex_Definitions(shaderPart: string): CustomMaterial;
  78478. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  78479. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  78480. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  78481. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  78482. }
  78483. }
  78484. declare module BABYLON {
  78485. export class ShaderAlebdoParts {
  78486. constructor();
  78487. Fragment_Begin: string;
  78488. Fragment_Definitions: string;
  78489. Fragment_MainBegin: string;
  78490. Fragment_Custom_Albedo: string;
  78491. Fragment_Before_Lights: string;
  78492. Fragment_Custom_MetallicRoughness: string;
  78493. Fragment_Custom_MicroSurface: string;
  78494. Fragment_Before_Fog: string;
  78495. Fragment_Custom_Alpha: string;
  78496. Fragment_Before_FragColor: string;
  78497. Vertex_Begin: string;
  78498. Vertex_Definitions: string;
  78499. Vertex_MainBegin: string;
  78500. Vertex_Before_PositionUpdated: string;
  78501. Vertex_Before_NormalUpdated: string;
  78502. Vertex_MainEnd: string;
  78503. }
  78504. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  78505. static ShaderIndexer: number;
  78506. CustomParts: ShaderAlebdoParts;
  78507. _isCreatedShader: boolean;
  78508. _createdShaderName: string;
  78509. _customUniform: string[];
  78510. _newUniforms: string[];
  78511. _newUniformInstances: any[];
  78512. _newSamplerInstances: BABYLON.Texture[];
  78513. FragmentShader: string;
  78514. VertexShader: string;
  78515. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  78516. ReviewUniform(name: string, arr: string[]): string[];
  78517. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  78518. constructor(name: string, scene: BABYLON.Scene);
  78519. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  78520. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  78521. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  78522. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  78523. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  78524. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  78525. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  78526. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  78527. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  78528. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  78529. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  78530. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  78531. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  78532. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  78533. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  78534. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  78535. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  78536. }
  78537. }
  78538. declare module BABYLON {
  78539. /** @hidden */
  78540. export var firePixelShader: {
  78541. name: string;
  78542. shader: string;
  78543. };
  78544. }
  78545. declare module BABYLON {
  78546. /** @hidden */
  78547. export var fireVertexShader: {
  78548. name: string;
  78549. shader: string;
  78550. };
  78551. }
  78552. declare module BABYLON {
  78553. export class FireMaterial extends BABYLON.PushMaterial {
  78554. private _diffuseTexture;
  78555. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  78556. private _distortionTexture;
  78557. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  78558. private _opacityTexture;
  78559. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  78560. diffuseColor: BABYLON.Color3;
  78561. speed: number;
  78562. private _scaledDiffuse;
  78563. private _renderId;
  78564. private _lastTime;
  78565. constructor(name: string, scene: BABYLON.Scene);
  78566. needAlphaBlending(): boolean;
  78567. needAlphaTesting(): boolean;
  78568. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78569. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78570. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78571. getAnimatables(): BABYLON.IAnimatable[];
  78572. getActiveTextures(): BABYLON.BaseTexture[];
  78573. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78574. getClassName(): string;
  78575. dispose(forceDisposeEffect?: boolean): void;
  78576. clone(name: string): FireMaterial;
  78577. serialize(): any;
  78578. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  78579. }
  78580. }
  78581. declare module BABYLON {
  78582. /** @hidden */
  78583. export var furPixelShader: {
  78584. name: string;
  78585. shader: string;
  78586. };
  78587. }
  78588. declare module BABYLON {
  78589. /** @hidden */
  78590. export var furVertexShader: {
  78591. name: string;
  78592. shader: string;
  78593. };
  78594. }
  78595. declare module BABYLON {
  78596. export class FurMaterial extends BABYLON.PushMaterial {
  78597. private _diffuseTexture;
  78598. diffuseTexture: BABYLON.BaseTexture;
  78599. private _heightTexture;
  78600. heightTexture: BABYLON.BaseTexture;
  78601. diffuseColor: BABYLON.Color3;
  78602. furLength: number;
  78603. furAngle: number;
  78604. furColor: BABYLON.Color3;
  78605. furOffset: number;
  78606. furSpacing: number;
  78607. furGravity: BABYLON.Vector3;
  78608. furSpeed: number;
  78609. furDensity: number;
  78610. furOcclusion: number;
  78611. furTexture: BABYLON.DynamicTexture;
  78612. private _disableLighting;
  78613. disableLighting: boolean;
  78614. private _maxSimultaneousLights;
  78615. maxSimultaneousLights: number;
  78616. highLevelFur: boolean;
  78617. _meshes: BABYLON.AbstractMesh[];
  78618. private _renderId;
  78619. private _furTime;
  78620. constructor(name: string, scene: BABYLON.Scene);
  78621. get furTime(): number;
  78622. set furTime(furTime: number);
  78623. needAlphaBlending(): boolean;
  78624. needAlphaTesting(): boolean;
  78625. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78626. updateFur(): void;
  78627. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78628. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78629. getAnimatables(): BABYLON.IAnimatable[];
  78630. getActiveTextures(): BABYLON.BaseTexture[];
  78631. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78632. dispose(forceDisposeEffect?: boolean): void;
  78633. clone(name: string): FurMaterial;
  78634. serialize(): any;
  78635. getClassName(): string;
  78636. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  78637. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  78638. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  78639. }
  78640. }
  78641. declare module BABYLON {
  78642. /** @hidden */
  78643. export var gradientPixelShader: {
  78644. name: string;
  78645. shader: string;
  78646. };
  78647. }
  78648. declare module BABYLON {
  78649. /** @hidden */
  78650. export var gradientVertexShader: {
  78651. name: string;
  78652. shader: string;
  78653. };
  78654. }
  78655. declare module BABYLON {
  78656. export class GradientMaterial extends BABYLON.PushMaterial {
  78657. private _maxSimultaneousLights;
  78658. maxSimultaneousLights: number;
  78659. topColor: BABYLON.Color3;
  78660. topColorAlpha: number;
  78661. bottomColor: BABYLON.Color3;
  78662. bottomColorAlpha: number;
  78663. offset: number;
  78664. scale: number;
  78665. smoothness: number;
  78666. private _disableLighting;
  78667. disableLighting: boolean;
  78668. private _renderId;
  78669. constructor(name: string, scene: BABYLON.Scene);
  78670. needAlphaBlending(): boolean;
  78671. needAlphaTesting(): boolean;
  78672. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78673. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78674. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78675. getAnimatables(): BABYLON.IAnimatable[];
  78676. dispose(forceDisposeEffect?: boolean): void;
  78677. clone(name: string): GradientMaterial;
  78678. serialize(): any;
  78679. getClassName(): string;
  78680. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  78681. }
  78682. }
  78683. declare module BABYLON {
  78684. /** @hidden */
  78685. export var gridPixelShader: {
  78686. name: string;
  78687. shader: string;
  78688. };
  78689. }
  78690. declare module BABYLON {
  78691. /** @hidden */
  78692. export var gridVertexShader: {
  78693. name: string;
  78694. shader: string;
  78695. };
  78696. }
  78697. declare module BABYLON {
  78698. /**
  78699. * The grid materials allows you to wrap any shape with a grid.
  78700. * Colors are customizable.
  78701. */
  78702. export class GridMaterial extends BABYLON.PushMaterial {
  78703. /**
  78704. * Main color of the grid (e.g. between lines)
  78705. */
  78706. mainColor: BABYLON.Color3;
  78707. /**
  78708. * Color of the grid lines.
  78709. */
  78710. lineColor: BABYLON.Color3;
  78711. /**
  78712. * The scale of the grid compared to unit.
  78713. */
  78714. gridRatio: number;
  78715. /**
  78716. * Allows setting an offset for the grid lines.
  78717. */
  78718. gridOffset: BABYLON.Vector3;
  78719. /**
  78720. * The frequency of thicker lines.
  78721. */
  78722. majorUnitFrequency: number;
  78723. /**
  78724. * The visibility of minor units in the grid.
  78725. */
  78726. minorUnitVisibility: number;
  78727. /**
  78728. * The grid opacity outside of the lines.
  78729. */
  78730. opacity: number;
  78731. /**
  78732. * Determine RBG output is premultiplied by alpha value.
  78733. */
  78734. preMultiplyAlpha: boolean;
  78735. private _opacityTexture;
  78736. opacityTexture: BABYLON.BaseTexture;
  78737. private _gridControl;
  78738. private _renderId;
  78739. /**
  78740. * constructor
  78741. * @param name The name given to the material in order to identify it afterwards.
  78742. * @param scene The scene the material is used in.
  78743. */
  78744. constructor(name: string, scene: BABYLON.Scene);
  78745. /**
  78746. * Returns wehter or not the grid requires alpha blending.
  78747. */
  78748. needAlphaBlending(): boolean;
  78749. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  78750. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78751. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78752. /**
  78753. * Dispose the material and its associated resources.
  78754. * @param forceDisposeEffect will also dispose the used effect when true
  78755. */
  78756. dispose(forceDisposeEffect?: boolean): void;
  78757. clone(name: string): GridMaterial;
  78758. serialize(): any;
  78759. getClassName(): string;
  78760. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  78761. }
  78762. }
  78763. declare module BABYLON {
  78764. /** @hidden */
  78765. export var lavaPixelShader: {
  78766. name: string;
  78767. shader: string;
  78768. };
  78769. }
  78770. declare module BABYLON {
  78771. /** @hidden */
  78772. export var lavaVertexShader: {
  78773. name: string;
  78774. shader: string;
  78775. };
  78776. }
  78777. declare module BABYLON {
  78778. export class LavaMaterial extends BABYLON.PushMaterial {
  78779. private _diffuseTexture;
  78780. diffuseTexture: BABYLON.BaseTexture;
  78781. noiseTexture: BABYLON.BaseTexture;
  78782. fogColor: BABYLON.Color3;
  78783. speed: number;
  78784. movingSpeed: number;
  78785. lowFrequencySpeed: number;
  78786. fogDensity: number;
  78787. private _lastTime;
  78788. diffuseColor: BABYLON.Color3;
  78789. private _disableLighting;
  78790. disableLighting: boolean;
  78791. private _unlit;
  78792. unlit: boolean;
  78793. private _maxSimultaneousLights;
  78794. maxSimultaneousLights: number;
  78795. private _scaledDiffuse;
  78796. private _renderId;
  78797. constructor(name: string, scene: BABYLON.Scene);
  78798. needAlphaBlending(): boolean;
  78799. needAlphaTesting(): boolean;
  78800. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78801. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78802. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78803. getAnimatables(): BABYLON.IAnimatable[];
  78804. getActiveTextures(): BABYLON.BaseTexture[];
  78805. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78806. dispose(forceDisposeEffect?: boolean): void;
  78807. clone(name: string): LavaMaterial;
  78808. serialize(): any;
  78809. getClassName(): string;
  78810. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  78811. }
  78812. }
  78813. declare module BABYLON {
  78814. /** @hidden */
  78815. export var mixPixelShader: {
  78816. name: string;
  78817. shader: string;
  78818. };
  78819. }
  78820. declare module BABYLON {
  78821. /** @hidden */
  78822. export var mixVertexShader: {
  78823. name: string;
  78824. shader: string;
  78825. };
  78826. }
  78827. declare module BABYLON {
  78828. export class MixMaterial extends BABYLON.PushMaterial {
  78829. /**
  78830. * Mix textures
  78831. */
  78832. private _mixTexture1;
  78833. mixTexture1: BABYLON.BaseTexture;
  78834. private _mixTexture2;
  78835. mixTexture2: BABYLON.BaseTexture;
  78836. /**
  78837. * Diffuse textures
  78838. */
  78839. private _diffuseTexture1;
  78840. diffuseTexture1: BABYLON.Texture;
  78841. private _diffuseTexture2;
  78842. diffuseTexture2: BABYLON.Texture;
  78843. private _diffuseTexture3;
  78844. diffuseTexture3: BABYLON.Texture;
  78845. private _diffuseTexture4;
  78846. diffuseTexture4: BABYLON.Texture;
  78847. private _diffuseTexture5;
  78848. diffuseTexture5: BABYLON.Texture;
  78849. private _diffuseTexture6;
  78850. diffuseTexture6: BABYLON.Texture;
  78851. private _diffuseTexture7;
  78852. diffuseTexture7: BABYLON.Texture;
  78853. private _diffuseTexture8;
  78854. diffuseTexture8: BABYLON.Texture;
  78855. /**
  78856. * Uniforms
  78857. */
  78858. diffuseColor: BABYLON.Color3;
  78859. specularColor: BABYLON.Color3;
  78860. specularPower: number;
  78861. private _disableLighting;
  78862. disableLighting: boolean;
  78863. private _maxSimultaneousLights;
  78864. maxSimultaneousLights: number;
  78865. private _renderId;
  78866. constructor(name: string, scene: BABYLON.Scene);
  78867. needAlphaBlending(): boolean;
  78868. needAlphaTesting(): boolean;
  78869. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78870. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78871. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78872. getAnimatables(): BABYLON.IAnimatable[];
  78873. getActiveTextures(): BABYLON.BaseTexture[];
  78874. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78875. dispose(forceDisposeEffect?: boolean): void;
  78876. clone(name: string): MixMaterial;
  78877. serialize(): any;
  78878. getClassName(): string;
  78879. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  78880. }
  78881. }
  78882. declare module BABYLON {
  78883. /** @hidden */
  78884. export var normalPixelShader: {
  78885. name: string;
  78886. shader: string;
  78887. };
  78888. }
  78889. declare module BABYLON {
  78890. /** @hidden */
  78891. export var normalVertexShader: {
  78892. name: string;
  78893. shader: string;
  78894. };
  78895. }
  78896. declare module BABYLON {
  78897. export class NormalMaterial extends BABYLON.PushMaterial {
  78898. private _diffuseTexture;
  78899. diffuseTexture: BABYLON.BaseTexture;
  78900. diffuseColor: BABYLON.Color3;
  78901. private _disableLighting;
  78902. disableLighting: boolean;
  78903. private _maxSimultaneousLights;
  78904. maxSimultaneousLights: number;
  78905. private _renderId;
  78906. constructor(name: string, scene: BABYLON.Scene);
  78907. needAlphaBlending(): boolean;
  78908. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  78909. needAlphaTesting(): boolean;
  78910. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78911. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78912. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78913. getAnimatables(): BABYLON.IAnimatable[];
  78914. getActiveTextures(): BABYLON.BaseTexture[];
  78915. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78916. dispose(forceDisposeEffect?: boolean): void;
  78917. clone(name: string): NormalMaterial;
  78918. serialize(): any;
  78919. getClassName(): string;
  78920. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  78921. }
  78922. }
  78923. declare module BABYLON {
  78924. /** @hidden */
  78925. export var shadowOnlyPixelShader: {
  78926. name: string;
  78927. shader: string;
  78928. };
  78929. }
  78930. declare module BABYLON {
  78931. /** @hidden */
  78932. export var shadowOnlyVertexShader: {
  78933. name: string;
  78934. shader: string;
  78935. };
  78936. }
  78937. declare module BABYLON {
  78938. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  78939. private _renderId;
  78940. private _activeLight;
  78941. constructor(name: string, scene: BABYLON.Scene);
  78942. shadowColor: BABYLON.Color3;
  78943. needAlphaBlending(): boolean;
  78944. needAlphaTesting(): boolean;
  78945. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78946. get activeLight(): BABYLON.IShadowLight;
  78947. set activeLight(light: BABYLON.IShadowLight);
  78948. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78949. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78950. clone(name: string): ShadowOnlyMaterial;
  78951. serialize(): any;
  78952. getClassName(): string;
  78953. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  78954. }
  78955. }
  78956. declare module BABYLON {
  78957. /** @hidden */
  78958. export var simplePixelShader: {
  78959. name: string;
  78960. shader: string;
  78961. };
  78962. }
  78963. declare module BABYLON {
  78964. /** @hidden */
  78965. export var simpleVertexShader: {
  78966. name: string;
  78967. shader: string;
  78968. };
  78969. }
  78970. declare module BABYLON {
  78971. export class SimpleMaterial extends BABYLON.PushMaterial {
  78972. private _diffuseTexture;
  78973. diffuseTexture: BABYLON.BaseTexture;
  78974. diffuseColor: BABYLON.Color3;
  78975. private _disableLighting;
  78976. disableLighting: boolean;
  78977. private _maxSimultaneousLights;
  78978. maxSimultaneousLights: number;
  78979. private _renderId;
  78980. constructor(name: string, scene: BABYLON.Scene);
  78981. needAlphaBlending(): boolean;
  78982. needAlphaTesting(): boolean;
  78983. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  78984. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  78985. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  78986. getAnimatables(): BABYLON.IAnimatable[];
  78987. getActiveTextures(): BABYLON.BaseTexture[];
  78988. hasTexture(texture: BABYLON.BaseTexture): boolean;
  78989. dispose(forceDisposeEffect?: boolean): void;
  78990. clone(name: string): SimpleMaterial;
  78991. serialize(): any;
  78992. getClassName(): string;
  78993. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  78994. }
  78995. }
  78996. declare module BABYLON {
  78997. /** @hidden */
  78998. export var skyPixelShader: {
  78999. name: string;
  79000. shader: string;
  79001. };
  79002. }
  79003. declare module BABYLON {
  79004. /** @hidden */
  79005. export var skyVertexShader: {
  79006. name: string;
  79007. shader: string;
  79008. };
  79009. }
  79010. declare module BABYLON {
  79011. /**
  79012. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  79013. * @see https://doc.babylonjs.com/extensions/sky
  79014. */
  79015. export class SkyMaterial extends BABYLON.PushMaterial {
  79016. /**
  79017. * Defines the overall luminance of sky in interval ]0, 1[.
  79018. */
  79019. luminance: number;
  79020. /**
  79021. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  79022. */
  79023. turbidity: number;
  79024. /**
  79025. * Defines the sky appearance (light intensity).
  79026. */
  79027. rayleigh: number;
  79028. /**
  79029. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  79030. */
  79031. mieCoefficient: number;
  79032. /**
  79033. * Defines the amount of haze particles following the Mie scattering theory.
  79034. */
  79035. mieDirectionalG: number;
  79036. /**
  79037. * Defines the distance of the sun according to the active scene camera.
  79038. */
  79039. distance: number;
  79040. /**
  79041. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  79042. * "inclined".
  79043. */
  79044. inclination: number;
  79045. /**
  79046. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  79047. * an object direction and a reference direction.
  79048. */
  79049. azimuth: number;
  79050. /**
  79051. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  79052. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  79053. */
  79054. sunPosition: BABYLON.Vector3;
  79055. /**
  79056. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  79057. * .sunPosition property.
  79058. */
  79059. useSunPosition: boolean;
  79060. /**
  79061. * Defines an offset vector used to get a horizon offset.
  79062. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  79063. */
  79064. cameraOffset: BABYLON.Vector3;
  79065. private _cameraPosition;
  79066. private _renderId;
  79067. /**
  79068. * Instantiates a new sky material.
  79069. * This material allows to create dynamic and texture free
  79070. * effects for skyboxes by taking care of the atmosphere state.
  79071. * @see https://doc.babylonjs.com/extensions/sky
  79072. * @param name Define the name of the material in the scene
  79073. * @param scene Define the scene the material belong to
  79074. */
  79075. constructor(name: string, scene: BABYLON.Scene);
  79076. /**
  79077. * Specifies if the material will require alpha blending
  79078. * @returns a boolean specifying if alpha blending is needed
  79079. */
  79080. needAlphaBlending(): boolean;
  79081. /**
  79082. * Specifies if this material should be rendered in alpha test mode
  79083. * @returns false as the sky material doesn't need alpha testing.
  79084. */
  79085. needAlphaTesting(): boolean;
  79086. /**
  79087. * Get the texture used for alpha test purpose.
  79088. * @returns null as the sky material has no texture.
  79089. */
  79090. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79091. /**
  79092. * Get if the submesh is ready to be used and all its information available.
  79093. * Child classes can use it to update shaders
  79094. * @param mesh defines the mesh to check
  79095. * @param subMesh defines which submesh to check
  79096. * @param useInstances specifies that instances should be used
  79097. * @returns a boolean indicating that the submesh is ready or not
  79098. */
  79099. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79100. /**
  79101. * Binds the submesh to this material by preparing the effect and shader to draw
  79102. * @param world defines the world transformation matrix
  79103. * @param mesh defines the mesh containing the submesh
  79104. * @param subMesh defines the submesh to bind the material to
  79105. */
  79106. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79107. /**
  79108. * Get the list of animatables in the material.
  79109. * @returns the list of animatables object used in the material
  79110. */
  79111. getAnimatables(): BABYLON.IAnimatable[];
  79112. /**
  79113. * Disposes the material
  79114. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  79115. */
  79116. dispose(forceDisposeEffect?: boolean): void;
  79117. /**
  79118. * Makes a duplicate of the material, and gives it a new name
  79119. * @param name defines the new name for the duplicated material
  79120. * @returns the cloned material
  79121. */
  79122. clone(name: string): SkyMaterial;
  79123. /**
  79124. * Serializes this material in a JSON representation
  79125. * @returns the serialized material object
  79126. */
  79127. serialize(): any;
  79128. /**
  79129. * Gets the current class name of the material e.g. "SkyMaterial"
  79130. * Mainly use in serialization.
  79131. * @returns the class name
  79132. */
  79133. getClassName(): string;
  79134. /**
  79135. * Creates a sky material from parsed material data
  79136. * @param source defines the JSON representation of the material
  79137. * @param scene defines the hosting scene
  79138. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  79139. * @returns a new sky material
  79140. */
  79141. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  79142. }
  79143. }
  79144. declare module BABYLON {
  79145. /** @hidden */
  79146. export var terrainPixelShader: {
  79147. name: string;
  79148. shader: string;
  79149. };
  79150. }
  79151. declare module BABYLON {
  79152. /** @hidden */
  79153. export var terrainVertexShader: {
  79154. name: string;
  79155. shader: string;
  79156. };
  79157. }
  79158. declare module BABYLON {
  79159. export class TerrainMaterial extends BABYLON.PushMaterial {
  79160. private _mixTexture;
  79161. mixTexture: BABYLON.BaseTexture;
  79162. private _diffuseTexture1;
  79163. diffuseTexture1: BABYLON.Texture;
  79164. private _diffuseTexture2;
  79165. diffuseTexture2: BABYLON.Texture;
  79166. private _diffuseTexture3;
  79167. diffuseTexture3: BABYLON.Texture;
  79168. private _bumpTexture1;
  79169. bumpTexture1: BABYLON.Texture;
  79170. private _bumpTexture2;
  79171. bumpTexture2: BABYLON.Texture;
  79172. private _bumpTexture3;
  79173. bumpTexture3: BABYLON.Texture;
  79174. diffuseColor: BABYLON.Color3;
  79175. specularColor: BABYLON.Color3;
  79176. specularPower: number;
  79177. private _disableLighting;
  79178. disableLighting: boolean;
  79179. private _maxSimultaneousLights;
  79180. maxSimultaneousLights: number;
  79181. private _renderId;
  79182. constructor(name: string, scene: BABYLON.Scene);
  79183. needAlphaBlending(): boolean;
  79184. needAlphaTesting(): boolean;
  79185. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79186. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79187. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79188. getAnimatables(): BABYLON.IAnimatable[];
  79189. getActiveTextures(): BABYLON.BaseTexture[];
  79190. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79191. dispose(forceDisposeEffect?: boolean): void;
  79192. clone(name: string): TerrainMaterial;
  79193. serialize(): any;
  79194. getClassName(): string;
  79195. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  79196. }
  79197. }
  79198. declare module BABYLON {
  79199. /** @hidden */
  79200. export var triplanarPixelShader: {
  79201. name: string;
  79202. shader: string;
  79203. };
  79204. }
  79205. declare module BABYLON {
  79206. /** @hidden */
  79207. export var triplanarVertexShader: {
  79208. name: string;
  79209. shader: string;
  79210. };
  79211. }
  79212. declare module BABYLON {
  79213. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  79214. mixTexture: BABYLON.BaseTexture;
  79215. private _diffuseTextureX;
  79216. diffuseTextureX: BABYLON.BaseTexture;
  79217. private _diffuseTextureY;
  79218. diffuseTextureY: BABYLON.BaseTexture;
  79219. private _diffuseTextureZ;
  79220. diffuseTextureZ: BABYLON.BaseTexture;
  79221. private _normalTextureX;
  79222. normalTextureX: BABYLON.BaseTexture;
  79223. private _normalTextureY;
  79224. normalTextureY: BABYLON.BaseTexture;
  79225. private _normalTextureZ;
  79226. normalTextureZ: BABYLON.BaseTexture;
  79227. tileSize: number;
  79228. diffuseColor: BABYLON.Color3;
  79229. specularColor: BABYLON.Color3;
  79230. specularPower: number;
  79231. private _disableLighting;
  79232. disableLighting: boolean;
  79233. private _maxSimultaneousLights;
  79234. maxSimultaneousLights: number;
  79235. private _renderId;
  79236. constructor(name: string, scene: BABYLON.Scene);
  79237. needAlphaBlending(): boolean;
  79238. needAlphaTesting(): boolean;
  79239. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79240. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79241. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79242. getAnimatables(): BABYLON.IAnimatable[];
  79243. getActiveTextures(): BABYLON.BaseTexture[];
  79244. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79245. dispose(forceDisposeEffect?: boolean): void;
  79246. clone(name: string): TriPlanarMaterial;
  79247. serialize(): any;
  79248. getClassName(): string;
  79249. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  79250. }
  79251. }
  79252. declare module BABYLON {
  79253. /** @hidden */
  79254. export var waterPixelShader: {
  79255. name: string;
  79256. shader: string;
  79257. };
  79258. }
  79259. declare module BABYLON {
  79260. /** @hidden */
  79261. export var waterVertexShader: {
  79262. name: string;
  79263. shader: string;
  79264. };
  79265. }
  79266. declare module BABYLON {
  79267. export class WaterMaterial extends BABYLON.PushMaterial {
  79268. renderTargetSize: BABYLON.Vector2;
  79269. private _bumpTexture;
  79270. bumpTexture: BABYLON.BaseTexture;
  79271. diffuseColor: BABYLON.Color3;
  79272. specularColor: BABYLON.Color3;
  79273. specularPower: number;
  79274. private _disableLighting;
  79275. disableLighting: boolean;
  79276. private _maxSimultaneousLights;
  79277. maxSimultaneousLights: number;
  79278. /**
  79279. * @param {number}: Represents the wind force
  79280. */
  79281. windForce: number;
  79282. /**
  79283. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  79284. */
  79285. windDirection: BABYLON.Vector2;
  79286. /**
  79287. * @param {number}: Wave height, represents the height of the waves
  79288. */
  79289. waveHeight: number;
  79290. /**
  79291. * @param {number}: Bump height, represents the bump height related to the bump map
  79292. */
  79293. bumpHeight: number;
  79294. /**
  79295. * @param {boolean}: Add a smaller moving bump to less steady waves.
  79296. */
  79297. private _bumpSuperimpose;
  79298. bumpSuperimpose: boolean;
  79299. /**
  79300. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  79301. */
  79302. private _fresnelSeparate;
  79303. fresnelSeparate: boolean;
  79304. /**
  79305. * @param {boolean}: bump Waves modify the reflection.
  79306. */
  79307. private _bumpAffectsReflection;
  79308. bumpAffectsReflection: boolean;
  79309. /**
  79310. * @param {number}: The water color blended with the refraction (near)
  79311. */
  79312. waterColor: BABYLON.Color3;
  79313. /**
  79314. * @param {number}: The blend factor related to the water color
  79315. */
  79316. colorBlendFactor: number;
  79317. /**
  79318. * @param {number}: The water color blended with the reflection (far)
  79319. */
  79320. waterColor2: BABYLON.Color3;
  79321. /**
  79322. * @param {number}: The blend factor related to the water color (reflection, far)
  79323. */
  79324. colorBlendFactor2: number;
  79325. /**
  79326. * @param {number}: Represents the maximum length of a wave
  79327. */
  79328. waveLength: number;
  79329. /**
  79330. * @param {number}: Defines the waves speed
  79331. */
  79332. waveSpeed: number;
  79333. /**
  79334. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  79335. * will avoid calculating useless pixels in the pixel shader of the water material.
  79336. */
  79337. disableClipPlane: boolean;
  79338. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  79339. private _mesh;
  79340. private _refractionRTT;
  79341. private _reflectionRTT;
  79342. private _reflectionTransform;
  79343. private _lastTime;
  79344. private _lastDeltaTime;
  79345. private _renderId;
  79346. private _useLogarithmicDepth;
  79347. private _waitingRenderList;
  79348. private _imageProcessingConfiguration;
  79349. private _imageProcessingObserver;
  79350. /**
  79351. * Gets a boolean indicating that current material needs to register RTT
  79352. */
  79353. get hasRenderTargetTextures(): boolean;
  79354. /**
  79355. * Constructor
  79356. */
  79357. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  79358. get useLogarithmicDepth(): boolean;
  79359. set useLogarithmicDepth(value: boolean);
  79360. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  79361. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  79362. addToRenderList(node: any): void;
  79363. enableRenderTargets(enable: boolean): void;
  79364. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  79365. get renderTargetsEnabled(): boolean;
  79366. needAlphaBlending(): boolean;
  79367. needAlphaTesting(): boolean;
  79368. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79369. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79370. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79371. private _createRenderTargets;
  79372. getAnimatables(): BABYLON.IAnimatable[];
  79373. getActiveTextures(): BABYLON.BaseTexture[];
  79374. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79375. dispose(forceDisposeEffect?: boolean): void;
  79376. clone(name: string): WaterMaterial;
  79377. serialize(): any;
  79378. getClassName(): string;
  79379. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  79380. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  79381. }
  79382. }
  79383. declare module BABYLON {
  79384. /** @hidden */
  79385. export var asciiartPixelShader: {
  79386. name: string;
  79387. shader: string;
  79388. };
  79389. }
  79390. declare module BABYLON {
  79391. /**
  79392. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  79393. *
  79394. * It basically takes care rendering the font front the given font size to a texture.
  79395. * This is used later on in the postprocess.
  79396. */
  79397. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  79398. private _font;
  79399. private _text;
  79400. private _charSize;
  79401. /**
  79402. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  79403. */
  79404. get charSize(): number;
  79405. /**
  79406. * Create a new instance of the Ascii Art FontTexture class
  79407. * @param name the name of the texture
  79408. * @param font the font to use, use the W3C CSS notation
  79409. * @param text the caracter set to use in the rendering.
  79410. * @param scene the scene that owns the texture
  79411. */
  79412. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  79413. /**
  79414. * Gets the max char width of a font.
  79415. * @param font the font to use, use the W3C CSS notation
  79416. * @return the max char width
  79417. */
  79418. private getFontWidth;
  79419. /**
  79420. * Gets the max char height of a font.
  79421. * @param font the font to use, use the W3C CSS notation
  79422. * @return the max char height
  79423. */
  79424. private getFontHeight;
  79425. /**
  79426. * Clones the current AsciiArtTexture.
  79427. * @return the clone of the texture.
  79428. */
  79429. clone(): AsciiArtFontTexture;
  79430. /**
  79431. * Parses a json object representing the texture and returns an instance of it.
  79432. * @param source the source JSON representation
  79433. * @param scene the scene to create the texture for
  79434. * @return the parsed texture
  79435. */
  79436. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  79437. }
  79438. /**
  79439. * Option available in the Ascii Art Post Process.
  79440. */
  79441. export interface IAsciiArtPostProcessOptions {
  79442. /**
  79443. * The font to use following the w3c font definition.
  79444. */
  79445. font?: string;
  79446. /**
  79447. * The character set to use in the postprocess.
  79448. */
  79449. characterSet?: string;
  79450. /**
  79451. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  79452. * This number is defined between 0 and 1;
  79453. */
  79454. mixToTile?: number;
  79455. /**
  79456. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  79457. * This number is defined between 0 and 1;
  79458. */
  79459. mixToNormal?: number;
  79460. }
  79461. /**
  79462. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  79463. *
  79464. * Simmply add it to your scene and let the nerd that lives in you have fun.
  79465. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  79466. */
  79467. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  79468. /**
  79469. * The font texture used to render the char in the post process.
  79470. */
  79471. private _asciiArtFontTexture;
  79472. /**
  79473. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  79474. * This number is defined between 0 and 1;
  79475. */
  79476. mixToTile: number;
  79477. /**
  79478. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  79479. * This number is defined between 0 and 1;
  79480. */
  79481. mixToNormal: number;
  79482. /**
  79483. * Instantiates a new Ascii Art Post Process.
  79484. * @param name the name to give to the postprocess
  79485. * @camera the camera to apply the post process to.
  79486. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  79487. */
  79488. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  79489. }
  79490. }
  79491. declare module BABYLON {
  79492. /** @hidden */
  79493. export var digitalrainPixelShader: {
  79494. name: string;
  79495. shader: string;
  79496. };
  79497. }
  79498. declare module BABYLON {
  79499. /**
  79500. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  79501. *
  79502. * It basically takes care rendering the font front the given font size to a texture.
  79503. * This is used later on in the postprocess.
  79504. */
  79505. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  79506. private _font;
  79507. private _text;
  79508. private _charSize;
  79509. /**
  79510. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  79511. */
  79512. get charSize(): number;
  79513. /**
  79514. * Create a new instance of the Digital Rain FontTexture class
  79515. * @param name the name of the texture
  79516. * @param font the font to use, use the W3C CSS notation
  79517. * @param text the caracter set to use in the rendering.
  79518. * @param scene the scene that owns the texture
  79519. */
  79520. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  79521. /**
  79522. * Gets the max char width of a font.
  79523. * @param font the font to use, use the W3C CSS notation
  79524. * @return the max char width
  79525. */
  79526. private getFontWidth;
  79527. /**
  79528. * Gets the max char height of a font.
  79529. * @param font the font to use, use the W3C CSS notation
  79530. * @return the max char height
  79531. */
  79532. private getFontHeight;
  79533. /**
  79534. * Clones the current DigitalRainFontTexture.
  79535. * @return the clone of the texture.
  79536. */
  79537. clone(): DigitalRainFontTexture;
  79538. /**
  79539. * Parses a json object representing the texture and returns an instance of it.
  79540. * @param source the source JSON representation
  79541. * @param scene the scene to create the texture for
  79542. * @return the parsed texture
  79543. */
  79544. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  79545. }
  79546. /**
  79547. * Option available in the Digital Rain Post Process.
  79548. */
  79549. export interface IDigitalRainPostProcessOptions {
  79550. /**
  79551. * The font to use following the w3c font definition.
  79552. */
  79553. font?: string;
  79554. /**
  79555. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  79556. * This number is defined between 0 and 1;
  79557. */
  79558. mixToTile?: number;
  79559. /**
  79560. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  79561. * This number is defined between 0 and 1;
  79562. */
  79563. mixToNormal?: number;
  79564. }
  79565. /**
  79566. * DigitalRainPostProcess helps rendering everithing in digital rain.
  79567. *
  79568. * Simmply add it to your scene and let the nerd that lives in you have fun.
  79569. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  79570. */
  79571. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  79572. /**
  79573. * The font texture used to render the char in the post process.
  79574. */
  79575. private _digitalRainFontTexture;
  79576. /**
  79577. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  79578. * This number is defined between 0 and 1;
  79579. */
  79580. mixToTile: number;
  79581. /**
  79582. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  79583. * This number is defined between 0 and 1;
  79584. */
  79585. mixToNormal: number;
  79586. /**
  79587. * Instantiates a new Digital Rain Post Process.
  79588. * @param name the name to give to the postprocess
  79589. * @camera the camera to apply the post process to.
  79590. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  79591. */
  79592. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  79593. }
  79594. }
  79595. declare module BABYLON {
  79596. /** @hidden */
  79597. export var brickProceduralTexturePixelShader: {
  79598. name: string;
  79599. shader: string;
  79600. };
  79601. }
  79602. declare module BABYLON {
  79603. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  79604. private _numberOfBricksHeight;
  79605. private _numberOfBricksWidth;
  79606. private _jointColor;
  79607. private _brickColor;
  79608. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79609. updateShaderUniforms(): void;
  79610. get numberOfBricksHeight(): number;
  79611. set numberOfBricksHeight(value: number);
  79612. get numberOfBricksWidth(): number;
  79613. set numberOfBricksWidth(value: number);
  79614. get jointColor(): BABYLON.Color3;
  79615. set jointColor(value: BABYLON.Color3);
  79616. get brickColor(): BABYLON.Color3;
  79617. set brickColor(value: BABYLON.Color3);
  79618. /**
  79619. * Serializes this brick procedural texture
  79620. * @returns a serialized brick procedural texture object
  79621. */
  79622. serialize(): any;
  79623. /**
  79624. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  79625. * @param parsedTexture defines parsed texture data
  79626. * @param scene defines the current scene
  79627. * @param rootUrl defines the root URL containing brick procedural texture information
  79628. * @returns a parsed Brick Procedural BABYLON.Texture
  79629. */
  79630. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  79631. }
  79632. }
  79633. declare module BABYLON {
  79634. /** @hidden */
  79635. export var cloudProceduralTexturePixelShader: {
  79636. name: string;
  79637. shader: string;
  79638. };
  79639. }
  79640. declare module BABYLON {
  79641. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  79642. private _skyColor;
  79643. private _cloudColor;
  79644. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79645. updateShaderUniforms(): void;
  79646. get skyColor(): BABYLON.Color4;
  79647. set skyColor(value: BABYLON.Color4);
  79648. get cloudColor(): BABYLON.Color4;
  79649. set cloudColor(value: BABYLON.Color4);
  79650. /**
  79651. * Serializes this cloud procedural texture
  79652. * @returns a serialized cloud procedural texture object
  79653. */
  79654. serialize(): any;
  79655. /**
  79656. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  79657. * @param parsedTexture defines parsed texture data
  79658. * @param scene defines the current scene
  79659. * @param rootUrl defines the root URL containing cloud procedural texture information
  79660. * @returns a parsed Cloud Procedural BABYLON.Texture
  79661. */
  79662. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  79663. }
  79664. }
  79665. declare module BABYLON {
  79666. /** @hidden */
  79667. export var fireProceduralTexturePixelShader: {
  79668. name: string;
  79669. shader: string;
  79670. };
  79671. }
  79672. declare module BABYLON {
  79673. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  79674. private _time;
  79675. private _speed;
  79676. private _autoGenerateTime;
  79677. private _fireColors;
  79678. private _alphaThreshold;
  79679. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79680. updateShaderUniforms(): void;
  79681. render(useCameraPostProcess?: boolean): void;
  79682. static get PurpleFireColors(): BABYLON.Color3[];
  79683. static get GreenFireColors(): BABYLON.Color3[];
  79684. static get RedFireColors(): BABYLON.Color3[];
  79685. static get BlueFireColors(): BABYLON.Color3[];
  79686. get autoGenerateTime(): boolean;
  79687. set autoGenerateTime(value: boolean);
  79688. get fireColors(): BABYLON.Color3[];
  79689. set fireColors(value: BABYLON.Color3[]);
  79690. get time(): number;
  79691. set time(value: number);
  79692. get speed(): BABYLON.Vector2;
  79693. set speed(value: BABYLON.Vector2);
  79694. get alphaThreshold(): number;
  79695. set alphaThreshold(value: number);
  79696. /**
  79697. * Serializes this fire procedural texture
  79698. * @returns a serialized fire procedural texture object
  79699. */
  79700. serialize(): any;
  79701. /**
  79702. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  79703. * @param parsedTexture defines parsed texture data
  79704. * @param scene defines the current scene
  79705. * @param rootUrl defines the root URL containing fire procedural texture information
  79706. * @returns a parsed Fire Procedural BABYLON.Texture
  79707. */
  79708. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  79709. }
  79710. }
  79711. declare module BABYLON {
  79712. /** @hidden */
  79713. export var grassProceduralTexturePixelShader: {
  79714. name: string;
  79715. shader: string;
  79716. };
  79717. }
  79718. declare module BABYLON {
  79719. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  79720. private _grassColors;
  79721. private _groundColor;
  79722. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79723. updateShaderUniforms(): void;
  79724. get grassColors(): BABYLON.Color3[];
  79725. set grassColors(value: BABYLON.Color3[]);
  79726. get groundColor(): BABYLON.Color3;
  79727. set groundColor(value: BABYLON.Color3);
  79728. /**
  79729. * Serializes this grass procedural texture
  79730. * @returns a serialized grass procedural texture object
  79731. */
  79732. serialize(): any;
  79733. /**
  79734. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  79735. * @param parsedTexture defines parsed texture data
  79736. * @param scene defines the current scene
  79737. * @param rootUrl defines the root URL containing grass procedural texture information
  79738. * @returns a parsed Grass Procedural BABYLON.Texture
  79739. */
  79740. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  79741. }
  79742. }
  79743. declare module BABYLON {
  79744. /** @hidden */
  79745. export var marbleProceduralTexturePixelShader: {
  79746. name: string;
  79747. shader: string;
  79748. };
  79749. }
  79750. declare module BABYLON {
  79751. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  79752. private _numberOfTilesHeight;
  79753. private _numberOfTilesWidth;
  79754. private _amplitude;
  79755. private _jointColor;
  79756. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79757. updateShaderUniforms(): void;
  79758. get numberOfTilesHeight(): number;
  79759. set numberOfTilesHeight(value: number);
  79760. get amplitude(): number;
  79761. set amplitude(value: number);
  79762. get numberOfTilesWidth(): number;
  79763. set numberOfTilesWidth(value: number);
  79764. get jointColor(): BABYLON.Color3;
  79765. set jointColor(value: BABYLON.Color3);
  79766. /**
  79767. * Serializes this marble procedural texture
  79768. * @returns a serialized marble procedural texture object
  79769. */
  79770. serialize(): any;
  79771. /**
  79772. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  79773. * @param parsedTexture defines parsed texture data
  79774. * @param scene defines the current scene
  79775. * @param rootUrl defines the root URL containing marble procedural texture information
  79776. * @returns a parsed Marble Procedural BABYLON.Texture
  79777. */
  79778. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  79779. }
  79780. }
  79781. declare module BABYLON {
  79782. /** @hidden */
  79783. export var normalMapProceduralTexturePixelShader: {
  79784. name: string;
  79785. shader: string;
  79786. };
  79787. }
  79788. declare module BABYLON {
  79789. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  79790. private _baseTexture;
  79791. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79792. updateShaderUniforms(): void;
  79793. render(useCameraPostProcess?: boolean): void;
  79794. resize(size: any, generateMipMaps: any): void;
  79795. get baseTexture(): BABYLON.Texture;
  79796. set baseTexture(texture: BABYLON.Texture);
  79797. /**
  79798. * Serializes this normal map procedural texture
  79799. * @returns a serialized normal map procedural texture object
  79800. */
  79801. serialize(): any;
  79802. /**
  79803. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  79804. * @param parsedTexture defines parsed texture data
  79805. * @param scene defines the current scene
  79806. * @param rootUrl defines the root URL containing normal map procedural texture information
  79807. * @returns a parsed Normal Map Procedural BABYLON.Texture
  79808. */
  79809. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  79810. }
  79811. }
  79812. declare module BABYLON {
  79813. /** @hidden */
  79814. export var perlinNoiseProceduralTexturePixelShader: {
  79815. name: string;
  79816. shader: string;
  79817. };
  79818. }
  79819. declare module BABYLON {
  79820. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  79821. time: number;
  79822. timeScale: number;
  79823. translationSpeed: number;
  79824. private _currentTranslation;
  79825. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79826. updateShaderUniforms(): void;
  79827. render(useCameraPostProcess?: boolean): void;
  79828. resize(size: any, generateMipMaps: any): void;
  79829. /**
  79830. * Serializes this perlin noise procedural texture
  79831. * @returns a serialized perlin noise procedural texture object
  79832. */
  79833. serialize(): any;
  79834. /**
  79835. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  79836. * @param parsedTexture defines parsed texture data
  79837. * @param scene defines the current scene
  79838. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  79839. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  79840. */
  79841. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  79842. }
  79843. }
  79844. declare module BABYLON {
  79845. /** @hidden */
  79846. export var roadProceduralTexturePixelShader: {
  79847. name: string;
  79848. shader: string;
  79849. };
  79850. }
  79851. declare module BABYLON {
  79852. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  79853. private _roadColor;
  79854. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79855. updateShaderUniforms(): void;
  79856. get roadColor(): BABYLON.Color3;
  79857. set roadColor(value: BABYLON.Color3);
  79858. /**
  79859. * Serializes this road procedural texture
  79860. * @returns a serialized road procedural texture object
  79861. */
  79862. serialize(): any;
  79863. /**
  79864. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  79865. * @param parsedTexture defines parsed texture data
  79866. * @param scene defines the current scene
  79867. * @param rootUrl defines the root URL containing road procedural texture information
  79868. * @returns a parsed Road Procedural BABYLON.Texture
  79869. */
  79870. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  79871. }
  79872. }
  79873. declare module BABYLON {
  79874. /** @hidden */
  79875. export var starfieldProceduralTexturePixelShader: {
  79876. name: string;
  79877. shader: string;
  79878. };
  79879. }
  79880. declare module BABYLON {
  79881. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  79882. private _time;
  79883. private _alpha;
  79884. private _beta;
  79885. private _zoom;
  79886. private _formuparam;
  79887. private _stepsize;
  79888. private _tile;
  79889. private _brightness;
  79890. private _darkmatter;
  79891. private _distfading;
  79892. private _saturation;
  79893. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79894. updateShaderUniforms(): void;
  79895. get time(): number;
  79896. set time(value: number);
  79897. get alpha(): number;
  79898. set alpha(value: number);
  79899. get beta(): number;
  79900. set beta(value: number);
  79901. get formuparam(): number;
  79902. set formuparam(value: number);
  79903. get stepsize(): number;
  79904. set stepsize(value: number);
  79905. get zoom(): number;
  79906. set zoom(value: number);
  79907. get tile(): number;
  79908. set tile(value: number);
  79909. get brightness(): number;
  79910. set brightness(value: number);
  79911. get darkmatter(): number;
  79912. set darkmatter(value: number);
  79913. get distfading(): number;
  79914. set distfading(value: number);
  79915. get saturation(): number;
  79916. set saturation(value: number);
  79917. /**
  79918. * Serializes this starfield procedural texture
  79919. * @returns a serialized starfield procedural texture object
  79920. */
  79921. serialize(): any;
  79922. /**
  79923. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  79924. * @param parsedTexture defines parsed texture data
  79925. * @param scene defines the current scene
  79926. * @param rootUrl defines the root URL containing startfield procedural texture information
  79927. * @returns a parsed Starfield Procedural BABYLON.Texture
  79928. */
  79929. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  79930. }
  79931. }
  79932. declare module BABYLON {
  79933. /** @hidden */
  79934. export var woodProceduralTexturePixelShader: {
  79935. name: string;
  79936. shader: string;
  79937. };
  79938. }
  79939. declare module BABYLON {
  79940. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  79941. private _ampScale;
  79942. private _woodColor;
  79943. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  79944. updateShaderUniforms(): void;
  79945. get ampScale(): number;
  79946. set ampScale(value: number);
  79947. get woodColor(): BABYLON.Color3;
  79948. set woodColor(value: BABYLON.Color3);
  79949. /**
  79950. * Serializes this wood procedural texture
  79951. * @returns a serialized wood procedural texture object
  79952. */
  79953. serialize(): any;
  79954. /**
  79955. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  79956. * @param parsedTexture defines parsed texture data
  79957. * @param scene defines the current scene
  79958. * @param rootUrl defines the root URL containing wood procedural texture information
  79959. * @returns a parsed Wood Procedural BABYLON.Texture
  79960. */
  79961. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  79962. }
  79963. }